From 8fab2bd2f7ddf491a41e09cdf0a473e66b868375 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 22 May 2015 21:39:00 +0200 Subject: [PATCH] Transparently use DOM/Change/Listener in DOMNodeInsertedHandler --- wcfsetup/install/files/js/WCF.js | 46 +++---------------- .../js/WoltLab/WCF/DOM/Change/Listener.js | 2 +- 2 files changed, 8 insertions(+), 40 deletions(-) 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(); }); -- 2.20.1