diff options
| author | Misko Hevery | 2010-01-18 10:47:03 -0800 |
|---|---|---|
| committer | Misko Hevery | 2010-01-18 10:47:03 -0800 |
| commit | 595b4ea097bcb512173b6d4a12924ea1a3d70ecd (patch) | |
| tree | 24a85ee2ab41d6eb16661cf4d55443954c6c62c0 /src | |
| parent | 27709c3f69384a7630aa336a1e73e730ea5f9790 (diff) | |
| download | angular.js-595b4ea097bcb512173b6d4a12924ea1a3d70ecd.tar.bz2 | |
checkpoint for integration with angular
Diffstat (limited to 'src')
| -rw-r--r-- | src/Angular.js (renamed from src/Loader.js) | 24 | ||||
| -rw-r--r-- | src/angular-bootstrap.js | 115 |
2 files changed, 7 insertions, 132 deletions
diff --git a/src/Loader.js b/src/Angular.js index f3c765cd..69cab0a2 100644 --- a/src/Loader.js +++ b/src/Angular.js @@ -177,17 +177,17 @@ function merge(src, dst) { } // //////////////////////////// -// Loader +// Angular // //////////////////////////// -function Loader(document, head, config) { +function Angular(document, head, config) { this.document = jQuery(document); this.head = jQuery(head); this.config = config; this.location = window.location; } -Loader.prototype = { +Angular.prototype = { load: function() { this.configureLogging(); log("Server: " + this.config.server); @@ -197,7 +197,7 @@ Loader.prototype = { }, configureJQueryPlugins: function() { - log('Loader.configureJQueryPlugins()'); + log('Angular.configureJQueryPlugins()'); jQuery['fn']['scope'] = function() { var element = this; while (element && element.get(0)) { @@ -226,7 +226,7 @@ Loader.prototype = { }, bindHtml: function() { - log('Loader.bindHtml()'); + log('Angular.bindHtml()'); var watcher = new UrlWatcher(this.location); var document = this.document; var widgetFactory = new WidgetFactory(this.config.server, this.config.database); @@ -333,16 +333,6 @@ Loader.prototype = { consoleLog('ng-console-error', arguments); }; } - }, - - loadCss: function(css) { - var cssTag = document.createElement('link'); - cssTag.rel = "stylesheet"; - cssTag.type = "text/css"; - if (!css.match(/^http:/)) - css = this.config.server + css; - cssTag.href = css; - this.head[0].appendChild(cssTag); } }; @@ -408,11 +398,11 @@ angular['compile'] = function(root, config) { 'addUrlChangeListener': noop }; //todo: don't start watcher - var loader = new Loader(root, jQuery("head"), _(defaults).extend(config)); + var angular = new Angular(root, jQuery("head"), _(defaults).extend(config)); //todo: don't load stylesheet by default // loader.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css'); // loader.loadCss('/stylesheets/css'); - loader.load(); + angular.load(); var scope = jQuery(root).scope(); //TODO: cleanup return { diff --git a/src/angular-bootstrap.js b/src/angular-bootstrap.js deleted file mode 100644 index 50c78f81..00000000 --- a/src/angular-bootstrap.js +++ /dev/null @@ -1,115 +0,0 @@ -/** - * The MIT License - * - * Copyright (c) 2010 Adam Abrons and Misko Hevery http://getangular.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -(function(previousOnLoad){ - var filename = /(.*)\/angular-(.*).js(#(.*))?/; - var scripts = document.getElementsByTagName("script"); - var scriptConfig = { - autoSubmit:true, - autoBind:true, - autoLoadDependencies:false - }; - for(var j = 0; j < scripts.length; j++) { - var src = scripts[j].src; - if (src && src.match(filename)) { - var parts = src.match(filename); - if (parts[2] == 'bootstrap') { - scriptConfig.autoLoadDependencies = true; - } - scriptConfig.server = parts[1] || ''; - if (!scriptConfig.server) { - scriptConfig.server = window.location.toString().split(window.location.pathname)[0]; - } - if (parts[4]) { - var directive = parts[4].split('&'); - for ( var i = 0; i < directive.length; i++) { - var keyValue = directive[i].split('='); - var key = keyValue[0]; - var value = keyValue.length == 1 ? true : keyValue[1]; - if (value == 'false') value = false; - if (value == 'true') value = true; - scriptConfig[key] = value; - } - } - } - } - - var addScript = function(path, server){ - server = server || scriptConfig.server; - document.write('<script type="text/javascript" src="' + server + path +'"></script>'); - }; - - if (scriptConfig.autoLoadDependencies) { - addScript("/../lib/webtoolkit/webtoolkit.base64.js"); - addScript("/../lib/swfobject/swfobject.js"); - addScript("/../lib/jquery/jquery-1.3.2.js"); - addScript("/../lib/jquery/jquery-ui-1.7.1.custom.min.js"); - addScript("/../lib/underscore/underscore.js"); - addScript("/Loader.js"); - addScript("/API.js"); - addScript("/Binder.js"); - addScript("/ControlBar.js"); - addScript("/DataStore.js"); - addScript("/Filters.js"); - addScript("/JSON.js"); - addScript("/Model.js"); - addScript("/Parser.js"); - addScript("/Scope.js"); - addScript("/Server.js"); - addScript("/Users.js"); - addScript("/Validators.js"); - addScript("/Widgets.js"); - } else { - addScript("/ajax/libs/swfobject/2.2/swfobject.js", "http://ajax.googleapis.com"); - addScript("/ajax/libs/jquery/1.3.2/jquery.min.js", "http://ajax.googleapis.com"); - addScript("/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js", "http://ajax.googleapis.com"); - } - - window.onload = function() { - var doc = window.document; - if (scriptConfig.bindRootId) { - doc = null; - var ids = scriptConfig.bindRootId.split('|'); - for ( var i = 0; i < ids.length && !doc; i++) { - var idCond = ids[i].split('?'); - var id = idCond[0]; - if (idCond.length > 1) { - if (!window.document.getElementById(idCond[1])) { - continue; - } - } - doc = window.document.getElementById(id); - } - } - if (scriptConfig.autoBind && doc) { - window.angularScope = angular.compile(doc, scriptConfig); - } - if (typeof previousOnLoad === 'function') { - try { - previousOnLoad.apply(this, arguments); - } catch (e) {} - } - }; -})(window.onload); - - |
