]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Needed to add notice_id to selected fields ... :-(
[quix0rs-gnu-social.git] / js / util.js
index 82ca6e4bcec149bb118742e0915b629c82c8dac7..9c727e9a5376b2cde9d5d9a2418ea57988dc6af0 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?
@@ -1382,14 +1382,11 @@ 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, setFocus) {
+            if (typeof setFocus === 'undefined') { setFocus = true; }
+            // 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');
             }
 
@@ -1401,17 +1398,24 @@ 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;
-    },
+            var noticeForm = $('#input_form_' + tag)
+                    .addClass('current')
+                    .find('.ajax-notice').each(function () {
+                        var form = $(this);
+                        SN.Init.NoticeFormSetup(form);
+                    });
+            if (setFocus) {
+                noticeForm.find('.notice_data-text').focus();
+            }
+
+            return false;
+        },
 
         showMoreMenuItems: function (menuid) {
             $('#' + menuid + ' .more_link').remove();
@@ -1436,28 +1440,14 @@ 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");
+                // Initialize the input form field
+                $('#input_form_nav .input_form_nav_tab.current').each(function () {
+                    current_tab_id = $(this).attr('id').substring('input_form_nav_'.length);
+                    SN.U.switchInputFormTab(current_tab_id, false);
                 });
 
                 // Make inline reply forms self-close when clicking out.
                 $('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 () {
-                                anything = anything || $(this).val();
-                            });
-                            if (!anything) {
-                                SN.U.switchInputFormTab("placeholder");
-                            }
-                        }
-                    }
-
                     var openReplies = $('li.notice-reply');
                     if (openReplies.length > 0) {
                         var target = $(e.target);
@@ -1480,7 +1470,6 @@ var SN = { // StatusNet
 
                 // Infield labels for notice form inputs.
                 $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 });
-
             }
         },