Improved generic avatars for guests
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / WoltLabSuite / Core / 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
50d96bd8 7 * @copyright 2001-2017 WoltLab GmbH
a3a09eff 8 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
58d7e8f8 9 * @module WoltLabSuite/Core/Bootstrap
a3a09eff
TD
10 */
11define(
0127caf7 12 [
58d7e8f8
MS
13 'favico', 'enquire', 'perfect-scrollbar', 'WoltLabSuite/Core/Date/Time/Relative',
14 'Ui/SimpleDropdown', 'WoltLabSuite/Core/Ui/Mobile', 'WoltLabSuite/Core/Ui/TabMenu', 'WoltLabSuite/Core/Ui/FlexibleMenu',
15 'Ui/Dialog', 'WoltLabSuite/Core/Ui/Tooltip', 'WoltLabSuite/Core/Language', 'WoltLabSuite/Core/Environment',
32669648
AE
16 'WoltLabSuite/Core/Date/Picker', 'EventHandler', 'Core', 'WoltLabSuite/Core/Ui/Page/JumpToTop',
17 'Devtools'
0127caf7
AE
18 ],
19 function(
f317bc66 20 favico, enquire, perfectScrollbar, DateTimeRelative,
9a421cc7
AE
21 UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu,
22 UiDialog, UiTooltip, Language, Environment,
32669648
AE
23 DatePicker, EventHandler, Core, UiPageJumpToTop,
24 Devtools
0127caf7 25 )
a3a09eff 26{
c318ad3b
AE
27 "use strict";
28
b7f79b30 29 // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js
17e6272b
TD
30 window.Favico = favico;
31 window.enquire = enquire;
46badb6a
TD
32 // non strict equals by intent
33 if (window.WCF == null) window.WCF = { };
34 if (window.WCF.Language == null) window.WCF.Language = { };
3f043599
TD
35 window.WCF.Language.get = Language.get;
36 window.WCF.Language.add = Language.add;
37 window.WCF.Language.addObject = Language.addObject;
17e6272b 38
126b3f33
AE
39 // WCF.System.Event compatibility
40 window.__wcf_bc_eventHandler = EventHandler;
41
a3a09eff 42 /**
58d7e8f8 43 * @exports WoltLabSuite/Core/Bootstrap
a3a09eff 44 */
cbbb348c 45 return {
a3a09eff
TD
46 /**
47 * Initializes the core UI modifications and unblocks jQuery's ready event.
cbbb348c
AE
48 *
49 * @param {Object=} options initialization options
a3a09eff 50 */
cbbb348c
AE
51 setup: function(options) {
52 options = Core.extend({
53 enableMobileMenu: true
54 }, options);
55
32669648
AE
56 //noinspection JSUnresolvedVariable
57 if (window.ENABLE_DEVELOPER_TOOLS) Devtools._internal_.enable();
58
bd969ed4
AE
59 Environment.setup();
60
61 DateTimeRelative.setup();
f317bc66 62 DatePicker.init();
bd969ed4 63
9a421cc7 64 UiSimpleDropdown.setup();
cbbb348c
AE
65 UiMobile.setup({
66 enableMobileMenu: options.enableMobileMenu
67 });
9a421cc7 68 UiTabMenu.setup();
b8eab696 69 //UiFlexibleMenu.setup();
9a421cc7
AE
70 UiDialog.setup();
71 UiTooltip.setup();
a3a09eff 72
d0f8cab0
AE
73 new UiPageJumpToTop();
74
d63c6f77 75 // convert method=get into method=post
d0023381 76 var forms = elBySelAll('form[method=get]');
d63c6f77
AE
77 for (var i = 0, length = forms.length; i < length; i++) {
78 forms[i].setAttribute('method', 'post');
79 }
80
bd969ed4 81 if (Environment.browser() === 'microsoft') {
d63c6f77
AE
82 window.onbeforeunload = function() {
83 /* Prevent "Back navigation caching" (http://msdn.microsoft.com/en-us/library/ie/dn265017%28v=vs.85%29.aspx) */
84 };
85 }
86
bd969ed4
AE
87 // DEBUG ONLY
88 var interval = 0;
89 interval = window.setInterval(function() {
90 if (typeof window.jQuery === 'function') {
91 window.clearInterval(interval);
92
93 window.jQuery.holdReady(false);
94 }
95 }, 20);
a3a09eff 96 }
c318ad3b 97 };
a3a09eff 98});