2 * Bootstraps WCF's JavaScript with additions for the frontend usage.
4 * @author Alexander Ebert
5 * @copyright 2001-2018 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @module WoltLabSuite/Core/BootstrapFrontend
11 'WoltLabSuite/Core/BackgroundQueue', 'WoltLabSuite/Core/Bootstrap', 'WoltLabSuite/Core/Controller/Style/Changer',
12 'WoltLabSuite/Core/Controller/Popover', 'WoltLabSuite/Core/Ui/User/Ignore', 'WoltLabSuite/Core/Ui/Page/Header/Menu'
15 BackgroundQueue
, Bootstrap
, ControllerStyleChanger
,
16 ControllerPopover
, UiUserIgnore
, UiPageHeaderMenu
22 * @exports WoltLabSuite/Core/BootstrapFrontend
26 * Bootstraps general modules and frontend exclusive ones.
28 * @param {object<string, *>} options bootstrap options
30 setup: function(options
) {
31 // fix the background queue URL to always run against the current domain (avoiding CORS)
32 options
.backgroundQueue
.url
= WSC_API_URL
+ options
.backgroundQueue
.url
.substr(WCF_PATH
.length
);
36 UiPageHeaderMenu
.init();
38 if (options
.styleChanger
) {
39 ControllerStyleChanger
.setup();
42 if (options
.enableUserPopover
) {
43 this._initUserPopover();
46 BackgroundQueue
.setUrl(options
.backgroundQueue
.url
);
47 if (Math
.random() < 0.1 || options
.backgroundQueue
.force
) {
48 // invoke the queue roughly every 10th request or on demand
49 BackgroundQueue
.invoke();
52 if (COMPILER_TARGET_DEFAULT
) {
58 * Initializes user profile popover.
60 _initUserPopover: function() {
61 ControllerPopover
.init({
62 attributeName
: 'data-user-id',
63 className
: 'userLink',
64 identifier
: 'com.woltlab.wcf.user',
65 loadCallback: function(objectId
, popover
) {
66 var callback = function(data
) {
67 popover
.setContent('com.woltlab.wcf.user', objectId
, data
.returnValues
.template
);
71 actionName
: 'getUserProfile',
72 className
: 'wcf\\data\\user\\UserProfileAction',
73 objectIDs
: [ objectId
]
74 }, callback
, callback
);