Repository navigation
Expand file tree
/
Copy path_edit_.js
More file actions
111 lines (90 loc) · 2.76 KB
/
Copy path_edit_.js
File metadata and controls
111 lines (90 loc) · 2.76 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
elf = (function(elf) {
var isLoading = {},
isLoaded = {},
isCSSLoading = {};
elf.importCSS = function(url, media, doc) {
doc = doc || document;
if (typeof url == "string") {
if (! isCSSLoading[url]) {
isCSSLoading[url] = true;
if (doc.createStyleSheet) {
var sheet = doc.createStyleSheet(url);
sheet.media = media || "all";
} else {
var link = doc.createElement("link");
link.setAttribute("href", url);
link.setAttribute("rel", "stylesheet");
link.setAttribute("type", "text/css");
link.setAttribute("media", media || "all");
var head = doc.documentElement.firstChild;
head.insertBefore(link, head.firstChild || null);
head = link = undefined;
}
}
}
return (typeof this.add != "undefined") ? this : chainFactory();
};
elf.include = function(url) {
if (typeof url == "string" && url.length !== 0) {
var chain = this === elf ? chainFactory() : this;
if (url && ! isLoading[url] && ! isLoaded[url]) {
isLoading[url] = true;
isLoaded[url] = false;
var script = document.createElement("script");
script.src = url;
script.charset = "UTF-8";
script.type = "text/javascript";
if (elf.browser.msie) {
script.onreadystatechange = function() {
if ((/loaded|complete/).test(this.readyState)) {
this.removeAttribute("onreadystatechange");
isLoaded[url] = true;
}
};
} else {
script.onload = function() {
this.removeAttribute("onload");
isLoaded[url] = true;
};
}
var head = document.documentElement.firstChild;
head.insertBefore(script, head.firstChild || null);
head = script = null;
}
if (url && isLoading[url]) {
chain.add(url);
}
return chain;
}
return null;
};
function chainFactory() {
var collection = [];
executor.collection = collection;
function executor(process, context) {
if (typeof process == "function") {
(function() {
if (! ready()) {
setTimeout(arguments.callee, 1);
} else {
process.call(context || null, elf);
}
})();
}
}
executor.importCSS = elf.importCSS;
executor.include = elf.include;
executor.add =
function add(component) {
collection.push(component);
}
function ready() {
var script = collection[0];
if (typeof script == "string" && isLoaded[script]) {
collection.shift();
}
return (collection.length === 0);
}
return executor;
}
})({});