Get rid of WCF.Language in require.js based JavaScript
authorTim Düsterhus <duesterhus@woltlab.com>
Sun, 17 May 2015 17:36:26 +0000 (19:36 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Sun, 17 May 2015 17:36:26 +0000 (19:36 +0200)
com.woltlab.wcf/templates/headIncludeJavaScript.tpl
wcfsetup/install/files/js/WoltLab/WCF/Controller/Sitemap.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js
wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Alignment.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Dialog.js
wcfsetup/install/files/js/WoltLab/WCF/UI/Mobile.js
wcfsetup/install/files/js/require.config.js

index cc19269589bb958b16d0e3ccbc3764a86e378640..53afea9e25de8ac20f92d7a934b923a5456ff2c9 100644 (file)
@@ -52,7 +52,7 @@
 <script data-relocate="true">
        WCF.User.init({@$__wcf->user->userID}, '{@$__wcf->user->username|encodeJS}');
        
-       require(['WoltLab/WCF/Language'], function(Language) {
+       require(['Language'], function(Language) {
                Language.addObject({
                        '__days': [ '{lang}wcf.date.day.sunday{/lang}', '{lang}wcf.date.day.monday{/lang}', '{lang}wcf.date.day.tuesday{/lang}', '{lang}wcf.date.day.wednesday{/lang}', '{lang}wcf.date.day.thursday{/lang}', '{lang}wcf.date.day.friday{/lang}', '{lang}wcf.date.day.saturday{/lang}' ],
                        '__daysShort': [ '{lang}wcf.date.day.sun{/lang}', '{lang}wcf.date.day.mon{/lang}', '{lang}wcf.date.day.tue{/lang}', '{lang}wcf.date.day.wed{/lang}', '{lang}wcf.date.day.thu{/lang}', '{lang}wcf.date.day.fri{/lang}', '{lang}wcf.date.day.sat{/lang}' ],
index 5a3516d03dce106e6ea4d3c3765f2586be31c97e..eeeb5e1774aedf7ccdde783a52bcd68981e3c0c4 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Controller/Sitemap
  */
-define(['EventHandler', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu'], function(EventHandler, DOMUtil, UIDialog, UITabMenu) {
+define(['EventHandler', 'Language', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu'], function(EventHandler, Language, DOMUtil, UIDialog, UITabMenu) {
        "use strict";
        
        var _cache = [];
@@ -44,7 +44,7 @@ define(['EventHandler', 'DOM/Util', 'UI/Dialog', 'UI/TabMenu'], function(EventHa
                                                
                                                _dialog = UIDialog.open('sitemapDialog', data.returnValues.template, {
                                                        disableContentPadding: true,
-                                                       title: WCF.Language.get('wcf.page.sitemap')
+                                                       title: Language.get('wcf.page.sitemap')
                                                });
                                                
                                                var tabMenuContainer = _dialog.content.querySelector('.tabMenuContainer');
index 000b59d620a1441135cf6db78c753ac45fec6158..4d3a13f2e6594050c446cf9cbb5ec710bca0888d 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/Controller/Style/Changer
  */
-define(['UI/Dialog'], function(UIDialog) {
+define(['Language', 'UI/Dialog'], function(Language, UIDialog) {
        "use strict";
        
        /**
@@ -29,7 +29,7 @@ define(['UI/Dialog'], function(UIDialog) {
                        
                        var link = document.createElement('a');
                        link.setAttribute('href', '#');
-                       link.textContent = WCF.Language.get('wcf.style.changeStyle');
+                       link.textContent = Language.get('wcf.style.changeStyle');
                        listItem.appendChild(link);
                        
                        list.appendChild(listItem);
@@ -53,7 +53,7 @@ define(['UI/Dialog'], function(UIDialog) {
                                        success: (function(data) {
                                                var dialog = UIDialog.open('styleChanger', data.returnValues.template, {
                                                        disableContentPadding: true,
-                                                       title: WCF.Language.get('wcf.style.changeStyle')
+                                                       title: Language.get('wcf.style.changeStyle')
                                                });
                                                
                                                var styles = dialog.content.querySelectorAll('.styleList > li');
index e136c69b91568c7ccdfdd8557aa62d8194c17ba3..8a7644cb13b0479a9ddb720d5905c3d24cded26e 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(function() {
+define(['Language'], function(Language) {
        "use strict";
        
        var _elements = null;
@@ -49,17 +49,17 @@ define(function() {
                                
                                // timestamp is less than 60 seconds ago
                                if (elTimestamp >= timestamp || timestamp < (elTimestamp + 60)) {
-                                       element.textContent = WCF.Language.get('wcf.date.relative.now');
+                                       element.textContent = Language.get('wcf.date.relative.now');
                                }
                                // timestamp is less than 60 minutes ago (display 1 hour ago rather than 60 minutes ago)
                                else if (timestamp < (elTimestamp + 3540)) {
                                        var minutes = Math.max(Math.round((timestamp - elTimestamp) / 60), 1);
-                                       element.textContent = WCF.Language.get('wcf.date.relative.minutes', { minutes: minutes });
+                                       element.textContent = Language.get('wcf.date.relative.minutes', { minutes: minutes });
                                }
                                // timestamp is less than 24 hours ago
                                else if (timestamp < (elTimestamp + 86400)) {
                                        var hours = Math.round((timestamp - elTimestamp) / 3600);
-                                       element.textContent = WCF.Language.get('wcf.date.relative.hours', { hours: hours });
+                                       element.textContent = Language.get('wcf.date.relative.hours', { hours: hours });
                                }
                                // timestamp is less than 6 days ago
                                else if (timestamp < (elTimestamp + 518400)) {
@@ -69,13 +69,13 @@ define(function() {
                                        // get day of week
                                        var dateObj = WCF.Date.Util.getTimezoneDate((elTimestamp * 1000), elOffset * 1000);
                                        var dow = dateObj.getDay();
-                                       var day = WCF.Language.get('__days')[dow];
+                                       var day = Language.get('__days')[dow];
                                        
-                                       element.textContent = WCF.Language.get('wcf.date.relative.pastDays', { days: days, day: day, time: elTime });
+                                       element.textContent = Language.get('wcf.date.relative.pastDays', { days: days, day: day, time: elTime });
                                }
                                // timestamp is between ~700 million years BC and last week
                                else {
-                                       element.textContent = WCF.Language.get('wcf.date.shortDateTimeFormat').replace(/\%date\%/, elDate).replace(/\%time\%/, elTime);
+                                       element.textContent = Language.get('wcf.date.shortDateTimeFormat').replace(/\%date\%/, elDate).replace(/\%time\%/, elTime);
                                }
                        }
                }
index 4ca50472d831621c99e5c82e6971b3317d505665..207472890855fba6030572a0ada23ac07dd1e0da 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/Alignment
  */
-define(['Core', 'DOM/Traverse', 'DOM/Util'], function(Core, DOMTraverse, DOMUtil) {
+define(['Core', 'Language', 'DOM/Traverse', 'DOM/Util'], function(Core, Language, DOMTraverse, DOMUtil) {
        "use strict";
        
        /**
@@ -82,7 +82,7 @@ define(['Core', 'DOM/Traverse', 'DOM/Util'], function(Core, DOMTraverse, DOMUtil
                        }
                        
                        // in rtl languages we simply swap the value for 'horizontal'
-                       if (WCF.Language.get('wcf.global.pageDirection') === 'rtl') {
+                       if (Language.get('wcf.global.pageDirection') === 'rtl') {
                                options.horizontal = (options.horizontal === 'left') ? 'right' : 'left';
                        }
                        
index 0c993a26406c72983bb2626219e99f988cd7361e..3002ba4d2601dda564f209b4aad8a362ea44e219 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/Dialog
  */
-define(['jquery', 'enquire', 'Core', 'Dictionary', 'DOM/Util'], function($, enquire, Core, Dictionary, DOMUtil) {
+define(['jquery', 'enquire', 'Core', 'Dictionary', 'Language', 'DOM/Util'], function($, enquire, Core, Dictionary, Language, DOMUtil) {
        "use strict";
        
        var _activeDialog = null;
@@ -73,7 +73,7 @@ define(['jquery', 'enquire', 'Core', 'Dictionary', 'DOM/Util'], function($, enqu
                                options = Core.extend({
                                        backdropCloseOnClick: true,
                                        closable: true,
-                                       closeButtonLabel: WCF.Language.get('wcf.global.button.close'),
+                                       closeButtonLabel: Language.get('wcf.global.button.close'),
                                        closeConfirmMessage: '',
                                        disableContentPadding: false,
                                        disposeOnClose: false,
index ea3fc4fbc59c5cdc6cbfd22ffa1e02fd23250b11..bce846d5386f2696e80c68ffac87c9100bcc6506 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @module     WoltLab/WCF/UI/Mobile
  */
-define(['jquery', 'enquire', 'DOM/Traverse'], function($, enquire, DOMTraverse) {
+define(['jquery', 'enquire', 'Language', 'DOM/Traverse'], function($, enquire, Language, DOMTraverse) {
        "use strict";
        
        var _buttonGroupNavigations = null;
@@ -86,13 +86,13 @@ define(['jquery', 'enquire', 'DOM/Traverse'], function($, enquire, DOMTraverse)
                        
                        // use icons if language item is empty/non-existant
                        var languageShowSidebar = 'wcf.global.sidebar.show' + sidebarPosition + 'Sidebar';
-                       if (languageShowSidebar === WCF.Language.get(languageShowSidebar) || WCF.Language.get(languageShowSidebar) === '') {
+                       if (languageShowSidebar === Language.get(languageShowSidebar) || Language.get(languageShowSidebar) === '') {
                                languageShowSidebar = document.createElement('span');
                                languageShowSidebar.className = 'icon icon16 fa-angle-double-' + sidebarPosition.toLowerCase();
                        }
                        
                        var languageHideSidebar = 'wcf.global.sidebar.hide' + sidebarPosition + 'Sidebar';
-                       if (languageHideSidebar === WCF.Language.get(languageHideSidebar) || WCF.Language.get(languageHideSidebar) === '') {
+                       if (languageHideSidebar === Language.get(languageHideSidebar) || Language.get(languageHideSidebar) === '') {
                                languageHideSidebar = document.createElement('span');
                                languageHideSidebar.className = 'icon icon16 fa-angle-double-' + (sidebarPosition === 'Left' ? 'right' : 'left');
                        }
index c311007e76036d2b0a2d43bf92926877d3d9db69..8673fe10561a29854e78187cc20ca2ad47b3581f 100644 (file)
@@ -11,6 +11,7 @@ requirejs.config({
                        'DOM/Traverse': 'WoltLab/WCF/DOM/Traverse',
                        'DOM/Util': 'WoltLab/WCF/DOM/Util',
                        'EventHandler': 'WoltLab/WCF/Event/Handler',
+                       'Language': 'WoltLab/WCF/Language',
                        'UI/Alignment': 'WoltLab/WCF/UI/Alignment',
                        'UI/Dialog': 'WoltLab/WCF/UI/Dialog',
                        'UI/SimpleDropdown': 'WoltLab/WCF/UI/Dropdown/Simple',