-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.js
More file actions
45 lines (40 loc) · 1.23 KB
/
utils.js
File metadata and controls
45 lines (40 loc) · 1.23 KB
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
36
37
38
39
40
41
42
43
44
45
(function () {
window.__customizer = {
/*
* Utility function to let us wait for a specific element of the page to load...
*/
waitFor: function(callback, elXpath, maxInter, waitTime) {
if (!maxInter) var maxInter = 300; // number of intervals before expiring
if (!waitTime) var waitTime = 100; // 1000=1 second
var waitInter = 0; // current interval
var intId = setInterval( function() {
if (++waitInter >= maxInter) return;
if (typeof(dojo) == "undefined") return;
if (!dojo.query(elXpath, dojo.body()).length) return;
clearInterval(intId);
if (waitInter < maxInter) {
callback();
}
}, waitTime);
},
/*
* Queue of callbacks for the onHashChange event
*/
onHashChangeQueue: [],
/*
* window.onhashchange handler
*/
handleOnHashChange: function() {
for(var i = 0; i < this.onHashChangeQueue.length; i++) {
this.onHashChangeQueue[i]();
}
},
/*
* Utility function to add to the onHashChange callback queue
*/
addOnHashChangeCallback: function(callback) {
this.onHashChangeQueue.push(callback);
window.onhashchange = this.handleOnHashChange;
}
};
})();