summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/util.js38
1 files changed, 22 insertions, 16 deletions
diff --git a/js/util.js b/js/util.js
index 67df73507..60865d352 100644
--- a/js/util.js
+++ b/js/util.js
@@ -57,21 +57,28 @@ var SN = { // StatusNet
U: { // Utils
FormNoticeEnhancements: function(form) {
form_id = form.attr('id');
- $('#'+form_id+' #'+SN.C.S.NoticeDataText).unbind('keyup');
- $('#'+form_id+' #'+SN.C.S.NoticeDataText).unbind('keydown');
- if (maxLength > 0) {
- $('#'+form_id+' #'+SN.C.S.NoticeDataText).bind('keyup', function(e) {
+
+ if (jQuery.data(form[0], 'ElementData') === undefined) {
+ MaxLength = $('#'+form_id+' #'+SN.C.S.NoticeTextCount).text();
+ if (typeof(MaxLength) == 'undefined') {
+ MaxLength = SN.C.I.MaxLength;
+ }
+ jQuery.data(form[0], 'ElementData', {MaxLength:MaxLength});
+
+ SN.U.Counter(form);
+
+ NDT = $('#'+form_id+' #'+SN.C.S.NoticeDataText);
+
+ NDT.bind('keyup', function(e) {
SN.U.Counter(form);
});
- // run once in case there's something in there
- SN.U.Counter(form);
- }
- $('#'+form_id+' #'+SN.C.S.NoticeDataText).bind('keydown', function(e) {
- SN.U.SubmitOnReturn(e, form);
- });
+ NDT.bind('keydown', function(e) {
+ SN.U.SubmitOnReturn(e, form);
+ });
+ }
- if($('body')[0].id != 'conversation') {
+ if ($('body')[0].id != 'conversation') {
$('#'+form_id+' textarea').focus();
}
},
@@ -91,15 +98,14 @@ var SN = { // StatusNet
Counter: function(form) {
SN.C.I.FormNoticeCurrent = form;
form_id = form.attr('id');
- if (typeof(maxLength) == "undefined") {
- maxLength = SN.C.I.MaxLength;
- }
- if (maxLength <= 0) {
+ var MaxLength = jQuery.data(form[0], 'ElementData').MaxLength;
+
+ if (MaxLength <= 0) {
return;
}
- var remaining = maxLength - $('#'+form_id+' #'+SN.C.S.NoticeDataText).val().length;
+ var remaining = MaxLength - $('#'+form_id+' #'+SN.C.S.NoticeDataText).val().length;
var counter = $('#'+form_id+' #'+SN.C.S.NoticeTextCount);
if (remaining.toString() != counter.text()) {