Commit | Line | Data |
---|---|---|
4bbf6ff1 AE |
1 | "use strict"; |
2 | ||
3 | /** | |
4 | * Provides the basic core functionality. | |
5 | * | |
6 | * @author Alexander Ebert | |
7 | * @copyright 2001-2015 WoltLab GmbH | |
8 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> | |
9 | * @module WoltLab/WCF/Core | |
10 | */ | |
11 | define(['jQuery'], function($) { | |
12 | /** | |
13 | * @constructor | |
14 | */ | |
a0c09b4b | 15 | function Core() {}; |
4bbf6ff1 AE |
16 | Core.prototype = { |
17 | /** | |
18 | * Initializes the core UI modifications and unblocks jQuery's ready event. | |
19 | */ | |
20 | setup: function() { | |
21 | require(['WoltLab/WCF/Date/Time/Relative', 'UI/SimpleDropdown', 'WoltLab/WCF/UI/Mobile', 'WoltLab/WCF/UI/TabMenu'], function(relativeTime, simpleDropdown, uiMobile, TabMenu) { | |
22 | relativeTime.setup(); | |
23 | simpleDropdown.setup(); | |
24 | uiMobile.setup(); | |
25 | TabMenu.init(); | |
26 | ||
27 | $.holdReady(false); | |
28 | }); | |
29 | }, | |
30 | ||
31 | /** | |
32 | * Merges objects with the first argument. | |
33 | * | |
34 | * @param {object} out destination object | |
35 | * @param {...object} arguments variable number of objects to be merged into the destination object | |
36 | * @return {object} destination object with all provided objects merged into | |
37 | */ | |
38 | extend: function(out) { | |
39 | out = out || {}; | |
40 | ||
41 | for (var i = 1, length = arguments.length; i < length; i++) { | |
42 | var obj = arguments[i]; | |
43 | ||
44 | if (!obj) continue; | |
45 | ||
46 | for (var key in obj) { | |
47 | if (obj.hasOwnProperty(key)) { | |
48 | if (typeof obj[key] === 'object') { | |
49 | this.extend(out[key], obj[key]); | |
50 | } | |
51 | else { | |
52 | out[key] = obj[key]; | |
53 | } | |
54 | } | |
55 | } | |
56 | } | |
57 | ||
58 | return out; | |
59 | }, | |
60 | ||
61 | triggerEvent: function(el, eventName) { | |
62 | var ev; | |
63 | if (document.createEvent) { | |
64 | ev = new Event(eventName); | |
65 | el.dispatchEvent(ev); | |
66 | } | |
67 | else { | |
68 | ev = document.createEventObject(); | |
69 | el.fireEvent('on' + eventName, ev); | |
70 | } | |
71 | } | |
72 | }; | |
73 | ||
74 | return new Core(); | |
75 | }); |