Merge branch 'next' of github.com:WoltLab/WCF into next
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / js / WoltLab / WCF / Bootstrap.js
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(
12 [
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 ],
17 function(
18 favico, enquire, perfectScrollbar, DateTimeRelative,
19 UISimpleDropdown, UIMobile, UITabMenu, UIFlexibleMenu,
20 UIDialog, UITooltip, Language, Environment
21 )
22 {
23 "use strict";
24
25 // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js
26 window.Favico = favico;
27 window.enquire = enquire;
28 // non strict equals by intent
29 if (window.WCF == null) window.WCF = { };
30 if (window.WCF.Language == null) window.WCF.Language = { };
31 window.WCF.Language.get = Language.get;
32 window.WCF.Language.add = Language.add;
33 window.WCF.Language.addObject = Language.addObject;
34
35 /**
36 * @exports WoltLab/WCF/Bootstrap
37 */
38 var Bootstrap = {
39 /**
40 * Initializes the core UI modifications and unblocks jQuery's ready event.
41 */
42 setup: function() {
43 Environment.setup();
44
45 DateTimeRelative.setup();
46
47 UISimpleDropdown.setup();
48 UIMobile.setup();
49 UITabMenu.setup();
50 UIFlexibleMenu.setup();
51 UIDialog.setup();
52 UITooltip.setup();
53
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
60 if (Environment.browser() === 'microsoft') {
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
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);
75 }
76 };
77
78 return Bootstrap;
79 });