]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Merge branch '1.0.x' into 1.1.x
[quix0rs-gnu-social.git] / js / util.js
index b983f2e8a64875e4c44bc34b64e86495e5c34204..c22802651a1f270eae9ba4a7714f0ceabf04e239 100644 (file)
@@ -273,15 +273,14 @@ var SN = { // StatusNet
                 },
                 success: function(data, textStatus) {
                     if (typeof($('form', data)[0]) != 'undefined') {
-                        var form_new = $('form', $(data).children());
+                        form_new = document._importNode($('form', data)[0], true);
                         form.replaceWith(form_new);
                         if (onSuccess) {
                             onSuccess();
                         }
                     }
                     else if (typeof($('p', data)[0]) != 'undefined') {
-                        var p_new = $('p', $(data).children());
-                        form.replaceWith(p_new);
+                        form.replaceWith(document._importNode($('p', data)[0], true));
                         if (onSuccess) {
                             onSuccess();
                         }
@@ -503,11 +502,11 @@ var SN = { // StatusNet
                 success: function(data, textStatus) {
                     var results_placeholder = $('#profile_search_results');
                     if (typeof($('ul', data)[0]) != 'undefined') {
-                        var list = $('ul', $(data).children());
+                        var list = document._importNode($('ul', data)[0], true);
                         results_placeholder.replaceWith(list);
                     }
                     else {
-                        var _error = $('<li/>').append($('p', $(data).children()));
+                        var _error = $('<li/>').append(document._importNode($('p', data)[0], true));
                         results_placeholder.html(_error);
                     }
                     form
@@ -537,12 +536,12 @@ var SN = { // StatusNet
                 success: function(data, textStatus) {
                     var results_placeholder = form.parents('.entity_tags');
                     if (typeof($('.entity_tags', data)[0]) != 'undefined') {
-                        var tags = $('.entity_tags', $(data).children());
+                        var tags = document._importNode($('.entity_tags', data)[0], true);
                         $(tags).find('.editable').append($('<button class="peopletags_edit_button"/>'));
                         results_placeholder.replaceWith(tags);
                     } else {
                         results_placeholder.find('p').remove();
-                        results_placeholder.append($('p', $(data).children()));
+                        results_placeholder.append(document._importNode($('p', data)[0], true));
                         form.removeClass(SN.C.S.Processing)
                             .find('.submit')
                                 .removeClass(SN.C.S.Disabled)
@@ -639,13 +638,23 @@ var SN = { // StatusNet
             // Find the notice we're replying to...
             var id = $($('.notice_id', notice)[0]).text();
             var parentNotice = notice;
+            var stripForm = true; // strip a couple things out of reply forms that are inline
 
             // Find the threaded replies view we'll be adding to...
             var list = notice.closest('.notices');
-            if (list.hasClass('threaded-replies')) {
+            if (list.closest('.old-school').length) {
+               // We're replying to an old-school conversation thread;
+               // use the old-style ping into the top form.
+               SN.U.switchInputFormTab("status")
+               replyForm = $('#input_form_status').find('form');
+               stripForm = false;
+            } else if (list.hasClass('threaded-replies')) {
                 // We're replying to a reply; use reply form on the end of this list.
                 // We'll add our form at the end of this; grab the root notice.
                 parentNotice = list.closest('.notice');
+
+                       // See if the form's already open...
+                       var replyForm = $('.notice-reply-form', list);
             } else {
                 // We're replying to a parent notice; pull its threaded list
                 // and we'll add on the end of it. Will add if needed.
@@ -659,18 +668,21 @@ var SN = { // StatusNet
                         SN.U.NoticeInlineReplyPlaceholder(notice);
                     }
                 }
-            }
 
-            // See if the form's already open...
-            var replyForm = $('.notice-reply-form', list);
+                       // See if the form's already open...
+                       var replyForm = $('.notice-reply-form', list);
+            }
 
             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();
+                if (stripForm) {
+                       // Don't do this for old-school reply form, as they don't come back!
+                       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');
@@ -702,10 +714,11 @@ var SN = { // StatusNet
                     replyItem = $('<li class="notice-reply"></li>');
 
                     var intermediateStep = function(formMaster) {
-                        replyItem.append(formMaster);
+                        var formEl = document._importNode(formMaster, true);
+                        replyItem.append(formEl);
                         list.append(replyItem); // *after* the placeholder
 
-                        var form = replyForm = formMaster;
+                        var form = replyForm = $(formEl);
                         SN.Init.NoticeFormSetup(form);
 
                         nextStep();
@@ -720,8 +733,8 @@ var SN = { // StatusNet
                         // @fixme this fallback may or may not work
                         var url = $('#form_notice').attr('action');
                         $.get(url, {ajax: 1}, function(data, textStatus, xhr) {
-                            intermediateStep($('form', $(data).children()));
-                        }, 'xml');
+                            intermediateStep($('form', data)[0]);
+                        });
                     }
                 }
             }
@@ -735,7 +748,7 @@ var SN = { // StatusNet
                 list = notice.find('ul.threaded-replies');
             }
             var placeholder = $('<li class="notice-reply-placeholder">' +
-                                    '<input class="placeholder">' +
+                                    '<input class="placeholder" />' +
                                 '</li>');
             placeholder.find('input')
                 .val(SN.msg('reply_placeholder'));
@@ -760,11 +773,11 @@ var SN = { // StatusNet
                     var url = $(this).attr('href');
                     var area = $(this).closest('.threaded-replies');
                     $.get(url, {ajax: 1}, function(data, textStatus, xhr) {
-                        var replies = $('.threaded-replies', $(data).children());
+                        var replies = $('.threaded-replies', data);
                         if (replies.length) {
-                            area.replaceWith(replies);
+                            area.replaceWith(document._importNode(replies[0], true));
                         }
-                    }, 'xml');
+                    });
                     return false;
                 });
         },
@@ -1267,7 +1280,7 @@ var SN = { // StatusNet
                 if (NDMF.length === 0) {
                     $(this).addClass(SN.C.S.Processing);
                     $.get(NDM.attr('href'), null, function(data) {
-                        $('.entity_send-a-message').append($('form', $(data).children()));
+                        $('.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);
@@ -1277,7 +1290,7 @@ var SN = { // StatusNet
                             return false;
                         });
                         NDM.removeClass(SN.C.S.Processing);
-                    }, 'xml');
+                    });
                 }
                 else {
                     NDMF.show();
@@ -1422,7 +1435,15 @@ var SN = { // StatusNet
                     SN.Init.NoticeFormSetup(form);
                 })
                 .find('.notice_data-text').focus();
-       }
+       },
+
+        showMoreMenuItems: function(menuid) {
+            $('#'+menuid+' .more_link').remove();
+            var selector = '#'+menuid+' .extended_menu';
+            var extended = $(selector);
+            extended.removeClass('extended_menu');
+            return void(0);
+        }
     },
 
     Init: {
@@ -1514,7 +1535,7 @@ var SN = { // StatusNet
             if ($('body.user_in').length > 0) {
                 var masterForm = $('.form_notice:first');
                 if (masterForm.length > 0) {
-                    SN.C.I.NoticeFormMaster = masterForm;
+                    SN.C.I.NoticeFormMaster = document._importNode(masterForm[0], true);
                 }
                 SN.U.NoticeRepeat();
                 SN.U.NoticeReply();