]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Just had to update util.min.js one more time for extra merge conflict fun!
[quix0rs-gnu-social.git] / js / util.js
index 844a5adb8dfab8ee294a924f95696c07643f2883..5c12ab111db536d221a22d841c2db013f4e0e346 100644 (file)
@@ -236,10 +236,11 @@ var SN = { // StatusNet
          * @fixme can't submit file uploads
          *
          * @param {jQuery} form: jQuery object whose first element is a form
+         * @param function onSuccess: something extra to do on success
          *
          * @access public
          */
-        FormXHR: function(form) {
+        FormXHR: function(form, onSuccess) {
             $.ajax({
                 type: 'POST',
                 dataType: 'xml',
@@ -261,7 +262,7 @@ var SN = { // StatusNet
                         errorReported = $('#error', xhr.responseXML).text();
                     }
                     alert(errorReported || errorThrown || textStatus);
-                    
+
                     // Restore the form to original state.
                     // Hopefully. :D
                     form
@@ -274,9 +275,15 @@ var SN = { // StatusNet
                     if (typeof($('form', data)[0]) != 'undefined') {
                         form_new = document._importNode($('form', data)[0], true);
                         form.replaceWith(form_new);
+                        if (onSuccess) {
+                            onSuccess();
+                        }
                     }
                     else if (typeof($('p', data)[0]) != 'undefined') {
                         form.replaceWith(document._importNode($('p', data)[0], true));
+                        if (onSuccess) {
+                            onSuccess();
+                        }
                     }
                     else {
                         alert('Unknown error.');
@@ -499,7 +506,7 @@ var SN = { // StatusNet
                         results_placeholder.replaceWith(list);
                     }
                     else {
-                        var _error = $('<li/>').append(document._importNode($('p', data)[0], true)); 
+                        var _error = $('<li/>').append(document._importNode($('p', data)[0], true));
                         results_placeholder.html(_error);
                     }
                     form
@@ -609,8 +616,7 @@ var SN = { // StatusNet
             $('#content .notice_reply').live('click', function(e) {
                 e.preventDefault();
                 var notice = $(this).closest('li.notice');
-                var nickname = ($('.author .nickname', notice).length > 0) ? $($('.author .nickname', notice)[0]) : $('.author .nickname.uid');
-                SN.U.NoticeInlineReplyTrigger(notice, '@' + nickname.text());
+                SN.U.NoticeInlineReplyTrigger(notice);
                 return false;
             });
         },
@@ -644,8 +650,13 @@ var SN = { // StatusNet
                 // and we'll add on the end of it. Will add if needed.
                 list = $('ul.threaded-replies', notice);
                 if (list.length == 0) {
-                    list = $('<ul class="notices threaded-replies xoxo"></ul>');
-                    notice.append(list);
+                    SN.U.NoticeInlineReplyPlaceholder(notice);
+                    list = $('ul.threaded-replies', notice);
+                } else {
+                    var placeholder = $('li.notice-reply-placeholder', notice);
+                    if (placeholder.length == 0) {
+                        SN.U.NoticeInlineReplyPlaceholder(notice);
+                    }
                 }
             }
 
@@ -655,6 +666,10 @@ var SN = { // StatusNet
             var nextStep = function() {
                 // Override...?
                 replyForm.find('input[name=inreplyto]').val(id);
+                replyForm.find('#notice_to').attr('disabled', 'disabled').hide();
+                replyForm.find('#notice_private').attr('disabled', 'disabled').hide();
+                replyForm.find('label[for=notice_to]').hide();
+                replyForm.find('label[for=notice_private]').hide();
 
                 // Set focus...
                 var text = replyForm.find('textarea');
@@ -714,6 +729,11 @@ var SN = { // StatusNet
 
         NoticeInlineReplyPlaceholder: function(notice) {
             var list = notice.find('ul.threaded-replies');
+            if (list.length == 0) {
+                list = $('<ul class="notices threaded-replies xoxo"></ul>');
+                notice.append(list);
+                list = notice.find('ul.threaded-replies');
+            }
             var placeholder = $('<li class="notice-reply-placeholder">' +
                                     '<input class="placeholder">' +
                                 '</li>');
@@ -756,6 +776,7 @@ var SN = { // StatusNet
          * popout before submitting.
          *
          * Uses 'live' rather than 'bind', so applies to future as well as present items.
+         *
          */
         NoticeRepeat: function() {
             $('.form_repeat').live('click', function(e) {
@@ -1385,6 +1406,14 @@ var SN = { // StatusNet
                 $('#input_form_nav_'+tag).addClass('current');
             }
 
+            // Don't remove 'current' if we also have the "nonav" class.
+            // An example would be the message input form. removing
+            // 'current' will cause the form to vanish from the page.
+            var nonav = $('.input_form.current.nonav');
+            if (nonav.length > 0) {
+                return;
+            }
+
            $('.input_form.current').removeClass('current');
            $('#input_form_'+tag)
                 .addClass('current')
@@ -1392,7 +1421,7 @@ var SN = { // StatusNet
                     var form = $(this);
                     SN.Init.NoticeFormSetup(form);
                 })
-                .find('textarea:first').focus();
+                .find('.notice_data-text').focus();
        }
     },
 
@@ -1451,6 +1480,10 @@ var SN = { // StatusNet
                         });
                     }
                 });
+
+                // Infield labels for notice form inputs.
+                $('.input_forms fieldset fieldset label').inFieldLabels({ fadeOpacity:0 });
+
             }
         },