Commit | Line | Data |
---|---|---|
a3a09eff TD |
1 | /** |
2 | * Bootstraps WCF's JavaScript. | |
3 | * It defines globals needed for backwards compatibility | |
4 | * and runs modules that are needed on page load. | |
5 | * | |
6 | * @author Tim Duesterhus | |
7 | * @copyright 2001-2015 WoltLab GmbH | |
8 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
9 | * @module WoltLab/WCF/Bootstrap | |
10 | */ | |
11 | define( | |
0127caf7 | 12 | [ |
b7f79b30 | 13 | 'favico', 'enquire', 'perfect-scrollbar', 'WoltLab/WCF/Date/Time/Relative', |
0127caf7 | 14 | 'UI/SimpleDropdown', 'WoltLab/WCF/UI/Mobile', 'WoltLab/WCF/UI/TabMenu', 'WoltLab/WCF/UI/FlexibleMenu', |
bd969ed4 | 15 | 'UI/Dialog', 'WoltLab/WCF/UI/Tooltip', 'WoltLab/WCF/Language', 'WoltLab/WCF/Environment' |
0127caf7 AE |
16 | ], |
17 | function( | |
b7f79b30 | 18 | favico, enquire, perfectScrollbar, DateTimeRelative, |
bd969ed4 AE |
19 | UISimpleDropdown, UIMobile, UITabMenu, UIFlexibleMenu, |
20 | UIDialog, UITooltip, Language, Environment | |
0127caf7 | 21 | ) |
a3a09eff | 22 | { |
c318ad3b AE |
23 | "use strict"; |
24 | ||
b7f79b30 | 25 | // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js |
17e6272b TD |
26 | window.Favico = favico; |
27 | window.enquire = enquire; | |
46badb6a TD |
28 | // non strict equals by intent |
29 | if (window.WCF == null) window.WCF = { }; | |
30 | if (window.WCF.Language == null) window.WCF.Language = { }; | |
3f043599 TD |
31 | window.WCF.Language.get = Language.get; |
32 | window.WCF.Language.add = Language.add; | |
33 | window.WCF.Language.addObject = Language.addObject; | |
17e6272b | 34 | |
a3a09eff | 35 | /** |
bc8cd0ff | 36 | * @exports WoltLab/WCF/Bootstrap |
a3a09eff | 37 | */ |
bc8cd0ff | 38 | var Bootstrap = { |
a3a09eff TD |
39 | /** |
40 | * Initializes the core UI modifications and unblocks jQuery's ready event. | |
41 | */ | |
42 | setup: function() { | |
bd969ed4 AE |
43 | Environment.setup(); |
44 | ||
45 | DateTimeRelative.setup(); | |
46 | ||
47 | UISimpleDropdown.setup(); | |
09f7100b AE |
48 | UIMobile.setup(); |
49 | UITabMenu.setup(); | |
71c93c40 | 50 | UIFlexibleMenu.setup(); |
09f7100b AE |
51 | UIDialog.setup(); |
52 | UITooltip.setup(); | |
a3a09eff | 53 | |
d63c6f77 AE |
54 | // convert method=get into method=post |
55 | var forms = document.querySelectorAll('form[method=get]'); | |
56 | for (var i = 0, length = forms.length; i < length; i++) { | |
57 | forms[i].setAttribute('method', 'post'); | |
58 | } | |
59 | ||
bd969ed4 | 60 | if (Environment.browser() === 'microsoft') { |
d63c6f77 AE |
61 | window.onbeforeunload = function() { |
62 | /* Prevent "Back navigation caching" (http://msdn.microsoft.com/en-us/library/ie/dn265017%28v=vs.85%29.aspx) */ | |
63 | }; | |
64 | } | |
65 | ||
bd969ed4 AE |
66 | // DEBUG ONLY |
67 | var interval = 0; | |
68 | interval = window.setInterval(function() { | |
69 | if (typeof window.jQuery === 'function') { | |
70 | window.clearInterval(interval); | |
71 | ||
72 | window.jQuery.holdReady(false); | |
73 | } | |
74 | }, 20); | |
a3a09eff | 75 | } |
c318ad3b | 76 | }; |
a3a09eff | 77 | |
bc8cd0ff | 78 | return Bootstrap; |
a3a09eff | 79 | }); |