diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js | 19 | ||||
| -rw-r--r-- | src/Browser.js | 17 | ||||
| -rw-r--r-- | src/angular-bootstrap.js | 12 | 
3 files changed, 41 insertions, 7 deletions
| diff --git a/src/Angular.js b/src/Angular.js index 79557c2c..8cacb9e4 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -32,7 +32,8 @@ var _undefined        = undefined,      PRIORITY          = {'FIRST': PRIORITY_FIRST, 'LAST': PRIORITY_LAST, 'WATCH':PRIORITY_WATCH},      jQuery            = window['jQuery'] || window['$'], // weirdness to make IE happy      _                 = window['_'], -    msie              = !!/(msie) ([\w.]+)/.exec(lowercase(navigator.userAgent)), +    /** holds major version number for IE or NaN for real browsers */ +    msie              = parseInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1], 10),      jqLite            = jQuery || jqLiteWrap,      slice             = Array.prototype.slice,      push              = Array.prototype.push, @@ -408,25 +409,31 @@ function toKeyValue(obj) {  function angularInit(config){    if (config.autobind) {      // TODO default to the source of angular.js -    var scope = compile(window.document, _null, {'$config':config}); +    var scope = compile(window.document, _null, {'$config':config}), +        $browser = scope.$inject('$browser'); +      if (config.css) -      scope.$inject('$browser').addCss(config.base_url + config.css); +      $browser.addCss(config.base_url + config.css); +    else if(msie<8) +      $browser.addJs(config.base_url + config.ie_compat, config.ie_compat_id); +      scope.$init();    }  }  function angularJsConfig(document, config) { -  var filename = /^(.*)\/angular(-([^\/]*))?.js(\?[^#]*)?(#(.*))?$/, +  var filename = /^(.*)angular(-([^\/]*))?.js(\?[^#]*)?(#(.*))?$/,        scripts = document.getElementsByTagName("script"),        match;    config = extend({      base_url: '', -    css: '../css/angular.css' +    ie_compat: 'angular-ie-compat.js', +    ie_compat_id: 'ng-ie-compat'    }, config);    for(var j = 0; j < scripts.length; j++) {      match = (scripts[j].src || "").match(filename);      if (match) { -      config.base_url = match[1] + '/'; +      config.base_url = match[1];        extend(config, parseKeyValue(match[6]));        eachAttribute(jqLite(scripts[j]), function(value, name){          if (/^ng:/.exec(name)) { diff --git a/src/Browser.js b/src/Browser.js index aa80ef47..dcdc0a73 100644 --- a/src/Browser.js +++ b/src/Browser.js @@ -188,11 +188,26 @@ function Browser(location, document, head, XHR, $log) {    }; -  self.addCss = function(url) { +  /** +   * Adds a stylesheet tag to the head. +   */ +  self.addCss = function(/**string*/url) {      var link = jqLite(rawDocument.createElement('link'));      link.attr('rel', 'stylesheet');      link.attr('type', 'text/css');      link.attr('href', url);      head.append(link);    }; + + +  /** +   * Adds a script tag to the head. +   */ +  self.addJs = function(/**string*/url, /**string*/dom_id) { +    var script = jqLite(rawDocument.createElement('script')); +    script.attr('type', 'text/javascript'); +    script.attr('src', url); +    if (dom_id) script.attr('id', dom_id); +    head.append(script); +  };  } diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js index 4c95e8b0..416acbde 100644 --- a/src/angular-bootstrap.js +++ b/src/angular-bootstrap.js @@ -37,6 +37,13 @@      document.write('<script type="text/javascript" src="' + serverPath + file +'"></script>');    } +  function addCss(file) { +    document.write('<link rel="stylesheet" type="text/css" href="' + +                      serverPath + '/../css' + file  + '"/>'); +  } + +  addCss("/angular.css"); +    addScript("/Angular.js");    addScript("/JSON.js");    addScript("/Compiler.js"); @@ -58,10 +65,15 @@    addScript("/markups.js");    addScript("/widgets.js"); +    window.onload = function(){      try {        if (previousOnLoad) previousOnLoad();      } catch(e) {} + +    //angular-ie-compat.js needs to be pregenerated for development with IE<8 +    if (msie<8) addScript('../angular-ie-compat.js'); +      angularInit(angularJsConfig(document));    }; | 
