-
Notifications
You must be signed in to change notification settings - Fork 1
/
amd_core-1.0.1.min.js
24 lines (21 loc) · 3.8 KB
/
amd_core-1.0.1.min.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
/*!
* @overview amd_core.
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/adussaq/amd_core/gh-pages/LICENSE
* @version 1.0.0
* @Compressed with: https://closure-compiler.appspot.com/home
*/
var amd_core=function(){
var k,f,q,r,t,p,g,w,x,e,y,u,l,v
//These are the required compents. Point them to your jQuery,
// es6-promise and whatever other libraries all your tools require.
jQueryURL = "https://alexdussaq.info/amd_core/jquery.min.js",
promiseURL = "https://raw.githubusercontent.com/jakearchibald/es6-promise/master/dist/es6-promise.min.js",
restURL = ['amd_ww-2.0.0.min.js', 'amd_cf-2.0.0.min.js'];
g=[];l={};v={};k=restURL;e={require:function(a){g.push(a)}};e.isArray=function(){if(Array.isArray)return Array.isArray;var a=Object.prototype.toString,b=a.call([]);return function(c){return a.call(c)===b}}();p=function(a){var b,c,d;b=function(b){return function(){b(a)}};c=function(b){return function(c){v[a]=!0;b(Error("Failed to get: "+a+" statusText: "+c.statusText+" status: "+c.status))}};d=l[a]&&!v[a]?l[a]:function(){return new Promise(function(d,
e){$.ajax({url:a,dataType:"script",success:b(d),error:c(e)})})}();return l[a]=d};x=function(a){if("function"===typeof a)return!0;console.error(Error("Callback in coreObj.require not defined, this is a required parameter."));return!1};w=function(a){var b=!0,c;"object"!==typeof a&&(console.error(Error("List for require must be an object.")),b=!1);if(a.hasOwnProperty("ordered"))if(e.isArray(a.ordered))for(c=0;c<a.ordered.length;c+=1)e.isArray(a.ordered[c])||(console.error(Error("Each element in the array for Ordered List for require must also be an array.")),
b=!1);else console.error(Error("Ordered list for require must be an array.")),b=!1;else a.ordered=[[]];a.hasOwnProperty("async")?e.isArray(a.async)||(console.error(Error("Async List for require must be an array.")),b=!1):a.async=[];return b};y=function(){var a;e.require=u;for(a=0;a<g.length;a+=1)u(g[a])};u=function(a){var b,c,d,e,f,m,g,k,h,n;c=[];h=[];n={};k=a.callback;g=function(a){console.error("Was unable to load module: ",a)};e=function(a){return function(){return p(a)}};if(w(a)&&x(k)){h=h.concat(a.async);
h=h.concat.apply(h,a.ordered);for(d=0;d<a.async.length;d+=1)f=a.async[d],b=p(f),c.push(b["catch"](g));for(d=0;d<a.ordered.length;d+=1){m=Promise.resolve();for(b=0;b<a.ordered[d].length;b+=1)f=a.ordered[d][b],m=m.then(e(f));m=m["catch"](g);c.push(m)}}Promise.all(c).then(function(){var a,b,c,d,e;c=[];d=function(a){return function(){n[a].loaded=!0}};e=function(a){return function(){n[a].loaded=!1}};for(a=0;a<h.length;a+=1)b=h[a],n[b]=l[b]?{url:b,promise:l[b]}:{url:b,promise:Promise.reject(Error(b+": Script never reached, at least one of the prerequisites failed to load."))},
c.push(n[b].promise.then(d(b),e(b)));Promise.all(c).then(function(){k(n)})})};q=function(a,b){var c;c=new XMLHttpRequest;c.open("GET",jQueryURL);c.onload=function(){200===c.status?(eval(c.response),console.log("Got jQuery, other loading will now begin."),a(c.response)):b(Error("Could not load jQuery: "+c.statusText))};c.onerror=function(){b(Error("Could not load jQuery: Network Error"))};c.send()};r=function(a,b){console.warn("This browser does not support promises, getting polyfill for promises, but this only offerspartial support, see: https://github.com/jakearchibald/es6-promise#readme");
$.ajax({url:promiseURL,dataType:"script",success:a,error:b})};f=function(){var a,b=[],c;c=function(a){console.error("Failed to get core module: "+a)};for(a=0;a<k.length;a+=1)b.push(p(k[a])["catch"](c));Promise.all(b).then(y)};t=function(){window.Promise?f():r(f,function(a){r(f,function(b){console.error("After two attempts, could not load Promises.",a,b)})})};window.jQuery||q(t,function(a){q(t,function(b){console.error("After two attempts, could not load jQuery.",
a,b)})});e.getScript = p;return e}();