-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathensure.js
107 lines (98 loc) · 3.8 KB
/
ensure.js
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
// Generated by CoffeeScript 1.6.1
(function() {
var libs, load_script, loader, protocol,
__slice = [].slice;
libs = {
angular: function() {
return typeof angular !== "undefined" && angular !== null ? angular : '//ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.min.js';
},
backbone: function() {
return typeof Backbone !== "undefined" && Backbone !== null ? Backbone : '//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.10/backbone-min.js';
},
fastclick: function() {
return typeof FastClick !== "undefined" && FastClick !== null ? FastClick : '//cdnjs.cloudflare.com/ajax/libs/fastclick/0.6.0/fastclick.min.js';
},
hammer: function() {
return typeof Hammer !== "undefined" && Hammer !== null ? Hammer : '//cdnjs.cloudflare.com/ajax/libs/hammer.js/0.6.4/hammer.js';
},
jquery: function() {
return typeof jQuery !== "undefined" && jQuery !== null ? jQuery : '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
},
jqueryui: function() {
var _ref;
return (_ref = typeof jQuery !== "undefined" && jQuery !== null ? jQuery.Widget : void 0) != null ? _ref : '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js';
},
underscore: function() {
return typeof _ !== "undefined" && _ !== null ? _ : '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js';
},
webfont: function() {
return typeof WebFont !== "undefined" && WebFont !== null ? WebFont : '//ajax.googleapis.com/ajax/libs/webfont/1.1.2/webfont.js';
},
zepto: function() {
return typeof Zepto !== "undefined" && Zepto !== null ? Zepto : '//cdnjs.cloudflare.com/ajax/libs/zepto/1.0/zepto.min.js';
}
};
protocol = location.protocol === 'file:' ? "http:" : '';
load_script = function(name, callback) {
var script, url, _ref, _ref1;
url = (_ref = (_ref1 = typeof name === "function" ? name() : void 0) != null ? _ref1 : typeof libs[name] === "function" ? libs[name]() : void 0) != null ? _ref : null;
if (typeof url !== 'string') {
return callback(null);
}
script = document.createElement('script');
script.type = "text/javascript";
if (loader.defer) {
script.defer = true;
}
if (loader.async) {
script.async = true;
}
script.onload = function(e) {
return callback(null);
};
script.onerror = function(e) {
return callback(new Error("Could not load external resource: " + name + " from " + url));
};
script.src = "" + protocol + url;
script.onreadystatechange = function() {
if (script.readyState === 'loaded' || script.readyState === 'complete') {
script.onreadystatechange = null;
return callback(null);
}
};
document.getElementsByTagName('HTML')[0].appendChild(script);
return script;
};
loader = function() {
var callback, libs, load_handler, nextLib;
libs = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
callback = typeof libs.slice(-1)[0] === 'function' ? libs.pop() : function(err) {
if (err != null) {
throw err;
}
return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log("Library loading complete.") : void 0 : void 0;
};
nextLib = libs.shift();
load_handler = function(err) {
if (err != null) {
return callback(err);
}
if (libs.length === 0) {
return callback(null);
} else {
nextLib = libs.shift();
return load_script(nextLib, load_handler);
}
};
load_script(nextLib, load_handler);
return null;
};
loader.async = true;
loader.defer = false;
loader.libs = libs;
if (typeof module !== "undefined" && module !== null) {
module.exports = loader;
} else {
this.ensure = loader;
}
}).call(this);