]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Make sure we add ajax=1 to inputform if using javascript
[quix0rs-gnu-social.git] / js / util.js
index 1d01f72ecd27a472368d03beccd4ab71399ffdd1..793626ed25bfd580374415bdd980d1e3ebceeae6 100644 (file)
@@ -433,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?
@@ -749,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) {
@@ -773,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));
@@ -857,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: 1}, function (data) {
-                        m.parent('.e-content').html($(data).find('#attachment_view .e-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'));
-            }
         },
 
         /**
@@ -1374,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;
         },
 
@@ -1385,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');
             }
 
@@ -1404,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;
+            }
+
+            $('#input_form_' + tag)
+                    .addClass('current')
+                    .find('.ajax-notice').each(function () {
+                        var form = $(this);
+                        SN.Init.NoticeFormSetup(form);
+                    })
+                    .find('.notice_data-text').focus();
 
-        return false;
-    },
+            return false;
+        },
 
         showMoreMenuItems: function (menuid) {
             $('#' + menuid + ' .more_link').remove();
@@ -1439,10 +1437,8 @@ 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 show Status tab
+                SN.U.switchInputFormTab("status");
 
                 // Make inline reply forms self-close when clicking out.
                 $('body').on('click', function (e) {
@@ -1456,7 +1452,7 @@ var SN = { // StatusNet
                                 anything = anything || $(this).val();
                             });
                             if (!anything) {
-                                SN.U.switchInputFormTab("placeholder");
+                                SN.U.switchInputFormTab(null);
                             }
                         }
                     }
@@ -1483,7 +1479,6 @@ var SN = { // StatusNet
 
                 // Infield labels for notice form inputs.
                 $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 });
-
             }
         },