aboutsummaryrefslogtreecommitdiffstats
path: root/src/Loader.js
diff options
context:
space:
mode:
authorMisko Hevery2010-01-10 08:58:57 -0800
committerMisko Hevery2010-01-10 08:58:57 -0800
commit1aba6b53b88c70b61a0cc991b1371739305d117b (patch)
treed1d21efbd2df191824b7a02020190df0195f2fbb /src/Loader.js
parent9b9a0dadcce82ae42ac09ad396d647739af20a06 (diff)
downloadangular.js-1aba6b53b88c70b61a0cc991b1371739305d117b.tar.bz2
basic calculator works with minified.js, lots of references still broken
Diffstat (limited to 'src/Loader.js')
-rw-r--r--src/Loader.js47
1 files changed, 22 insertions, 25 deletions
diff --git a/src/Loader.js b/src/Loader.js
index dfaa355a..19840567 100644
--- a/src/Loader.js
+++ b/src/Loader.js
@@ -23,6 +23,8 @@ if (typeof Node == 'undefined') {
}
var callbacks = {};
+var jQuery = window['jQuery'];
+var msie = jQuery['browser']['msie'];
if (!window.angular){ angular = {}; window['angular'] = angular; }
if (!angular.validator) angular.validator = {};
@@ -32,8 +34,8 @@ if (!window.console)
log:function() {},
error:function() {}
};
-if (_.isUndefined(alert)) {
- alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
+if (!angular.alert) {
+ angular.alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
}
var consoleNode;
@@ -169,7 +171,6 @@ Loader.prototype.load = function() {
this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
this.loadCss('/stylesheets/css');
console.log("Server: " + this.config.server);
- msie = jQuery.browser.msie;
this.configureJQueryPlugins();
this.computeConfiguration();
this.bindHtml();
@@ -177,11 +178,7 @@ Loader.prototype.load = function() {
Loader.prototype.configureJQueryPlugins = function() {
console.log('Loader.configureJQueryPlugins()');
- jQuery.fn.removeNode = function() {
- var node = this.get(0);
- node.parentNode.removeChild(node);
- };
- jQuery.fn.scope = function() {
+ jQuery['fn']['scope'] = function() {
var element = this;
while (element && element.get(0)) {
var scope = element.data("scope");
@@ -191,7 +188,7 @@ Loader.prototype.configureJQueryPlugins = function() {
}
return null;
};
- jQuery.fn.controller = function() {
+ jQuery['fn']['controller'] = function() {
return this.data('controller') || NullController.instance;
};
};
@@ -229,24 +226,19 @@ Loader.prototype.bindHtml = function() {
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) {
+ '$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
+ '$window' : window,
+ '$uid' : this.uid,
+ '$users' : users
}, "ROOT");
- jQuery.each(["get", "set", "eval", "addWatchListener", "updateView"],
- function(i, method){
- angular[method] = bind(scope, scope[method]);
- });
-
document.data('scope', scope);
console.log('$binder.entity()');
binder.entity(scope);
@@ -284,7 +276,6 @@ Loader.prototype.bindHtml = function() {
watcher.watch();
document.find("body").show();
console.log('ready()');
-
};
Loader.prototype.visualPost = function(delegate) {
@@ -399,6 +390,12 @@ angular['compile'] = function(root, config) {
//todo: don't start watcher
var loader = new Loader(root, jQuery("head"), _(defaults).extend(config));
loader.load();
- return jQuery(root).scope();
+ var scope = jQuery(root).scope();
+ //TODO: cleanup
+ return {
+ 'updateView':function(){return scope.updateView.apply(scope, arguments);},
+ 'set':function(){return scope.set.apply(scope, arguments);},
+ 'get':function(){return scope.get.apply(scope, arguments);}
+ };
};