From a4d04d24de59f2694aaeb65dda50afe40a58b931 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Tue, 10 Sep 2013 15:14:42 +0200 Subject: [PATCH] Fixed regression from util.js updates + syntax cleanup We introduced a regression in 6fa9062d28713e81d508854fa232ce65a8a59319 based on syntax error, as a curly brace ({) was lost. This is now fixed. --- js/util.js | 531 ++++++++++++++++++++++++------------------------- js/util.min.js | 2 +- 2 files changed, 256 insertions(+), 277 deletions(-) diff --git a/js/util.js b/js/util.js index a7adb803d3..ae9a67dbb3 100644 --- a/js/util.js +++ b/js/util.js @@ -54,7 +54,7 @@ var SN = { // StatusNet NoticeDataGeo: 'notice_data-geo', NoticeDataGeoCookie: 'NoticeDataGeo', NoticeDataGeoSelected: 'notice_data-geo_selected', - StatusNetInstance:'StatusNetInstance' + StatusNetInstance: 'StatusNetInstance' } }, @@ -77,12 +77,11 @@ var SN = { // StatusNet * @param {String} key: string key name to pull from message index * @return matching localized message string */ - msg: function(key) { - if (typeof SN.messages[key] == "undefined") { + msg: function (key) { + if (SN.messages[key] === undefined) { return '[' + key + ']'; - } else { - return SN.messages[key]; } + return SN.messages[key]; }, U: { // Utils @@ -94,36 +93,35 @@ var SN = { // StatusNet * @param {jQuery} form: jQuery object whose first matching element is the form * @access private */ - FormNoticeEnhancements: function(form) { + FormNoticeEnhancements: function (form) { if (jQuery.data(form[0], 'ElementData') === undefined) { - MaxLength = form.find('.count').text(); - if (typeof(MaxLength) == 'undefined') { - MaxLength = SN.C.I.MaxLength; + var MaxLength = form.find('.count').text(); + if (MaxLength === undefined) { + MaxLength = SN.C.I.MaxLength; } - jQuery.data(form[0], 'ElementData', {MaxLength:MaxLength}); + jQuery.data(form[0], 'ElementData', {MaxLength: MaxLength}); SN.U.Counter(form); - NDT = form.find('.notice_data-text:first'); + var NDT = form.find('.notice_data-text:first'); - NDT.on('keyup', function(e) { + NDT.on('keyup', function (e) { SN.U.Counter(form); }); - var delayedUpdate= function(e) { + var delayedUpdate = function (e) { // Cut and paste events fire *before* the operation, // so we need to trigger an update in a little bit. // This would be so much easier if the 'change' event // actually fired every time the value changed. :P - window.setTimeout(function() { + window.setTimeout(function () { SN.U.Counter(form); }, 50); }; // Note there's still no event for mouse-triggered 'delete'. NDT.on('cut', delayedUpdate) - .on('paste', delayedUpdate); - } - else { + .on('paste', delayedUpdate); + } else { form.find('.count').text(jQuery.data(form[0], 'ElementData').MaxLength); } }, @@ -142,7 +140,7 @@ var SN = { // StatusNet * @param {jQuery} form: jQuery object whose first element is the notice posting form * @access private */ - Counter: function(form) { + Counter: function (form) { SN.C.I.FormNoticeCurrent = form; var MaxLength = jQuery.data(form[0], 'ElementData').MaxLength; @@ -182,7 +180,7 @@ var SN = { // StatusNet * @param {jQuery} form: jQuery object whose first element is the notice posting form * @return number of chars */ - CharacterCount: function(form) { + CharacterCount: function (form) { return form.find('.notice_data-text:first').val().length; }, @@ -193,7 +191,7 @@ var SN = { // StatusNet * @param {jQuery} form: jQuery object whose first element is the notice posting form * @access private */ - ClearCounterBlackout: function(form) { + ClearCounterBlackout: function (form) { // Allow keyup events to poke the counter again SN.C.I.CounterBlackout = false; // Check if the string changed since we last looked @@ -211,13 +209,12 @@ var SN = { // StatusNet * @param {String} url * @return string */ - RewriteAjaxAction: function(url) { + RewriteAjaxAction: function (url) { // Quick hack: rewrite AJAX submits to HTTPS if they'd fail otherwise. - if (document.location.protocol == 'https:' && url.substr(0, 5) == 'http:') { + if (document.location.protocol === 'https:' && url.substr(0, 5) === 'http:') { return url.replace(/^http:\/\/[^:\/]+/, 'https://' + document.location.host); - } else { - return url; } + return url; }, /** @@ -240,13 +237,13 @@ var SN = { // StatusNet * * @access public */ - FormXHR: function(form, onSuccess) { + FormXHR: function (form, onSuccess) { $.ajax({ type: 'POST', dataType: 'xml', url: SN.U.RewriteAjaxAction(form.attr('action')), data: form.serialize() + '&ajax=1', - beforeSend: function(xhr) { + beforeSend: function (xhr) { form .addClass(SN.C.S.Processing) .find('.submit') @@ -261,7 +258,7 @@ var SN = { // StatusNet if (xhr.responseXML) { errorReported = $('#error', xhr.responseXML).text(); } - alert(errorReported || errorThrown || textStatus); + window.alert(errorReported || errorThrown || textStatus); // Restore the form to original state. // Hopefully. :D @@ -271,22 +268,20 @@ var SN = { // StatusNet .removeClass(SN.C.S.Disabled) .prop(SN.C.S.Disabled, false); }, - success: function(data, textStatus) { - if (typeof($('form', data)[0]) != 'undefined') { - form_new = document._importNode($('form', data)[0], true); + success: function (data, textStatus) { + if ($('form', data)[0] !== undefined) { + var form_new = document._importNode($('form', data)[0], true); form.replaceWith(form_new); if (onSuccess) { onSuccess(); } - } - else if (typeof($('p', data)[0]) != 'undefined') { + } else if ($('p', data)[0] !== undefined) { form.replaceWith(document._importNode($('p', data)[0], true)); if (onSuccess) { onSuccess(); } - } - else { - alert('Unknown error.'); + } else { + window.alert('Unknown error.'); } } }); @@ -319,7 +314,7 @@ var SN = { // StatusNet * * @access public */ - FormNoticeXHR: function(form) { + FormNoticeXHR: function (form) { SN.C.I.NoticeDataGeo = {}; form.append(''); @@ -333,7 +328,7 @@ var SN = { // StatusNet * @param {String} text * @access private */ - var showFeedback = function(cls, text) { + var showFeedback = function (cls, text) { form.append( $('

') .addClass(cls) @@ -344,14 +339,14 @@ var SN = { // StatusNet /** * Hide the previous response feedback, if any. */ - var removeFeedback = function() { + var removeFeedback = function () { form.find('.form_response').remove(); }; form.ajaxForm({ dataType: 'xml', timeout: '60000', - beforeSend: function(formData) { + beforeSend: function (formData) { if (form.find('.notice_data-text:first').val() == '') { form.addClass(SN.C.S.Warning); return false; @@ -376,43 +371,38 @@ var SN = { // StatusNet if (textStatus == 'timeout') { // @fixme i18n showFeedback('error', 'Sorry! We had trouble sending your notice. The servers are overloaded. Please try again, and contact the site administrator if this problem persists.'); - } - else { + } else { var response = SN.U.GetResponseXML(xhr); - if ($('.'+SN.C.S.Error, response).length > 0) { - form.append(document._importNode($('.'+SN.C.S.Error, response)[0], true)); - } - else { + if ($('.' + SN.C.S.Error, response).length > 0) { + form.append(document._importNode($('.' + SN.C.S.Error, response)[0], true)); + } else { if (parseInt(xhr.status) === 0 || jQuery.inArray(parseInt(xhr.status), SN.C.I.HTTP20x30x) >= 0) { form .resetForm() .find('.attach-status').remove(); SN.U.FormNoticeEnhancements(form); - } - else { + } else { // @fixme i18n - showFeedback('error', '(Sorry! We had trouble sending your notice ('+xhr.status+' '+xhr.statusText+'). Please report the problem to the site administrator if this happens again.'); + showFeedback('error', '(Sorry! We had trouble sending your notice (' + xhr.status + ' ' + xhr.statusText + '). Please report the problem to the site administrator if this happens again.'); } } } }, - success: function(data, textStatus) { + success: function (data, textStatus) { removeFeedback(); - var errorResult = $('#'+SN.C.S.Error, data); + var errorResult = $('#' + SN.C.S.Error, data); if (errorResult.length > 0) { showFeedback('error', errorResult.text()); - } - else { - if($('body')[0].id == 'bookmarklet') { + } else { + if ($('body')[0].id == 'bookmarklet') { // @fixme self is not referenced anywhere? self.close(); } - var commandResult = $('#'+SN.C.S.CommandResult, data); + var commandResult = $('#' + SN.C.S.CommandResult, data); if (commandResult.length > 0) { showFeedback('success', commandResult.text()); - } - else { + } else { // New notice post was successful. If on our timeline, show it! var notice = document._importNode($('li', data)[0], true); var notices = $('#notices_primary .notices:first'); @@ -425,33 +415,30 @@ var SN = { // StatusNet replyItem.remove(); var id = $(notice).attr('id'); - if ($("#"+id).length == 0) { + if ($('#' + id).length == 0) { $(notice).insertBefore(placeholder); - } else { - // Realtime came through before us... - } + } // else Realtime came through before us... // ...and show the placeholder form. placeholder.show(); } else if (notices.length > 0 && SN.U.belongsOnTimeline(notice)) { // Not a reply. If on our timeline, show it at the top! - if ($('#'+notice.id).length === 0) { + if ($('#' + notice.id).length === 0) { var notice_irt_value = form.find('[name=inreplyto]').val(); - var notice_irt = '#notices_primary #notice-'+notice_irt_value; - if($('body')[0].id == 'conversation') { - if(notice_irt_value.length > 0 && $(notice_irt+' .notices').length < 1) { + var notice_irt = '#notices_primary #notice-' + notice_irt_value; + if ($('body')[0].id == 'conversation') { + if (notice_irt_value.length > 0 && $(notice_irt + ' .notices').length < 1) { $(notice_irt).append(''); } - $($(notice_irt+' .notices')[0]).append(notice); - } - else { + $($(notice_irt + ' .notices')[0]).append(notice); + } else { notices.prepend(notice); } - $('#'+notice.id) - .css({display:'none'}) + $('#' + notice.id) + .css({display: 'none'}) .fadeIn(2500); - SN.U.NoticeWithAttachment($('#'+notice.id)); + SN.U.NoticeWithAttachment($('#' + notice.id)); SN.U.switchInputFormTab("placeholder"); } } else { @@ -467,7 +454,7 @@ var SN = { // StatusNet SN.U.FormNoticeEnhancements(form); } }, - complete: function(xhr, textStatus) { + complete: function (xhr, textStatus) { form .removeClass(SN.C.S.Processing) .find('.submit') @@ -483,13 +470,13 @@ var SN = { // StatusNet }); }, - FormProfileSearchXHR: function(form) { + FormProfileSearchXHR: function (form) { $.ajax({ type: 'POST', dataType: 'xml', url: form.attr('action'), data: form.serialize() + '&ajax=1', - beforeSend: function(xhr) { + beforeSend: function (xhr) { form .addClass(SN.C.S.Processing) .find('.submit') @@ -497,15 +484,14 @@ var SN = { // StatusNet .prop(SN.C.S.Disabled, true); }, error: function (xhr, textStatus, errorThrown) { - alert(errorThrown || textStatus); + window.alert(errorThrown || textStatus); }, - success: function(data, textStatus) { + success: function (data, textStatus) { var results_placeholder = $('#profile_search_results'); - if (typeof($('ul', data)[0]) != 'undefined') { + if ($('ul', data)[0] !== undefined) { var list = document._importNode($('ul', data)[0], true); results_placeholder.replaceWith(list); - } - else { + } else { var _error = $('
  • ').append(document._importNode($('p', data)[0], true)); results_placeholder.html(_error); } @@ -518,24 +504,24 @@ var SN = { // StatusNet }); }, - FormPeopletagsXHR: function(form) { + FormPeopletagsXHR: function (form) { $.ajax({ type: 'POST', dataType: 'xml', url: form.attr('action'), data: form.serialize() + '&ajax=1', - beforeSend: function(xhr) { + beforeSend: function (xhr) { form.find('.submit') .addClass(SN.C.S.Processing) .addClass(SN.C.S.Disabled) .prop(SN.C.S.Disabled, true); }, error: function (xhr, textStatus, errorThrown) { - alert(errorThrown || textStatus); + window.alert(errorThrown || textStatus); }, - success: function(data, textStatus) { + success: function (data, textStatus) { var results_placeholder = form.parents('.entity_tags'); - if (typeof($('.entity_tags', data)[0]) != 'undefined') { + if ($('.entity_tags', data)[0] !== undefined) { var tags = document._importNode($('.entity_tags', data)[0], true); $(tags).find('.editable').append($(''); + var attachStatus = $('
    '); attachStatus.find('code').text(filename); - attachStatus.find('button').click(function(){ + attachStatus.find('button').click(function () { attachStatus.remove(); NDA.val(''); @@ -924,9 +912,9 @@ var SN = { // StatusNet }); form.append(attachStatus); - if (typeof this.files == "object") { + if (typeof this.files === "object") { // Some newer browsers will let us fetch the files for preview. - for (var i = 0; i < this.files.length; i++) { + for (i = 0; i < this.files.length; i++) { SN.U.PreviewAttach(form, this.files[i]); } } @@ -940,13 +928,12 @@ var SN = { // StatusNet * @param {jQuery} form * @return int max size in bytes; 0 or negative means no limit */ - maxFileSize: function(form) { + maxFileSize: function (form) { var max = $(form).find('input[name=MAX_FILE_SIZE]').attr('value'); if (max) { return parseInt(max); - } else { - return 0; } + return 0; }, /** @@ -970,12 +957,12 @@ var SN = { // StatusNet * @todo detect pixel size? * @todo should we render a thumbnail to a canvas and then use the smaller image? */ - PreviewAttach: function(form, file) { + PreviewAttach: function (form, file) { var tooltip = file.type + ' ' + Math.round(file.size / 1024) + 'KB'; var preview = true; var blobAsDataURL; - if (typeof window.createObjectURL != "undefined") { + if (window.createObjectURL !== undefined) { /** * createObjectURL lets us reference the file directly from an * This produces a compact URL with an opaque reference to the file, @@ -986,10 +973,10 @@ var SN = { // StatusNet * - Safari 5.0.2: no * - Chrome 8.0.552.210: works! */ - blobAsDataURL = function(blob, callback) { + blobAsDataURL = function (blob, callback) { callback(window.createObjectURL(blob)); - } - } else if (typeof window.FileReader != "undefined") { + }; + } else if (window.FileReader !== undefined) { /** * FileAPI's FileReader can build a data URL from a blob's contents, * but it must read the file and build it asynchronously. This means @@ -1000,13 +987,13 @@ var SN = { // StatusNet * - Safari 5.0.2: no * - Chrome 8.0.552.210: works! */ - blobAsDataURL = function(blob, callback) { + blobAsDataURL = function (blob, callback) { var reader = new FileReader(); - reader.onload = function(event) { + reader.onload = function (event) { callback(reader.result); - } + }; reader.readAsDataURL(blob); - } + }; } else { preview = false; } @@ -1024,7 +1011,7 @@ var SN = { // StatusNet } if (preview) { - blobAsDataURL(file, function(url) { + blobAsDataURL(file, function (url) { var img = $('') .attr('title', tooltip) .attr('alt', tooltip) @@ -1052,10 +1039,10 @@ var SN = { // StatusNet * hard time figuring out if it's working or fixing if it's wrong. * */ - NoticeLocationAttach: function(form) { + NoticeLocationAttach: function (form) { // @fixme this should not be tied to the main notice form, as there may be multiple notice forms... - var NLat = form.find('[name=lat]') - var NLon = form.find('[name=lon]') + var NLat = form.find('[name=lat]'); + var NLon = form.find('[name=lon]'); var NLNS = form.find('[name=location_ns]').val(); var NLID = form.find('[name=location_id]').val(); var NLN = ''; // @fixme @@ -1086,23 +1073,22 @@ var SN = { // StatusNet function getJSONgeocodeURL(geocodeURL, data) { SN.U.NoticeGeoStatus(form, 'Looking up place name...'); - $.getJSON(geocodeURL, data, function(location) { - var lns, lid; + $.getJSON(geocodeURL, data, function (location) { + var lns, lid, NLN_text; - if (typeof(location.location_ns) != 'undefined') { + if (location.location_ns !== undefined) { form.find('[name=location_ns]').val(location.location_ns); lns = location.location_ns; } - if (typeof(location.location_id) != 'undefined') { + if (location.location_id !== undefined) { form.find('[name=location_id]').val(location.location_id); lid = location.location_id; } - if (typeof(location.name) == 'undefined') { + if (location.name === undefined) { NLN_text = data.lat + ';' + data.lon; - } - else { + } else { NLN_text = location.name; } @@ -1133,19 +1119,17 @@ var SN = { // StatusNet if (check.length > 0) { if ($.cookie(SN.C.S.NoticeDataGeoCookie) == 'disabled') { check.prop('checked', false); - } - else { + } else { check.prop('checked', true); } var NGW = form.find('.notice_data-geo_wrap'); var geocodeURL = NGW.attr('data-api'); - label - .attr('title', label.text()); + label.attr('title', label.text()); - check.change(function() { - if (check.prop('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === null) + check.change(function () { + if (check.prop('checked') === true || $.cookie(SN.C.S.NoticeDataGeoCookie) === null) { label .attr('title', NoticeDataGeo_text.ShareDisable) .addClass('checked'); @@ -1154,7 +1138,7 @@ var SN = { // StatusNet if (navigator.geolocation) { SN.U.NoticeGeoStatus(form, 'Requesting location from browser...'); navigator.geolocation.getCurrentPosition( - function(position) { + function (position) { form.find('[name=lat]').val(position.coords.latitude); form.find('[name=lon]').val(position.coords.longitude); @@ -1167,13 +1151,13 @@ var SN = { // StatusNet getJSONgeocodeURL(geocodeURL, data); }, - function(error) { + function (error) { switch(error.code) { case error.PERMISSION_DENIED: removeNoticeDataGeo('Location permission denied.'); break; case error.TIMEOUT: - //$('#'+SN.C.S.NoticeDataGeo).prop('checked', false); + //$('#' + SN.C.S.NoticeDataGeo).prop('checked', false); removeNoticeDataGeo('Location lookup timeout.'); break; } @@ -1183,8 +1167,7 @@ var SN = { // StatusNet timeout: 10000 } ); - } - else { + } else { if (NLat.length > 0 && NLon.length > 0) { var data = { lat: NLat, @@ -1193,15 +1176,13 @@ var SN = { // StatusNet }; getJSONgeocodeURL(geocodeURL, data); - } - else { + } else { removeNoticeDataGeo(); check.remove(); label.remove(); } } - } - else { + } else { var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie)); form.find('[name=lat]').val(cookieValue.NLat); @@ -1215,8 +1196,7 @@ var SN = { // StatusNet .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')') .addClass('checked'); } - } - else { + } else { removeNoticeDataGeo(); } }).change(); @@ -1232,12 +1212,12 @@ var SN = { // StatusNet * @param {String} lon (optional) * @param {String} url (optional) */ - NoticeGeoStatus: function(form, status, lat, lon, url) + NoticeGeoStatus: function (form, status, lat, lon, url) { var wrapper = form.find('.geo_status_wrapper'); if (wrapper.length == 0) { - wrapper = $('
    '); - wrapper.find('button.close').click(function() { + wrapper = $('
    '); + wrapper.find('button.close').click(function () { form.find('[name=notice_data-geo]').prop('checked', false).change(); return false; }); @@ -1272,27 +1252,26 @@ var SN = { // StatusNet * * @fixme breaks ability to open link in new window? */ - NewDirectMessage: function() { + NewDirectMessage: function () { NDM = $('.entity_send-a-message a'); - NDM.attr({'href':NDM.attr('href')+'&ajax=1'}); - NDM.on('click', function() { + NDM.attr({'href': NDM.attr('href') + '&ajax=1'}); + NDM.on('click', function () { var NDMF = $('.entity_send-a-message form'); if (NDMF.length === 0) { $(this).addClass(SN.C.S.Processing); - $.get(NDM.attr('href'), null, function(data) { + $.get(NDM.attr('href'), null, function (data) { $('.entity_send-a-message').append(document._importNode($('form', data)[0], true)); NDMF = $('.entity_send-a-message .form_notice'); SN.U.FormNoticeXHR(NDMF); SN.U.FormNoticeEnhancements(NDMF); NDMF.append(''); - $('.entity_send-a-message button').click(function(){ + $('.entity_send-a-message button').click(function () { NDMF.hide(); return false; }); NDM.removeClass(SN.C.S.Processing); }); - } - else { + } else { NDMF.show(); $('.entity_send-a-message textarea').focus(); } @@ -1309,7 +1288,7 @@ var SN = { // StatusNet * @param {number} day: 1 == 1 * @return {Date} */ - GetFullYear: function(year, month, day) { + GetFullYear: function (year, month, day) { var date = new Date(); date.setFullYear(year, month, day); @@ -1332,7 +1311,7 @@ var SN = { // StatusNet /** * @fixme what is this? */ - Set: function(value) { + Set: function (value) { var SNI = SN.U.StatusNetInstance.Get(); if (SNI !== null) { value = $.extend(SNI, value); @@ -1350,7 +1329,7 @@ var SN = { // StatusNet /** * @fixme what is this? */ - Get: function() { + Get: function () { var cookieValue = $.cookie(SN.C.S.StatusNetInstance); if (cookieValue !== null) { return JSON.parse(cookieValue); @@ -1361,7 +1340,7 @@ var SN = { // StatusNet /** * @fixme what is this? */ - Delete: function() { + Delete: function () { $.cookie(SN.C.S.StatusNetInstance, null); } }, @@ -1376,7 +1355,7 @@ var SN = { // StatusNet * @param {DOMElement} notice: HTML chunk with formatted notice * @return boolean */ - belongsOnTimeline: function(notice) { + belongsOnTimeline: function (notice) { var action = $("body").attr('id'); if (action == 'public') { return true; @@ -1408,15 +1387,15 @@ var SN = { // StatusNet * * @param {String} tag */ - switchInputFormTab: function(tag) { - // The one that's current isn't current anymore - $('.input_form_nav_tab.current').removeClass('current'); + switchInputFormTab: function (tag) { + // The one that's current isn't current anymore + $('.input_form_nav_tab.current').removeClass('current'); if (tag == 'placeholder') { // Hack: when showing the placeholder, mark the tab // as current for 'Status'. $('#input_form_nav_status').addClass('current'); } else { - $('#input_form_nav_'+tag).addClass('current'); + $('#input_form_nav_' + tag).addClass('current'); } // Don't remove 'current' if we also have the "nonav" class. @@ -1427,19 +1406,19 @@ var SN = { // StatusNet return; } - $('.input_form.current').removeClass('current'); - $('#input_form_'+tag) + $('.input_form.current').removeClass('current'); + $('#input_form_' + tag) .addClass('current') - .find('.ajax-notice').each(function() { + .find('.ajax-notice').each(function () { var form = $(this); SN.Init.NoticeFormSetup(form); }) .find('.notice_data-text').focus(); - }, + }, - showMoreMenuItems: function(menuid) { - $('#'+menuid+' .more_link').remove(); - var selector = '#'+menuid+' .extended_menu'; + showMoreMenuItems: function (menuid) { + $('#' + menuid + ' .more_link').remove(); + var selector = '#' + menuid + ' .extended_menu'; var extended = $(selector); extended.removeClass('extended_menu'); return void(0); @@ -1455,25 +1434,25 @@ var SN = { // StatusNet * - location events * - file upload events */ - NoticeForm: function() { + NoticeForm: function () { if ($('body.user_in').length > 0) { // SN.Init.NoticeFormSetup() will get run // when forms get displayed for the first time... // Hack to initialize the placeholder at top - $('#input_form_placeholder input.placeholder').focus(function() { + $('#input_form_placeholder input.placeholder').focus(function () { SN.U.switchInputFormTab("status"); }); // Make inline reply forms self-close when clicking out. - $('body').on('click', function(e) { + $('body').on('click', function (e) { var currentForm = $('#content .input_forms div.current'); if (currentForm.length > 0) { if ($('#content .input_forms').has(e.target).length == 0) { // If all fields are empty, switch back to the placeholder. var fields = currentForm.find('textarea, input[type=text], input[type=""]'); var anything = false; - fields.each(function() { + fields.each(function () { anything = anything || $(this).val(); }); if (!anything) { @@ -1485,7 +1464,7 @@ var SN = { // StatusNet var openReplies = $('li.notice-reply'); if (openReplies.length > 0) { var target = $(e.target); - openReplies.each(function() { + openReplies.each(function () { // Did we click outside this one? var replyItem = $(this); if (replyItem.has(e.target).length == 0) { @@ -1515,7 +1494,7 @@ var SN = { // StatusNet * * @param {jQuery} form */ - NoticeFormSetup: function(form) { + NoticeFormSetup: function (form) { if (!form.data('NoticeFormSetup')) { SN.U.NoticeLocationAttach(form); SN.U.FormNoticeXHR(form); @@ -1531,7 +1510,7 @@ var SN = { // StatusNet * - AJAX submission for fave/repeat/reply (if logged in) * - Attachment link extras ('more' links) */ - Notices: function() { + Notices: function () { if ($('body.user_in').length > 0) { var masterForm = $('.form_notice:first'); if (masterForm.length > 0) { @@ -1551,25 +1530,25 @@ var SN = { // StatusNet * - AJAX submission for sub/unsub/join/leave/nudge * - AJAX form popup for direct-message */ - EntityActions: function() { + EntityActions: function () { if ($('body.user_in').length > 0) { - $(document).on('click', '.form_user_subscribe', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_user_unsubscribe', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_group_join', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_group_leave', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_user_nudge', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_peopletag_subscribe', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_peopletag_unsubscribe', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_user_add_peopletag', function() { SN.U.FormXHR($(this)); return false; }); - $(document).on('click', '.form_user_remove_peopletag', function() { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_user_subscribe', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_user_unsubscribe', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_group_join', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_group_leave', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_user_nudge', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_peopletag_subscribe', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_peopletag_unsubscribe', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_user_add_peopletag', function () { SN.U.FormXHR($(this)); return false; }); + $(document).on('click', '.form_user_remove_peopletag', function () { SN.U.FormXHR($(this)); return false; }); SN.U.NewDirectMessage(); } }, - ProfileSearch: function() { + ProfileSearch: function () { if ($('body.user_in').length > 0) { - $(document).on('click', '.form_peopletag_edit_user_search input.submit', function() { + $(document).on('click', '.form_peopletag_edit_user_search input.submit', function () { SN.U.FormProfileSearchXHR($(this).parents('form')); return false; }); } @@ -1583,7 +1562,7 @@ var SN = { // StatusNet * * @fixme is this necessary? Browsers do their own form saving these days. */ - Login: function() { + Login: function () { if (SN.U.StatusNetInstance.Get() !== null) { var nickname = SN.U.StatusNetInstance.Get().Nickname; if (nickname !== null) { @@ -1591,7 +1570,7 @@ var SN = { // StatusNet } } - $('#form_login').on('submit', function() { + $('#form_login').on('submit', function () { SN.U.StatusNetInstance.Set({Nickname: $('#form_login #nickname').val()}); return true; }); @@ -1604,51 +1583,51 @@ var SN = { // StatusNet * - sets event handlers for tag completion * */ - PeopletagAutocomplete: function(txtBox) { - var split = function(val) { + PeopletagAutocomplete: function (txtBox) { + var split = function (val) { return val.split( /\s+/ ); } - var extractLast = function(term) { + var extractLast = function (term) { return split(term).pop(); } // don't navigate away from the field on tab when selecting an item - txtBox.on( "keydown", function( event ) { + txtBox.on( "keydown", function ( event ) { if ( event.keyCode === $.ui.keyCode.TAB && $(this).data( "autocomplete" ).menu.active ) { event.preventDefault(); } }).autocomplete({ minLength: 0, - source: function(request, response) { - // delegate back to autocomplete, but extract the last term - response($.ui.autocomplete.filter( - SN.C.PtagACData, extractLast(request.term))); - }, - focus: function() { - return false; + source: function (request, response) { + // delegate back to autocomplete, but extract the last term + response($.ui.autocomplete.filter( + SN.C.PtagACData, extractLast(request.term))); }, - select: function(event, ui) { - var terms = split(this.value); - terms.pop(); - terms.push(ui.item.value); - terms.push(""); - this.value = terms.join(" "); - return false; - } - }).data('autocomplete')._renderItem = function(ul, item) { + focus: function () { + return false; + }, + select: function (event, ui) { + var terms = split(this.value); + terms.pop(); + terms.push(ui.item.value); + terms.push(""); + this.value = terms.join(" "); + return false; + } + }).data('autocomplete')._renderItem = function (ul, item) { // FIXME: with jQuery UI you cannot have it highlight the match var _l = '' + item.tag + ' ' + item.mode + '' + '' + item.freq + '' - return $("
  • ") - .addClass('mode-' + item.mode) + return $("
  • ") + .addClass('mode-' + item.mode) .addClass('ptag-ac-line') .data("item.autocomplete", item) .append(_l) .appendTo(ul); - } + } }, /** @@ -1660,10 +1639,10 @@ var SN = { // StatusNet * or if it is stale. * */ - PeopleTags: function() { + PeopleTags: function () { $('.user_profile_tags .editable').append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(b){var a=b.find("input[type=file]");a.change(function(f){b.find(".attach-status").remove();var d=$(this).val();if(!d){return false}var c=$('
    ');c.find("code").text(d);c.find("button").click(function(){c.remove();a.val("");return false});b.append(c);if(typeof this.files=="object"){for(var e=0;eg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
    ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").attr("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,s;if(typeof(q.location_ns)!="undefined"){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(typeof(q.location_id)!="undefined"){a.find("[name=location_id]").val(q.location_id);s=q.location_id}if(typeof(q.name)=="undefined"){NLN_text=p.lat+";"+p.lon}else{NLN_text=q.name}SN.U.NoticeGeoStatus(a,NLN_text,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+NLN_text+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(s);a.find("[name=notice_data-geo]").attr("checked",true);var t={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:s,NLN:NLN_text,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(t),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.attr("checked",false)}else{c.attr("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.attr("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").attr("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
    ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").removeAttr("checked").change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.bind("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()},showMoreMenuItems:function(c){$("#"+c+" .more_link").remove();var b="#"+c+" .extended_menu";var a=$(b);a.removeClass("extended_menu");return void (0)}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").bind("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(".form_user_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_join").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_group_leave").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_nudge").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_subscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_peopletag_unsubscribe").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_add_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});$(".form_user_remove_peopletag").live("click",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(".form_peopletag_edit_user_search input.submit").live("click",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").bind("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.live("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
  • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('').closest(".notice-options").addClass("opaque");a.find("button.close").click(function(){$(this).remove();a.removeClass("dialogbox").closest(".notice-options").removeClass("opaque");a.find(".submit_dialogbox").remove();a.find(".submit").show();return false})},NoticeAttachments:function(){$(".notice a.attachment").each(function(){SN.U.NoticeWithAttachment($(this).closest(".notice"))})},NoticeWithAttachment:function(b){if(b.find(".attachment").length===0){return}var a=b.find(".attachment.more");if(a.length>0){$(a[0]).click(function(){var c=$(this);c.addClass(SN.C.S.Processing);$.get(c.attr("href")+"/ajax",null,function(d){c.parent(".entry-content").html($(d).find("#attachment_view .entry-content").html())});return false}).attr("title",SN.msg("showmore_tooltip"))}},NoticeDataAttach:function(c){var b;var a=c.find("input[type=file]");a.change(function(f){c.find(".attach-status").remove();var e=$(this).val();if(!e){return false}var d=$('
    ');d.find("code").text(e);d.find("button").click(function(){d.remove();a.val("");return false});c.append(d);if(typeof this.files==="object"){for(b=0;bg){f=false}if(f){h(c,function(k){var j=$("").attr("title",e).attr("alt",e).attr("src",k).attr("style","height: 120px");d.find(".attach-status").append(j)})}else{var b=$("
    ").text(e);d.find(".attach-status").append(b)}},NoticeLocationAttach:function(a){var e=a.find("[name=lat]");var l=a.find("[name=lon]");var g=a.find("[name=location_ns]").val();var m=a.find("[name=location_id]").val();var b="";var d=a.find("[name=notice_data-geo]");var c=a.find("[name=notice_data-geo]");var k=a.find("label.notice_data-geo");function f(o){k.attr("title",jQuery.trim(k.text())).removeClass("checked");a.find("[name=lat]").val("");a.find("[name=lon]").val("");a.find("[name=location_ns]").val("");a.find("[name=location_id]").val("");a.find("[name=notice_data-geo]").prop("checked",false);$.cookie(SN.C.S.NoticeDataGeoCookie,"disabled",{path:"/"});if(o){a.find(".geo_status_wrapper").removeClass("success").addClass("error");a.find(".geo_status_wrapper .geo_status").text(o)}else{a.find(".geo_status_wrapper").remove()}}function n(o,p){SN.U.NoticeGeoStatus(a,"Looking up place name...");$.getJSON(o,p,function(q){var r,t,s;if(q.location_ns!==undefined){a.find("[name=location_ns]").val(q.location_ns);r=q.location_ns}if(q.location_id!==undefined){a.find("[name=location_id]").val(q.location_id);t=q.location_id}if(q.name===undefined){s=p.lat+";"+p.lon}else{s=q.name}SN.U.NoticeGeoStatus(a,s,p.lat,p.lon,q.url);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+s+")");a.find("[name=lat]").val(p.lat);a.find("[name=lon]").val(p.lon);a.find("[name=location_ns]").val(r);a.find("[name=location_id]").val(t);a.find("[name=notice_data-geo]").prop("checked",true);var u={NLat:p.lat,NLon:p.lon,NLNS:r,NLID:t,NLN:s,NLNU:q.url,NDG:true};$.cookie(SN.C.S.NoticeDataGeoCookie,JSON.stringify(u),{path:"/"})})}if(c.length>0){if($.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){c.prop("checked",false)}else{c.prop("checked",true)}var h=a.find(".notice_data-geo_wrap");var j=h.attr("data-api");k.attr("title",k.text());c.change(function(){if(c.prop("checked")===true||$.cookie(SN.C.S.NoticeDataGeoCookie)===null){k.attr("title",NoticeDataGeo_text.ShareDisable).addClass("checked");if($.cookie(SN.C.S.NoticeDataGeoCookie)===null||$.cookie(SN.C.S.NoticeDataGeoCookie)=="disabled"){if(navigator.geolocation){SN.U.NoticeGeoStatus(a,"Requesting location from browser...");navigator.geolocation.getCurrentPosition(function(q){a.find("[name=lat]").val(q.coords.latitude);a.find("[name=lon]").val(q.coords.longitude);var r={lat:q.coords.latitude,lon:q.coords.longitude,token:$("#token").val()};n(j,r)},function(q){switch(q.code){case q.PERMISSION_DENIED:f("Location permission denied.");break;case q.TIMEOUT:f("Location lookup timeout.");break}},{timeout:10000})}else{if(e.length>0&&l.length>0){var o={lat:e,lon:l,token:$("#token").val()};n(j,o)}else{f();c.remove();k.remove()}}}else{var p=JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie));a.find("[name=lat]").val(p.NLat);a.find("[name=lon]").val(p.NLon);a.find("[name=location_ns]").val(p.NLNS);a.find("[name=location_id]").val(p.NLID);a.find("[name=notice_data-geo]").prop("checked",p.NDG);SN.U.NoticeGeoStatus(a,p.NLN,p.NLat,p.NLon,p.NLNU);k.attr("title",NoticeDataGeo_text.ShareDisable+" ("+p.NLN+")").addClass("checked")}}else{f()}}).change()}},NoticeGeoStatus:function(e,a,f,g,c){var h=e.find(".geo_status_wrapper");if(h.length==0){h=$('
    ');h.find("button.close").click(function(){e.find("[name=notice_data-geo]").prop("checked",false).change();return false});e.append(h)}var b;if(c){b=$("").attr("href",c)}else{b=$("")}b.text(a);if(f||g){var d=f+";"+g;b.attr("title",d);if(!a){b.text(d)}}h.find(".geo_status").empty().append(b)},NewDirectMessage:function(){NDM=$(".entity_send-a-message a");NDM.attr({href:NDM.attr("href")+"&ajax=1"});NDM.on("click",function(){var a=$(".entity_send-a-message form");if(a.length===0){$(this).addClass(SN.C.S.Processing);$.get(NDM.attr("href"),null,function(b){$(".entity_send-a-message").append(document._importNode($("form",b)[0],true));a=$(".entity_send-a-message .form_notice");SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);a.append('');$(".entity_send-a-message button").click(function(){a.hide();return false});NDM.removeClass(SN.C.S.Processing)})}else{a.show();$(".entity_send-a-message textarea").focus()}return false})},GetFullYear:function(c,d,a){var b=new Date();b.setFullYear(c,d,a);return b},StatusNetInstance:{Set:function(b){var a=SN.U.StatusNetInstance.Get();if(a!==null){b=$.extend(a,b)}$.cookie(SN.C.S.StatusNetInstance,JSON.stringify(b),{path:"/",expires:SN.U.GetFullYear(2029,0,1)})},Get:function(){var a=$.cookie(SN.C.S.StatusNetInstance);if(a!==null){return JSON.parse(a)}return null},Delete:function(){$.cookie(SN.C.S.StatusNetInstance,null)}},belongsOnTimeline:function(b){var a=$("body").attr("id");if(a=="public"){return true}var c=$("#nav_profile a").attr("href");if(c){var d=$(b).find(".vcard.author a.url").attr("href");if(d==c){if(a=="all"||a=="showstream"){return true}}}return false},switchInputFormTab:function(a){$(".input_form_nav_tab.current").removeClass("current");if(a=="placeholder"){$("#input_form_nav_status").addClass("current")}else{$("#input_form_nav_"+a).addClass("current")}var b=$(".input_form.current.nonav");if(b.length>0){return}$(".input_form.current").removeClass("current");$("#input_form_"+a).addClass("current").find(".ajax-notice").each(function(){var c=$(this);SN.Init.NoticeFormSetup(c)}).find(".notice_data-text").focus()},showMoreMenuItems:function(c){$("#"+c+" .more_link").remove();var b="#"+c+" .extended_menu";var a=$(b);a.removeClass("extended_menu");return void (0)}},Init:{NoticeForm:function(){if($("body.user_in").length>0){$("#input_form_placeholder input.placeholder").focus(function(){SN.U.switchInputFormTab("status")});$("body").on("click",function(g){var d=$("#content .input_forms div.current");if(d.length>0){if($("#content .input_forms").has(g.target).length==0){var a=d.find('textarea, input[type=text], input[type=""]');var c=false;a.each(function(){c=c||$(this).val()});if(!c){SN.U.switchInputFormTab("placeholder")}}}var b=$("li.notice-reply");if(b.length>0){var f=$(g.target);b.each(function(){var k=$(this);if(k.has(g.target).length==0){var h=k.find(".notice_data-text:first");var j=$.trim(h.val());if(j==""||j==h.data("initialText")){var e=k.closest("li.notice");k.remove();e.find("li.notice-reply-placeholder").show()}}})}});$(".input_forms fieldset fieldset label").inFieldLabels({fadeOpacity:0})}},NoticeFormSetup:function(a){if(!a.data("NoticeFormSetup")){SN.U.NoticeLocationAttach(a);SN.U.FormNoticeXHR(a);SN.U.FormNoticeEnhancements(a);SN.U.NoticeDataAttach(a);a.data("NoticeFormSetup",true)}},Notices:function(){if($("body.user_in").length>0){var a=$(".form_notice:first");if(a.length>0){SN.C.I.NoticeFormMaster=document._importNode(a[0],true)}SN.U.NoticeRepeat();SN.U.NoticeReply();SN.U.NoticeInlineReplySetup()}SN.U.NoticeAttachments()},EntityActions:function(){if($("body.user_in").length>0){$(document).on("click",".form_user_subscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_unsubscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_group_join",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_group_leave",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_nudge",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_peopletag_subscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_peopletag_unsubscribe",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_add_peopletag",function(){SN.U.FormXHR($(this));return false});$(document).on("click",".form_user_remove_peopletag",function(){SN.U.FormXHR($(this));return false});SN.U.NewDirectMessage()}},ProfileSearch:function(){if($("body.user_in").length>0){$(document).on("click",".form_peopletag_edit_user_search input.submit",function(){SN.U.FormProfileSearchXHR($(this).parents("form"));return false})}},Login:function(){if(SN.U.StatusNetInstance.Get()!==null){var a=SN.U.StatusNetInstance.Get().Nickname;if(a!==null){$("#form_login #nickname").val(a)}}$("#form_login").on("submit",function(){SN.U.StatusNetInstance.Set({Nickname:$("#form_login #nickname").val()});return true})},PeopletagAutocomplete:function(b){var a=function(d){return d.split(/\s+/)};var c=function(d){return a(d).pop()};b.on("keydown",function(d){if(d.keyCode===$.ui.keyCode.TAB&&$(this).data("autocomplete").menu.active){d.preventDefault()}}).autocomplete({minLength:0,source:function(e,d){d($.ui.autocomplete.filter(SN.C.PtagACData,c(e.term)))},focus:function(){return false},select:function(e,f){var d=a(this.value);d.pop();d.push(f.item.value);d.push("");this.value=d.join(" ");return false}}).data("autocomplete")._renderItem=function(e,f){var d=''+f.tag+' '+f.mode+''+f.freq+"";return $("
  • ").addClass("mode-"+f.mode).addClass("ptag-ac-line").data("item.autocomplete",f).append(d).appendTo(e)}},PeopleTags:function(){$(".user_profile_tags .editable").append($('