' +
+ '
' +
'Sorry, you do not have permission for this!'+
'
';
diff --git a/src/widgets.js b/src/widgets.js
index efafa9c5..94f09c7b 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -196,7 +196,7 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) {
action = element.attr('ng-change') || '',
lastValue;
initFn.call(scope, model, view, element);
- this.$eval(element.attr('ng-init')||'');
+ this.$eval(element.attr('ng:init')||'');
// Don't register a handler if we are a button (noopAccessor) and there is no action
if (action || modelAccessor !== noopAccessor) {
element.bind(events, function(){
@@ -236,11 +236,11 @@ angularWidget('NG:INCLUDE', function(element){
var compiler = this,
srcExp = element.attr("src"),
scopeExp = element.attr("scope") || '';
- if (element[0]['ng-compiled']) {
+ if (element[0]['ng:compiled']) {
this.descend(true);
this.directives(true);
} else {
- element[0]['ng-compiled'] = true;
+ element[0]['ng:compiled'] = true;
return function(element){
var scope = this, childScope;
var changeCounter = 0;
@@ -276,7 +276,7 @@ var ngSwitch = angularWidget('NG:SWITCH', function (element){
cases = [];
if (!usingFn) throw "Using expression '" + usingExpr + "' unknown.";
eachNode(element, function(caseElement){
- var when = caseElement.attr('ng-switch-when');
+ var when = caseElement.attr('ng:switch-when');
if (when) {
cases.push({
when: function(scope, value){
--
cgit v1.2.3
From b5195b8f67b143d6c38de9ae2295cb364fab0d95 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 2 Jul 2010 17:26:26 -0700
Subject: changed the eval for ie to be able to return a function
---
src/Scope.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/Scope.js b/src/Scope.js
index e9b61ec4..b45efbce 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -72,8 +72,8 @@ function getterFn(path){
}
});
code += ' return self;\n}';
- fn = eval('(' + code + ')');
- fn.toString = function(){ return code; };
+ fn = eval('fn = ' + code);
+ fn["toString"] = function(){ return code; };
return getterFnCache[path] = fn;
}
--
cgit v1.2.3
From ee82dae3186b7a4fc4d339fc97d5792b2b5e2648 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Thu, 8 Jul 2010 10:40:54 -0700
Subject: added class as a constant keyword to generated code
---
src/Scope.js | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/Scope.js b/src/Scope.js
index b45efbce..35da77fe 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -46,7 +46,14 @@ function setter(instance, path, value){
///////////////////////////////////
var getterFnCache = {};
-var JS_KEYWORDS = ["this", "throw", "for", "foreach", "var", "const"];
+var JS_KEYWORDS = {};
+foreach(
+ ["break", "const", "continue", "class", "delete",
+ "do", "while", "for", "function", "if",
+ "instanceof", "new", "return", "switch",
+ "this", "throw", "try", "catch", "with"],
+ function(key){ JS_KEYWORDS[key] = true;}
+);
function getterFn(path){
var fn = getterFnCache[path];
if (fn) return fn;
@@ -54,7 +61,7 @@ function getterFn(path){
var code = 'function (self){\n';
code += ' var last, fn, type;\n';
foreach(path.split('.'), function(key) {
- key = (includes(JS_KEYWORDS, key)) ? '["' + key + '"]' : '.' + key;
+ key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key;
code += ' if(!self) return self;\n';
code += ' last = self;\n';
code += ' self = self' + key + ';\n';
--
cgit v1.2.3
From 00bb79039251ca6e4622df677fe4894552774bd5 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Thu, 8 Jul 2010 15:55:00 -0700
Subject: fixed IE tests
---
src/scenario/DSL.js | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
(limited to 'src')
diff --git a/src/scenario/DSL.js b/src/scenario/DSL.js
index 194a28d6..b713cfd6 100644
--- a/src/scenario/DSL.js
+++ b/src/scenario/DSL.js
@@ -35,9 +35,8 @@ angular.scenario.dsl.input = function(selector) {
value + "'", function(done){
var input = this.testDocument.
find(':radio[name$=@' + selector + '][value=' + value + ']');
- var event = this.testWindow.document.createEvent('MouseEvent');
- event.initMouseEvent('click', true, true, this.testWindow, 0,0,0,0,0, false, false, false, false, 0, null);
- input[0].dispatchEvent(event);
+ jqLiteWrap(input[0]).trigger('click');
+ input[0].checked = true;
done();
});
}
--
cgit v1.2.3
From 228b54aa2ea9c5faf9280f39317fdf07b2d49580 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 9 Jul 2010 14:45:29 -0700
Subject: ng:repeat ignores prototype keys
---
src/directives.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/directives.js b/src/directives.js
index 1b422331..a333c4c4 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -162,8 +162,9 @@ angularWidget("@ng:repeat", function(expression, element){
var children = [], currentScope = this;
this.$onEval(function(){
var index = 0, childCount = children.length, childScope, lastElement = reference,
- collection = this.$tryEval(rhs, reference);
+ collection = this.$tryEval(rhs, reference), is_array = isArray(collection);
for ( var key in collection) {
+ if (is_array && !collection.hasOwnProperty(key)) break;
if (index < childCount) {
// reuse existing child
childScope = children[index];
--
cgit v1.2.3
From 87cfc27be331685043ea2a4414eba4fd8fbb4a2c Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Tue, 13 Jul 2010 11:20:11 -0700
Subject: changed remaining ng- to ng:
---
src/delete/Widgets.js | 6 +++---
src/filters.js | 2 +-
src/widgets.js | 8 ++++----
3 files changed, 8 insertions(+), 8 deletions(-)
(limited to 'src')
diff --git a/src/delete/Widgets.js b/src/delete/Widgets.js
index d2f0c75a..53536ed0 100644
--- a/src/delete/Widgets.js
+++ b/src/delete/Widgets.js
@@ -19,7 +19,7 @@ WidgetFactory.prototype = {
if (exp) exp = exp.split(':').pop();
var event = "change";
var bubbleEvent = true;
- var formatter = angularFormatter[input.attr('ng-format')] || angularFormatter['noop'];
+ var formatter = angularFormatter[input.attr('ng:format')] || angularFormatter['noop'];
if (type == 'button' || type == 'submit' || type == 'reset' || type == 'image') {
controller = new ButtonController(input[0], exp, formatter);
event = "click";
@@ -191,8 +191,8 @@ function TextController(view, exp, formatter) {
this.view = view;
this.formatter = formatter;
this.exp = exp;
- this.validator = view.getAttribute('ng-validate');
- this.required = typeof view.attributes['ng-required'] != "undefined";
+ this.validator = view.getAttribute('ng:validate');
+ this.required = typeof view.attributes['ng:required'] != "undefined";
this.lastErrorText = null;
this.lastValue = undefined;
this.initialValue = this.formatter['parse'](view.value);
diff --git a/src/filters.js b/src/filters.js
index a911b935..24464477 100644
--- a/src/filters.js
+++ b/src/filters.js
@@ -2,7 +2,7 @@ var angularFilterGoogleChartApi;
foreach({
'currency': function(amount){
- this.$element.toggleClass('ng-format-negative', amount < 0);
+ this.$element.toggleClass('ng:format-negative', amount < 0);
return '$' + angularFilter['number'].apply(this, [amount, 2]);
},
diff --git a/src/widgets.js b/src/widgets.js
index 94f09c7b..ebfcc456 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -15,7 +15,7 @@ function modelAccessor(scope, element) {
function modelFormattedAccessor(scope, element) {
var accessor = modelAccessor(scope, element),
- formatterName = element.attr('ng-format') || NOOP,
+ formatterName = element.attr('ng:format') || NOOP,
formatter = angularFormatter(formatterName);
if (!formatter) throw "Formatter named '" + formatterName + "' not found.";
return {
@@ -33,10 +33,10 @@ function compileValidator(expr) {
}
function valueAccessor(scope, element) {
- var validatorName = element.attr('ng-validate') || NOOP,
+ var validatorName = element.attr('ng:validate') || NOOP,
validator = compileValidator(validatorName),
- requiredExpr = element.attr('ng-required'),
- formatterName = element.attr('ng-format') || NOOP,
+ requiredExpr = element.attr('ng:required'),
+ formatterName = element.attr('ng:format') || NOOP,
formatter = angularFormatter(formatterName),
format, parse, lastError, required;
invalidWidgets = scope.$invalidWidgets || {markValid:noop, markInvalid:noop};
--
cgit v1.2.3
From 4034a2d1e2efb6c76020273c96c3da5ae146f5ca Mon Sep 17 00:00:00 2001
From: Rob Spies
Date: Tue, 13 Jul 2010 14:09:53 -0700
Subject: better naming for our verify cache scheme, and tests.
---
src/Resource.js | 9 +++++----
src/services.js | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
(limited to 'src')
diff --git a/src/Resource.js b/src/Resource.js
index ba460c30..1279dc54 100644
--- a/src/Resource.js
+++ b/src/Resource.js
@@ -1,3 +1,5 @@
+
+
function Route(template, defaults) {
this.template = template = template + '#';
this.defaults = defaults || {};
@@ -86,7 +88,7 @@ ResourceFactory.prototype = {
throw "Expected between 0-3 arguments [params, data, callback], got " + arguments.length + " arguments.";
}
- var value = action.isArray ? [] : new Resource(data;)
+ var value = action.isArray ? [] : new Resource(data)
self.xhr(
action.method,
route.url(extend({}, action.params || {}, extractParams(data), params)),
@@ -94,8 +96,7 @@ ResourceFactory.prototype = {
function(status, response, clear) {
if (status == 200) {
if (action.isArray) {
- if (action.cacheThenRetrieve)
- value = [];
+ value.length = 0;
foreach(response, function(item){
value.push(new Resource(item));
});
@@ -107,7 +108,7 @@ ResourceFactory.prototype = {
throw {status: status, response:response, message: status + ": " + response};
}
},
- action.cacheThenRetrieve
+ action.verifyCache
);
return value;
};
diff --git a/src/services.js b/src/services.js
index 64f2ea4f..ed6f73ad 100644
--- a/src/services.js
+++ b/src/services.js
@@ -313,7 +313,7 @@ angularService('$xhr.bulk', function($xhr, $error, $log){
angularService('$xhr.cache', function($xhr){
var inflight = {}, self = this;;
- function cache(method, url, post, callback, cacheThenRetrieve){
+ function cache(method, url, post, callback, verifyCache){
if (isFunction(post)) {
callback = post;
post = null;
@@ -322,7 +322,7 @@ angularService('$xhr.cache', function($xhr){
var data;
if (data = cache.data[url]) {
callback(200, copy(data.value));
- if (!cacheThenRetrieve)
+ if (!verifyCache)
return;
}
--
cgit v1.2.3
From 10cd9751ea4c76f5f0ebcd0197054b6ac3be563c Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Tue, 13 Jul 2010 15:21:42 -0700
Subject: ng-change ng:change
---
src/widgets.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/widgets.js b/src/widgets.js
index ebfcc456..0b77dbf4 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -193,7 +193,7 @@ function inputWidget(events, modelAccessor, viewAccessor, initFn) {
var scope = this,
model = modelAccessor(scope, element),
view = viewAccessor(scope, element),
- action = element.attr('ng-change') || '',
+ action = element.attr('ng:change') || '',
lastValue;
initFn.call(scope, model, view, element);
this.$eval(element.attr('ng:init')||'');
--
cgit v1.2.3
From 0a57273f0000421639c926d4d180680e3a64c0f7 Mon Sep 17 00:00:00 2001
From: Kai Compagner
Date: Thu, 15 Jul 2010 03:08:55 +0800
Subject: fix undefine style
---
src/directives.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/directives.js b/src/directives.js
index a333c4c4..6b81d864 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -255,7 +255,7 @@ angularDirective("ng:hide", function(expression, element){
angularDirective("ng:style", function(expression, element){
return function(element){
this.$onEval(function(){
- element.css(this.$eval(expression));
+ element.css(this.$eval(expression) || {});
}, element);
};
});
--
cgit v1.2.3
From e3e9ac86750b20fb8ad6765011e06d569899612d Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Wed, 14 Jul 2010 17:07:23 -0700
Subject: ng:style remembers previous style and properly resets to it
---
src/directives.js | 11 ++++++++++-
src/jqLite.js | 9 ++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
(limited to 'src')
diff --git a/src/directives.js b/src/directives.js
index 6b81d864..4e7c070b 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -254,8 +254,17 @@ angularDirective("ng:hide", function(expression, element){
angularDirective("ng:style", function(expression, element){
return function(element){
+ var resetStyle = element.css();
this.$onEval(function(){
- element.css(this.$eval(expression) || {});
+ var style = this.$eval(expression) || {}, key, mergedStyle = {};
+ for(key in style) {
+ if (typeof resetStyle[key] == 'undefined') resetStyle[key] = null;
+ mergedStyle[key] = style[key];
+ }
+ for(key in resetStyle) {
+ mergedStyle[key] = mergedStyle[key] || resetStyle[key];
+ }
+ element.css(mergedStyle);
}, element);
};
});
diff --git a/src/jqLite.js b/src/jqLite.js
index 68172fd8..a024507f 100644
--- a/src/jqLite.js
+++ b/src/jqLite.js
@@ -175,8 +175,15 @@ JQLite.prototype = {
} else {
return style[name];
}
- } else {
+ } else if(name) {
extend(style, name);
+ } else {
+ var current = {};
+ for (var i=0; i
undefined
---
src/Parser.js | 2 ++
1 file changed, 2 insertions(+)
(limited to 'src')
diff --git a/src/Parser.js b/src/Parser.js
index df270792..5c2307e4 100644
--- a/src/Parser.js
+++ b/src/Parser.js
@@ -602,6 +602,8 @@ Parser.prototype = {
var fnPtr = fn(self);
if (typeof fnPtr === 'function') {
return fnPtr.apply(self, args);
+ } else if (fnPtr === undefined) {
+ return fnPtr;
} else {
throw "Expression '" + fn.isAssignable + "' is not a function.";
}
--
cgit v1.2.3
From 748e91ba92af4a85de3579be504914092381c7e1 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 23 Jul 2010 11:38:52 -0700
Subject: fixed some of the IE bugs
---
src/Browser.js | 1 -
src/services.js | 10 +++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
(limited to 'src')
diff --git a/src/Browser.js b/src/Browser.js
index 2777dcda..3299540c 100644
--- a/src/Browser.js
+++ b/src/Browser.js
@@ -22,7 +22,6 @@ function Browser(location, document, head) {
this.location = location;
this.document = document;
- this.body = jqLite(document[0].body);
this.head = head;
this.idCounter = 0;
}
diff --git a/src/services.js b/src/services.js
index c9799b32..89cca6fc 100644
--- a/src/services.js
+++ b/src/services.js
@@ -75,8 +75,8 @@ angularService("$log", function($window){
};
}, {inject:['$window']});
-angularService("$hover", function(browser) {
- var tooltip, self = this, error, width = 300, arrowWidth = 10;
+angularService("$hover", function(browser, document) {
+ var tooltip, self = this, error, width = 300, arrowWidth = 10, body = jqLite(document[0].body);;
browser.hover(function(element, show){
if (show && (error = element.attr(NG_EXCEPTION) || element.attr(NG_VALIDATION_ERROR))) {
if (!tooltip) {
@@ -89,9 +89,9 @@ angularService("$hover", function(browser) {
tooltip.callout.append(tooltip.arrow);
tooltip.callout.append(tooltip.title);
tooltip.callout.append(tooltip.content);
- self.$browser.body.append(tooltip.callout);
+ body.append(tooltip.callout);
}
- var docRect = self.$browser.body[0].getBoundingClientRect(),
+ var docRect = body[0].getBoundingClientRect(),
elementRect = element[0].getBoundingClientRect(),
leftSpace = docRect.right - elementRect.right - arrowWidth;
tooltip.title.text(element.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...");
@@ -119,7 +119,7 @@ angularService("$hover", function(browser) {
tooltip = null;
}
});
-}, {inject:['$browser']});
+}, {inject:['$browser', '$document']});
angularService("$invalidWidgets", function(){
var invalidWidgets = [];
--
cgit v1.2.3
From 1a730a9996f6a1ec420e23e5dae0b863b9c7ba12 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 23 Jul 2010 11:46:04 -0700
Subject: fixed some of the IE bugs
---
src/Browser.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/Browser.js b/src/Browser.js
index 3299540c..3287cf0e 100644
--- a/src/Browser.js
+++ b/src/Browser.js
@@ -67,7 +67,7 @@ Browser.prototype = {
script.src = url.replace('JSON_CALLBACK', callbackId);
this.head.append(script);
window[callbackId] = function(data){
- delete window[callbackId];
+ window[callbackId] = undefined;
callback(200, data);
};
} else {
--
cgit v1.2.3
From 2ac66b78f0d2068166c617e6e82d038ac4d46f0a Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 23 Jul 2010 12:01:59 -0700
Subject: minor per improvement
---
src/directives.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src')
diff --git a/src/directives.js b/src/directives.js
index 3e0aeffb..32b012f3 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -224,8 +224,8 @@ function ngClass(selector) {
var existing = element[0].className + ' ';
return function(element){
this.$onEval(function(){
- var value = this.$eval(expression);
if (selector(this.$index)) {
+ var value = this.$eval(expression);
if (isArray(value)) value = value.join(' ');
element[0].className = trim(existing + value);
}
--
cgit v1.2.3
From 3b41979891f5dc6a68e05cd5ed9c355c34774193 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Fri, 23 Jul 2010 13:36:08 -0700
Subject: fix bug which only showed up in ie7
---
src/directives.js | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
(limited to 'src')
diff --git a/src/directives.js b/src/directives.js
index 32b012f3..ffe37890 100644
--- a/src/directives.js
+++ b/src/directives.js
@@ -166,26 +166,27 @@ angularWidget("@ng:repeat", function(expression, element){
var index = 0, childCount = children.length, childScope, lastElement = reference,
collection = this.$tryEval(rhs, reference), is_array = isArray(collection);
for ( var key in collection) {
- if (is_array && !collection.hasOwnProperty(key)) break;
- if (index < childCount) {
- // reuse existing child
- childScope = children[index];
- childScope[valueIdent] = collection[key];
- if (keyIdent) childScope[keyIdent] = key;
- } else {
- // grow children
- childScope = template(element.clone(), createScope(currentScope));
- childScope[valueIdent] = collection[key];
- if (keyIdent) childScope[keyIdent] = key;
- lastElement.after(childScope.$element);
- childScope.$index = index;
- childScope.$element.attr('ng:repeat-index', index);
- childScope.$init();
- children.push(childScope);
+ if (!is_array || collection.hasOwnProperty(key)) {
+ if (index < childCount) {
+ // reuse existing child
+ childScope = children[index];
+ childScope[valueIdent] = collection[key];
+ if (keyIdent) childScope[keyIdent] = key;
+ } else {
+ // grow children
+ childScope = template(element.clone(), createScope(currentScope));
+ childScope[valueIdent] = collection[key];
+ if (keyIdent) childScope[keyIdent] = key;
+ lastElement.after(childScope.$element);
+ childScope.$index = index;
+ childScope.$element.attr('ng:repeat-index', index);
+ childScope.$init();
+ children.push(childScope);
+ }
+ childScope.$eval();
+ lastElement = childScope.$element;
+ index ++;
}
- childScope.$eval();
- lastElement = childScope.$element;
- index ++;
};
// shrink children
while(children.length > index) {
--
cgit v1.2.3
From b288cb08b450cd28423595de82693631cc6d6dda Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Mon, 26 Jul 2010 15:32:08 -0700
Subject: minor performance improvements
---
src/Angular.js | 18 ++++++++++--------
src/Compiler.js | 4 +++-
src/Scope.js | 9 ++++++---
3 files changed, 19 insertions(+), 12 deletions(-)
(limited to 'src')
diff --git a/src/Angular.js b/src/Angular.js
index 404d241d..850fe34c 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -16,7 +16,7 @@ var consoleNode,
msie = !!/(msie) ([\w.]+)/.exec(lowercase(navigator.userAgent)),
jqLite = jQuery || jqLiteWrap,
slice = Array.prototype.slice,
- error = window['console'] ? bind(window['console'], window['console']['error']) : noop,
+ error = window['console'] ? bind(window['console'], window['console']['error'] || noop) : noop,
angular = window['angular'] || (window['angular'] = {}),
angularTextMarkup = extensionMap(angular, 'textMarkup'),
angularAttrMarkup = extensionMap(angular, 'attrMarkup'),
@@ -292,12 +292,14 @@ function escapeAttr(html) {
}
function bind(_this, _function) {
- if (!isFunction(_function))
- throw "Not a function!";
var curryArgs = slice.call(arguments, 2, arguments.length);
- return function() {
- return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length)));
- };
+ return curryArgs.length == 0 ?
+ function() {
+ return _function.apply(_this, arguments);
+ } :
+ function() {
+ return _function.apply(_this, curryArgs.concat(slice.call(arguments, 0, arguments.length)));
+ };
}
function outerHTML(node) {
@@ -331,12 +333,12 @@ function merge(src, dst) {
}
}
-function compile(element, parentScope, overrides) {
+function compile(element, parentScope) {
var compiler = new Compiler(angularTextMarkup, angularAttrMarkup, angularDirective, angularWidget),
$element = jqLite(element),
parent = extend({}, parentScope);
parent.$element = $element;
- return compiler.compile($element)($element, parent, overrides);
+ return compiler.compile($element)($element, parent);
}
/////////////////////////////////////////////////
diff --git a/src/Compiler.js b/src/Compiler.js
index a6fd88ec..bcf1f61a 100644
--- a/src/Compiler.js
+++ b/src/Compiler.js
@@ -30,7 +30,9 @@ Template.prototype = {
element = jqLite(element);
foreach(this.inits, function(fn) {
queue.push(function(scope) {
- scope.$tryEval(fn, element, element);
+ scope.$tryEval(function(){
+ return fn.call(scope, element);
+ }, element);
});
});
diff --git a/src/Scope.js b/src/Scope.js
index 549cc944..6b011936 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -131,7 +131,7 @@ function createScope(parent, services, existing) {
$eval: function $eval(exp) {
if (exp !== undefined) {
- return expressionCompile(exp).apply(instance, slice.call(arguments, 1, arguments.length));
+ return expressionCompile(exp).call(instance);
} else {
for ( var i = 0, iSize = evalLists.sorted.length; i < iSize; i++) {
for ( var queue = evalLists.sorted[i],
@@ -145,7 +145,7 @@ function createScope(parent, services, existing) {
$tryEval: function (expression, exceptionHandler) {
try {
- return expressionCompile(expression).apply(instance, slice.call(arguments, 2, arguments.length));
+ return expressionCompile(expression).call(instance);
} catch (e) {
(instance.$log || {error:error}).error(e);
if (isFunction(exceptionHandler)) {
@@ -161,12 +161,15 @@ function createScope(parent, services, existing) {
$watch: function(watchExp, listener, exceptionHandler) {
var watch = expressionCompile(watchExp),
last;
+ listener = expressionCompile(listener);
function watcher(){
var value = watch.call(instance),
lastValue = last;
if (last !== value) {
last = value;
- instance.$tryEval(listener, exceptionHandler, value, lastValue);
+ instance.$tryEval(function(){
+ return listener.call(instance, value, lastValue);
+ }, exceptionHandler);
}
}
instance.$onEval(PRIORITY_WATCH, watcher);
--
cgit v1.2.3
From 94759f4c2cab91d35a18159a00fbdaec0af79aa9 Mon Sep 17 00:00:00 2001
From: Misko Hevery
Date: Mon, 26 Jul 2010 15:35:02 -0700
Subject: remove old unneded files
---
src/delete/Binder.js | 356 ------------
src/delete/Model.js | 65 ---
src/delete/Scope.js | 407 --------------
src/delete/Widgets.js | 806 ---------------------------
src/moveToAngularCom/ControlBar.js | 72 ---
src/moveToAngularCom/DataStore.js | 330 -----------
src/moveToAngularCom/Server.js | 68 ---
src/moveToAngularCom/Users.js | 35 --
src/moveToAngularCom/directivesAngularCom.js | 29 -
9 files changed, 2168 deletions(-)
delete mode 100644 src/delete/Binder.js
delete mode 100644 src/delete/Model.js
delete mode 100644 src/delete/Scope.js
delete mode 100644 src/delete/Widgets.js
delete mode 100644 src/moveToAngularCom/ControlBar.js
delete mode 100644 src/moveToAngularCom/DataStore.js
delete mode 100644 src/moveToAngularCom/Server.js
delete mode 100644 src/moveToAngularCom/Users.js
delete mode 100644 src/moveToAngularCom/directivesAngularCom.js
(limited to 'src')
diff --git a/src/delete/Binder.js b/src/delete/Binder.js
deleted file mode 100644
index 095e2b08..00000000
--- a/src/delete/Binder.js
+++ /dev/null
@@ -1,356 +0,0 @@
-function Binder(doc, widgetFactory, datastore, location, config) {
- this.doc = doc;
- this.location = location;
- this.datastore = datastore;
- this.anchor = {};
- this.widgetFactory = widgetFactory;
- this.config = config || {};
- this.updateListeners = [];
-}
-
-Binder.parseBindings = function(string) {
- var results = [];
- var lastIndex = 0;
- var index;
- while((index = string.indexOf('{{', lastIndex)) > -1) {
- if (lastIndex < index)
- results.push(string.substr(lastIndex, index - lastIndex));
- lastIndex = index;
-
- index = string.indexOf('}}', index);
- index = index < 0 ? string.length : index + 2;
-
- results.push(string.substr(lastIndex, index - lastIndex));
- lastIndex = index;
- }
- if (lastIndex != string.length)
- results.push(string.substr(lastIndex, string.length - lastIndex));
- return results.length === 0 ? [ string ] : results;
-};
-
-Binder.hasBinding = function(string) {
- var bindings = Binder.parseBindings(string);
- return bindings.length > 1 || Binder.binding(bindings[0]) !== null;
-};
-
-Binder.binding = function(string) {
- var binding = string.replace(/\n/gm, ' ').match(/^\{\{(.*)\}\}$/);
- return binding ? binding[1] : null;
-};
-
-
-Binder.prototype = {
- parseQueryString: function(query) {
- var params = {};
- query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,
- function (match, left, right) {
- if (left) params[decodeURIComponent(left)] = decodeURIComponent(right);
- });
- return params;
- },
-
- parseAnchor: function() {
- var self = this, url = this.location['get']() || "";
-
- var anchorIndex = url.indexOf('#');
- if (anchorIndex < 0) return;
- var anchor = url.substring(anchorIndex + 1);
-
- var anchorQuery = this.parseQueryString(anchor);
- foreach(self.anchor, function(newValue, key) {
- delete self.anchor[key];
- });
- foreach(anchorQuery, function(newValue, key) {
- self.anchor[key] = newValue;
- });
- },
-
- onUrlChange: function() {
- this.parseAnchor();
- this.updateView();
- },
-
- updateAnchor: function() {
- var url = this.location['get']() || "";
- var anchorIndex = url.indexOf('#');
- if (anchorIndex > -1)
- url = url.substring(0, anchorIndex);
- url += "#";
- var sep = '';
- for (var key in this.anchor) {
- var value = this.anchor[key];
- if (typeof value === 'undefined' || value === null) {
- delete this.anchor[key];
- } else {
- url += sep + encodeURIComponent(key);
- if (value !== true)
- url += "=" + encodeURIComponent(value);
- sep = '&';
- }
- }
- this.location['set'](url);
- return url;
- },
-
- updateView: function() {
- var start = new Date().getTime();
- var scope = jQuery(this.doc).scope();
- scope.clearInvalid();
- scope.updateView();
- var end = new Date().getTime();
- this.updateAnchor();
- foreach(this.updateListeners, function(fn) {fn();});
- },
-
- docFindWithSelf: function(exp){
- var doc = jQuery(this.doc);
- var selection = doc.find(exp);
- if (doc.is(exp)){
- selection = selection.andSelf();
- }
- return selection;
- },
-
- executeInit: function() {
- this.docFindWithSelf("[ng:init]").each(function() {
- var jThis = jQuery(this);
- var scope = jThis.scope();
- try {
- scope.eval(jThis.attr('ng:init'));
- } catch (e) {
- alert("EVAL ERROR:\n" + jThis.attr('ng:init') + '\n' + toJson(e, true));
- }
- });
- },
-
- entity: function (scope) {
- var self = this;
- this.docFindWithSelf("[ng-entity]").attr("ng:watch", function() {
- try {
- var jNode = jQuery(this);
- var decl = scope.entity(jNode.attr("ng-entity"), self.datastore);
- return decl + (jNode.attr('ng:watch') || "");
- } catch (e) {
- log(e);
- alert(e);
- }
- });
- },
-
- compile: function() {
- var jNode = jQuery(this.doc);
- if (this.config['autoSubmit']) {
- var submits = this.docFindWithSelf(":submit").not("[ng-action]");
- submits.attr("ng-action", "$save()");
- submits.not(":disabled").not("ng:bind-attr").attr("ng:bind-attr", '{disabled:"{{$invalidWidgets}}"}');
- }
- this.precompile(this.doc)(this.doc, jNode.scope(), "");
- this.docFindWithSelf("a[ng-action]").live('click', function (event) {
- var jNode = jQuery(this);
- var scope = jNode.scope();
- try {
- scope.eval(jNode.attr('ng-action'));
- jNode.removeAttr('ng-error');
- jNode.removeClass("ng-exception");
- } catch (e) {
- jNode.addClass("ng-exception");
- jNode.attr('ng-error', toJson(e, true));
- }
- scope.get('$updateView')();
- return false;
- });
- },
-
- translateBinding: function(node, parentPath, factories) {
- var path = parentPath.concat();
- var offset = path.pop();
- var parts = Binder.parseBindings(node.nodeValue);
- if (parts.length > 1 || Binder.binding(parts[0])) {
- var parent = node.parentNode;
- if (isLeafNode(parent)) {
- parent.setAttribute('ng:bind-template', node.nodeValue);
- factories.push({path:path, fn:function(node, scope, prefix) {
- return new BindUpdater(node, node.getAttribute('ng:bind-template'));
- }});
- } else {
- for (var i = 0; i < parts.length; i++) {
- var part = parts[i];
- var binding = Binder.binding(part);
- var newNode;
- if (binding) {
- newNode = document.createElement("span");
- var jNewNode = jQuery(newNode);
- jNewNode.attr("ng:bind", binding);
- if (i === 0) {
- factories.push({path:path.concat(offset + i), fn:this.ng_bind});
- }
- } else if (msie && part.charAt(0) == ' ') {
- newNode = document.createElement("span");
- newNode.innerHTML = ' ' + part.substring(1);
- } else {
- newNode = document.createTextNode(part);
- }
- parent.insertBefore(newNode, node);
- }
- }
- parent.removeChild(node);
- }
- },
-
- precompile: function(root) {
- var factories = [];
- this.precompileNode(root, [], factories);
- return function (template, scope, prefix) {
- var len = factories.length;
- for (var i = 0; i < len; i++) {
- var factory = factories[i];
- var node = template;
- var path = factory.path;
- for (var j = 0; j < path.length; j++) {
- node = node.childNodes[path[j]];
- }
- try {
- scope.addWidget(factory.fn(node, scope, prefix));
- } catch (e) {
- alert(e);
- }
- }
- };
- },
-
- precompileNode: function(node, path, factories) {
- var nodeType = node.nodeType;
- if (nodeType == Node.TEXT_NODE) {
- this.translateBinding(node, path, factories);
- return;
- } else if (nodeType != Node.ELEMENT_NODE && nodeType != Node.DOCUMENT_NODE) {
- return;
- }
-
- if (!node.getAttribute) return;
- var nonBindable = node.getAttribute('ng:non-bindable');
- if (nonBindable || nonBindable === "") return;
-
- var attributes = node.attributes;
- if (attributes) {
- var bindings = node.getAttribute('ng:bind-attr');
- node.removeAttribute('ng:bind-attr');
- bindings = bindings ? fromJson(bindings) : {};
- var attrLen = attributes.length;
- for (var i = 0; i < attrLen; i++) {
- var attr = attributes[i];
- var attrName = attr.name;
- // http://www.glennjones.net/Post/809/getAttributehrefbug.htm
- var attrValue = msie && attrName == 'href' ?
- decodeURI(node.getAttribute(attrName, 2)) : attr.value;
- if (Binder.hasBinding(attrValue)) {
- bindings[attrName] = attrValue;
- }
- }
- var json = toJson(bindings);
- if (json.length > 2) {
- node.setAttribute("ng:bind-attr", json);
- }
- }
-
- if (!node.getAttribute) log(node);
- var repeaterExpression = node.getAttribute('ng:repeat');
- if (repeaterExpression) {
- node.removeAttribute('ng:repeat');
- var precompiled = this.precompile(node);
- var view = document.createComment("ng:repeat: " + repeaterExpression);
- var parentNode = node.parentNode;
- parentNode.insertBefore(view, node);
- parentNode.removeChild(node);
- function template(childScope, prefix, i) {
- var clone = jQuery(node).clone();
- clone.css('display', '');
- clone.attr('ng:repeat-index', "" + i);
- clone.data('scope', childScope);
- precompiled(clone[0], childScope, prefix + i + ":");
- return clone;
- }
- factories.push({path:path, fn:function(node, scope, prefix) {
- return new RepeaterUpdater(jQuery(node), repeaterExpression, template, prefix);
- }});
- return;
- }
-
- if (node.getAttribute('ng:eval')) factories.push({path:path, fn:this.ng_eval});
- if (node.getAttribute('ng:bind')) factories.push({path:path, fn:this.ng_bind});
- if (node.getAttribute('ng:bind-attr')) factories.push({path:path, fn:this.ng_bind_attr});
- if (node.getAttribute('ng:hide')) factories.push({path:path, fn:this.ng_hide});
- if (node.getAttribute('ng:show')) factories.push({path:path, fn:this.ng_show});
- if (node.getAttribute('ng:class')) factories.push({path:path, fn:this.ng_class});
- if (node.getAttribute('ng:class-odd')) factories.push({path:path, fn:this.ng_class_odd});
- if (node.getAttribute('ng:class-even')) factories.push({path:path, fn:this.ng_class_even});
- if (node.getAttribute('ng:style')) factories.push({path:path, fn:this.ng_style});
- if (node.getAttribute('ng:watch')) factories.push({path:path, fn:this.ng_watch});
- var nodeName = node.nodeName;
- if ((nodeName == 'INPUT' ) ||
- nodeName == 'TEXTAREA' ||
- nodeName == 'SELECT' ||
- nodeName == 'BUTTON') {
- var self = this;
- factories.push({path:path, fn:function(node, scope, prefix) {
- node.name = prefix + node.name.split(":").pop();
- return self.widgetFactory.createController(jQuery(node), scope);
- }});
- }
- if (nodeName == 'OPTION') {
- var html = jQuery('').append(jQuery(node).clone()).html();
- if (!html.match(/