blob: 5e7806e8cab0b8375248022ad69cc0b4b044e51b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
/* This is the base Horizon JavaScript object. There is only ever one of these
* loaded (referenced as horizon with a lower-case h) which happens immediately
* after the definition below.
*
* Scripts that are dependent on functionality defined in the Horizon object
* must be included after this script in templates/base.html.
*/
var Horizon = function () {
var horizon = {},
initFunctions = [];
/* Use the addInitFunction() function to add initialization code which must
* be called on DOM ready. This is useful for adding things like event
* handlers or any other initialization functions which should preceed user
* interaction but rely on DOM readiness.
*/
horizon.addInitFunction = function (fn) {
initFunctions.push(fn);
};
/* Call all initialization functions and clear the queue. */
horizon.init = function () {
for (var i = 0; i < initFunctions.length; i += 1) {
initFunctions[i]();
}
// Prevent multiple executions, just in case.
initFunctions = [];
};
return horizon;
};
// Create the one and only horizon object.
var horizon = new Horizon();
|