diff options
| author | Misko Hevery | 2010-02-17 16:05:26 -0800 | 
|---|---|---|
| committer | Misko Hevery | 2010-02-17 16:05:26 -0800 | 
| commit | 7e14dff90516a41ff1903cc44fe3389710f15556 (patch) | |
| tree | b636e82bbcf1661ff744fcbc490b468af725f069 | |
| parent | 3f9a2ab9bdfcd12cb7df74b0d38cecf2ee4ac94a (diff) | |
| download | angular.js-7e14dff90516a41ff1903cc44fe3389710f15556.tar.bz2 | |
fix this on filter to point to scope
| -rw-r--r-- | angular-minified.js | 28 | ||||
| -rw-r--r-- | angular.js | 1 | ||||
| -rw-r--r-- | src/Scope.js | 1 | ||||
| -rw-r--r-- | test/FiltersTest.js | 3 | 
4 files changed, 18 insertions, 15 deletions
diff --git a/angular-minified.js b/angular-minified.js index ac4dd0c4..bc103b44 100644 --- a/angular-minified.js +++ b/angular-minified.js @@ -4,11 +4,11 @@ default:return false}}function ka(a,b){if(ja(a))if(V)a.innerText=b;else a.textCo  b.appendChild(a);var c=b.innerHTML;b.removeChild(a);return c}function W(a){var b=(""+a).toLowerCase();if(b=="f"||b=="0"||b=="false"||b=="no")a=false;return!!a}function X(a,b){for(var c in a){var d=b[c],e=typeof d;if(e=="undefined")b[c]=L(v(a[c]));else e=="object"&&d.constructor!=array&&c.substring(0,1)!="$"&&X(a[c],d)}}function ma(a){this.location=a;this.delay=25;this.setTimeout=function(b,c){p.setTimeout(b,c)};this.Ha=function(b){return b};this.N=a.href}function Ma(){var a=k.fn;a.scope=function(){for(var b=  this;b&&b.get(0);){var c=b.data("scope");if(c)return c;b=b.parent()}return null};a.controller=function(){return this.data("controller")||R.Kb}}function Na(a){if(a.Gc=="console"&&!Q){Q=x.createElement("div");Q.id="ng-console";x.getElementsByTagName("body")[0].appendChild(Q);K=function(){ia("ng-console-info",arguments)};console.error=function(){ia("ng-console-error",arguments)}}}function ca(a,b){var c={};o(b,function(d,e){c[e]=_(d).bind(a)});return c}function Oa(a,b){var c=new na(b.server,b.database),  d=new w(a[0],c,h,b.location,b);d.sa.push(b.Nc);c=new S(a.find("body"),b.server,b.database);var e=b.database=="$MEMORY"?new da(p):new oa(b.server,k.getScript);e=new pa(e,new Y(a.find("body")),function(){d.d()});var f=new qa(e,c),g="/data/"+b.database,h=new Z(function(l,q){e.P("POST",g,l,q)},f,d.anchor);d.l=h;d.sa.push(function(){h.W()});var i=new u({$anchor:d.anchor,$updateView:_(d.d).bind(d),$config:b,$invalidWidgets:[],$console:p.console,$datastore:ca(h,{load:h.load,loadMany:h.ma,loadOrCreate:h.Ka, -loadAll:h.Ja,save:h.save,remove:h.remove,flush:h.W,query:h.Sa,entity:h.G,entities:h.entities,documentCountsByUser:h.zb,userDocumentIdsByEntity:h.sc,join:h.join}),$save:function(l){h.mc(i.k,l,d.anchor)},$window:p,$uid:function(){return""+(new Date).getTime()},$users:f},"ROOT");a.data("scope",i);d.G(i);d.compile();c.bind();(new z(a)).bind();var j=_(ca(i,{set:i.i,get:i.get,eval:i.eval})).extend({init:function(){b.location.listen(_(d.gc).bind(d));d.Pa();d.Eb();d.d();return j},element:a[0],updateView:_(d.d).bind(d), +loadAll:h.Ja,save:h.save,remove:h.remove,flush:h.W,query:h.Sa,entity:h.G,entities:h.entities,documentCountsByUser:h.zb,userDocumentIdsByEntity:h.sc,join:h.join}),$save:function(l){h.mc(i.j,l,d.anchor)},$window:p,$uid:function(){return""+(new Date).getTime()},$users:f},"ROOT");a.data("scope",i);d.G(i);d.compile();c.bind();(new z(a)).bind();var j=_(ca(i,{set:i.i,get:i.get,eval:i.eval})).extend({init:function(){b.location.listen(_(d.gc).bind(d));d.Pa();d.Eb();d.d();return j},element:a[0],updateView:_(d.d).bind(d),  config:b});return j}function F(a,b,c){var d=_.last(b);o(c,function(e){d[e]=_[e]});m[a]=m[a]||{};o(b,function(e){B(m[a],e)})}function w(a,b,c,d,e){this.F=a;this.location=d;this.l=c;this.anchor={};this.xc=b;this.tb=e||{};this.sa=[]}function S(a,b,c){this.eb=a;this.fa=b;this.ka=c;this.ib=p;this.H=[]}function Z(a,b,c){this.post=a;this.Xa=b;this.K=[];this.ha={$collections:this.K};this.anchor=c;this.S=[]}function T(a,b){return{format:a,parse:b||a}}function ra(a){return""+a}function v(a,b){var c=[];ea(c,  a,b?"\n  ":null,_([]));return c.join("")}function L(a){try{var b=new D(a,true),c=b.da();b.L();return c()}catch(d){ba("fromJson error: ",a,d);throw d;}}function ea(a,b,c,d){if(typeof b=="object"){if(d.include(b)){a.push("RECURSION");return}d.push(b)}var e=typeof b;if(b===null)a.push("null");else if(e==="function")return;else if(e==="boolean")a.push(""+b);else if(e==="number")isNaN(b)?a.push("null"):a.push(""+b);else if(e==="string")return a.push(m.String.quoteUnicode(b));else if(e==="object")if(b instanceof  Array){a.push("[");var f=b.length;e=false;for(var g=0;g<f;g++){var h=b[g];e&&a.push(",");typeof h=="function"||typeof h=="undefined"?a.push("null"):ea(a,h,c,d);e=true}a.push("]")}else if(b instanceof Date)a.push(m.String.quoteUnicode(m.Date.toString(b)));else{a.push("{");c&&a.push(c);e=false;g=c?c+"  ":false;h=[];for(var i in b)i.indexOf("$$")!==0&&h.push(i);h.sort();for(i=0;i<h.length;i++){var j=h[i];try{f=b[j];if(typeof f!="function"){if(e){a.push(",");c&&a.push(c)}a.push(m.String.quote(j));a.push(":"); -ea(a,f,g,d);e=true}}catch(l){}}a.push("}")}typeof b=="object"&&d.pop()}function G(a,b){this.$$entity=a;this.$loadFrom(b||{});this.$entity=a.title;this.$migrate()}function E(a,b){this.text=a;this.xb=b?20:-1;this.h=[];this.index=0}function D(a,b){this.text=a;this.h=(new E(a,b)).parse();this.index=0}function u(a,b){this.Ya=[];this.ta={};this.name=b;a=a||{};function c(){}c.prototype=a;this.k=new c;this.k.$parent=a;if(b=="ROOT")this.k.$root=this.k}function oa(a,b){this.url=a;this.Tb=0;this.getScript=b; +ea(a,f,g,d);e=true}}catch(l){}}a.push("}")}typeof b=="object"&&d.pop()}function G(a,b){this.$$entity=a;this.$loadFrom(b||{});this.$entity=a.title;this.$migrate()}function E(a,b){this.text=a;this.xb=b?20:-1;this.h=[];this.index=0}function D(a,b){this.text=a;this.h=(new E(a,b)).parse();this.index=0}function u(a,b){this.Ya=[];this.ta={};this.name=b;a=a||{};function c(){}c.prototype=a;this.j=new c;this.j.$parent=a;if(b=="ROOT")this.j.$root=this.j}function oa(a,b){this.url=a;this.Tb=0;this.getScript=b;  this.tc="_"+(""+Math.random()).substr(2)+"_";this.oa=1800}function da(a){this.frame=a}function pa(a,b,c){this.yb=a;this.update=c;this.status=b}function qa(a,b){this.nc=a;this.ia=b}function na(a,b){this.Ub=0;this.fa=a;this.ka=b;this.wb=p.swfobject?p.swfobject.createSWF:function(){alert("ERROR: swfobject not loaded!")}}function U(a,b,c,d){this.view=a;this.rc=c;this.J=b;this.ya=d+"/_attachments";this.value=null;this.c=undefined}function R(a){this.view=a}function sa(a,b,c){this.view=a;this.A=c;this.exp=  b;this.Q=a.getAttribute("ng-validate");this.lc=typeof a.attributes["ng-required"]!="undefined";this.Ga=null;this.c=undefined;this.w=this.A.parse(a.value);a.getAttribute("ng-widget")==="datepicker"&&k(a).Fc()}function ta(a,b,c){this.view=a;this.exp=b;this.c=undefined;this.A=c;this.w=this.A.parse(a.checked?a.value:"")}function ua(a,b){this.view=a;this.exp=b;this.c=undefined;this.w=a.value}function va(a,b){this.view=a;this.exp=b;this.c=undefined;this.w=this.selected()}function wa(a,b){this.view=a;this.exp=  b;this.c=this.la=undefined;this.Fa=a.value;this.w=a.checked?a.value:null}function M(a,b){this.view=a;this.exp=w.ba(b);this.C=false}function xa(a,b){this.view=a;this.ob=b}function ya(a,b){this.view=a;this.exp=b;this.C=false}function za(a,b){this.view=a;this.exp=b}function Aa(a,b){this.view=a;this.exp=b}function Ba(a,b){this.view=a;this.exp=b}function Ca(a,b){this.view=a;this.exp=b}function Da(a,b){this.view=a;this.exp=b}function Ea(a,b){this.view=a;this.exp=b}function Fa(a,b,c,d){this.view=a;this.template= @@ -25,7 +25,7 @@ c.push(function(l){return e(l,j)})}():function(){var j=f,l=(""+b[f]).toLowerCase  i){return f(i,h)}:f}function e(f,g){var h=typeof f,i=typeof g;if(h==i){if(h=="string")f=f.toLowerCase();if(h=="string")g=g.toLowerCase();if(f===g)return 0;return f<g?-1:1}else return h<i?-1:1}b=_.isArray(b)?b:[b];b=_.map(b,function(f){var g=false;if(typeof f=="string"&&(f.charAt(0)=="+"||f.charAt(0)=="-")){g=f.charAt(0)=="-";f=f.substring(1)}var h=f?m.Function.compile(f):_.identity;return d(function(i,j){return e(h(i),h(j))},g)});return _.clone(a).sort(d(function(f,g){for(var h=0;h<b.length;h++){var i=  b[h](f,g);if(i!==0)return i}return 0},c))},orderByToggle:function(a,b){var c=false,d=-1;_.detect(a,function(e,f){if(e==b){c=true;d=f;return true}if((e.charAt(0)=="+"||e.charAt(0)=="-")&&e.substring(1)==b){c=e.charAt(0)=="+";d=f;return true}});d>=0&&a.splice(d,1);a.unshift((c?"-":"+")+b);return a},orderByDirection:function(a,b,c,d){c=c||"ng-ascend";d=d||"ng-descend";a=a[0]||"";var e=true;if(a.charAt(0)=="-"){a=a.substring(1);e=false}else if(a.charAt(0)=="+")a=a.substring(1);return a==b?e?c:d:""},merge:function(a,  b,c){var d=a[b];if(!d){d={};a[b]=d}X(c,d);return a}},Pa={quote:function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v")+'"'},quoteUnicode:function(a){a=m.String.quote(a);for(var b=[],c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d<128)b.push(a.charAt(c));else{d="000"+d.toString(16);b.push("\\u"+d.substring(d.length-4))}}return b.join("")},toDate:function(a){var b;if(typeof a=="string"&& -(b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/))){a=new Date(0);a.setUTCFullYear(b[1],b[2]-1,b[3]);a.setUTCHours(b[4],b[5],b[6],0);return a}return a}},Ja={toString:function(a){function b(c){return c<10?"0"+c:c}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"Z"}},Qa={compile:function(a){if(_.isFunction(a))return a;else if(a){var b=new u;return function(c){b.k=c;return b.eval(a)}}else return function(c){return c}}}; +(b=a.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/))){a=new Date(0);a.setUTCFullYear(b[1],b[2]-1,b[3]);a.setUTCHours(b[4],b[5],b[6],0);return a}return a}},Ja={toString:function(a){function b(c){return c<10?"0"+c:c}return a.getUTCFullYear()+"-"+b(a.getUTCMonth()+1)+"-"+b(a.getUTCDate())+"T"+b(a.getUTCHours())+":"+b(a.getUTCMinutes())+":"+b(a.getUTCSeconds())+"Z"}},Qa={compile:function(a){if(_.isFunction(a))return a;else if(a){var b=new u;return function(c){b.j=c;return b.eval(a)}}else return function(c){return c}}};  F("Global",[H],["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);F("Collection",[H,aa],["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);F("Array",[H,aa,Ia],["first","last","compact","flatten","without","uniq","intersect","zip","indexOf","lastIndexOf"]);F("Object",[H,aa,{}],["keys","values"]);F("String",[H,Pa],[]);F("Date",[H,Ja],[]);m.Date.toString=Ja.toString;F("Function",  [H,aa,Qa],["bind","bindAll","delay","defer","wrap","compose"]);w.ba=function(a){for(var b=[],c=0,d;(d=a.indexOf("{{",c))>-1;){c<d&&b.push(a.substr(c,d-c));c=d;d=a.indexOf("}}",d);d=d<0?a.length:d+2;b.push(a.substr(c,d-c));c=d}c!=a.length&&b.push(a.substr(c,a.length-c));return b.length===0?[a]:b};w.Jb=function(a){a=w.ba(a);return a.length>1||w.M(a[0])!==null};w.M=function(a){return(a=a.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?a[1]:null};w.prototype={hc:function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,  function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b},Pa:function(){var a=this,b=this.location.get()||"",c=b.indexOf("#");if(!(c<0)){b=this.hc(b.substring(c+1));o(a.anchor,function(d,e){delete a.anchor[e]});o(b,function(d,e){a.anchor[e]=d})}},gc:function(){this.Pa();this.d()},qc:function(){var a=this.location.get()||"",b=a.indexOf("#");if(b>-1)a=a.substring(0,b);a+="#";b="";for(var c in this.anchor){var d=this.anchor[c];if(typeof d==="undefined"||d===null)delete this.anchor[c]; @@ -66,21 +66,21 @@ d==";"){a.push({index:this.index,text:d});this.index++;c=true}else if(c&&d=="/")  this.text.charAt(this.index);if(c=="."||this.Y(c)||this.isNumber(c))a+=c;else break;this.index++}c=E.ua[a];if(!c){c=function(d){return d.scope.get(a)};c.X=a}this.h.push({index:b,text:a,b:c})},kc:function(a){var b=this.index,c=this.xb;this.index++;for(var d="",e=false;this.index<this.text.length;){var f=this.text.charAt(this.index);if(e){if(f=="u"){f=this.text.substring(this.index+1,this.index+5);this.index+=4;d+=String.fromCharCode(parseInt(f,16))}else{e=E.ab[f];d+=e?e:f}e=false}else if(f=="\\")e=  true;else if(f==a){this.index++;this.h.push({index:b,text:d,b:function(){return d.length==c?m.String.toDate(d):d}});return}else d+=f;this.index++}throw"Lexer Error: Unterminated quote ["+this.text.substring(b)+"] starting at column '"+(b+1)+"' in expression '"+this.text+"'.";},jc:function(){var a=this.index;this.index++;for(var b="",c=false;this.index<this.text.length;){var d=this.text.charAt(this.index);if(c){b+=d;c=false}else if(d==="\\"){b+=d;c=true}else if(d==="/"){this.index++;c="";if(this.Y(this.text.charAt(this.index))){this.Ta();  c=this.h.pop().text}var e=new RegExp(b,c);this.h.push({index:a,text:b,Lc:c,b:function(){return e}});return}else b+=d;this.index++}throw"Lexer Error: Unterminated RegExp ["+this.text.substring(a)+"] starting at column '"+(a+1)+"' in expression '"+this.text+"'.";}};D.db=P(0);D.prototype={error:function(a,b){throw"Token '"+b.text+"' is "+a+" at column='"+(b.index+1)+"' of expression '"+this.text+"' starting at '"+this.text.substring(b.index)+"'.";},ca:function(){if(this.h.length===0)throw"Unexpected end of expression: "+ -this.text;return this.h[0]},I:function(a,b,c,d){var e=this.h;if(e.length>0){e=e[0];var f=e.text;if(f==a||f==b||f==c||f==d||!a&&!b&&!c&&!d)return e}return false},a:function(a,b,c,d){if(a=this.I(a,b,c,d)){this.h.shift();return this.Ec=a}return false},j:function(a){if(!this.a(a)){var b=this.I();throw"Expecting '"+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}},fb:function(a,b){return function(c){return a(c,b(c))}},z:function(a,b,c){return function(d){return b(d, +this.text;return this.h[0]},I:function(a,b,c,d){var e=this.h;if(e.length>0){e=e[0];var f=e.text;if(f==a||f==b||f==c||f==d||!a&&!b&&!c&&!d)return e}return false},a:function(a,b,c,d){if(a=this.I(a,b,c,d)){this.h.shift();return this.Ec=a}return false},k:function(a){if(!this.a(a)){var b=this.I();throw"Expecting '"+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}},fb:function(a,b){return function(c){return a(c,b(c))}},z:function(a,b,c){return function(d){return b(d,  a(d),c(d))}},Ea:function(){return this.h.length>0},L:function(){if(this.h.length!==0)throw"Did not understand '"+this.text.substring(this.h[0].index)+"' while evaluating '"+this.text+"'.";},ra:function(){for(var a=[];;){this.h.length>0&&!this.I("}",")",";","]")&&a.push(this.Ca());if(!this.a(";"))return function(b){for(var c,d=0;d<a.length;d++){var e=a[d];if(e)c=e(b)}return c}}},Ca:function(){for(var a=this.s(),b;;)if(b=this.a("|"))a=this.z(a,b.b,this.filter());else return a},filter:function(){return this.wa(s)},  Q:function(){return this.wa(ga)},wa:function(a){for(var b=this.Ib(a),c=[];;)if(this.a(":"))c.push(this.s());else{var d=function(e,f){f=[f];for(var g=0;g<c.length;g++)f.push(c[g](e));function h(){var i=this;o(e,function(j,l){if(l.charAt(0)=="$")i[l]=j})}h.prototype=e.self;return b.apply(new h,f)};return function(){return d}}},s:function(){return this.oc()},oc:function(){if(this.a("throw")){var a=this.xa();return function(b){throw a(b);}}else return this.xa()},xa:function(){var a=this.Ma(),b;if(b=this.a("=")){if(!a.X)throw"Left hand side '"+  this.text.substring(0,b.index)+"' of assignment '"+this.text.substring(b.index)+"' is not assignable.";return this.z(function(){return a.X},b.b,this.Ma())}else return a},Ma:function(){for(var a=this.na(),b;;)if(b=this.a("||"))a=this.z(a,b.b,this.na());else return a},na:function(){var a=this.Ba(),b;if(b=this.a("&&"))a=this.z(a,b.b,this.na());return a},Ba:function(){var a=this.Ua(),b;if(b=this.a("==","!="))a=this.z(a,b.b,this.Ba());return a},Ua:function(){var a=this.mb(),b;if(b=this.a("<",">","<=",  ">="))a=this.z(a,b.b,this.Ua());return a},mb:function(){for(var a=this.Na(),b;b=this.a("+","-");)a=this.z(a,b.b,this.Na());return a},Na:function(){for(var a=this.ga(),b;b=this.a("*","/","%");)a=this.z(a,b.b,this.ga());return a},ga:function(){var a;return this.a("+")?this.da():(a=this.a("-"))?this.z(D.db,a.b,this.ga()):(a=this.a("!"))?this.fb(a.b,this.ga()):this.da()},Ib:function(a){var b=this.a(),c=b.text.split(".");a=a;for(var d,e=0;e<c.length;e++){d=c[e];if(a)a=a[d]}if(typeof a!="function")throw"Function '"+ -b.text+"' at column '"+(b.index+1)+"' in '"+this.text+"' is not defined.";return a},da:function(){var a;if(this.a("(")){a=this.Ca();this.j(")");a=a}else if(this.a("["))a=this.nb();else if(this.a("{"))a=this.object();else if(this.a("{:"))a=this.za(false);else if(this.a("{("))a=this.za(true);else{var b=this.a();(a=b.b)||this.error("not a primary expression",b)}for(;b=this.a("(","[",".");)if(b.text==="(")a=this.Hb(a);else if(b.text==="[")a=this.ec(a);else if(b.text===".")a=this.Fb(a);else throw"IMPOSSIBLE"; -return a},za:function(a){var b=[];if(a){if(!this.a(")")){for(b.push(this.a().text);this.a(",");)b.push(this.a().text);this.j(")")}this.j(":")}var c=this.ra();this.j("}");return function(d){return function(e){var f=new u(d.scope.k);f.i("$",e);for(var g=0;g<b.length;g++)f.i(b[g],arguments[g]);return c({scope:f})}}},Fb:function(a){var b=this.a().text;function c(d){return u.O(a(d),b)}c.X=b;return c},ec:function(a){var b=this.s();this.j("]");if(this.a("=")){var c=this.s();return function(d){return a(d)[b(d)]= -c(d)}}else return function(d){var e=a(d);d=b(d);return e?e[d]:undefined}},Hb:function(a){var b=[];if(this.ca().text!=")"){do b.push(this.s());while(this.a(","))}this.j(")");return function(c){for(var d=[],e=0;e<b.length;e++)d.push(b[e](c));e=a(c);if(typeof e==="function")return e.apply(c,d);else throw"Expression '"+a.X+"' is not a function.";}},nb:function(){var a=[];if(this.ca().text!="]"){do a.push(this.s());while(this.a(","))}this.j("]");return function(b){for(var c=[],d=0;d<a.length;d++)c.push(a[d](b)); -return c}},object:function(){var a=[];if(this.ca().text!="}"){do{var b=this.a().text;this.j(":");var c=this.s();a.push({Nb:b,value:c})}while(this.a(","))}this.j("}");return function(d){for(var e={},f=0;f<a.length;f++){var g=a[f],h=g.value(d);e[g.Nb]=h}return e}},Db:function(){for(var a=[];this.Ea();){a.push(this.Cb());this.a(";")||this.L()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}},Cb:function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c= -this.da()(null);return function(d){var e=d.l.G(a,c);d.scope.i(a,e);if(b){e=e();e.$$anchor=b;d.scope.i(b,e);return"$anchor."+b+":{"+b+"="+a+".load($anchor."+b+");"+b+".$$anchor="+m.String.quote(b)+";};"}else return""}},watch:function(){for(var a=[];this.Ea();){a.push(this.wc());this.a(";")||this.L()}this.L();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.jb(d.name,d.b)}}},wc:function(){var a=this.a().text;this.j(":");var b;if(this.ca().text=="{"){this.j("{");b=this.ra();this.j("}")}else b= +b.text+"' at column '"+(b.index+1)+"' in '"+this.text+"' is not defined.";return a},da:function(){var a;if(this.a("(")){a=this.Ca();this.k(")");a=a}else if(this.a("["))a=this.nb();else if(this.a("{"))a=this.object();else if(this.a("{:"))a=this.za(false);else if(this.a("{("))a=this.za(true);else{var b=this.a();(a=b.b)||this.error("not a primary expression",b)}for(;b=this.a("(","[",".");)if(b.text==="(")a=this.Hb(a);else if(b.text==="[")a=this.ec(a);else if(b.text===".")a=this.Fb(a);else throw"IMPOSSIBLE"; +return a},za:function(a){var b=[];if(a){if(!this.a(")")){for(b.push(this.a().text);this.a(",");)b.push(this.a().text);this.k(")")}this.k(":")}var c=this.ra();this.k("}");return function(d){return function(e){var f=new u(d.scope.j);f.i("$",e);for(var g=0;g<b.length;g++)f.i(b[g],arguments[g]);return c({scope:f})}}},Fb:function(a){var b=this.a().text;function c(d){return u.O(a(d),b)}c.X=b;return c},ec:function(a){var b=this.s();this.k("]");if(this.a("=")){var c=this.s();return function(d){return a(d)[b(d)]= +c(d)}}else return function(d){var e=a(d);d=b(d);return e?e[d]:undefined}},Hb:function(a){var b=[];if(this.ca().text!=")"){do b.push(this.s());while(this.a(","))}this.k(")");return function(c){for(var d=[],e=0;e<b.length;e++)d.push(b[e](c));e=a(c);if(typeof e==="function")return e.apply(c,d);else throw"Expression '"+a.X+"' is not a function.";}},nb:function(){var a=[];if(this.ca().text!="]"){do a.push(this.s());while(this.a(","))}this.k("]");return function(b){for(var c=[],d=0;d<a.length;d++)c.push(a[d](b)); +return c}},object:function(){var a=[];if(this.ca().text!="}"){do{var b=this.a().text;this.k(":");var c=this.s();a.push({Nb:b,value:c})}while(this.a(","))}this.k("}");return function(d){for(var e={},f=0;f<a.length;f++){var g=a[f],h=g.value(d);e[g.Nb]=h}return e}},Db:function(){for(var a=[];this.Ea();){a.push(this.Cb());this.a(";")||this.L()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}},Cb:function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c= +this.da()(null);return function(d){var e=d.l.G(a,c);d.scope.i(a,e);if(b){e=e();e.$$anchor=b;d.scope.i(b,e);return"$anchor."+b+":{"+b+"="+a+".load($anchor."+b+");"+b+".$$anchor="+m.String.quote(b)+";};"}else return""}},watch:function(){for(var a=[];this.Ea();){a.push(this.wc());this.a(";")||this.L()}this.L();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.jb(d.name,d.b)}}},wc:function(){var a=this.a().text;this.k(":");var b;if(this.ca().text=="{"){this.k("{");b=this.ra();this.k("}")}else b=  this.s();return function(){return{name:a,b:b}}}};u.V={};u.O=function(a,b){if(!b)return a;for(var c=b.split("."),d,e=a,f=c.length,g=0;g<f;g++){d=c[g];if(!d.match(/^[\$\w][\$\w\d]*$/))throw"Expression '"+b+"' is not a valid expression for accesing variables.";if(a){e=a;a=a[d]}if(_.isUndefined(a)&&d.charAt(0)=="$"){var h=m.Global.typeOf(e);if(d=(h=m[h.charAt(0).toUpperCase()+h.substring(1)])?h[[d.substring(1)]]:undefined)return a=_.bind(d,e,e)}}if(typeof a==="function"&&!a.$$factory)return La(e,a);return a}; -u.prototype={d:function(){var a=this;this.Gb();_.each(this.Ya,function(b){a.o(b,"",{},function(){this.d(a)})})},lb:function(a){a&&this.Ya.push(a)},Lb:function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!E.prototype.Y(c))return false}return true},get:function(a){return u.O(this.k,a)},i:function(a,b){a=a.split(".");for(var c=this.k,d=0;a.length>1;d++){var e=a.shift(),f=c[e];if(!f){f={};c[e]=f}c=f}return c[a.shift()]=b},q:function(a,b){this.eval(a+"="+v(b))},eval:function(a,b){var c= -u.V[a];if(!c){var d=new D(a);c=d.ra();d.L();u.V[a]=c}b=b||{};b.scope=this;return c(b)},o:function(a,b,c,d,e){try{var f=this.eval(b,c);if(a.C){a.C=false;k(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){ba("Eval Widget Error:",g);b=v(g,true);a.C=true;k(a.view).addClass("ng-exception").attr("ng-error",b);e&&e.apply(a,[g,b]);return false}},uc:function(a,b,c){var d=u.V[a];if(!d){d=(new D(a)).Q();u.V[a]=d}a={scope:this,self:this.k,$element:c};return d(a)(a, -b)},G:function(a,b){return(new D(a)).Db()({scope:this,l:b})},sb:function(){for(var a=this.k.$invalidWidgets;a.length>0;)a.pop()},Sb:function(a){this.k.$invalidWidgets.push(a)},watch:function(a){var b=this;(new D(a)).watch()({scope:this,jb:function(c,d){b.kb(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})},kb:function(a,b){var c=this.ta[a];if(!c){c={Ia:[],s:a};this.ta[a]=c}c.Ia.push(b)},Gb:function(){var a=this,b=false;o(this.ta,function(c){var d=a.eval(c.s);if(d!==c.c){o(c.Ia, -function(e){e(d,c.c);b=true});c.c=d}});return b}};oa.prototype={pb:function(a){return fa.Ab(a)},P:function(a,b,c,d){var e=this.tc+this.Tb++;a=this.pb(v({u:b,m:a,p:c}));b=Math.ceil(a.length/this.oa);c=this.url+"/$/"+e+"/"+b+"/";N[e]=function(h){delete N[e];d(200,h)};for(var f=0;f<b;f++){var g=a.substr(f*this.oa,this.oa);this.getScript(c+(f+1)+"?h="+g,n)}}};da.Bc="$DATASET:";da.prototype={P:J()};pa.prototype={P:function(a,b,c,d){var e=this;this.status.qb(c);this.yb.P(a,b,c,function(){e.status.Bb(); +u.prototype={d:function(){var a=this;this.Gb();_.each(this.Ya,function(b){a.o(b,"",{},function(){this.d(a)})})},lb:function(a){a&&this.Ya.push(a)},Lb:function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!E.prototype.Y(c))return false}return true},get:function(a){return u.O(this.j,a)},i:function(a,b){a=a.split(".");for(var c=this.j,d=0;a.length>1;d++){var e=a.shift(),f=c[e];if(!f){f={};c[e]=f}c=f}return c[a.shift()]=b},q:function(a,b){this.eval(a+"="+v(b))},eval:function(a,b){var c= +u.V[a];if(!c){var d=new D(a);c=d.ra();d.L();u.V[a]=c}b=b||{};b.scope=this;b.self=this.j;return c(b)},o:function(a,b,c,d,e){try{var f=this.eval(b,c);if(a.C){a.C=false;k(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){ba("Eval Widget Error:",g);b=v(g,true);a.C=true;k(a.view).addClass("ng-exception").attr("ng-error",b);e&&e.apply(a,[g,b]);return false}},uc:function(a,b,c){var d=u.V[a];if(!d){d=(new D(a)).Q();u.V[a]=d}a={scope:this,self:this.j,$element:c}; +return d(a)(a,b)},G:function(a,b){return(new D(a)).Db()({scope:this,l:b})},sb:function(){for(var a=this.j.$invalidWidgets;a.length>0;)a.pop()},Sb:function(a){this.j.$invalidWidgets.push(a)},watch:function(a){var b=this;(new D(a)).watch()({scope:this,jb:function(c,d){b.kb(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})},kb:function(a,b){var c=this.ta[a];if(!c){c={Ia:[],s:a};this.ta[a]=c}c.Ia.push(b)},Gb:function(){var a=this,b=false;o(this.ta,function(c){var d=a.eval(c.s);if(d!== +c.c){o(c.Ia,function(e){e(d,c.c);b=true});c.c=d}});return b}};oa.prototype={pb:function(a){return fa.Ab(a)},P:function(a,b,c,d){var e=this.tc+this.Tb++;a=this.pb(v({u:b,m:a,p:c}));b=Math.ceil(a.length/this.oa);c=this.url+"/$/"+e+"/"+b+"/";N[e]=function(h){delete N[e];d(200,h)};for(var f=0;f<b;f++){var g=a.substr(f*this.oa,this.oa);this.getScript(c+(f+1)+"?h="+g,n)}}};da.Bc="$DATASET:";da.prototype={P:J()};pa.prototype={P:function(a,b,c,d){var e=this;this.status.qb(c);this.yb.P(a,b,c,function(){e.status.Bb();  try{d.apply(this,arguments)}catch(f){alert(v(f))}e.update()})}};B(qa.prototype,{fetchCurrentUser:function(a){var b=this;this.nc.P("GET","/account.json",{},function(c,d){b.current=d.user;a(d.Pc)})},logout:function(a){var b=this;this.ia.Rb(function(){delete b.current;(a||n)()})},login:function(a){var b=this;this.ia.Qb(function(){b.fetchCurrentUser(function(){(a||n)()})})},notAuthorized:function(){this.ia.dc()}});o({regexp:function(a,b,c){return a.match(b)?null:c||"Value does not match expected format "+  b+"."},number:function(a,b,c){var d=1*a;if(d==a){if(typeof b!="undefined"&&d<b)return"Value can not be less than "+b+".";if(typeof b!="undefined"&&d>c)return"Value can not be greater than "+c+".";return null}else return"Value is not a number."},integer:function(a,b,c){if(b=ga.number(a,b,c))return b;if(!(""+a).match(/^\s*[\d+]*\s*$/)||a!=Math.round(a))return"Value is not a whole number.";return null},date:function(a){if(a.match(/^\d\d?\/\d\d?\/\d\d\d\d$/))return null;return"Value is not a date. (Expecting format: 12/31/2009)."},  ssn:function(a){if(a.match(/^\d\d\d-\d\d-\d\d\d\d$/))return null;return"SSN needs to be in 999-99-9999 format."},email:function(a){if(a.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/))return null;return"Email needs to be in username@host.com format."},phone:function(a){if(a.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/))return null;if(a.match(/^\+\d{2,3} (\(\d{1,5}\))?[\d ]+\d$/))return null;return"Phone number needs to be in 1(987)654-3210 format in North America or +999 (123) 45678 906 internationaly."}, @@ -98,7 +98,7 @@ c}}};M.Va=function(a){switch(typeof a){case "string":case "boolean":case "number  case "function":return C(a.text());default:break}}if(a===null)return"";return C(v(a,true));default:return""}};M.prototype={e:n,d:function(a){for(var b=[],c=this.exp,d=c.length,e=0;e<d;e++){var f=c[e],g=w.M(f);if(g){a.o(this,g,{R:this.view},function(h){b.push(M.Va(h))},function(h,i){ka(this.view,i)});if(this.C)return}else b.push(C(f))}ka(this.view,b.join(""))}};xa.prototype={e:n,d:function(a){var b=k(this.view),c=this.ob;if(this.C){this.C=false;b.removeClass("ng-exception").removeAttr("ng-error")}var d=  b.is("img");for(var e in c){for(var f=w.ba(c[e]),g=[],h=0;h<f.length;h++){var i=w.M(f[h]);if(i)try{var j=a.eval(i,{R:b[0],attrName:e});if(j&&(j.constructor!==array||j.length!==0))g.push(j)}catch(l){this.C=true;ba("BindAttrUpdater",l);i=v(l,true);g.push("["+i+"]");b.addClass("ng-exception").attr("ng-error",i)}else g.push(f[h])}f=g.length?g.join(""):null;if(d&&e=="src"&&!f)f=a.get("$config.blankImage");b.attr(e,f)}}};ya.prototype={e:n,d:function(a){a.o(this,this.exp)}};za.prototype={e:n,d:function(a){a.o(this,  this.exp,{},function(b){var c=k(this.view);W(b)?c.hide():c.show()})}};Aa.prototype={e:n,d:function(a){a.o(this,this.exp,{},function(b){var c=k(this.view);W(b)?c.show():c.hide()})}};Ba.prototype={e:n,d:function(a){a.o(this,this.exp,{},function(b){if(b!==null&&b!==undefined)this.view.className=b})}};Ca.prototype={e:n,d:function(a){a.o(this,this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,c%2===1)})}};Da.prototype={e:n,d:function(a){a.o(this,this.exp,{},function(b){var c=a.get("$index"); -k(this.view).toggleClass(b,c%2===0)})}};Ea.prototype={e:n,d:function(a){a.o(this,this.exp,{},function(b){k(this.view).attr("style","").css(b)})}};Fa.prototype={e:n,d:function(a){a.o(this,this.Z,{},function(b){var c=this;if(!b){b=[];a.Lb(this.Z)&&a.i(this.Z,b)}var d=b.length,e=this.children.length,f=this.view,g=0,h=null,i=this.Ob,j=this.vc,l=0;o(b,function(q,O){if(l<e){h=c.children[l];h.scope.i(j,q)}else{var r=new u(a.k,c.prefix+j+" in "+c.Z+"["+l+"]");r.i("$index",l);i&&r.i(i,O);r.i(j,q);h={scope:r, +k(this.view).toggleClass(b,c%2===0)})}};Ea.prototype={e:n,d:function(a){a.o(this,this.exp,{},function(b){k(this.view).attr("style","").css(b)})}};Fa.prototype={e:n,d:function(a){a.o(this,this.Z,{},function(b){var c=this;if(!b){b=[];a.Lb(this.Z)&&a.i(this.Z,b)}var d=b.length,e=this.children.length,f=this.view,g=0,h=null,i=this.Ob,j=this.vc,l=0;o(b,function(q,O){if(l<e){h=c.children[l];h.scope.i(j,q)}else{var r=new u(a.j,c.prefix+j+" in "+c.Z+"["+l+"]");r.i("$index",l);i&&r.i(i,O);r.i(j,q);h={scope:r,  element:c.template(r,c.prefix,l)};f.after(h.element);c.children.push(h)}f=h.element;q=(new Date).getTime();h.scope.d();g+=(new Date).getTime()-q;l++});for(b=e;b>d;--b)this.children.pop().element.remove();if(h&&h.element[0].nodeName==="OPTION")if(d=k(h.element[0].parentNode).data("controller")){d.c=undefined;d.d(a)}})}};z.va="mouseleave mouseout click dblclick keypress keyup";z.fc=function(){z.pa();var a=k(this);a.bind(z.va,z.pa);var b=a.position(),c=x.documentElement,d=(self.innerWidth||c&&c.clientWidth||  x.body.clientWidth)-b.left;c=a.hasClass("ng-exception")?"EXCEPTION:":"Validation error...";a=a.attr("ng-error");d=d>375?"left":"right";c=k("<div id='ng-callout' style='width:300px'><div class='ng-arrow-"+d+"'/><div class='ng-title'>"+c+"</div><div class='ng-content'>"+a+"</div></div>");k("body").append(c);if(d==="left")a=b.left+this.offsetWidth+11;else{a=b.left-315;c.find(".ng-arrow-right").css({left:301})}c.css({left:a+"px",top:b.top-3+"px"});return true};z.pa=function(){k("#ng-callout").unbind(z.va,  z.pa).remove();return true};z.prototype={bind:function(){this.F.find(".ng-validation-error,.ng-exception").live("mouseover",z.fc)}};Y.$a='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';Y.prototype={qb:function(){if(this.ea===0)(this.La=this.La||this.body.append(Y.$a).find("#ng-loading")).show();this.ea++},Bb:function(){this.ea--;this.ea===0&&this.La.hide("fold")}}})(window,document); @@ -2961,6 +2961,7 @@ Scope.prototype = {      }      context = context || {};      context.scope = this; +    context.self = this.state;      return expression(context);    }, diff --git a/src/Scope.js b/src/Scope.js index c0998168..4de57dd2 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -105,6 +105,7 @@ Scope.prototype = {      }      context = context || {};      context.scope = this; +    context.self = this.state;      return expression(context);    }, diff --git a/test/FiltersTest.js b/test/FiltersTest.js index e6e8b662..9552c820 100644 --- a/test/FiltersTest.js +++ b/test/FiltersTest.js @@ -17,7 +17,8 @@ FiltersTest.prototype.testFilterThisIsContext = function(){    expectAsserts(2);    var scope = new Scope();    Scope.expressionCache = {}; -  var context = {$element:123, self:{name:'misko'}}; +  scope.set('name', 'misko'); +  var context = {$element:123};    angular.filter.testFn = function () {      assertEquals('Context not equal', 123, this.$element);      assertEquals('scope not equal', 'misko', this.name);  | 
