From 46badb6a09f7fb866e0c7d92b273f9c425aa1500 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 25 May 2015 02:56:12 +0200 Subject: [PATCH] Work around race condition in WCF.js loading --- wcfsetup/install/files/js/WCF.js | 44 ++++++++++--------- .../install/files/js/WoltLab/WCF/Bootstrap.js | 3 ++ 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 9df9906bec..9eb35d71b2 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -186,7 +186,8 @@ window.shuffle = function(array) { /** * Initialize WCF namespace */ -window.WCF = {}; +// non strict equals by intent +if (window.WCF == null) window.WCF = { }; /** * Extends jQuery with additional methods. @@ -3239,25 +3240,28 @@ WCF.Dictionary = Class.extend({ } }); -/** - * @deprecated Use WoltLab/WCF/Language - */ -WCF.Language = { - add: function(key, value) { - require(['WoltLab/WCF/Language'], function(Language) { - Language.add(key, value); - }); - }, - addObject: function(object) { - require(['WoltLab/WCF/Language'], function(Language) { - Language.addObject(object); - }); - }, - get: function(key, parameters) { - // This cannot be sanely provided as a compatibility wrapper. - throw new Error('Call to deprecated WCF.Language.get("' + key + '")'); - } -}; +// non strict equals by intent +if (window.WCF.Language == null) { + /** + * @deprecated Use WoltLab/WCF/Language + */ + WCF.Language = { + add: function(key, value) { + require(['WoltLab/WCF/Language'], function(Language) { + Language.add(key, value); + }); + }, + addObject: function(object) { + require(['WoltLab/WCF/Language'], function(Language) { + Language.addObject(object); + }); + }, + get: function(key, parameters) { + // This cannot be sanely provided as a compatibility wrapper. + throw new Error('Call to deprecated WCF.Language.get("' + key + '")'); + } + }; +} /** * Handles multiple language input fields. diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js b/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js index 1638436554..659313b7a8 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Bootstrap.js @@ -25,6 +25,9 @@ define( // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js window.Favico = favico; window.enquire = enquire; + // non strict equals by intent + if (window.WCF == null) window.WCF = { }; + if (window.WCF.Language == null) window.WCF.Language = { }; window.WCF.Language.get = Language.get; window.WCF.Language.add = Language.add; window.WCF.Language.addObject = Language.addObject; -- 2.20.1