]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - js/util.js
Revert "Revert back to using document._importNode() for ajax posting"
[quix0rs-gnu-social.git] / js / util.js
index 2cb370ef5f8922b4256999a0cdaf25802c4594a8..b983f2e8a64875e4c44bc34b64e86495e5c34204 100644 (file)
@@ -95,7 +95,6 @@ var SN = { // StatusNet
          * @access private
          */
         FormNoticeEnhancements: function(form) {
-            console.log("FormNoticeEnhancements - begin");
             if (jQuery.data(form[0], 'ElementData') === undefined) {
                 MaxLength = form.find('.count').text();
                 if (typeof(MaxLength) == 'undefined') {
@@ -274,14 +273,15 @@ var SN = { // StatusNet
                 },
                 success: function(data, textStatus) {
                     if (typeof($('form', data)[0]) != 'undefined') {
-                        form_new = document._importNode($('form', data)[0], true);
+                        var form_new = $('form', $(data).children());
                         form.replaceWith(form_new);
                         if (onSuccess) {
                             onSuccess();
                         }
                     }
                     else if (typeof($('p', data)[0]) != 'undefined') {
-                        form.replaceWith(document._importNode($('p', data)[0], true));
+                        var p_new = $('p', $(data).children());
+                        form.replaceWith(p_new);
                         if (onSuccess) {
                             onSuccess();
                         }
@@ -321,7 +321,6 @@ var SN = { // StatusNet
          * @access public
          */
         FormNoticeXHR: function(form) {
-            console.log("FormNoticeXHR - begin");
             SN.C.I.NoticeDataGeo = {};
             form.append('<input type="hidden" name="ajax" value="1"/>');
 
@@ -504,11 +503,11 @@ var SN = { // StatusNet
                 success: function(data, textStatus) {
                     var results_placeholder = $('#profile_search_results');
                     if (typeof($('ul', data)[0]) != 'undefined') {
-                        var list = document._importNode($('ul', data)[0], true);
+                        var list = $('ul', $(data).children());
                         results_placeholder.replaceWith(list);
                     }
                     else {
-                        var _error = $('<li/>').append(document._importNode($('p', data)[0], true));
+                        var _error = $('<li/>').append($('p', $(data).children()));
                         results_placeholder.html(_error);
                     }
                     form
@@ -538,12 +537,12 @@ var SN = { // StatusNet
                 success: function(data, textStatus) {
                     var results_placeholder = form.parents('.entity_tags');
                     if (typeof($('.entity_tags', data)[0]) != 'undefined') {
-                        var tags = document._importNode($('.entity_tags', data)[0], true);
+                        var tags = $('.entity_tags', $(data).children());
                         $(tags).find('.editable').append($('<button class="peopletags_edit_button"/>'));
                         results_placeholder.replaceWith(tags);
                     } else {
                         results_placeholder.find('p').remove();
-                        results_placeholder.append(document._importNode($('p', data)[0], true));
+                        results_placeholder.append($('p', $(data).children()));
                         form.removeClass(SN.C.S.Processing)
                             .find('.submit')
                                 .removeClass(SN.C.S.Disabled)
@@ -652,7 +651,6 @@ 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) {
-                    console.log("list = 0");
                     SN.U.NoticeInlineReplyPlaceholder(notice);
                     list = $('ul.threaded-replies', notice);
                 } else {
@@ -704,11 +702,10 @@ var SN = { // StatusNet
                     replyItem = $('<li class="notice-reply"></li>');
 
                     var intermediateStep = function(formMaster) {
-                        var formEl = document._importNode(formMaster, true);
-                        replyItem.append(formEl);
+                        replyItem.append(formMaster);
                         list.append(replyItem); // *after* the placeholder
 
-                        var form = replyForm = $(formEl);
+                        var form = replyForm = formMaster;
                         SN.Init.NoticeFormSetup(form);
 
                         nextStep();
@@ -723,8 +720,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)[0]);
-                        });
+                            intermediateStep($('form', $(data).children()));
+                        }, 'xml');
                     }
                 }
             }
@@ -763,11 +760,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);
+                        var replies = $('.threaded-replies', $(data).children());
                         if (replies.length) {
-                            area.replaceWith(document._importNode(replies[0], true));
+                            area.replaceWith(replies);
                         }
-                    });
+                    }, 'xml');
                     return false;
                 });
         },
@@ -1270,7 +1267,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(document._importNode($('form', data)[0], true));
+                        $('.entity_send-a-message').append($('form', $(data).children()));
                         NDMF = $('.entity_send-a-message .form_notice');
                         SN.U.FormNoticeXHR(NDMF);
                         SN.U.FormNoticeEnhancements(NDMF);
@@ -1280,7 +1277,7 @@ var SN = { // StatusNet
                             return false;
                         });
                         NDM.removeClass(SN.C.S.Processing);
-                    });
+                    }, 'xml');
                 }
                 else {
                     NDMF.show();
@@ -1517,7 +1514,7 @@ var SN = { // StatusNet
             if ($('body.user_in').length > 0) {
                 var masterForm = $('.form_notice:first');
                 if (masterForm.length > 0) {
-                    SN.C.I.NoticeFormMaster = document._importNode(masterForm[0], true);
+                    SN.C.I.NoticeFormMaster = masterForm;
                 }
                 SN.U.NoticeRepeat();
                 SN.U.NoticeReply();