From b806b308614668c2590996a72b26b3529e909ebd Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 20 Apr 2012 13:28:58 -0700
Subject: fix(bootstrap): rewritten to $script
---
src/angular-bootstrap.js | 119 ++++++++++++++++++++++++-----------------------
1 file changed, 61 insertions(+), 58 deletions(-)
(limited to 'src')
diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js
index 50211416..742e74f2 100644
--- a/src/angular-bootstrap.js
+++ b/src/angular-bootstrap.js
@@ -1,4 +1,11 @@
-'use strict';
+
+/*!
+ * $script.js Async loader & dependency manager
+ * https://github.com/ded/script.js
+ * (c) Dustin Diaz, Jacob Thornton 2011
+ * License: MIT
+ */
+(function(a,b){typeof module!="undefined"?module.exports=b():typeof define=="function"&&define.amd?define(a,b):this[a]=b()})("$script",function(){function q(a,b,c){for(c=0,j=a.length;c');
+
+ $script.path(serverPath+'../');
+ $script('angularFiles', function() {
+ var index = 0,
+ scripts = angularFiles.angularSrc;
+
+ try { delete window.angularFiles; } catch(e) { window.angularFiles = undefined; }
+ // initialize the window property cache
+ for (var prop in window) {
+ if (IGNORE[prop] || prop.match(/^moz[A-Z]/)) { //skip special variables which keep on changing
+ continue;
+ }
+ try {
+ globalVars[key(prop)] = window[prop];
+ } catch(e) {} //ignore properties that throw exception when accessed (common in FF)
+ }
+
+ (function next() {
+ if (index < scripts.length) {
+ var file = scripts[index++];
+
+ $script(file.replace(/\.js$/, ''), function() {
+ angularClobberTest(file);
+ next();
+ });
+ } else {
+ // empty the cache to prevent mem leaks
+ globalVars = {};
+
+ bindJQuery();
+ publishExternalAPI(window.angular);
+
+ angularInit(document, angular.bootstrap);
+ }
+ })();
+ });
+
function key(prop) {
return "ng-clobber_" + prop;
}
- window.angularClobberTest = function(file) {
+ function angularClobberTest(file) {
var varKey, prop,
- clobbered = [];
+ clobbered = {};
for (prop in window) {
varKey = key(prop);
- if (prop === 'event') { //skip special variables which keep on changing
+ if (IGNORE[prop] || prop.match(/^moz[A-Z]/)) { //skip special variables which keep on changing
continue;
- }
- else if (!globalVars.hasOwnProperty(varKey)) {
+ } else if (!globalVars.hasOwnProperty(varKey)) {
//console.log('new global variable found: ', prop);
try {
globalVars[varKey] = window[prop];
} catch(e) {} //ignore properties that throw exception when accessed (common in FF)
} else if (globalVars[varKey] !== window[prop] && !isActuallyNaN(window[prop]) && prop != 'jqLite') {
- clobbered.push(prop);
+ clobbered[prop] = true;
console.error("Global variable clobbered by script " + file + "! Variable name: " + prop);
globalVars[varKey] = window[prop];
}
}
for (varKey in globalVars) {
prop = varKey.substr(11);
- if (clobbered.indexOf(prop) == -1 &&
+ if (prop === 'event' || prop.match(/^moz[A-Z]/)) { //skip special variables which keep on changing
+ continue;
+ }
+ if (!clobbered[prop] &&
prop != 'event' &&
prop != 'jqLite' &&
!isActuallyNaN(globalVars[varKey]) &&
@@ -60,56 +111,8 @@
}
function isActuallyNaN(val) {
- return isNaN(val) && (typeof val === 'number');
- }
- };
-
- window.addScripts = function(scripts) {
- delete window.addScripts;
- delete window.angularFiles;
-
- var prop, i;
-
- // initialize the window property cache
- for (prop in window) {
- try {
- globalVars[key(prop)] = window[prop];
- } catch(e) {} //ignore properties that throw exception when accessed (common in FF)
- }
-
- // load the js scripts
- for (i in scripts) {
- var file = scripts[i].replace(/src\//, '');
- document.write('');
+ return (typeof val === 'number') && isNaN(val);
}
};
-
- function addCss(file) {
- document.write('');
- }
-
- addCss('angular.css');
-
- document.write('');
-
- function onLoadListener() {
- // empty the cache to prevent mem leaks
- globalVars = {};
-
- bindJQuery();
- publishExternalAPI(window.angular);
-
- angularInit(document, angular.bootstrap);
- }
-
- if (window.addEventListener) {
- window.addEventListener('load', onLoadListener, false);
- } else if (window.attachEvent) {
- window.attachEvent('onload', onLoadListener);
- }
-
})(window, document);
--
cgit v1.2.3