From: Tim Düsterhus Date: Fri, 22 May 2015 19:39:00 +0000 (+0200) Subject: Transparently use DOM/Change/Listener in DOMNodeInsertedHandler X-Git-Tag: 3.0.0_Beta_1~2349^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8fab2bd2f7ddf491a41e09cdf0a473e66b868375;p=GitHub%2FWoltLab%2FWCF.git Transparently use DOM/Change/Listener in DOMNodeInsertedHandler --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index eec52b467b..7800ac6e33 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -5119,51 +5119,19 @@ WCF.CloseOverlayHandler = { }; /** - * Notifies objects once a DOM node was inserted. + * @deprecated Use WoltLab/WCF/DOM/Change/Listener */ WCF.DOMNodeInsertedHandler = { - /** - * list of callbacks - * @var array - */ - _callbacks: [ ], - - /** - * prevent infinite loop if a callback manipulates DOM - * @var boolean - */ - _isExecuting: false, - - /** - * Adds a new callback. - * - * @param string identifier - * @param object callback - */ addCallback: function(identifier, callback) { - this._callbacks.push(callback); + require(['WoltLab/WCF/DOM/Change/Listener'], function (ChangeListener) { + ChangeListener.add('__legacy__', callback); + }); }, - - /** - * Executes callbacks on click. - */ _executeCallbacks: function() { - if (this._isExecuting) return; - - // do not track events while executing callbacks - this._isExecuting = true; - - for (var $i = 0, $length = this._callbacks.length; $i < $length; $i++) { - this._callbacks[$i](); - } - - // enable listener again - this._isExecuting = false; + require(['WoltLab/WCF/DOM/Change/Listener'], function (ChangeListener) { + ChangeListener.trigger(); + }); }, - - /** - * Executes all callbacks. - */ execute: function() { this._executeCallbacks(); } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js index d2b85769c8..0f5d05ddcd 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js @@ -49,5 +49,5 @@ define(['CallbackList'], function(CallbackList) { } }; - return Listener; + return new Listener(); });