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 | [ |
f317bc66 MS |
13 | 'favico', 'enquire', 'perfect-scrollbar', 'WoltLab/WCF/Date/Time/Relative', |
14 | 'UI/SimpleDropdown', 'WoltLab/WCF/UI/Mobile', 'WoltLab/WCF/UI/TabMenu', 'WoltLab/WCF/UI/FlexibleMenu', | |
15 | 'UI/Dialog', 'WoltLab/WCF/UI/Tooltip', 'WoltLab/WCF/Language', 'WoltLab/WCF/Environment', | |
16 | 'WoltLab/WCF/Date/Picker' | |
0127caf7 AE |
17 | ], |
18 | function( | |
f317bc66 MS |
19 | favico, enquire, perfectScrollbar, DateTimeRelative, |
20 | UISimpleDropdown, UIMobile, UITabMenu, UIFlexibleMenu, | |
21 | UIDialog, UITooltip, Language, Environment, | |
22 | DatePicker | |
0127caf7 | 23 | ) |
a3a09eff | 24 | { |
c318ad3b AE |
25 | "use strict"; |
26 | ||
b7f79b30 | 27 | // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js |
17e6272b TD |
28 | window.Favico = favico; |
29 | window.enquire = enquire; | |
46badb6a TD |
30 | // non strict equals by intent |
31 | if (window.WCF == null) window.WCF = { }; | |
32 | if (window.WCF.Language == null) window.WCF.Language = { }; | |
3f043599 TD |
33 | window.WCF.Language.get = Language.get; |
34 | window.WCF.Language.add = Language.add; | |
35 | window.WCF.Language.addObject = Language.addObject; | |
17e6272b | 36 | |
a3a09eff | 37 | /** |
bc8cd0ff | 38 | * @exports WoltLab/WCF/Bootstrap |
a3a09eff | 39 | */ |
bc8cd0ff | 40 | var Bootstrap = { |
a3a09eff TD |
41 | /** |
42 | * Initializes the core UI modifications and unblocks jQuery's ready event. | |
43 | */ | |
44 | setup: function() { | |
bd969ed4 AE |
45 | Environment.setup(); |
46 | ||
47 | DateTimeRelative.setup(); | |
f317bc66 | 48 | DatePicker.init(); |
bd969ed4 AE |
49 | |
50 | UISimpleDropdown.setup(); | |
09f7100b AE |
51 | UIMobile.setup(); |
52 | UITabMenu.setup(); | |
71c93c40 | 53 | UIFlexibleMenu.setup(); |
09f7100b AE |
54 | UIDialog.setup(); |
55 | UITooltip.setup(); | |
a3a09eff | 56 | |
d63c6f77 AE |
57 | // convert method=get into method=post |
58 | var forms = document.querySelectorAll('form[method=get]'); | |
59 | for (var i = 0, length = forms.length; i < length; i++) { | |
60 | forms[i].setAttribute('method', 'post'); | |
61 | } | |
62 | ||
bd969ed4 | 63 | if (Environment.browser() === 'microsoft') { |
d63c6f77 AE |
64 | window.onbeforeunload = function() { |
65 | /* Prevent "Back navigation caching" (http://msdn.microsoft.com/en-us/library/ie/dn265017%28v=vs.85%29.aspx) */ | |
66 | }; | |
67 | } | |
68 | ||
bd969ed4 AE |
69 | // DEBUG ONLY |
70 | var interval = 0; | |
71 | interval = window.setInterval(function() { | |
72 | if (typeof window.jQuery === 'function') { | |
73 | window.clearInterval(interval); | |
74 | ||
75 | window.jQuery.holdReady(false); | |
76 | } | |
77 | }, 20); | |
a3a09eff | 78 | } |
c318ad3b | 79 | }; |
a3a09eff | 80 | |
bc8cd0ff | 81 | return Bootstrap; |
a3a09eff | 82 | }); |