Fix JavaScript references in templates
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / WoltLab / WCF / Bootstrap.js
CommitLineData
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 */
11define(
0127caf7 12 [
f317bc66 13 'favico', 'enquire', 'perfect-scrollbar', 'WoltLab/WCF/Date/Time/Relative',
9a421cc7
AE
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',
f317bc66 16 'WoltLab/WCF/Date/Picker'
0127caf7
AE
17 ],
18 function(
f317bc66 19 favico, enquire, perfectScrollbar, DateTimeRelative,
9a421cc7
AE
20 UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu,
21 UiDialog, UiTooltip, Language, Environment,
f317bc66 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 49
9a421cc7
AE
50 UiSimpleDropdown.setup();
51 UiMobile.setup();
52 UiTabMenu.setup();
53 UiFlexibleMenu.setup();
54 UiDialog.setup();
55 UiTooltip.setup();
a3a09eff 56
d63c6f77 57 // convert method=get into method=post
d0023381 58 var forms = elBySelAll('form[method=get]');
d63c6f77
AE
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});