X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=js%2Futil.js;h=19a9ead52462f236f7878146104846dfad35e89e;hb=59ec9c6988608f665fb7cea5eb4f3feb56db892f;hp=5f95595edd134ec5c646ee151b7e9c536709447c;hpb=c0f65f6ea76ffa035cbf2c4126bedaae9d8752c8;p=quix0rs-gnu-social.git diff --git a/js/util.js b/js/util.js index 5f95595edd..19a9ead524 100644 --- a/js/util.js +++ b/js/util.js @@ -308,7 +308,6 @@ var SN = { // StatusNet * @fixme cookieValue is a global variable, but probably shouldn't be * @fixme saving the location cache cookies should be split out * @fixme some error messages are hardcoded english: needs i18n - * @fixme special-case for bookmarklet is confusing and uses a global var "self". Is this ok? * * @param {jQuery} form: jQuery object whose first element is a form * @@ -394,11 +393,6 @@ var SN = { // StatusNet if (errorResult.length > 0) { showFeedback('error', errorResult.text()); } else { - if ($('body')[0].id == 'bookmarklet') { - // @fixme self is not referenced anywhere? - self.close(); - } - var commandResult = $('#' + SN.C.S.CommandResult, data); if (commandResult.length > 0) { showFeedback('success', commandResult.text()); @@ -439,7 +433,7 @@ var SN = { // StatusNet .css({display: 'none'}) .fadeIn(2500); SN.U.NoticeWithAttachment($('#' + notice.id)); - SN.U.switchInputFormTab("placeholder"); + SN.U.switchInputFormTab(null); } } else { // Not on a timeline that this belongs on? @@ -755,8 +749,7 @@ var SN = { // StatusNet SN.U.NoticeInlineReplyTrigger(notice); return false; }); - $('li.notice-reply-comments a') - .on('click', function () { + $(document).on('click', 'li.notice-reply-comments a', function () { var url = $(this).attr('href'); var area = $(this).closest('.threaded-replies'); $.get(url, {ajax: 1}, function (data, textStatus, xhr) { @@ -779,7 +772,7 @@ var SN = { // StatusNet * */ NoticeRepeat: function () { - $('.form_repeat').on('click', function (e) { + $('body').on('click', '.form_repeat', function (e) { e.preventDefault(); SN.U.NoticeRepeatConfirmation($(this)); @@ -863,18 +856,16 @@ var SN = { // StatusNet return; } - var attachment_more = notice.find('.attachment.more'); - if (attachment_more.length > 0) { - $(attachment_more[0]).click(function () { - var m = $(this); - m.addClass(SN.C.S.Processing); - $.get(m.attr('href') + '/ajax', null, function (data) { - m.parent('.entry-content').html($(data).find('#attachment_view .entry-content').html()); - }); + $(document).on('click','.attachment.more',function () { + var m = $(this); + m.addClass(SN.C.S.Processing); + $.get(m.attr('href'), {ajax: 1}, function (data) { + m.parent('.e-content').html($(data).find('#attachment_view .e-content').html()); + }); + + return false; + }); - return false; - }).attr('title', SN.msg('showmore_tooltip')); - } }, /** @@ -1183,18 +1174,22 @@ var SN = { // StatusNet } } } else { - var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie)); - - form.find('[name=lat]').val(cookieValue.NLat); - form.find('[name=lon]').val(cookieValue.NLon); - form.find('[name=location_ns]').val(cookieValue.NLNS); - form.find('[name=location_id]').val(cookieValue.NLID); - form.find('[name=notice_data-geo]').prop('checked', cookieValue.NDG); - - SN.U.NoticeGeoStatus(form, cookieValue.NLN, cookieValue.NLat, cookieValue.NLon, cookieValue.NLNU); - label - .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')') - .addClass('checked'); + try { + var cookieValue = JSON.parse($.cookie(SN.C.S.NoticeDataGeoCookie)); + + form.find('[name=lat]').val(cookieValue.NLat); + form.find('[name=lon]').val(cookieValue.NLon); + form.find('[name=location_ns]').val(cookieValue.NLNS); + form.find('[name=location_id]').val(cookieValue.NLID); + form.find('[name=notice_data-geo]').prop('checked', cookieValue.NDG); + + SN.U.NoticeGeoStatus(form, cookieValue.NLN, cookieValue.NLat, cookieValue.NLon, cookieValue.NLNU); + label + .attr('title', NoticeDataGeo_text.ShareDisable + ' (' + cookieValue.NLN + ')') + .addClass('checked'); + } catch (e) { + console.log('Parsing error:', e); + } } } else { removeNoticeDataGeo(); @@ -1363,7 +1358,7 @@ var SN = { // StatusNet var profileLink = $('#nav_profile a').attr('href'); if (profileLink) { - var authorUrl = $(notice).find('.vcard.author a.url').attr('href'); + var authorUrl = $(notice).find('.h-card.p-author').attr('href'); if (authorUrl == profileLink) { if (action == 'all' || action == 'showstream') { // Posts always show on your own friends and profile streams. @@ -1376,7 +1371,7 @@ var SN = { // StatusNet // Mismatch between id-based and name-based user/group links currently complicates // the lookup, since all our inline mentions contain the absolute links but the // UI links currently on the page use malleable names. - + return false; }, @@ -1387,14 +1382,10 @@ 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'); - if (tag == 'placeholder') { - // Hack: when showing the placeholder, mark the tab - // as current for 'Status'. - $('#input_form_nav_status').addClass('current'); - } else { + switchInputFormTab: function (tag) { + // The one that's current isn't current anymore + $('.input_form_nav_tab.current').removeClass('current'); + if (tag != null) { $('#input_form_nav_' + tag).addClass('current'); } @@ -1406,17 +1397,22 @@ var SN = { // StatusNet return; } - $('.input_form.current').removeClass('current'); - $('#input_form_' + tag) - .addClass('current') - .find('.ajax-notice').each(function () { - var form = $(this); - SN.Init.NoticeFormSetup(form); - }) - .find('.notice_data-text').focus(); + $('.input_form.current').removeClass('current'); + if (tag == null) { + // we're done here, no new inputform to focus on + return false; + } - return false; - }, + $('#input_form_' + tag) + .addClass('current') + .find('.ajax-notice').each(function () { + var form = $(this); + SN.Init.NoticeFormSetup(form); + }) + .find('.notice_data-text').focus(); + + return false; + }, showMoreMenuItems: function (menuid) { $('#' + menuid + ' .more_link').remove(); @@ -1441,10 +1437,16 @@ var SN = { // StatusNet // 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 () { - SN.U.switchInputFormTab("status"); + // Initially hide all tabs on the top of the page + // if there's no data in there yet. + var fields = $('#content .input_forms .input_form.current').find('textarea, input[type=text], input[type=""]'); + var anything = false; + fields.each(function () { + anything = anything || $(this).val(); }); + if (!anything) { + SN.U.switchInputFormTab(null); + } // Make inline reply forms self-close when clicking out. $('body').on('click', function (e) { @@ -1458,7 +1460,7 @@ var SN = { // StatusNet anything = anything || $(this).val(); }); if (!anything) { - SN.U.switchInputFormTab("placeholder"); + SN.U.switchInputFormTab(null); } } } @@ -1485,7 +1487,6 @@ var SN = { // StatusNet // Infield labels for notice form inputs. $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 }); - } },