2 * Bootstraps WCF's JavaScript.
3 * It defines globals needed for backwards compatibility
4 * and runs modules that are needed on page load.
6 * @author Tim Duesterhus
7 * @copyright 2001-2018 WoltLab GmbH
8 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
9 * @module WoltLabSuite/Core/Bootstrap
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',
16 'WoltLabSuite/Core/Date/Picker', 'EventHandler', 'Core', 'WoltLabSuite/Core/Ui/Page/JumpToTop',
17 'Devtools', 'Dom/ChangeListener'
20 favico
, enquire
, perfectScrollbar
, DateTimeRelative
,
21 UiSimpleDropdown
, UiMobile
, UiTabMenu
, UiFlexibleMenu
,
22 UiDialog
, UiTooltip
, Language
, Environment
,
23 DatePicker
, EventHandler
, Core
, UiPageJumpToTop
,
24 Devtools
, DomChangeListener
29 // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js
30 window
.Favico
= favico
;
31 window
.enquire
= enquire
;
32 // non strict equals by intent
33 if (window
.WCF
== null) window
.WCF
= { };
34 if (window
.WCF
.Language
== null) window
.WCF
.Language
= { };
35 window
.WCF
.Language
.get = Language
.get;
36 window
.WCF
.Language
.add
= Language
.add
;
37 window
.WCF
.Language
.addObject
= Language
.addObject
;
39 // WCF.System.Event compatibility
40 window
.__wcf_bc_eventHandler
= EventHandler
;
43 * @exports WoltLabSuite/Core/Bootstrap
47 * Initializes the core UI modifications and unblocks jQuery's ready event.
49 * @param {Object=} options initialization options
51 setup: function(options
) {
52 options
= Core
.extend({
53 enableMobileMenu
: true
56 //noinspection JSUnresolvedVariable
57 if (window
.ENABLE_DEVELOPER_TOOLS
) Devtools
._internal_
.enable();
61 DateTimeRelative
.setup();
64 UiSimpleDropdown
.setup();
66 enableMobileMenu
: options
.enableMobileMenu
69 //UiFlexibleMenu.setup();
73 // convert method=get into method=post
74 var forms
= elBySelAll('form[method=get]');
75 for (var i
= 0, length
= forms
.length
; i
< length
; i
++) {
76 forms
[i
].setAttribute('method', 'post');
79 if (Environment
.browser() === 'microsoft') {
80 window
.onbeforeunload = function() {
81 /* Prevent "Back navigation caching" (http://msdn.microsoft.com/en-us/library/ie/dn265017%28v=vs.85%29.aspx) */
86 interval = window.setInterval(function() {
87 if (typeof window.jQuery === 'function') {
88 window.clearInterval(interval);
90 // the 'jump to top' button triggers style recalculation/layout,
91 // putting it at the end of the jQuery queue avoids trashing the
92 // layout too early and thus delaying the page initialization
93 window.jQuery(function() {
94 new UiPageJumpToTop();
97 window.jQuery.holdReady(false);
102 DomChangeListener.add('WoltLabSuite/Core/Bootstrap', this._initA11y.bind(this));
105 _initA11y: function() {
106 elBySelAll('nav:not([aria-label]):not([role])', undefined, function(element) {
107 elAttr(element, 'role', 'presentation');
110 elBySelAll('article:not([aria-label]):not([role])', undefined, function(element) {
111 elAttr(element, 'role', 'presentation');