Removed unnecessary form_id. Using jQuery .find() instead of

constructing the selector.
This commit is contained in:
Sarven Capadisli 2010-03-16 21:02:56 +01:00
parent f4339ddb7d
commit 7fc8b6af4a

View File

@ -61,10 +61,8 @@ var SN = { // StatusNet
U: { // Utils U: { // Utils
FormNoticeEnhancements: function(form) { FormNoticeEnhancements: function(form) {
form_id = form.attr('id');
if (jQuery.data(form[0], 'ElementData') === undefined) { if (jQuery.data(form[0], 'ElementData') === undefined) {
MaxLength = $('#'+form_id+' #'+SN.C.S.NoticeTextCount).text(); MaxLength = form.find('#'+SN.C.S.NoticeTextCount).text();
if (typeof(MaxLength) == 'undefined') { if (typeof(MaxLength) == 'undefined') {
MaxLength = SN.C.I.MaxLength; MaxLength = SN.C.I.MaxLength;
} }
@ -72,7 +70,7 @@ var SN = { // StatusNet
SN.U.Counter(form); SN.U.Counter(form);
NDT = $('#'+form_id+' #'+SN.C.S.NoticeDataText); NDT = form.find('#'+SN.C.S.NoticeDataText);
NDT.bind('keyup', function(e) { NDT.bind('keyup', function(e) {
SN.U.Counter(form); SN.U.Counter(form);
@ -83,11 +81,11 @@ var SN = { // StatusNet
}); });
} }
else { else {
$('#'+form_id+' #'+SN.C.S.NoticeTextCount).text(jQuery.data(form[0], 'ElementData').MaxLength); form.find('#'+SN.C.S.NoticeTextCount).text(jQuery.data(form[0], 'ElementData').MaxLength);
} }
if ($('body')[0].id != 'conversation' && window.location.hash.length === 0) { if ($('body')[0].id != 'conversation' && window.location.hash.length === 0) {
$('#'+form_id+' textarea').focus(); form.find('textarea').focus();
} }
}, },
@ -105,7 +103,6 @@ var SN = { // StatusNet
Counter: function(form) { Counter: function(form) {
SN.C.I.FormNoticeCurrent = form; SN.C.I.FormNoticeCurrent = form;
form_id = form.attr('id');
var MaxLength = jQuery.data(form[0], 'ElementData').MaxLength; var MaxLength = jQuery.data(form[0], 'ElementData').MaxLength;
@ -113,8 +110,8 @@ var SN = { // StatusNet
return; return;
} }
var remaining = MaxLength - $('#'+form_id+' #'+SN.C.S.NoticeDataText).val().length; var remaining = MaxLength - form.find('#'+SN.C.S.NoticeDataText).val().length;
var counter = $('#'+form_id+' #'+SN.C.S.NoticeTextCount); var counter = form.find('#'+SN.C.S.NoticeTextCount);
if (remaining.toString() != counter.text()) { if (remaining.toString() != counter.text()) {
if (!SN.C.I.CounterBlackout || remaining === 0) { if (!SN.C.I.CounterBlackout || remaining === 0) {
@ -174,7 +171,6 @@ var SN = { // StatusNet
FormNoticeXHR: function(form) { FormNoticeXHR: function(form) {
SN.C.I.NoticeDataGeo = {}; SN.C.I.NoticeDataGeo = {};
form_id = form.attr('id');
form.append('<input type="hidden" name="ajax" value="1"/>'); form.append('<input type="hidden" name="ajax" value="1"/>');
form.ajaxForm({ form.ajaxForm({
dataType: 'xml', dataType: 'xml',