From 981a52f5774651f2f5fc544a706302f03529d29b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 23 May 2015 00:13:36 +0200 Subject: [PATCH] Use DOM/Change/Listener in AMD JavaScript --- wcfsetup/install/files/js/WoltLab/WCF/Ajax.js | 4 ++-- .../install/files/js/WoltLab/WCF/Controller/Popover.js | 4 ++-- .../install/files/js/WoltLab/WCF/Date/Time/Relative.js | 4 ++-- wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js | 9 ++++++--- .../install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js | 8 ++++---- wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js | 4 ++-- wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js | 7 +++++-- wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js | 4 ++-- wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js | 6 +++--- wcfsetup/install/files/js/require.config.js | 1 + 10 files changed, 29 insertions(+), 22 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js index 08dc9b8069..26df32ee33 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @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*="#"]'); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js index 3c9790d43c..a54801875f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @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)); }, /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js index 8a7644cb13..253d95f58a 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @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() { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js index f181f04771..e8c3fafbbd 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js @@ -6,7 +6,10 @@ * @license GNU Lesser General Public License * @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(); }, /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js index 9a2823d75d..4049390b2e 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/Dropdown/Simple.js @@ -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 }); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js index 288a439660..3d9471389c 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/FlexibleMenu.js @@ -7,7 +7,7 @@ * @license GNU Lesser General Public License * @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)); }, /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js index f58ac94cb6..56673f1994 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js @@ -6,7 +6,10 @@ * @license GNU Lesser General Public License * @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() { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js index fcf06a4907..d6110aaf4e 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/TabMenu.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @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)); }, /** diff --git a/wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js b/wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js index 7763a6f8f6..591c5fd698 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/UI/Tooltip.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @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 +}); diff --git a/wcfsetup/install/files/js/require.config.js b/wcfsetup/install/files/js/require.config.js index 4d49395e16..412eb2f210 100644 --- a/wcfsetup/install/files/js/require.config.js +++ b/wcfsetup/install/files/js/require.config.js @@ -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', -- 2.20.1