forked from GNUsocial/gnu-social
Updated FormNoticeEnhancements and Counter to use the max text value
from HTML. It also allows each .form_notice to have its own counter.
This commit is contained in:
parent
155659dd1f
commit
1e166e1bc4
38
js/util.js
38
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);
|
||||
|
||||
NDT.bind('keydown', function(e) {
|
||||
SN.U.SubmitOnReturn(e, form);
|
||||
});
|
||||
}
|
||||
|
||||
$('#'+form_id+' #'+SN.C.S.NoticeDataText).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()) {
|
||||
|
@ -154,8 +154,6 @@ class MessageForm extends Form
|
||||
|
||||
$contentLimit = Message::maxContent();
|
||||
|
||||
$this->out->inlineScript('maxLength = ' . $contentLimit . ';');
|
||||
|
||||
if ($contentLimit > 0) {
|
||||
$this->out->elementStart('dl', 'form_note');
|
||||
$this->out->element('dt', null, _('Available characters'));
|
||||
|
@ -178,8 +178,6 @@ class NoticeForm extends Form
|
||||
|
||||
$contentLimit = Notice::maxContent();
|
||||
|
||||
$this->out->inlineScript('maxLength = ' . $contentLimit . ';');
|
||||
|
||||
if ($contentLimit > 0) {
|
||||
$this->out->elementStart('dl', 'form_note');
|
||||
$this->out->element('dt', null, _('Available characters'));
|
||||
|
Loading…
Reference in New Issue
Block a user