aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMisko Hevery2010-07-29 15:26:10 -0700
committerMisko Hevery2010-07-29 15:26:10 -0700
commit03aac8b0ab17a9e8a41c5794f1e838315875051a (patch)
tree422bd60c097b8c76b88d34b68f2010f46baf53ad /src
parent1b768b84439e725010acc943ebfda462e49d3704 (diff)
downloadangular.js-03aac8b0ab17a9e8a41c5794f1e838315875051a.tar.bz2
fix broken build, fix #autobind and css loading
Diffstat (limited to 'src')
-rw-r--r--src/Angular.js25
-rw-r--r--src/angular-bootstrap.js4
-rw-r--r--src/angular.suffix2
3 files changed, 22 insertions, 9 deletions
diff --git a/src/Angular.js b/src/Angular.js
index 80acddf0..a9362c69 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -369,22 +369,35 @@ function toKeyValue(obj) {
function angularInit(config){
if (config.autobind) {
- var scope = compile(window.document, null, {'$config':config});
// TODO default to the source of angular.js
- scope.$browser.addCss('css/angular.css');
+ var scope = compile(window.document, null, {'$config':config});
+ if (config.css)
+ scope.$browser.addCss(config.base_url + config.css);
scope.$init();
}
}
-function angularJsConfig(document) {
- var filename = /(.*)\/angular(-(.*))?.js(#(.*))?/,
+function angularJsConfig(document, config) {
+ var filename = /^(.*)\/angular(-([^\/]*))?.js(#(.*))?$/,
scripts = document.getElementsByTagName("script"),
match;
+ config = extend({
+ base_url: '',
+ css: '../css/angular.css'
+ }, config);
for(var j = 0; j < scripts.length; j++) {
match = (scripts[j].src || "").match(filename);
if (match) {
- return match[5];
+ config.base_url = match[1] + '/';
+ extend(match, config, toKeyValue(match[5]));
+ eachAttribute(jqLite(scripts[j]), function(value, name){
+ if (/^ng:/.exec(name)) {
+ name = name.substring(3).replace(/-/g, '_');
+ if (name == 'autobind') value = true;
+ config[name] = value;
+ }
+ });
}
}
- return "";
+ return config;
}
diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js
index e055371a..1f03b8a3 100644
--- a/src/angular-bootstrap.js
+++ b/src/angular-bootstrap.js
@@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
(function(previousOnLoad){
- var filename = /(.*)\/angular-(.*).js(#.*)?/,
+ var filename = /^(.*)\/angular-bootstrap.js(#.*)?$/,
scripts = document.getElementsByTagName("SCRIPT"),
serverPath,
match;
@@ -61,7 +61,7 @@
try {
if (previousOnLoad) previousOnLoad();
} catch(e) {}
- angularInit(parseKeyValue(angularJsConfig(document)));
+ angularInit(angularJsConfig(document));
};
})(window.onload);
diff --git a/src/angular.suffix b/src/angular.suffix
index 36d73df2..7e86c5d5 100644
--- a/src/angular.suffix
+++ b/src/angular.suffix
@@ -3,7 +3,7 @@
try {
if (previousOnLoad) previousOnLoad();
} catch(e) {}
- angularInit(parseKeyValue(angularJsConfig(document)));
+ angularInit(angularJsConfig(document));
};
})(window, document, window.onload);