Use DOM/Change/Listener in AMD JavaScript
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 22 May 2015 22:13:36 +0000 (00:13 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 22 May 2015 22:14:01 +0000 (00:14 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ajax.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js
wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js
wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js
wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js
wcfsetup/install/files/js/require.config.js

index 08dc9b8069ecdfbed6a61ac619d30f45bdb8f848..26df32ee33ad95378ad0e76a66e22e7d14fb26d2 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Ajax
  */
-define(['Core', 'Language', 'DOM/Util', 'UI/Dialog', 'WoltLab/WCF/Ajax/Status'], function(Core, Language, DOMUtil, UIDialog, AjaxStatus) {
+define(['Core', 'Language', 'DOM/ChangeListener', 'DOM/Util', 'UI/Dialog', 'WoltLab/WCF/Ajax/Status'], function(Core, Language, DOMChangeListener, DOMUtil, UIDialog, AjaxStatus) {
        "use strict";
        
        var _didInit = false;
@@ -226,7 +226,7 @@ define(['Core', 'Language', 'DOM/Util', 'UI/Dialog', 'WoltLab/WCF/Ajax/Status'],
                        
                        this._previousXhr = null;
                        
-                       WCF.DOMNodeInsertedHandler.execute();
+                       DOMChangeListener.trigger();
                        
                        // fix anchor tags generated through WCF::getAnchor()
                        var links = document.querySelectorAll('a[href*="#"]');
index 3c9790d43caf3d725732aa879fdee588e9c60092..a54801875f993d3fb2f8b52eda0bd74da6dfa2b5 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Controller/Popover
  */
-define(['Dictionary', 'Environment', 'DOM/Util', 'UI/Alignment'], function(Dictionary, Environment, DOMUtil, UIAlignment) {
+define(['Dictionary', 'Environment', 'DOM/ChangeListener', 'DOM/Util', 'UI/Alignment'], function(Dictionary, Environment, DOMChangeListener, DOMUtil, UIAlignment) {
        "use strict";
        
        var _activeId = null;
@@ -93,7 +93,7 @@ define(['Dictionary', 'Environment', 'DOM/Util', 'UI/Alignment'], function(Dicti
                                this._hide(true);
                        }).bind(this));
                        
-                       WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/Controller/Popover', this._init.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/Controller/Popover', this._init.bind(this));
                },
                
                /**
index 8a7644cb13b0479a9ddb720d5905c3d24cded26e..253d95f58ab5be8c3743eadf67c9bc2ad7a9bdc0 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Date/Time/Relative
  */
-define(['Language'], function(Language) {
+define(['DOM/ChangeListener', 'Language'], function(DOMChangeListener, Language) {
        "use strict";
        
        var _elements = null;
@@ -27,7 +27,7 @@ define(['Language'], function(Language) {
                        
                        new WCF.PeriodicalExecuter(this._refresh.bind(this), 60000);
                        
-                       WCF.DOMNodeInsertedHandler.addCallback('WCF.Date.Time', this._refresh.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/Date/Time/Relative', this._refresh.bind(this));
                },
                
                _refresh: function() {
index f181f047710094fc3318fa60f5b0d723b2a62767..e8c3fafbbd2b359e366f383febccdcfe7a4a7b15 100644 (file)
@@ -6,7 +6,10 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/Dialog
  */
-define(['enquire', 'Core', 'Dictionary', 'Environment', 'Language', 'DOM/Util'], function(enquire, Core, Dictionary, Environment, Language, DOMUtil) {
+define(
+       [       'enquire', 'Core', 'Dictionary', 'Environment', 'Language', 'DOM/ChangeListener', 'DOM/Util'],
+       function(enquire,   Core,   Dictionary,   Environment,   Language,    DOMChangeListener,    DOMUtil)
+{
        "use strict";
        
        var _activeDialog = null;
@@ -217,7 +220,7 @@ define(['enquire', 'Core', 'Dictionary', 'Environment', 'Language', 'DOM/Util'],
                                options.onShow(id);
                        }
                        
-                       WCF.DOMNodeInsertedHandler.execute();
+                       ChangeListener.trigger();
                },
                
                /**
@@ -256,7 +259,7 @@ define(['enquire', 'Core', 'Dictionary', 'Environment', 'Language', 'DOM/Util'],
                                }
                        }
                        
-                       WCF.DOMNodeInsertedHandler.execute();
+                       ChangeListener.trigger();
                },
                
                /**
index 9a2823d75df6bc700d150356175cd002ae098592..4049390b2ef33732c8e9a58b0ba3eea9ae0135fa 100644 (file)
@@ -7,8 +7,8 @@
  * @module     WoltLab/WCF/UI/Dropdown/Simple
  */
 define(
-       [       'CallbackList', 'Dictionary', 'UI/Alignment', 'DOM/Traverse', 'DOM/Util'],
-       function(CallbackList,   Dictionary,    uiAlignment,    DOMTraverse,    DOMUtil)
+       [       'CallbackList', 'Dictionary', 'UI/Alignment', 'DOM/ChangeListener', 'DOM/Traverse', 'DOM/Util'],
+       function(CallbackList,   Dictionary,    UIAlignment,    DOMChangeListener,    DOMTraverse,    DOMUtil)
 {
        "use strict";
        
@@ -38,7 +38,7 @@ define(
                        WCF.Dropdown.init(this);
                        
                        WCF.CloseOverlayHandler.addCallback('WoltLab/WCF/UI/Dropdown/Simple', this.closeAll.bind(this));
-                       WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/UI/Dropdown/Simple', this.initAll.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/UI/Dropdown/Simple', this.initAll.bind(this));
                        
                        document.addEventListener('scroll', this._onScroll.bind(this));
                },
@@ -165,7 +165,7 @@ define(
                                refDimensionsElement = button;
                        }
                        
-                       uiAlignment.set(dropdownMenu, dropdown, {
+                       UIAlignment.set(dropdownMenu, dropdown, {
                                pointerClassNames: ['dropdownArrowBottom', 'dropdownArrowRight'],
                                refDimensionsElement: refDimensionsElement
                        });
index 288a4396608cb0cbd67d3d79f3d4348fb45e0c58..3d9471389c4c3eaf301472e7141852d620c3101e 100644 (file)
@@ -7,7 +7,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/FlexibleMenu
  */
-define(['Core', 'Dictionary', 'DOM/Traverse', 'DOM/Util', 'UI/SimpleDropdown'], function(Core, Dictionary, DOMTraverse, DOMUtil, SimpleDropdown) {
+define(['Core', 'Dictionary', 'DOM/ChangeListener', 'DOM/Traverse', 'DOM/Util', 'UI/SimpleDropdown'], function(Core, Dictionary, DOMChangeListener, DOMTraverse, DOMUtil, SimpleDropdown) {
        "use strict";
        
        /**
@@ -30,7 +30,7 @@ define(['Core', 'Dictionary', 'DOM/Traverse', 'DOM/Util', 'UI/SimpleDropdown'],
                        
                        
                        window.addEventListener('resize', this.rebuildAll.bind(this));
-                       WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/UI/FlexibleMenu', this.registerTabMenus.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/UI/FlexibleMenu', this.registerTabMenus.bind(this));
                },
                
                /**
index f58ac94cb63d0e95d52377b9a4e33ffaad6a37a6..56673f1994aa3e854d844e1c0b56ca07d67a3c63 100644 (file)
@@ -6,7 +6,10 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/Mobile
  */
-define(['enquire', 'Environment', 'Language', 'DOM/Traverse'], function(enquire, Environment, Language, DOMTraverse) {
+define(
+       [       'enquire', 'Environment', 'Language', 'DOM/ChangeListener', 'DOM/Traverse'],
+       function(enquire,   Environment,   Language,    DOMChangeListener,    DOMTraverse)
+{
        "use strict";
        
        var _buttonGroupNavigations = null;
@@ -77,7 +80,7 @@ define(['enquire', 'Environment', 'Language', 'DOM/Traverse'], function(enquire,
                        this._initButtonGroupNavigation();
                        
                        WCF.CloseOverlayHandler.addCallback('WoltLab/WCF/UI/Mobile', this._closeAllMenus.bind(this));
-                       WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/UI/Mobile', this._initButtonGroupNavigation.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/UI/Mobile', this._initButtonGroupNavigation.bind(this));
                },
                
                _initSidebarToggleButtons: function() {
index fcf06a4907f9f4148ef13fb367c115933153c0e2..d6110aaf4e6b39da69c63fb76f82bf7c55ce7cbb 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/TabMenu
  */
-define(['Dictionary', 'DOM/Util', './TabMenu/Simple'], function(Dictionary, DOMUtil, SimpleTabMenu) {
+define(['Dictionary', 'DOM/ChangeListener', 'DOM/Util', './TabMenu/Simple'], function(Dictionary, DOMChangeListener, DOMUtil, SimpleTabMenu) {
        "use strict";
        
        var _tabMenus = new Dictionary();
@@ -22,7 +22,7 @@ define(['Dictionary', 'DOM/Util', './TabMenu/Simple'], function(Dictionary, DOMU
                setup: function() {
                        this._init();
                        
-                       WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/UI/TabMenu', this._init.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/UI/TabMenu', this._init.bind(this));
                },
                
                /**
index 7763a6f8f6a56f27658dce6ad395d71024648836..591c5fd6985faffbf29912777a8de4744f7db21e 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/Tooltip
  */
-define(['Environment', 'UI/Alignment'], function(Environment, UIAlignment) {
+define(['Environment', 'DOM/ChangeListener', 'UI/Alignment'], function(Environment, DOMChangeListener, UIAlignment) {
        "use strict";
        
        var _elements = null;
@@ -44,7 +44,7 @@ define(['Environment', 'UI/Alignment'], function(Environment, UIAlignment) {
                        
                        this.init();
                        
-                       WCF.DOMNodeInsertedHandler.addCallback('WoltLab/WCF/UI/Tooltip', this.init.bind(this));
+                       DOMChangeListener.add('WoltLab/WCF/UI/Tooltip', this.init.bind(this));
                },
                
                /**
@@ -120,4 +120,4 @@ define(['Environment', 'UI/Alignment'], function(Environment, UIAlignment) {
        };
        
        return new UITooltip();
-});
\ No newline at end of file
+});
index 4d49395e16d337540cd1656d6cf57399a23a57ef..412eb2f210e193800040db8ff64cd1456e756acc 100644 (file)
@@ -9,6 +9,7 @@ requirejs.config({
                        'CallbackList': 'WoltLab/WCF/CallbackList',
                        'Core': 'WoltLab/WCF/Core',
                        'Dictionary': 'WoltLab/WCF/Dictionary',
+                       'DOM/ChangeListener': 'WoltLab/WCF/DOM/Change/Listener',
                        'DOM/Traverse': 'WoltLab/WCF/DOM/Traverse',
                        'DOM/Util': 'WoltLab/WCF/DOM/Util',
                        'Environment': 'WoltLab/WCF/Environment',