From 41cbb90faeabc0a6002b41d40d392f45a59a7aba Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 8 Dec 2009 17:31:23 -0500 Subject: add (ugly) form to forward notices --- js/util.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index ed6a781f7..67df73507 100644 --- a/js/util.js +++ b/js/util.js @@ -208,7 +208,7 @@ var SN = { // StatusNet $('#'+form_id+' .form_response').remove(); var result; if ($('#'+SN.C.S.Error, data).length > 0) { - result = document._importNode($('p', data)[0], true); + result = document._importNode($('p', data)[0], true); result = result.textContent || result.innerHTML; form.append('

'+result+'

'); } @@ -306,8 +306,12 @@ var SN = { // StatusNet $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); }); }, + NoticeForward: function() { + $('.form_forward').each(function() { SN.U.FormXHR($(this)); }); + }, + NoticeAttachments: function() { - $('.notice a.attachment').each(function() { + $('.notice a.attachment').each(function() { SN.U.NoticeWithAttachment($(this).closest('.notice')); }); }, @@ -439,7 +443,7 @@ var SN = { // StatusNet Notices: function() { if ($('body.user_in').length > 0) { SN.U.NoticeFavor(); - + SN.U.NoticeForward(); SN.U.NoticeReply(); } -- cgit v1.2.3-54-g00ecf From 1e166e1bc4a8b16ad2ef8e99db6a112f47803eda Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:16:07 +0100 Subject: Updated FormNoticeEnhancements and Counter to use the max text value from HTML. It also allows each .form_notice to have its own counter. --- js/util.js | 38 ++++++++++++++++++++++---------------- lib/messageform.php | 2 -- lib/noticeform.php | 2 -- 3 files changed, 22 insertions(+), 20 deletions(-) (limited to 'js') 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()) { diff --git a/lib/messageform.php b/lib/messageform.php index 4df193c6d..0c568e1bd 100644 --- a/lib/messageform.php +++ b/lib/messageform.php @@ -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')); diff --git a/lib/noticeform.php b/lib/noticeform.php index 0dd3f2d77..593a1e932 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -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')); -- cgit v1.2.3-54-g00ecf From c855907f5943260a2b9740948a33f4170f3dda62 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:29:27 +0100 Subject: Calling NewDirectMessage --- js/util.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js') diff --git a/js/util.js b/js/util.js index 60865d352..66d66c154 100644 --- a/js/util.js +++ b/js/util.js @@ -463,6 +463,8 @@ var SN = { // StatusNet $('.form_group_join').each(function() { SN.U.FormXHR($(this)); }); $('.form_group_leave').each(function() { SN.U.FormXHR($(this)); }); $('.form_user_nudge').each(function() { SN.U.FormXHR($(this)); }); + + SN.U.NewDirectMessage(); } } } -- cgit v1.2.3-54-g00ecf From c0aad854f7f17cf817f488e0f2ee57303ff75305 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Thu, 10 Dec 2009 14:52:05 +0100 Subject: If ElementData is set on the notice form, use the existing MaxLength --- js/util.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'js') diff --git a/js/util.js b/js/util.js index 66d66c154..71514324b 100644 --- a/js/util.js +++ b/js/util.js @@ -77,6 +77,9 @@ var SN = { // StatusNet SN.U.SubmitOnReturn(e, form); }); } + else { + $('#'+form_id+' #'+SN.C.S.NoticeTextCount).text(jQuery.data(form[0], 'ElementData').MaxLength); + } if ($('body')[0].id != 'conversation') { $('#'+form_id+' textarea').focus(); -- cgit v1.2.3-54-g00ecf From 038fbddd02d2f144936357ed2ed40c09b1441c6b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 10 Dec 2009 14:41:18 -0500 Subject: remove NoticeForward from util.js --- js/util.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'js') diff --git a/js/util.js b/js/util.js index 71514324b..336cd8cfe 100644 --- a/js/util.js +++ b/js/util.js @@ -315,10 +315,6 @@ var SN = { // StatusNet $('.form_disfavor').each(function() { SN.U.FormXHR($(this)); }); }, - NoticeForward: function() { - $('.form_forward').each(function() { SN.U.FormXHR($(this)); }); - }, - NoticeAttachments: function() { $('.notice a.attachment').each(function() { SN.U.NoticeWithAttachment($(this).closest('.notice')); @@ -452,7 +448,6 @@ var SN = { // StatusNet Notices: function() { if ($('body.user_in').length > 0) { SN.U.NoticeFavor(); - SN.U.NoticeForward(); SN.U.NoticeReply(); } -- cgit v1.2.3-54-g00ecf