]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Changing js .live calls to .on for jquery 2.x
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 10 Sep 2013 16:52:09 +0000 (18:52 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 10 Sep 2013 16:52:09 +0000 (18:52 +0200)
plugins/DomainWhitelist/js/whitelistinvite.js
plugins/ExtendedProfile/js/profiledetail.js
plugins/ModPlus/modplus.js
plugins/OStatus/js/ostatus.js
plugins/OpenExternalLinkTarget/OpenExternalLinkTargetPlugin.php
plugins/QnA/js/qna.js

index 01e493fa6aaec12c622d4a42979e4dfe922d31d8..d8ef79d72afe5e8d112b881d9ff3de4ee7e4ddf1 100644 (file)
@@ -1,7 +1,7 @@
 // XXX: Should I do crazy SN.X.Y.Z.A namespace instead?
 var SN_WHITELIST = SN_WHITELIST || {};
 
-SN_WHITELIST.updateButtons = function() {
+SN_WHITELIST.updateButtons = function () {
    $("ul > li > a.remove_row").show();
    $("ul > li > a.add_row").hide();
 
@@ -14,36 +14,36 @@ SN_WHITELIST.updateButtons = function() {
     $("ul > li > a.add_row:last").show();
 };
 
-SN_WHITELIST.resetRow = function(row) {
+SN_WHITELIST.resetRow = function (row) {
     $("input", row).val('');
     // Make sure the default domain is the first selection
     $("select option:first", row).val();
     $("a.remove_row", row).show();
 };
 
-SN_WHITELIST.addRow = function() {
+SN_WHITELIST.addRow = function () {
     var row = $(this).closest("li");
     var newRow = row.clone();
     $(row).find('a.add_row').hide();
     SN_WHITELIST.resetRow(newRow);
-        $(newRow).insertAfter(row).show("blind", "fast", function() {
+        $(newRow).insertAfter(row).show("blind", "fast", function () {
             SN_WHITELIST.updateButtons();
         });
 };
 
-SN_WHITELIST.removeRow = function() {
+SN_WHITELIST.removeRow = function () {
     var that = this;
 
     $("#confirm-dialog").dialog({
         buttons : {
-            "Confirm" : function() {
+            "Confirm" : function () {
                 $(this).dialog("close");
-                $(that).closest("li").hide("blind", "fast", function() {
+                $(that).closest("li").hide("blind", "fast", function () {
                     $(this).remove();
                     SN_WHITELIST.updateButtons();
                 });
             },
-            "Cancel" : function() {
+            "Cancel" : function () {
                 $(this).dialog("close");
             }
         }
@@ -52,21 +52,21 @@ SN_WHITELIST.removeRow = function() {
     if ($(this).closest('li').find(':input[name^=username]').val()) {
         $("#confirm-dialog").dialog("open");
     } else {
-        $(that).closest("li").hide("blind", "fast", function() {
+        $(that).closest("li").hide("blind", "fast", function () {
             $(this).remove();
             SN_WHITELIST.updateButtons();
         });
     }
 };
 
-$(document).ready(function() {
+$(document).ready(function () {
     $("#confirm-dialog").dialog({
         autoOpen: false,
         modal: true
     });
 
-    $('.add_row').live('click', SN_WHITELIST.addRow);
-    $('.remove_row').live('click', SN_WHITELIST.removeRow);
+    $(document).on('click', '.add_row', SN_WHITELIST.addRow);
+    $(document).on('click', '.remove_row', SN_WHITELIST.removeRow);
 
     SN_WHITELIST.updateButtons();
 });
index 99a3f78a4332536a45e82c3c5fb6b016321e45bb..14ccf0ce9a6c24b8bdeee97932d3f411b9fe2126 100644 (file)
@@ -1,10 +1,10 @@
 var SN_EXTENDED = SN_EXTENDED || {};
 
-SN_EXTENDED.reorder = function(cls) {
+SN_EXTENDED.reorder = function (cls) {
 
     var divs = $('div[class=' + cls + ']');
 
-    $(divs).each(function(i, div) {
+    $(divs).each(function (i, div) {
         $(div).find('a.add_row').hide();
         $(div).find('a.remove_row').show();
         SN_EXTENDED.replaceIndex(SN_EXTENDED.rowIndex(div), i);
@@ -20,20 +20,20 @@ SN_EXTENDED.reorder = function(cls) {
     }
 };
 
-SN_EXTENDED.rowIndex = function(div) {
+SN_EXTENDED.rowIndex = function (div) {
     var idstr = $(div).attr('id');
     var id = idstr.match(/\d+/);
     return id;
 };
 
-SN_EXTENDED.rowCount = function(cls) {
+SN_EXTENDED.rowCount = function (cls) {
     var divs = $.find('div[class=' + cls + ']');
     return divs.length;
 };
 
-SN_EXTENDED.replaceIndex = function(elem, oldIndex, newIndex) {
-    $(elem).find('*').each(function() {
-        $.each(this.attributes, function(i, attrib) {
+SN_EXTENDED.replaceIndex = function (elem, oldIndex, newIndex) {
+    $(elem).find('*').each(function () {
+        $.each(this.attributes, function (i, attrib) {
             var regexp = /extprofile-.*-\d.*/;
             var value = attrib.value;
             var match = value.match(regexp);
@@ -44,18 +44,18 @@ SN_EXTENDED.replaceIndex = function(elem, oldIndex, newIndex) {
     });
 }
 
-SN_EXTENDED.resetRow = function(elem) {
+SN_EXTENDED.resetRow = function (elem) {
     $(elem).find('input, textarea').attr('value', '');
     $(elem).find('input').removeAttr('disabled');
     $(elem).find("select option[value='office']").attr("selected", true);
     $(elem).find("input:checkbox").attr('checked', false);
-    $(elem).find("input[name$=-start], input[name$=-end]").each(function() {
+    $(elem).find("input[name$=-start], input[name$=-end]").each(function () {
         $(this).removeClass('hasDatepicker');
         $(this).datepicker({ dateFormat: 'd M yy' });
     });
 };
 
-SN_EXTENDED.addRow = function() {
+SN_EXTENDED.addRow = function () {
     var div = $(this).closest('div');
     var id = div.attr('id');
     var cls = div.attr('class');
@@ -68,7 +68,7 @@ SN_EXTENDED.addRow = function() {
     SN_EXTENDED.reorder(cls);
 };
 
-SN_EXTENDED.removeRow = function() {
+SN_EXTENDED.removeRow = function () {
 
     var div = $(this).closest('div');
     var id = $(div).attr('id');
@@ -77,15 +77,15 @@ SN_EXTENDED.removeRow = function() {
 
     $("#confirm-dialog").dialog({
         buttons : {
-            "Confirm" : function() {
+            "Confirm" : function () {
                 $(this).dialog("close");
                 var target = $(that).closest('tr');
-                target.fadeOut("slow", function() {
+                target.fadeOut("slow", function () {
                     $(target).remove();
                     SN_EXTENDED.reorder(cls);
                 });
             },
-            "Cancel" : function() {
+            "Cancel" : function () {
                 $(this).dialog("close");
             }
         }
@@ -98,7 +98,7 @@ SN_EXTENDED.removeRow = function() {
     }
 };
 
-$(document).ready(function() {
+$(document).ready(function () {
 
     $("#confirm-dialog").dialog({
         autoOpen: false,
@@ -121,17 +121,17 @@ $(document).ready(function() {
         source: 'finduser',
         minLength: 2 });
 
-    $('.add_row').live('click', SN_EXTENDED.addRow);
-    $('.remove_row').live('click', SN_EXTENDED.removeRow);
+    $(document).on('click', '.add_row', SN_EXTENDED.addRow);
+    $(document).on('click', '.remove_row', SN_EXTENDED.removeRow);
 
-    $('input:checkbox[name$=current]').each(function() {
+    $('input:checkbox[name$=current]').each(function () {
         var input = $(this).parent().siblings('input[id$=-end]');
         if ($(this).is(':checked')) {
             $(input).attr('disabled', 'true');
         }
     });
 
-    $('input:checkbox[name$=current]').live('click', function()  {
+    $(document).on('click', 'input:checkbox[name$=current]', function ()  {
         var input = $(this).parent().siblings('input[id$=-end]');
         if ($(this).is(':checked')) {
             $(input).val('');
index 511e8ee1442dbbe2eda02138137ba6d6dc8dec1a..4116f3c5d52d406b25c388d064a5069ddb01621e 100644 (file)
@@ -5,14 +5,14 @@
 
 $(function() {
     // Notice lists...
-    $('.notice .author').live('mouseenter', function(e) {
+    $(document).on('mouseenter', '.notice .author', function(e) {
         var notice = $(this).closest('.notice');
         var popup = notice.find('.remote-profile-options');
         if (popup.length) {
             popup.fadeIn();
         }
     });
-    $('.notice').live('mouseleave', function(e) {
+    $(document).on('mouseleave', '.notice', function(e) {
         var notice = $(this);
         var popup = notice.find('.remote-profile-options');
         if (popup.length) {
@@ -21,14 +21,14 @@ $(function() {
     });
 
     // Profile lists...
-    $('.profile .avatar').live('mouseenter', function(e) {
+    $(document).on('mouseenter', '.profile .avatar', function(e) {
         var profile = $(this).closest('.profile');
         var popup = profile.find('.remote-profile-options');
         if (popup.length) {
             popup.fadeIn();
         }
     });
-    $('.profile').live('mouseleave', function(e) {
+    $(document).on('mouseleave', '.profile', function(e) {
         var profile = $(this);
         var popup = profile.find('.remote-profile-options');
         if (popup.length) {
index 59d9f23f0510b6027976e087702517cf7db2c77a..1fad3e816108fc10bc6ef53cb7133d314b7e9335 100644 (file)
  * @note      Everything in here should eventually migrate over to /js/util.js's SN.
  */
 
-SN.Init.OStatusCookie = function() {
+SN.Init.OStatusCookie = function () {
     if (SN.U.StatusNetInstance.Get() === null) {
         SN.U.StatusNetInstance.Set({RemoteProfile: null});
     }
 };
 
 SN.U.DialogBox = {
-    Subscribe: function(a) {
+    Subscribe: function (a) {
         var f = a.parent().find('.form_settings');
         if (f.length > 0) {
             f.show();
@@ -41,13 +41,13 @@ SN.U.DialogBox = {
                 type: 'GET',
                 dataType: 'xml',
                 url: a[0].href + ((a[0].href.match(/[\\?]/) === null)?'?':'&') + 'ajax=1',
-                beforeSend: function(formData) {
+                beforeSend: function (formData) {
                     a.addClass('processing');
                 },
                 error: function (xhr, textStatus, errorThrown) {
                     alert(errorThrown || textStatus);
                 },
-                success: function(data, textStatus, xhr) {
+                success: function (data, textStatus, xhr) {
                     if (typeof($('form', data)[0]) != 'undefined') {
                         a.after(document._importNode($('form', data)[0], true));
 
@@ -61,11 +61,11 @@ SN.U.DialogBox = {
                             .find('.submit')
                                 .addClass('submit_dialogbox')
                                 .removeClass('submit')
-                                .bind('click', function() {
+                                .bind('click', function () {
                                     form.addClass('processing');
                                 });
 
-                        form.find('button.close').click(function(){
+                        form.find('button.close').click(function (){
                             form.hide();
 
                             return false;
@@ -77,7 +77,7 @@ SN.U.DialogBox = {
                             SN.Init.OStatusCookie();
                             form.find('#profile').val(SN.U.StatusNetInstance.Get().RemoteProfile);
 
-                            form.find("[type=submit]").bind('click', function() {
+                            form.find("[type=submit]").bind('click', function () {
                                 SN.U.StatusNetInstance.Set({RemoteProfile: form.find('#profile').val()});
                                 return true;
                             });
@@ -91,13 +91,16 @@ SN.U.DialogBox = {
     }
 };
 
-SN.Init.Subscribe = function() {
-    $('.entity_subscribe .entity_remote_subscribe, .entity_tag .entity_remote_tag')
-        .live('click', function() { SN.U.DialogBox.Subscribe($(this)); return false; });
+SN.Init.Subscribe = function () {
+    $(document).on('click',
+        '.entity_subscribe .entity_remote_subscribe, .entity_tag .entity_remote_tag',
+        function () { SN.U.DialogBox.Subscribe($(this)); return false; });
 };
 
-$(document).ready(function() {
+$(document).ready(function () {
     SN.Init.Subscribe();
 
-    $('.form_remote_authorize').bind('submit', function() { $(this).addClass(SN.C.S.Processing); return true; });
+    $('.form_remote_authorize').bind('submit', function () {
+            $(this).addClass(SN.C.S.Processing); return true;
+        });
 });
index 4453c2f122069f115bcb2e8943b780fdb5d2b17a..0be250372676d9dd890526f7ad2471ccf102a55a 100644 (file)
@@ -44,7 +44,7 @@ class OpenExternalLinkTargetPlugin extends Plugin
 {
     function onEndShowScripts($action)
     {
-        $action->inlineScript('$("a[rel~=external]:not([class~=attachment])").live("click", function(){ window.open(this.href); return false; });');
+        $action->inlineScript('$(document).on("click", "a[rel~=external]:not([class~=attachment])", function () { window.open(this.href); return false; });');
 
         return true;
     }
index 5b1a5fef31eb073a3a02b3c006a988c92710c84e..cf211d691244dab8b1d3ef907ff54f120718dac7 100644 (file)
@@ -1,7 +1,7 @@
 var QnA = {
 
     // @fixme: Should use ID
-    close: function(form, best) {
+    close: function (form, best) {
         var notice = $(form).closest('li.hentry.notice.question');
 
         notice.find('input#qna-best-answer,#qna-question-close').hide();
@@ -20,13 +20,13 @@ var QnA = {
         }
     },
 
-    init: function() {
+    init: function () {
         QnA.NoticeInlineAnswerSetup();
 
-        $('form.form_question_show').live('submit', function() {
+        $(document).on('submit', 'form.form_question_show', function () {
             QnA.close(this);
         });
-        $('form.form_answer_show').live('submit', function() {
+        $(document).on('submit', 'form.form_answer_show', function () {
             QnA.close(this, true);
         });
     },
@@ -36,7 +36,7 @@ var QnA = {
      *
      * @param {jQuery} notice: jQuery object containing one notice
      */
-    NoticeInlineAnswerTrigger: function(notice) {
+    NoticeInlineAnswerTrigger: function (notice) {
         // Find the notice we're replying to...
         var id = $($('.notice_id', notice)[0]).text();
         var parentNotice = notice;
@@ -59,7 +59,7 @@ var QnA = {
         // See if the form's already open...
         var answerForm = $('.qna_answer_form', list);
 
-        var hideReplyPlaceholders = function(notice) {
+        var hideReplyPlaceholders = function (notice) {
             // Do we still have a dummy answer placeholder? If so get rid of
             // reply place holders for this question. If the current user hasn't
             // answered the question we want to direct her to providing an
@@ -71,7 +71,7 @@ var QnA = {
             }
         }
 
-        var nextStep = function() {
+        var nextStep = function () {
             var dummyAnswer = $('ul.qna-dummy', notice);
             dummyAnswer.hide();
 
@@ -84,7 +84,7 @@ var QnA = {
 
             text.focus();
 
-            $('body').click(function(e) {
+            $('body').click(function (e) {
                 var dummyAnswer = $('ul.qna-dummy', notice);
                 var style = dummyAnswer.attr('style');
                 var ans = $(notice).find('li.hentry.notice.anwer', notice)
@@ -95,7 +95,7 @@ var QnA = {
                 var openAnswers = $('li.notice-answer');
                     if (openAnswers.length > 0) {
                         var target = $(e.target);
-                        openAnswers.each(function() {
+                        openAnswers.each(function () {
 
                             // Did we click outside this one?
                             var answerItem = $(this);
@@ -126,7 +126,7 @@ var QnA = {
 
             if (answerItem.length == 0) {
                  answerItem = $('<li class="notice-answer"></li>');
-                 var intermediateStep = function(formMaster) {
+                 var intermediateStep = function (formMaster) {
                     // @todo cache the form if we can (worth it?)
                     var formEl = document._importNode(formMaster, true);
                     $(formEl).data('NoticeFormSetup', true);
@@ -145,7 +145,7 @@ var QnA = {
                     // Warning: this can have a delay, which looks bad.
                     // @fixme this fallback may or may not work
                     var url = $('#answer-action').attr('value');
-                     $.get(url, {ajax: 1}, function(data, textStatus, xhr) {
+                     $.get(url, {ajax: 1}, function (data, textStatus, xhr) {
                          intermediateStep($('form', data)[0]);
                      });
                  }
@@ -159,10 +159,11 @@ var QnA = {
      * Sets up event handlers for inline reply mini-form placeholders.
      * Uses 'live' rather than 'bind', so applies to future as well as present items.
      */
-    NoticeInlineAnswerSetup: function() {
+    NoticeInlineAnswerSetup: function () {
 
-        $('li.qna-dummy-placeholder input.placeholder')
-            .live('focus', function() {
+        $(document).on('focus',
+            'li.qna-dummy-placeholder input.placeholder',
+            function () {
                 var notice = $(this).closest('li.notice');
                 QnA.NoticeInlineAnswerTrigger(notice);
                 return false;
@@ -170,7 +171,7 @@ var QnA = {
 
     },
 
-    AnswerFormSetup: function(form) {
+    AnswerFormSetup: function (form) {
 
         form.find('textarea').focus();
 
@@ -200,7 +201,7 @@ var QnA = {
      *
      * @access public
      */
-    FormAnswerXHR: function(form) {
+    FormAnswerXHR: function (form) {
 
         //SN.C.I.NoticeDataGeo = {};
         form.append('<input type="hidden" name="ajax" value="1"/>');
@@ -215,7 +216,7 @@ var QnA = {
          * @param {String} text
          * @access private
          */
-        var showFeedback = function(cls, text) {
+        var showFeedback = function (cls, text) {
             form.append(
                 $('<p class="form_response"></p>')
                     .addClass(cls)
@@ -226,7 +227,7 @@ var QnA = {
         /**
          * Hide the previous response feedback, if any.
          */
-        var removeFeedback = function() {
+        var removeFeedback = function () {
             form.find('.form_response').remove();
         };
 
@@ -234,7 +235,7 @@ var QnA = {
             dataType: 'xml',
             timeout: '60000',
 
-            beforeSend: function(formData) {
+            beforeSend: function (formData) {
 
                 if (form.find('.notice_data-text:first').val() == '') {
                     form.addClass(SN.C.S.Warning);
@@ -277,7 +278,7 @@ var QnA = {
                     }
                 }
             },
-            success: function(data, textStatus) {
+            success: function (data, textStatus) {
 
                 removeFeedback();
                 var errorResult = $('#'+SN.C.S.Error, data);
@@ -343,7 +344,7 @@ var QnA = {
                     }
                 }
             },
-            complete: function(xhr, textStatus) {
+            complete: function (xhr, textStatus) {
                 form
                     .removeClass(SN.C.S.Processing)
                     .find('.submit')
@@ -354,6 +355,6 @@ var QnA = {
     }
 };
 
-$(document).ready(function() {
+$(document).ready(function () {
     QnA.init();
 });