From 595b4ea097bcb512173b6d4a12924ea1a3d70ecd Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 18 Jan 2010 10:47:03 -0800 Subject: checkpoint for integration with angular --- src/Angular.js | 414 +++++++++++++++++++++++++++++++++++++++++++++ src/Loader.js | 424 ----------------------------------------------- src/angular-bootstrap.js | 115 ------------- 3 files changed, 414 insertions(+), 539 deletions(-) create mode 100644 src/Angular.js delete mode 100644 src/Loader.js delete mode 100644 src/angular-bootstrap.js (limited to 'src') diff --git a/src/Angular.js b/src/Angular.js new file mode 100644 index 00000000..69cab0a2 --- /dev/null +++ b/src/Angular.js @@ -0,0 +1,414 @@ +if (typeof document.getAttribute == 'undefined') + document.getAttribute = function() {}; +if (typeof Node == 'undefined') { + Node = { + ELEMENT_NODE : 1, + ATTRIBUTE_NODE : 2, + TEXT_NODE : 3, + CDATA_SECTION_NODE : 4, + ENTITY_REFERENCE_NODE : 5, + ENTITY_NODE : 6, + PROCESSING_INSTRUCTION_NODE : 7, + COMMENT_NODE : 8, + DOCUMENT_NODE : 9, + DOCUMENT_TYPE_NODE : 10, + DOCUMENT_FRAGMENT_NODE : 11, + NOTATION_NODE : 12 + }; +} + +function noop() {} +if (!window['console']) window['console']={'log':noop, 'error':noop}; + +var consoleNode, + foreach = _.each, + extend = _.extend, + jQuery = window['jQuery'], + msie = jQuery['browser']['msie'], + angular = window['angular'] || (window['angular'] = {}), + angularValidator = angular['validator'] || (angular['validator'] = {}), + angularFilter = angular['filter'] || (angular['filter'] = {}), + angularCallbacks = angular['callbacks'] || (angular['callbacks'] = {}), + angularAlert = angular['alert'] || (angular['alert'] = function(){ + log(arguments); window.alert.apply(window, arguments); + }); + +function log(a, b, c){ + var console = window['console']; + switch(arguments.length) { + case 1: + console['log'](a); + break; + case 2: + console['log'](a, b); + break; + default: + console['log'](a, b, c); + break; + } +} + +function error(a, b, c){ + var console = window['console']; + switch(arguments.length) { + case 1: + console['error'](a); + break; + case 2: + console['error'](a, b); + break; + default: + console['error'](a, b, c); + break; + } +} + +function consoleLog(level, objs) { + var log = document.createElement("div"); + log.className = level; + var msg = ""; + var sep = ""; + for ( var i = 0; i < objs.length; i++) { + var obj = objs[i]; + msg += sep + (typeof obj == 'string' ? obj : toJson(obj)); + sep = " "; + } + log.appendChild(document.createTextNode(msg)); + consoleNode.appendChild(log); +} + +function isNode(inp) { + return inp && + inp.tagName && + inp.nodeName && + inp.ownerDocument && + inp.removeAttribute; +} + +function isLeafNode (node) { + switch (node.nodeName) { + case "OPTION": + case "PRE": + case "TITLE": + return true; + default: + return false; + } +} + +function setHtml(node, html) { + if (isLeafNode(node)) { + if (msie) { + node.innerText = html; + } else { + node.textContent = html; + } + } else { + node.innerHTML = html; + } +} + +function escapeHtml(html) { + if (!html || !html.replace) + return html; + return html. + replace(/&/g, '&'). + replace(//g, '>'); +} + +function escapeAttr(html) { + if (!html || !html.replace) + return html; + return html.replace(//g, '>').replace(/\"/g, + '"'); +} + +function bind(_this, _function) { + if (!_this) + throw "Missing this"; + if (!_.isFunction(_function)) + throw "Missing function"; + return function() { + return _function.apply(_this, arguments); + }; +} + +function shiftBind(_this, _function) { + return function() { + var args = [ this ]; + for ( var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + return _function.apply(_this, args); + }; +} + +function outerHTML(node) { + var temp = document.createElement('div'); + temp.appendChild(node); + var outerHTML = temp.innerHTML; + temp.removeChild(node); + return outerHTML; +} + +function trim(str) { + return str.replace(/^ */, '').replace(/ *$/, ''); +} + +function toBoolean(value) { + var v = ("" + value).toLowerCase(); + if (v == 'f' || v == '0' || v == 'false' || v == 'no') + value = false; + return !!value; +} + +function merge(src, dst) { + for ( var key in src) { + var value = dst[key]; + var type = typeof value; + if (type == 'undefined') { + dst[key] = fromJson(toJson(src[key])); + } else if (type == 'object' && value.constructor != array && + key.substring(0, 1) != "$") { + merge(src[key], value); + } + } +} + +// //////////////////////////// +// Angular +// //////////////////////////// + +function Angular(document, head, config) { + this.document = jQuery(document); + this.head = jQuery(head); + this.config = config; + this.location = window.location; +} + +Angular.prototype = { + load: function() { + this.configureLogging(); + log("Server: " + this.config.server); + this.configureJQueryPlugins(); + this.computeConfiguration(); + this.bindHtml(); + }, + + configureJQueryPlugins: function() { + log('Angular.configureJQueryPlugins()'); + jQuery['fn']['scope'] = function() { + var element = this; + while (element && element.get(0)) { + var scope = element.data("scope"); + if (scope) + return scope; + element = element.parent(); + } + return null; + }; + jQuery['fn']['controller'] = function() { + return this.data('controller') || NullController.instance; + }; + }, + + uid: function() { + return "" + new Date().getTime(); + }, + + computeConfiguration: function() { + var config = this.config; + if (!config.database) { + var match = config.server.match(/https?:\/\/([\w]*)/); + config.database = match ? match[1] : "$MEMORY"; + } + }, + + bindHtml: function() { + log('Angular.bindHtml()'); + var watcher = new UrlWatcher(this.location); + var document = this.document; + var widgetFactory = new WidgetFactory(this.config.server, this.config.database); + var binder = new Binder(document[0], widgetFactory, watcher, this.config); + widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel); + var controlBar = new ControlBar(document.find('body'), this.config.server); + var onUpdate = function(){binder.updateView();}; + var server = this.config.database=="$MEMORY" ? + new FrameServer(this.window) : + new Server(this.config.server, jQuery.getScript); + server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate); + var users = new Users(server, controlBar); + var databasePath = '/data/' + this.config.database; + var post = function(request, callback){ + server.request("POST", databasePath, request, callback); + }; + var datastore = new DataStore(post, users, binder.anchor); + binder.updateListeners.push(function(){datastore.flush();}); + var scope = new Scope( { + '$anchor' : binder.anchor, + '$binder' : binder, + '$config' : this.config, + '$console' : window.console, + '$datastore' : datastore, + '$save' : function(callback) { + datastore.saveScope(scope.state, callback, binder.anchor); + }, + '$window' : window, + '$uid' : this.uid, + '$users' : users + }, "ROOT"); + + document.data('scope', scope); + log('$binder.entity()'); + binder.entity(scope); + + log('$binder.compile()'); + binder.compile(); + + log('ControlBar.bind()'); + controlBar.bind(); + + log('$users.fetchCurrentUser()'); + function fetchCurrentUser() { + users.fetchCurrentUser(function(u) { + if (!u && document.find("[ng-auth=eager]").length) { + users.login(); + } + }); + } + fetchCurrentUser(); + + log('PopUp.bind()'); + new PopUp(document).bind(); + + log('$binder.parseAnchor()'); + binder.parseAnchor(); + + log('$binder.updateView()'); + binder.updateView(); + + //watcher.listener = bind(binder, binder.onUrlChange, watcher); + //watcher.onUpdate = function(){alert("update");}; + //watcher.watch(); + document.find("body").show(); + log('ready()'); + }, + + visualPost: function(delegate) { + var status = new Status(jQuery(document.body)); + return function(request, delegateCallback) { + status.beginRequest(request); + var callback = function() { + status.endRequest(); + try { + delegateCallback.apply(this, arguments); + } catch (e) { + alert(toJson(e)); + } + }; + delegate(request, callback); + }; + }, + + configureLogging: function() { + var url = window.location.href + '#'; + url = url.split('#')[1]; + var config = { + debug : null + }; + var configs = url.split('&'); + for ( var i = 0; i < configs.length; i++) { + var part = (configs[i] + '=').split('='); + config[part[0]] = part[1]; + } + if (config.debug == 'console') { + consoleNode = document.createElement("div"); + consoleNode.id = 'ng-console'; + document.getElementsByTagName('body')[0].appendChild(consoleNode); + log = function() { + consoleLog('ng-console-info', arguments); + }; + console.error = function() { + consoleLog('ng-console-error', arguments); + }; + } + } +}; + +function UrlWatcher(location) { + this.location = location; + this.delay = 25; + this.setTimeout = function(fn, delay) { + window.setTimeout(fn, delay); + }; + this.listener = function(url) { + return url; + }; + this.expectedUrl = location.href; +} + +UrlWatcher.prototype = { + watch: function() { + var self = this; + var pull = function() { + if (self.expectedUrl !== self.location.href) { + var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/); + if (notify) { + if (!self.expectedUrl.match(/#/)) { + self.expectedUrl += "#"; + } + self.location.href = self.expectedUrl; + var id = '_iframe_notify_' + notify[1]; + var notifyFn = angularCallbacks[id]; + delete angularCallbacks[id]; + try { + (notifyFn||noop)(); + } catch (e) { + alert(e); + } + } else { + self.listener(self.location.href); + self.expectedUrl = self.location.href; + } + } + self.setTimeout(pull, self.delay); + }; + pull(); + }, + + setUrl: function(url) { +// var existingURL = window.location.href; +// if (!existingURL.match(/#/)) +// existingURL += '#'; +// if (existingURL != url) +// window.location.href = url; +// this.existingURL = url; + }, + + getUrl: function() { + return window.location.href; + } +}; + +angular['compile'] = function(root, config) { + config = config || {}; + var defaults = { + 'server': "", + 'addUrlChangeListener': noop + }; + //todo: don't start watcher + 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'); + angular.load(); + var scope = jQuery(root).scope(); + //TODO: cleanup + return { + 'updateView':function(){return scope.updateView();}, + 'set':function(){return scope.set.apply(scope, arguments);}, + 'get':function(){return scope.get.apply(scope, arguments);}, + 'init':function(){scope.get('$binder.executeInit')(); scope.updateView();} + }; +}; \ No newline at end of file diff --git a/src/Loader.js b/src/Loader.js deleted file mode 100644 index f3c765cd..00000000 --- a/src/Loader.js +++ /dev/null @@ -1,424 +0,0 @@ -if (typeof document.getAttribute == 'undefined') - document.getAttribute = function() {}; -if (typeof Node == 'undefined') { - Node = { - ELEMENT_NODE : 1, - ATTRIBUTE_NODE : 2, - TEXT_NODE : 3, - CDATA_SECTION_NODE : 4, - ENTITY_REFERENCE_NODE : 5, - ENTITY_NODE : 6, - PROCESSING_INSTRUCTION_NODE : 7, - COMMENT_NODE : 8, - DOCUMENT_NODE : 9, - DOCUMENT_TYPE_NODE : 10, - DOCUMENT_FRAGMENT_NODE : 11, - NOTATION_NODE : 12 - }; -} - -function noop() {} -if (!window['console']) window['console']={'log':noop, 'error':noop}; - -var consoleNode, - foreach = _.each, - extend = _.extend, - jQuery = window['jQuery'], - msie = jQuery['browser']['msie'], - angular = window['angular'] || (window['angular'] = {}), - angularValidator = angular['validator'] || (angular['validator'] = {}), - angularFilter = angular['filter'] || (angular['filter'] = {}), - angularCallbacks = angular['callbacks'] || (angular['callbacks'] = {}), - angularAlert = angular['alert'] || (angular['alert'] = function(){ - log(arguments); window.alert.apply(window, arguments); - }); - -function log(a, b, c){ - var console = window['console']; - switch(arguments.length) { - case 1: - console['log'](a); - break; - case 2: - console['log'](a, b); - break; - default: - console['log'](a, b, c); - break; - } -} - -function error(a, b, c){ - var console = window['console']; - switch(arguments.length) { - case 1: - console['error'](a); - break; - case 2: - console['error'](a, b); - break; - default: - console['error'](a, b, c); - break; - } -} - -function consoleLog(level, objs) { - var log = document.createElement("div"); - log.className = level; - var msg = ""; - var sep = ""; - for ( var i = 0; i < objs.length; i++) { - var obj = objs[i]; - msg += sep + (typeof obj == 'string' ? obj : toJson(obj)); - sep = " "; - } - log.appendChild(document.createTextNode(msg)); - consoleNode.appendChild(log); -} - -function isNode(inp) { - return inp && - inp.tagName && - inp.nodeName && - inp.ownerDocument && - inp.removeAttribute; -} - -function isLeafNode (node) { - switch (node.nodeName) { - case "OPTION": - case "PRE": - case "TITLE": - return true; - default: - return false; - } -} - -function setHtml(node, html) { - if (isLeafNode(node)) { - if (msie) { - node.innerText = html; - } else { - node.textContent = html; - } - } else { - node.innerHTML = html; - } -} - -function escapeHtml(html) { - if (!html || !html.replace) - return html; - return html. - replace(/&/g, '&'). - replace(//g, '>'); -} - -function escapeAttr(html) { - if (!html || !html.replace) - return html; - return html.replace(//g, '>').replace(/\"/g, - '"'); -} - -function bind(_this, _function) { - if (!_this) - throw "Missing this"; - if (!_.isFunction(_function)) - throw "Missing function"; - return function() { - return _function.apply(_this, arguments); - }; -} - -function shiftBind(_this, _function) { - return function() { - var args = [ this ]; - for ( var i = 0; i < arguments.length; i++) { - args.push(arguments[i]); - } - return _function.apply(_this, args); - }; -} - -function outerHTML(node) { - var temp = document.createElement('div'); - temp.appendChild(node); - var outerHTML = temp.innerHTML; - temp.removeChild(node); - return outerHTML; -} - -function trim(str) { - return str.replace(/^ */, '').replace(/ *$/, ''); -} - -function toBoolean(value) { - var v = ("" + value).toLowerCase(); - if (v == 'f' || v == '0' || v == 'false' || v == 'no') - value = false; - return !!value; -} - -function merge(src, dst) { - for ( var key in src) { - var value = dst[key]; - var type = typeof value; - if (type == 'undefined') { - dst[key] = fromJson(toJson(src[key])); - } else if (type == 'object' && value.constructor != array && - key.substring(0, 1) != "$") { - merge(src[key], value); - } - } -} - -// //////////////////////////// -// Loader -// //////////////////////////// - -function Loader(document, head, config) { - this.document = jQuery(document); - this.head = jQuery(head); - this.config = config; - this.location = window.location; -} - -Loader.prototype = { - load: function() { - this.configureLogging(); - log("Server: " + this.config.server); - this.configureJQueryPlugins(); - this.computeConfiguration(); - this.bindHtml(); - }, - - configureJQueryPlugins: function() { - log('Loader.configureJQueryPlugins()'); - jQuery['fn']['scope'] = function() { - var element = this; - while (element && element.get(0)) { - var scope = element.data("scope"); - if (scope) - return scope; - element = element.parent(); - } - return null; - }; - jQuery['fn']['controller'] = function() { - return this.data('controller') || NullController.instance; - }; - }, - - uid: function() { - return "" + new Date().getTime(); - }, - - computeConfiguration: function() { - var config = this.config; - if (!config.database) { - var match = config.server.match(/https?:\/\/([\w]*)/); - config.database = match ? match[1] : "$MEMORY"; - } - }, - - bindHtml: function() { - log('Loader.bindHtml()'); - var watcher = new UrlWatcher(this.location); - var document = this.document; - var widgetFactory = new WidgetFactory(this.config.server, this.config.database); - var binder = new Binder(document[0], widgetFactory, watcher, this.config); - widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel); - var controlBar = new ControlBar(document.find('body'), this.config.server); - var onUpdate = function(){binder.updateView();}; - var server = this.config.database=="$MEMORY" ? - new FrameServer(this.window) : - new Server(this.config.server, jQuery.getScript); - server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate); - var users = new Users(server, controlBar); - var databasePath = '/data/' + this.config.database; - var post = function(request, callback){ - server.request("POST", databasePath, request, callback); - }; - var datastore = new DataStore(post, users, binder.anchor); - binder.updateListeners.push(function(){datastore.flush();}); - var scope = new Scope( { - '$anchor' : binder.anchor, - '$binder' : binder, - '$config' : this.config, - '$console' : window.console, - '$datastore' : datastore, - '$save' : function(callback) { - datastore.saveScope(scope.state, callback, binder.anchor); - }, - '$window' : window, - '$uid' : this.uid, - '$users' : users - }, "ROOT"); - - document.data('scope', scope); - log('$binder.entity()'); - binder.entity(scope); - - log('$binder.compile()'); - binder.compile(); - - log('ControlBar.bind()'); - controlBar.bind(); - - log('$users.fetchCurrentUser()'); - function fetchCurrentUser() { - users.fetchCurrentUser(function(u) { - if (!u && document.find("[ng-auth=eager]").length) { - users.login(); - } - }); - } - fetchCurrentUser(); - - log('PopUp.bind()'); - new PopUp(document).bind(); - - log('$binder.parseAnchor()'); - binder.parseAnchor(); - - log('$binder.updateView()'); - binder.updateView(); - - //watcher.listener = bind(binder, binder.onUrlChange, watcher); - //watcher.onUpdate = function(){alert("update");}; - //watcher.watch(); - document.find("body").show(); - log('ready()'); - }, - - visualPost: function(delegate) { - var status = new Status(jQuery(document.body)); - return function(request, delegateCallback) { - status.beginRequest(request); - var callback = function() { - status.endRequest(); - try { - delegateCallback.apply(this, arguments); - } catch (e) { - alert(toJson(e)); - } - }; - delegate(request, callback); - }; - }, - - configureLogging: function() { - var url = window.location.href + '#'; - url = url.split('#')[1]; - var config = { - debug : null - }; - var configs = url.split('&'); - for ( var i = 0; i < configs.length; i++) { - var part = (configs[i] + '=').split('='); - config[part[0]] = part[1]; - } - if (config.debug == 'console') { - consoleNode = document.createElement("div"); - consoleNode.id = 'ng-console'; - document.getElementsByTagName('body')[0].appendChild(consoleNode); - log = function() { - consoleLog('ng-console-info', arguments); - }; - console.error = function() { - 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); - } -}; - -function UrlWatcher(location) { - this.location = location; - this.delay = 25; - this.setTimeout = function(fn, delay) { - window.setTimeout(fn, delay); - }; - this.listener = function(url) { - return url; - }; - this.expectedUrl = location.href; -} - -UrlWatcher.prototype = { - watch: function() { - var self = this; - var pull = function() { - if (self.expectedUrl !== self.location.href) { - var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/); - if (notify) { - if (!self.expectedUrl.match(/#/)) { - self.expectedUrl += "#"; - } - self.location.href = self.expectedUrl; - var id = '_iframe_notify_' + notify[1]; - var notifyFn = angularCallbacks[id]; - delete angularCallbacks[id]; - try { - (notifyFn||noop)(); - } catch (e) { - alert(e); - } - } else { - self.listener(self.location.href); - self.expectedUrl = self.location.href; - } - } - self.setTimeout(pull, self.delay); - }; - pull(); - }, - - setUrl: function(url) { -// var existingURL = window.location.href; -// if (!existingURL.match(/#/)) -// existingURL += '#'; -// if (existingURL != url) -// window.location.href = url; -// this.existingURL = url; - }, - - getUrl: function() { - return window.location.href; - } -}; - -angular['compile'] = function(root, config) { - config = config || {}; - var defaults = { - 'server': "", - 'addUrlChangeListener': noop - }; - //todo: don't start watcher - var loader = new Loader(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(); - var scope = jQuery(root).scope(); - //TODO: cleanup - return { - 'updateView':function(){return scope.updateView();}, - 'set':function(){return scope.set.apply(scope, arguments);}, - 'get':function(){return scope.get.apply(scope, arguments);}, - 'init':function(){scope.get('$binder.executeInit')(); scope.updateView();} - }; -}; \ No newline at end of file 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(''); - }; - - 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); - - -- cgit v1.2.3