Transparently use DOM/Change/Listener in DOMNodeInsertedHandler
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 22 May 2015 19:39:00 +0000 (21:39 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 22 May 2015 19:39:00 +0000 (21:39 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/js/WoltLab/WCF/DOM/Change/Listener.js

index eec52b467bf5a088ce89fdd7e9c33267a84eaf1c..7800ac6e33690503ac74d7be4b3fb9b8ebaf5daa 100755 (executable)
@@ -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<object>
-        */
-       _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();
        }
index d2b85769c8cd1264ef49839f6a0db0fa73498da8..0f5d05ddcdda515a1ff9a57e9c1df3b1a0c3c115 100644 (file)
@@ -49,5 +49,5 @@ define(['CallbackList'], function(CallbackList) {
                }
        };
        
-       return Listener;
+       return new Listener();
 });