From 42d7d2cc5621e640d0323ad5f4e2d46c01b0227d Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 27 May 2013 17:47:39 +0200 Subject: [PATCH] Improved DOMNodeInsertedHandler Attention developers! I've redesigned it's entire API, you must now manually call WCF.DOMNodeInsertedHandler.execute() if you manipulate the DOM. The only exception are success-callbacks for WCF.Action.Proxy, in this case that method call is automatically invoked. --- wcfsetup/install/files/acp/js/WCF.ACP.js | 8 +- wcfsetup/install/files/js/WCF.ACL.js | 4 +- wcfsetup/install/files/js/WCF.Attachment.js | 2 +- wcfsetup/install/files/js/WCF.Comment.js | 6 +- wcfsetup/install/files/js/WCF.ImageViewer.js | 13 +-- wcfsetup/install/files/js/WCF.Like.js | 2 +- wcfsetup/install/files/js/WCF.Message.js | 6 +- wcfsetup/install/files/js/WCF.Poll.js | 2 +- wcfsetup/install/files/js/WCF.User.js | 8 +- wcfsetup/install/files/js/WCF.js | 95 +++----------------- 10 files changed, 31 insertions(+), 115 deletions(-) diff --git a/wcfsetup/install/files/acp/js/WCF.ACP.js b/wcfsetup/install/files/acp/js/WCF.ACP.js index c29741b4ba..1b1db9f0cd 100644 --- a/wcfsetup/install/files/acp/js/WCF.ACP.js +++ b/wcfsetup/install/files/acp/js/WCF.ACP.js @@ -69,9 +69,9 @@ WCF.ACP.Application.SetAsPrimary = Class.extend({ $('#setAsPrimary').parent().remove(); // insert icon - WCF.DOMNodeInsertedHandler.enable(); $('').appendTo($('.boxHeadline > h1')); - WCF.DOMNodeInsertedHandler.disable(); + + WCF.DOMNodeInsertedHandler.execute(); }, this) }); } @@ -1155,12 +1155,10 @@ WCF.ACP.Package.Search = Class.extend({ this._proxy.sendRequest(); } else { - WCF.DOMNodeInsertedHandler.enable(); - // show cached content this._packageSearchResultList.html(this._content[this._pageNo]); - WCF.DOMNodeInsertedHandler.disable(); + WCF.DOMNodeInsertedHandler.execute(); } } }); diff --git a/wcfsetup/install/files/js/WCF.ACL.js b/wcfsetup/install/files/js/WCF.ACL.js index ac7c406fa2..9d83e0bfde 100644 --- a/wcfsetup/install/files/js/WCF.ACL.js +++ b/wcfsetup/install/files/js/WCF.ACL.js @@ -187,7 +187,7 @@ WCF.ACL.List = Class.extend({ // show permissions this._containerElements.permissionList.show(); - WCF.DOMNodeInsertedHandler.forceExecution(); + WCF.DOMNodeInsertedHandler.execute(); }, /** @@ -337,7 +337,7 @@ WCF.ACL.List = Class.extend({ // add options this._values[type] = data.returnValues[type].option; - WCF.DOMNodeInsertedHandler.forceExecution(); + WCF.DOMNodeInsertedHandler.execute(); }, /** diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 657b813163..edc9f92090 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -205,7 +205,7 @@ WCF.Attachment.Upload = WCF.Upload.extend({ $li.css('display', 'block'); } - WCF.DOMNodeInsertedHandler.forceExecution(); + WCF.DOMNodeInsertedHandler.execute(); }, /** diff --git a/wcfsetup/install/files/js/WCF.Comment.js b/wcfsetup/install/files/js/WCF.Comment.js index 61a3073775..e4026bc9d8 100644 --- a/wcfsetup/install/files/js/WCF.Comment.js +++ b/wcfsetup/install/files/js/WCF.Comment.js @@ -96,8 +96,6 @@ WCF.Comment.Handler = Class.extend({ success: $.proxy(this._success, this) }); - WCF.DOMNodeInsertedHandler.enable(); - this._initComments(); this._initResponses(); @@ -106,7 +104,7 @@ WCF.Comment.Handler = Class.extend({ this._initAddComment(); } - WCF.DOMNodeInsertedHandler.disable(); + WCF.DOMNodeInsertedHandler.execute(); WCF.DOMNodeInsertedHandler.addCallback('WCF.Comment.Handler', $.proxy(this._domNodeInserted, this)); }, @@ -501,7 +499,7 @@ WCF.Comment.Handler = Class.extend({ break; } - WCF.DOMNodeInsertedHandler.forceExecution(); + WCF.DOMNodeInsertedHandler.execute(); }, /** diff --git a/wcfsetup/install/files/js/WCF.ImageViewer.js b/wcfsetup/install/files/js/WCF.ImageViewer.js index 64490bfff2..e6d794204f 100644 --- a/wcfsetup/install/files/js/WCF.ImageViewer.js +++ b/wcfsetup/install/files/js/WCF.ImageViewer.js @@ -11,10 +11,6 @@ WCF.ImageViewer = Class.extend({ * Initializes the ImageViewer for every a-tag with the attribute rel = imageviewer. */ init: function() { - WCF.DOMNodeInsertedHandler.addCallback('WCF.ImageViewer', $.proxy(this._domNodeInserted, this)); - - WCF.DOMNodeInsertedHandler.enable(); - // navigation buttons $('').appendTo($('#lbPrevLink')); $('').appendTo($('#lbNextLink')); @@ -23,12 +19,13 @@ WCF.ImageViewer = Class.extend({ $('').appendTo($('#lbCloseLink')); var $buttonEnlarge = $('').insertAfter($('#lbCloseLink')); - WCF.DOMNodeInsertedHandler.disable(); - // handle enlarge button $buttonEnlarge.click($.proxy(this._enlarge, this)); this._initImageViewer(); + + WCF.DOMNodeInsertedHandler.addCallback('WCF.ImageViewer', $.proxy(this._domNodeInserted, this)); + WCF.DOMNodeInsertedHandler.execute(); }, /** @@ -43,8 +40,6 @@ WCF.ImageViewer = Class.extend({ * Initializes the image viewer for all links with class ".jsImageViewer" */ _initImageViewer: function() { - WCF.DOMNodeInsertedHandler.enable(); - var $links = $('a.jsImageViewer'); if ($links.length) { $links.removeClass('jsImageViewer').slimbox({ @@ -52,8 +47,6 @@ WCF.ImageViewer = Class.extend({ loop: true }); } - - WCF.DOMNodeInsertedHandler.disable(); }, /** diff --git a/wcfsetup/install/files/js/WCF.Like.js b/wcfsetup/install/files/js/WCF.Like.js index 714cf1d854..592b994a3c 100644 --- a/wcfsetup/install/files/js/WCF.Like.js +++ b/wcfsetup/install/files/js/WCF.Like.js @@ -142,7 +142,7 @@ WCF.Like = Class.extend({ new WCF.PeriodicalExecuter(function(pe) { pe.stop(); - WCF.DOMNodeInsertedHandler.forceExecution(); + WCF.DOMNodeInsertedHandler.execute(); }, 250); } }, diff --git a/wcfsetup/install/files/js/WCF.Message.js b/wcfsetup/install/files/js/WCF.Message.js index 676d7bf4ef..be8b01f508 100644 --- a/wcfsetup/install/files/js/WCF.Message.js +++ b/wcfsetup/install/files/js/WCF.Message.js @@ -31,7 +31,7 @@ WCF.Message.BBCode.CodeViewer = Class.extend({ this._initCodeBoxes(); WCF.DOMNodeInsertedHandler.addCallback('WCF.Message.BBCode.CodeViewer', $.proxy(this._initCodeBoxes, this)); - WCF.DOMNodeInsertedHandler.forceExecution(); + WCF.DOMNodeInsertedHandler.execute(); }, /** @@ -1116,14 +1116,12 @@ WCF.Message.InlineEditor = Class.extend({ if (!$button.hasClass('dropdownToggle')) { var $containerID = $button.data('containerID'); - WCF.DOMNodeInsertedHandler.enable(); - $button.addClass('dropdownToggle').parent().addClass('dropdown'); var $dropdownMenu = $('