aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-01-23 15:54:58 -0800
committerMisko Hevery2010-01-23 15:54:58 -0800
commit4460328bc1173f5d97fb4ff54edc041968486fce (patch)
tree40e18a175f7f1ae104aa56347fe5038526374ed8
parente41ee88ef85986dcd0fea23fefcc57d89cee5c0b (diff)
downloadangular.js-4460328bc1173f5d97fb4ff54edc041968486fce.tar.bz2
lots of cleanup to get it ready for OS
-rw-r--r--angular-minified.js198
-rw-r--r--angular.js380
-rw-r--r--example/tweeter/tweeterclient.js5
-rw-r--r--jsTestDriver.conf2
-rw-r--r--src/Angular.js328
-rw-r--r--src/Binder.js19
-rw-r--r--src/JSON.js18
-rw-r--r--src/Users.js4
-rw-r--r--src/Widgets.js11
-rw-r--r--test/AngularTest.js15
-rw-r--r--test/BinderTest.js105
-rw-r--r--test/ControlBarTest.js2
-rw-r--r--test/ExternalApiTest.js15
-rw-r--r--test/JsonTest.js11
-rw-r--r--test/ScenarioSpec.js66
-rw-r--r--test/ScopeTest.js2
-rw-r--r--test/formsTest.js18
-rw-r--r--test/testabilityPatch.js8
18 files changed, 572 insertions, 635 deletions
diff --git a/angular-minified.js b/angular-minified.js
index 2209c269..c9103560 100644
--- a/angular-minified.js
+++ b/angular-minified.js
@@ -1,99 +1,99 @@
-function K(){return function(){}}function L(o){return function(){return o}}
-(function(o,y){function n(){}function w(a,b,c){var d=o.console;switch(arguments.length){case 1:d.log(a);break;case 2:d.log(a,b);break;default:d.log(a,b,c);break}}function W(a,b,c){var d=o.console;switch(arguments.length){case 1:d.error(a);break;case 2:d.error(a,b);break;default:d.error(a,b,c);break}}function da(a,b){var c=y.createElement("div");c.className=a;for(var d=a="",e=0;e<b.length;e++){var f=b[e];a+=d+(typeof f=="string"?f:z(f));d=" "}c.appendChild(y.createTextNode(a));R.appendChild(c)}function ea(a){switch(a.nodeName){case "OPTION":case "PRE":case "TITLE":return true;
-default:return false}}function fa(a,b){if(ea(a))if(X)a.innerText=b;else a.textContent=b;else a.innerHTML=b}function D(a){if(!a||!a.replace)return a;return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Da(a){if(!a||!a.replace)return a;return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;")}function ga(a,b){if(!a)throw"Missing this";if(!_.isFunction(b))throw"Missing function";return function(){return b.apply(a,arguments)}}function Ea(a,b){return function(){for(var c=
-[this],d=0;d<arguments.length;d++)c.push(arguments[d]);return b.apply(a,c)}}function ha(a){var b=y.createElement("div");b.appendChild(a);var c=b.innerHTML;b.removeChild(a);return c}function Y(a){var b=(""+a).toLowerCase();if(b=="f"||b=="0"||b=="false"||b=="no")a=false;return!!a}function Z(a,b){for(var c in a){var d=b[c],e=typeof d;if(e=="undefined")b[c]=O(z(a[c]));else e=="object"&&d.constructor!=array&&c.substring(0,1)!="$"&&Z(a[c],d)}}function ia(a,b,c){this.document=k(a);this.head=k(b);this.j=
-c;this.location=o.location}function ja(a){this.location=a;this.delay=25;this.setTimeout=function(b,c){o.setTimeout(b,c)};this.Ka=function(b){return b};this.L=a.href}function H(a,b,c){var d=_.last(b);q(c,function(e){d[e]=_[e]});m[a]=m[a]||{};q(b,function(e){S(m[a],e)})}function x(a,b,c,d){this.B=a;this.qa=c;this.anchor={};this.Oc=b;this.j=d||{};this.ab=[]}function P(a,b){this.document=a;this.ca=b;this.window=o;this.D=[]}function T(a,b,c){this.post=a;this.cb=b;this.A={P:[]};this.anchor=c;this.S=[]}
-function z(a,b){var c=[];$(c,a,b?"\n ":null);return c.join("")}function O(a){try{var b=new E(a,true),c=b.aa();b.I();return c()}catch(d){W("fromJson error: ",a,d);throw d;}}function $(a,b,c){var d=typeof b;if(b===null)a.push("null");else if(d!=="function")if(d==="boolean")a.push(""+b);else if(d==="number")isNaN(b)?a.push("null"):a.push(""+b);else if(d==="string")return a.push(m.String.quoteUnicode(b));else if(d==="object")if(b instanceof Array){a.push("[");var e=b.length;d=false;for(var f=0;f<e;f++){var g=
-b[f];d&&a.push(",");typeof g=="function"||typeof g=="undefined"?a.push("null"):$(a,g,c);d=true}a.push("]")}else if(b instanceof Date)a.push(m.String.quoteUnicode(m.Date.toString(b)));else{a.push("{");c&&a.push(c);d=false;f=c?c+" ":false;g=[];for(var h in b)h.indexOf("$$")!==0&&g.push(h);g.sort();for(h=0;h<g.length;h++){var i=g[h];try{e=b[i];if(typeof e!="function"){if(d){a.push(",");c&&a.push(c)}a.push(m.String.quote(i));a.push(":");$(a,e,f);d=true}}catch(j){}}a.push("}")}}function F(a,b){this.$$entity=
-a;this.R(b||{});this.Q=a.title;this.gb()}function G(a,b){this.text=a;this.Ib=b?20:-1;this.h=[];this.index=0}function E(a,b){this.text=a;this.h=(new G(a,b)).parse();this.index=0}function v(a,b){this.db=[];this.ra={};this.name=b;a=a||{};function c(){}c.prototype=a;this.q=new c;this.q.Uc=a;if(b=="ROOT")this.q.Vc=this.q}function ka(a,b){this.url=a;this.fc=0;this.getScript=b;this.Jc="_"+(""+Math.random()).substr(2)+"_";this.la=1800}function aa(a){this.frame=a}function la(a,b,c){this.Kb=a;this.update=c;
-this.status=b}function ma(a,b){this.H=a;this.fa=b}function na(a,b){this.gc=0;this.ca=a;this.F=b;this.Aa=o.Jd?swfobject.Aa:function(){alert("ERROR: swfobject not loaded!")};this.rc=K()}function M(a,b,c,d){this.view=a;this.Md=c;this.Ya=b;this.$c=d+"/_attachments";this.value=null;this.c=undefined}function Q(a){this.view=a}function oa(a,b){this.view=a;this.exp=b;this.O=a.getAttribute("ng-validate");this.zc=typeof a.attributes["ng-required"]!="undefined";this.Ja=null;this.c=undefined;this.p=a.value;a.getAttribute("ng-widget")===
-"datepicker"&&k(a).sd()}function pa(a,b){this.view=a;this.exp=b;this.c=undefined;this.p=a.checked?a.value:""}function qa(a,b){this.view=a;this.exp=b;this.c=undefined;this.p=a.value}function ra(a,b){this.view=a;this.exp=b;this.c=undefined;this.p=this.selected()}function sa(a,b){this.view=a;this.exp=b;this.c=this.ja=undefined;this.Ia=a.value;this.p=a.checked?a.value:null}function N(a,b){this.view=a;this.exp=x.Z(b);this.w=false;this.Bc={element:a}}function ta(a,b){this.view=a;this.ub=b}function ua(a,
-b){this.view=a;this.exp=b;this.w=false}function va(a,b){this.view=a;this.exp=b}function wa(a,b){this.view=a;this.exp=b}function xa(a,b){this.view=a;this.exp=b}function ya(a,b){this.view=a;this.exp=b}function za(a,b){this.view=a;this.exp=b}function Aa(a,b){this.view=a;this.exp=b}function Ba(a,b,c,d){this.view=a;this.template=c;this.prefix=d;this.children=[];a=b.match(/^\s*(.+)\s+in\s+(.*)\s*$/);if(!a)throw"Expected ng-repeat in form of 'item in collection' but got '"+b+"'.";b=a[1];this.X=a[2];a=b.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);
-if(!a)throw"'item' in 'item in collection' should be identifier or (key, value) but get '"+b+"'.";this.Lc=a[3]||a[1];this.$b=a[2]}function B(a){this.B=a}function U(a){this.Na=a.append(U.ib).find("#ng-loading");this.ba=0}var ba={u:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",Lb:function(a){var b="",c,d,e,f,g,h,i=0;for(a=ba.pb(a);i<a.length;){c=a.charCodeAt(i++);d=a.charCodeAt(i++);e=a.charCodeAt(i++);f=c>>2;c=(c&3)<<4|d>>4;g=(d&15)<<2|e>>6;h=e&63;if(isNaN(d))g=h=64;else if(isNaN(e))h=
-64;b=b+this.u.charAt(f)+this.u.charAt(c)+this.u.charAt(g)+this.u.charAt(h)}return b},td:function(a){var b="",c,d,e,f,g,h=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<a.length;){c=this.u.indexOf(a.charAt(h++));d=this.u.indexOf(a.charAt(h++));f=this.u.indexOf(a.charAt(h++));g=this.u.indexOf(a.charAt(h++));c=c<<2|d>>4;d=(d&15)<<4|f>>2;e=(f&3)<<6|g;b+=String.fromCharCode(c);if(f!=64)b+=String.fromCharCode(d);if(g!=64)b+=String.fromCharCode(e)}return b=ba.ob(b)},pb:function(a){a=a.replace(/\r\n/g,"\n");
-for(var b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d<128)b+=String.fromCharCode(d);else{if(d>127&&d<2048)b+=String.fromCharCode(d>>6|192);else{b+=String.fromCharCode(d>>12|224);b+=String.fromCharCode(d>>6&63|128)}b+=String.fromCharCode(d&63|128)}}return b},ob:function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;){d=a.charCodeAt(c);if(d<128){b+=String.fromCharCode(d);c++}else if(d>191&&d<224){c2=a.charCodeAt(c+1);b+=String.fromCharCode((d&31)<<6|c2&63);c+=2}else{c2=a.charCodeAt(c+1);c3=a.charCodeAt(c+
-2);b+=String.fromCharCode((d&15)<<12|(c2&63)<<6|c3&63);c+=3}}return b}};if(typeof y.getAttribute=="undefined")y.getAttribute=K();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};o.console||(o.console={log:n,error:n});var R,q=_.each,S=_.extend,k=o.jQuery,X=k.browser.msie,m=o.angular||(o.angular=
-{}),Ca=m.validator||(m.validator={}),r=m.filter||(m.filter={}),ca=m.callbacks||(m.callbacks={});m.alert||(m.alert=function(){w(arguments);o.alert.apply(o,arguments)});ia.prototype={load:function(){this.Db();w("Server: "+this.j.H);this.Cb();this.Bb();this.xb()},Cb:function(){w("Angular.configureJQueryPlugins()");k.fn.scope=function(){for(var a=this;a&&a.get(0);){var b=a.data("scope");if(b)return b;a=a.parent()}return null};k.fn.controller=function(){return this.data("controller")||Q.Wb}},Gc:function(){return""+
-(new Date).getTime()},Bb:function(){var a=this.j;if(!a.F){var b=a.H.match(/https?:\/\/([\w]*)/);a.F=b?b[1]:"$MEMORY"}},xb:function(){function a(){g.Qb(function(l){!l&&c.find("[ng-auth=eager]").length&&g.ka()})}w("Angular.bindHtml()");var b=this.Nc=new ja(this.location),c=this.document,d=new na(this.j.H,this.j.F),e=new x(c[0],d,b,this.j);d.rc=Ea(e,e.e);b=new P(c.find("body"),this.j.H);var f=this.j.F=="$MEMORY"?new aa(this.window):new ka(this.j.H,k.getScript);f=new la(f,new U(k(c.body)),function(){e.d()});
-var g=new ma(f,b),h="/data/"+this.j.F,i=new T(function(l,p){f.N("POST",h,l,p)},g,e.anchor);e.ab.push(function(){i.Ea()});var j=new v({$anchor:e.anchor,$binder:e,$config:this.j,$console:o.console,$datastore:i,$save:function(l){i.Ac(j.q,l,e.anchor)},$window:o,$uid:this.Gc,$users:g},"ROOT");c.data("scope",j);w("$binder.entity()");e.K(j);w("$binder.compile()");e.compile();w("ControlBar.bind()");b.bind();w("$users.fetchCurrentUser()");a();w("PopUp.bind()");(new B(c)).bind();w("$binder.parseAnchor()");
-e.Ta();c.find("body").show();w("ready()")},Db:function(){var a=o.location.href+"#";a=a.split("#")[1];var b={Jb:null};a=a.split("&");for(var c=0;c<a.length;c++){var d=(a[c]+"=").split("=");b[d[0]]=d[1]}if(b.Jb=="console"){R=y.createElement("div");R.id="ng-console";y.getElementsByTagName("body")[0].appendChild(R);w=function(){da("ng-console-info",arguments)};console.error=function(){da("ng-console-error",arguments)}}}};ja.prototype={watch:function(){var a=this;function b(){if(a.L!==a.location.href){var c=
-a.location.hash.match(/^#\$iframe_notify=(.*)$/);if(c){a.L.match(/#/)||(a.L+="#");a.location.href=a.L;c="_iframe_notify_"+c[1];var d=ca[c];delete ca[c];try{(d||n)()}catch(e){alert(e)}}else{a.Ka(a.location.href);a.L=a.location.href}}a.setTimeout(b,a.delay)}b()},Dc:function(a){var b=o.location.href;b.match(/#/)||(b+="#");if(b!=a)o.location.href=a;this.wd=a},Ga:function(){return o.location.href}};m.compile=function(a,b){b=b||{};var c={server:"",addUrlChangeListener:n},d=new ia(a,k("head"),_(c).extend(b));
-d.load();var e=k(a).scope();return{updateView:function(){return e.d()},set:function(){return e.i.apply(e,arguments)},get:function(){return e.get.apply(e,arguments)},init:function(){e.get("$binder.executeInit")();e.d()},watchUrl:function(){var f=e.get("$binder"),g=d.Nc;g.Ka=ga(f,f.tc,g);g.Bd=function(){alert("update")};g.watch()}}};var I={typeOf:function(a){if(a===null)return"null";var b=typeof a;if(b=="object"){if(a instanceof Array)return"array";if(a instanceof Date)return"date";if(a.nodeType==1)return"element"}return b}},
-V={},Fa={includeIf:function(a,b,c){var d=_.indexOf(a,b);if(c)d==-1&&a.push(b);else a.splice(d,1);return a},sum:function(a,b){b=m.Function.compile(b);for(var c=0,d=0;d<a.length;d++){var e=1*b(a[d]);isNaN(e)||(c+=e)}return c},remove:function(a,b){var c=_.indexOf(a,b);c>=0&&a.splice(c,1);return b},find:function(a,b,c){if(b){var d=m.Function.compile(b);_.detect(a,function(e){if(d(e)){c=e;return true}});return c}},findById:function(a,b){return m.Wc.find(a,function(c){return c.z==b},null)},filter:function(a,
-b){var c=[];c.yb=function(j){for(var l=0;l<c.length;l++)if(!c[l](j))return false;return true};var d=v.M;function e(j,l){if(l.charAt(0)==="!")return!e(j,l.substr(1));switch(typeof j){case "boolean":case "number":case "string":return(""+j).toLowerCase().indexOf(l)>-1;case "object":for(var p in j)if(p.charAt(0)!=="$"&&e(j[p],l))return true;return false;case "array":for(p=0;p<j.length;p++)if(e(j[p],l))return true;return false;default:return false}}switch(typeof b){case "boolean":case "number":case "string":b=
-{Qc:b};case "object":for(var f in b)f=="$"?function(){var j=(""+b[f]).toLowerCase();j&&c.push(function(l){return e(l,j)})}():function(){var j=f,l=(""+b[f]).toLowerCase();l&&c.push(function(p){return e(d(p,j),l)})}();break;case "function":c.push(b);break;default:return a}for(var g=[],h=0;h<a.length;h++){var i=a[h];c.yb(i)&&g.push(i)}return g},add:function(a,b){a.push(_.isUndefined(b)?{}:b);return a},count:function(a,b){if(!b)return a.length;var c=m.Function.compile(b);return _.reduce(a,0,function(d,
-e){return d+(c(e)?1:0)})},orderBy:function(a,b,c){function d(f,g){return Y(g)?function(h,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}Z(c,d);return a}},Ga={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}},Ha={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"}},Ia={compile:function(a){if(_.isFunction(a))return a;
-else if(a){var b=new v;return function(c){b.q=c;return b.eval(a)}}else return function(c){return c}}};H("Global",[I],["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);H("Collection",[I,V],["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);H("Array",[I,V,Fa],["first","last","compact","flatten","without","uniq","intersect","zip","indexOf","lastIndexOf"]);H("Object",
-[I,V,{}],["keys","values"]);H("String",[I,Ga],[]);H("Date",[I,Ha],[]);H("Function",[I,V,Ia],["bind","bindAll","delay","defer","wrap","compose"]);x.Z=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};x.Vb=function(a){a=x.Z(a);return a.length>1||x.J(a[0])!==null};x.J=function(a){return(a=a.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?
-a[1]:null};x.prototype={uc:function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b},Ta:function(a){var b=this;a=a||this.qa.Ga();var c=a.indexOf("#");if(!(c<0)){a=this.uc(a.substring(c+1));q(b.anchor,function(d,e){delete b.anchor[e]});q(a,function(d,e){b.anchor[e]=d})}},tc:function(a){this.Ta(a);this.d()},Hc:function(){var a=this.qa.Ga(),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];else{a+=b+encodeURIComponent(c);if(d!==true)a+="="+encodeURIComponent(d);b="&"}}this.qa.Dc(a);return a},d:function(){(new Date).getTime();var a=k(this.B).scope();a.i("$invalidWidgets",[]);a.d();(new Date).getTime();this.Hc();_.each(this.ab,function(b){b()})},ha:function(a){var b=k(this.B),c=b.find(a);if(b.is(a))c=c.andSelf();return c},K:function(a){this.ha("[ng-entity]").attr("ng-watch",function(){try{var b=k(this);return a.K(b.attr("ng-entity"))+
-(b.attr("ng-watch")||"")}catch(c){alert(c)}})},compile:function(){var a=k(this.B);if(this.j.ad){var b=this.ha(":submit").not("[ng-action]");b.attr("ng-action","$save()");b.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.Ua(this.B)(this.B,a.scope(),"");this.ha("a[ng-action]").live("click",function(){var c=k(this),d=c.scope();try{d.eval(c.attr("ng-action"));c.removeAttr("ng-error");c.removeClass("ng-exception")}catch(e){c.addClass("ng-exception");c.attr("ng-error",
-z(e,true))}d.eval("$binder.updateView()");return false})},Fc:function(a,b,c){b=b.concat();var d=b.pop(),e=x.Z(a.nodeValue);if(e.length>1||x.J(e[0])){var f=a.parentNode;if(ea(f)){f.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,b:function(l){return new N(l,l.getAttribute("ng-bind-template"))}})}else for(var g=0;g<e.length;g++){var h=e[g],i=x.J(h),j;if(i){j=y.createElement("span");k(j).attr("ng-bind",i);g===0&&c.push({path:b.concat(d+g),b:this.Ra})}else if(X&&h.charAt(0)==" "){j=y.createElement("span");
-j.innerHTML="&nbsp;"+h.substring(1)}else j=y.createTextNode(h);f.insertBefore(j,a)}f.removeChild(a)}},Ua:function(a){var b=[];this.Va(a,[],b);return function(c,d,e){for(var f=b.length,g=0;g<f;g++){for(var h=b[g],i=c,j=h.path,l=0;l<j.length;l++)i=i.childNodes[j[l]];try{d.sb(h.b(i,d,e))}catch(p){alert(p)}}}},Va:function(a,b,c){var d=a.nodeType;if(d==Node.TEXT_NODE)this.Fc(a,b,c);else if(!(d!=Node.ELEMENT_NODE&&d!=Node.DOCUMENT_NODE))if(a.getAttribute){d=a.getAttribute("ng-non-bindable");if(!(d||d===
-"")){if(d=a.attributes){var e=a.getAttribute("ng-bind-attr");a.removeAttribute("ng-bind-attr");e=e?O(e):{};for(var f=d.length,g=0;g<f;g++){var h=d[g],i=h.name;h=X&&i=="href"?decodeURI(a.getAttribute(i,2)):h.value;if(x.Vb(h))e[i]=h}d=z(e);d.length>2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||w(a);var j=a.getAttribute("ng-repeat");if(j){a.removeAttribute("ng-repeat");var l=this.Ua(a);d=y.createComment("ng-repeat: "+j);e=a.parentNode;e.insertBefore(d,a);e.removeChild(a);function p(s,t,A){var J=
-k(a).clone();J.css("display","");J.attr("ng-repeat-index",""+A);J.data("scope",s);l(J[0],s,t+A+":");return J}c.push({path:b,b:function(s,t,A){return new Ba(k(s),j,p,A)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,b:this.lc});a.getAttribute("ng-bind")&&c.push({path:b,b:this.Ra});a.getAttribute("ng-bind-attr")&&c.push({path:b,b:this.hc});a.getAttribute("ng-hide")&&c.push({path:b,b:this.mc});a.getAttribute("ng-show")&&c.push({path:b,b:this.nc});a.getAttribute("ng-class")&&c.push({path:b,b:this.ic});
-a.getAttribute("ng-class-odd")&&c.push({path:b,b:this.kc});a.getAttribute("ng-class-even")&&c.push({path:b,b:this.jc});a.getAttribute("ng-style")&&c.push({path:b,b:this.oc});a.getAttribute("ng-watch")&&c.push({path:b,b:this.pc});d=a.nodeName;if(d=="INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var C=this;c.push({path:b,b:function(s,t,A){s.name=A+s.name.split(":").pop();return C.Oc.Eb(k(s),t)}})}if(d=="OPTION")if(!k("<select/>").append(k(a).clone()).html().match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi))a.value=
-a.text;d=a.childNodes;for(e=0;e<d.length;e++)this.Va(d[e],b.concat(e),c)}}}},lc:function(a){return new ua(a,a.getAttribute("ng-eval"))},Ra:function(a){return new N(a,"{{"+a.getAttribute("ng-bind")+"}}")},hc:function(a){return new ta(a,O(a.getAttribute("ng-bind-attr")))},mc:function(a){return new va(a,a.getAttribute("ng-hide"))},nc:function(a){return new wa(a,a.getAttribute("ng-show"))},ic:function(a){return new xa(a,a.getAttribute("ng-class"))},jc:function(a){return new ya(a,a.getAttribute("ng-class-even"))},
-kc:function(a){return new za(a,a.getAttribute("ng-class-odd"))},oc:function(a){return new Aa(a,a.getAttribute("ng-style"))},pc:function(a,b){b.watch(a.getAttribute("ng-watch"))}};P.Xc='<div><div class="ui-widget-overlay"></div><div id="ng-login" ng-non-bindable="true"><div class="ng-login-container"></div></div></div>';P.kb='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';P.prototype={bind:K(),ka:function(a){this.D.push(a);this.D.length==1&&
-this.Ca("/user_session/new.mini?return_url="+encodeURIComponent(this.bb()))},cc:function(a){this.D.push(a);this.D.length==1&&this.Ca("/user_session/do_destroy.mini")},bb:function(){return this.window.location.href.split("#")[0]},Ca:function(a){var b=this,c=(new Date).getTime(),d=this.bb();d+="#$iframe_notify="+c;var e=k('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+d+'" src="'+this.ca+a+'" width="500" height="330"/></div>');this.document.append(e);e.Ba({height:363,width:500,Gd:false,
-ec:true,title:'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'});callbacks["_iframe_notify_"+c]=function(){e.Ba("destroy");e.remove();q(b.D,function(f){f()});b.D=[]}},Sa:function(){if(!this.Fa){this.Fa=k(P.kb);this.Fa.Ba({fd:true,height:70,ec:true})}}};T.lb=S(K(),{all:function(){return[]},query:function(){return[]},load:function(){return{}},title:undefined});T.prototype={T:function(a){if(!a instanceof F)throw"Parameter must be an instance of Entity! "+z(a);var b=
-a.Q+"/"+a.z,c=this.A[b];if(c)F.ga(a,c);else c=this.A[b]=a;return c},load:function(a,b,c,d){if(b&&b!=="*"){var e=this;this.C(["GET",a.Q+"/"+b],function(f){a.R(f);a.gb();f=a.Rc(a);e.T(f);(c||n)(a)},d)}return a},Ma:function(a,b,c){var d=this,e=[],f=0;q(b,function(g){e.push(d.load(a(),g,function(){f++;if(f==b.length)(c||n)(e)}))});return e},bc:function(a,b,c){return this.load(a,b,c,function(d){if(d.da==404){a.z=b;(c||n)(a)}else throw d;})},ac:function(a,b){var c=this,d=[];d.sa=function(e){return e.Q==
-a.title};this.A.P.push(d);this.C(["GET",a.title],function(e){for(var f=0;f<e.length;f++){var g=a();g.R(e[f]);d.push(c.T(g))}(b||n)(d)});return d},save:function(a,b){var c=this,d={};a.hb(d);this.C(["POST","",d],function(e){a.R(e);var f=c.T(a);_.each(c.A.P,function(g){g.sa(a)&&m.Array.includeIf(g,f,true)});if(a.ta)c.anchor[a.ta]=a.z;b&&b(a)})},remove:function(a,b){var c=this,d={};a.hb(d);this.C(["DELETE","",d],function(e){delete c.A[a.Q+"/"+a.z];_.each(c.A.P,function(f){for(var g=0;g<f.length;g++)f[g].z==
-a.z&&f.splice(g,1)});(b||n)(e)})},C:function(a,b,c){a.eb=b;a.fb=c||function(d){throw d;};this.S.push(a)},Ea:function(){function a(d,e){w("RESPONSE["+d+"]: ",e);if(e.da==401)b.cb.ka(function(){b.post(c,a)});else if(e.da)alert(z(e));else for(d=0;d<e.length;d++){var f=e[d],g=c[d],h=f.da;if(h)h==403?b.cb.Sa():g.fb(f);else g.eb(f)}}if(this.S.length!==0){var b=this,c=this.S;this.S=[];w("REQUEST:",c);this.post(c,a)}},Ac:function(a,b){function c(){d--;d===0&&b&&b()}var d=1;for(var e in a){var f=a[e];if(f&&
-f.ua==F.prototype.ua){d++;f.ua(c)}}c()},vc:function(a,b,c,d){var e=this,f=[];f.sa=L(false);this.A.P.push(f);this.C(["GET",a.title+"/"+b+"="+c],function(g){for(var h=0;h<g.length;h++){var i=(new a).R(g[h]);f.push(e.T(i))}d&&d(f)});return f},K:function(a,b){if(!a)return T.lb;var c=this,d=S(function(e){return new F(d,e)},{title:a,$$factory:true,datastore:this,defaults:b||{},load:function(e,f){return c.load(d(),e,f)},loadMany:function(e,f){return c.Ma(d,e,f)},loadOrCreate:function(e,f){return c.bc(d(),
-e,f)},all:function(e){return c.ac(d,e)},query:function(e,f,g){return c.vc(d,e,f,g)},properties:function(e){c.C(["GET",a+"/$properties"],e)}});return d},join:function(a){function b(){throw"Joined entities can not be instantiated into a document.";}var c=_(a).gd().map(function(d,e){return e}).sortBy(function(d){var e=[];do{if(_(e).include(d))throw"Infinite loop in join: "+e.join(" -> ");e.push(d);if(!a[d])throw _("Named entity '<%=name%>' is undefined.").template({name:d});d=a[d].Y?a[d].Y.substring(0,
-a[d].Y.indexOf(".")):undefined}while(d);return e.length}).value();if(_(c).select(function(d){return a[d].Y}).length!=c.length-1)throw"Exactly one entity needs to be primary.";b.query=function(d,e){var f=[],g=d?d.substring(0,d.indexOf(".")):undefined;if(g!=c[0])throw _("Named entity '<%=name%>' is not a primary entity.").template({name:g});var h=1;a[g].join.query(d.substring(d.indexOf(".")+1),e,function(i){var j=c[h++],l=a[j],p=l.Y,C={};_(i).each(function(s){var t={};f.push(t);t[g]=s;s=v.M(t,p);C[s]=
-s});l.join.Ma(_.toArray(C),function(s){var t={};_(s).each(function(A){t[A.z]=A});_(f).each(function(A){var J=v.M(A,p);A[j]=t[J]})})});return f};return b}};r.g=function(a){if(a)for(var b in a)this[b]=a[b]};r.g.get=function(a,b){b=b||"text";switch(typeof a){case "string":return b=="text"?a:undefined;case "object":if(a&&typeof a[b]!=="undefined")return a[b];return;default:return a}};var u;q({currency:function(a){k(this.element).toggleClass("ng-format-negative",a<0);return"$"+r.number.apply(this,[a,2])},
-number:function(a,b){if(isNaN(a)||!isFinite(a))return"";b=typeof b=="undefined"?2:b;var c=a<0;a=Math.abs(a);var d=Math.pow(10,b);a=""+Math.round(a*d);var e=a.substring(0,a.length-b);e=e||"0";d=a.substring(a.length-b);a=c?"-":"";for(c=0;c<e.length;c++){if((e.length-c)%3===0&&c!==0)a+=",";a+=e.charAt(c)}if(b>0){for(c=d.length;c<b;c++)d+="0";a+="."+d.substring(0,b)}return a},date:K(),json:function(a){k(this.element).addClass("ng-monospace");return z(a,true)},trackPackage:function(){var a=[{name:"UPS",
-url:"http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&track.x=0&track.y=0&InquiryNumber1=",oa:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",oa:[/^96\d{10}?$/i,/^96\d{17}?$/i,/^96\d{20}?$/i,/^\d{15}$/i,/^\d{12}$/i]},{name:"USPS",url:"http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=",oa:[/^(91\d{20})$/i,/^(91\d{18})$/i]}];return function(b,c){b=b.replace(/^ */,
-"").replace(/ *$/,"");var d=b.replace(/ /g,""),e;q(a,function(f){q(f.oa,function(g){if(g.test(d)){g=f.name+": "+b;var h=f.url+b;e=new r.g({text:g,url:h,html:'<a href="'+Da(h)+'">'+g+"</a>",Kd:b});_.breakLoop()}});e&&_.breakLoop()});return e?e:b?c||new r.g({text:b+" is not recognized"}):null}}(),link:function(a,b){b=b||r.g.get(a);var c=r.g.get(a,"url")||r.g.get(a);if(c){if(m.O.vd(c)===null)c="mailto:"+c;a='<a href="'+D(c)+'">'+b+"</a>";return new r.g({text:b,url:c,html:a})}return a},bytes:function(){var a=
-["bytes","KB","MB","GB","TB","PB"];return function(b){if(b===null)return"";for(var c=0;b>1E3;){b/=1024;c++}b=""+b;var d=b.indexOf(".");if(d>-1&&d+2<b.length)b=b.substring(0,d+2);return b+" "+a[c]}}(),image:function(a,b,c){if(a&&a.url){var d="";if(b)d=' style="max-width: '+b+"px; max-height: "+(c||b)+'px;"';return new r.g({url:a.url,text:a.url,html:'<img src="'+a.url+'"'+d+"/>"})}return null},lowercase:function(a){return(a=r.g.get(a))?(""+a).toLowerCase():a},uppercase:function(a){return(a=r.g.get(a))?
-(""+a).toUpperCase():a},linecount:function(a){a=r.g.get(a);if(a===""||!a)return 1;return a.split(/\n|\f/).length},"if":function(a,b){return b?a:undefined},unless:function(a,b){return b?undefined:a},googleChartApi:S(function(a,b,c,d){b=b||{};a={zb:a,hd:u.Ab(b,"color"),od:u.title(b),kd:u.Ab(b,"label"),jd:u.values(b),ld:"bg,s,FFFFFF00"};if(_.isArray(b.Pc)){a.qd="x";a.pd="0:|"+b.Pc.join("|")}return u.encode(a,c,d)},{values:function(a){var b=[];q(a.Cc||[],function(c){var d=[];q(c.values||[],function(e){d.push(e)});
-b.push(d.join(","))});a=b.join("|");return a===""?null:"t:"+a},title:function(a){var b=[];a=a.title||[];q(_.isArray(a)?a:[a],function(c){b.push(encodeURIComponent(c))});return b.join("|")},collect:function(a,b){var c=[],d=0;q(a.Cc||[],function(e){var f=[];e=e[b]||[];q(_.isArray(e)?e:[e],function(g){f.push(encodeURIComponent(g));d++});c.push(f.join("|"))});return d?c.join(","):null},encode:function(a,b,c){b=b||200;c=c||b;var d="http://chart.apis.google.com/chart?",e=[];a.nd=b+"x"+c;q(a,function(f,
-g){f&&e.push(g+"="+f)});e.sort();d+=e.join("&");return new r.g({url:d,html:'<img width="'+b+'" height="'+c+'" src="'+d+'"/>'})}}),qrcode:function(a,b,c){return u.encode({zb:"qr",md:encodeURIComponent(a)},b,c)},chart:{Dd:function(a,b,c){return u("p",a,b,c)},Ed:function(a,b,c){return u("p3",a,b,c)},Fd:function(a,b,c){return u("pc",a,b,c)},cd:function(a,b,c){return u("bhs",a,b,c)},bd:function(a,b,c){return u("bhg",a,b,c)},ed:function(a,b,c){return u("bvs",a,b,c)},dd:function(a,b,c){return u("bvg",a,
-b,c)},zd:function(a,b,c){return u("lc",a,b,c)},Id:function(a,b,c){return u("ls",a,b,c)},Hd:function(a,b,c){return u("s",a,b,c)}},html:function(a){return new r.g({html:a})},linky:function(a){if(!a)return a;for(var b=/(ftp|http|https|mailto):\/\/([^\(\)|\s]+)/,c,d=a,e=[];c=d.match(b);){c=c[0].replace(/[\.\;\,\(\)\{\}\<\>]$/,"");var f=d.indexOf(c);e.push(D(d.substr(0,f)));e.push('<a href="'+c+'">');e.push(c);e.push("</a>");d=d.substring(f+c.length)}e.push(D(d));return new r.g({text:a,html:e.join("")})}},
-function(a,b){r[b]=a});u=r.googleChartApi;array=[].constructor;m.toJson=z;m.fromJson=O;F.ga=function(a,b){if(!(a===b||!a||!b)){var c=function(e,f,g){return g.substring(0,2)!=="$$"&&typeof e[g]!=="function"&&typeof f[g]!=="function"};for(var d in b)c(a,b,d)&&delete b[d];for(d in a)if(c(a,b,d))b[d]=a[d]}};F.prototype={$migrate:function(){Z(this.$$entity.ud,this);return this},$save:function(a){this.$$entity.Hb.save(this,a===true?undefined:a);a===true&&this.$$entity.Hb.Ea();return this},$loadFrom:function(a){F.ga(a,
-this);return this},$saveTo:function(a){F.ga(this,a);return this}};G.va={"null":L(null),"true":L(true),"false":L(false),"+":function(a,b,c){return(b||0)+(c||0)},"-":function(a,b,c){return(b||0)-(c||0)},"*":function(a,b,c){return b*c},"/":function(a,b,c){return b/c},"%":function(a,b,c){return b%c},"^":function(a,b,c){return b^c},"=":function(a,b,c){return a.scope.i(b,c)},"==":function(a,b,c){return b==c},"!=":function(a,b,c){return b!=c},"<":function(a,b,c){return b<c},">":function(a,b,c){return b>
-c},"<=":function(a,b,c){return b<=c},">=":function(a,b,c){return b>=c},"&&":function(a,b,c){return b&&c},"||":function(a,b,c){return b||c},"&":function(a,b,c){return b&c},"|":function(a,b,c){return c(a,b)},"!":function(a,b){return!b}};G.jb={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'};G.prototype={G:function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false},parse:function(){for(var a=this.h,b=G.va,c=true;this.index<this.text.length;){var d=this.text.charAt(this.index);
-if(d=='"'||d=="'"){this.yc(d);c=true}else if(d=="("||d=="["){a.push({index:this.index,text:d});this.index++}else if(d=="{"){c=this.G();if(c==":"||c=="("){a.push({index:this.index,text:d+c});this.index++}else a.push({index:this.index,text:d});this.index++;c=true}else if(d==")"||d=="]"||d=="}"){a.push({index:this.index,text:d});this.index++;c=false}else if(d==":"||d=="."||d==","||d==";"){a.push({index:this.index,text:d});this.index++;c=true}else if(c&&d=="/"){this.xc();c=false}else if(this.ia(d)){this.wc();
-c=false}else if(this.W(d)){this.Wa();c=false}else if(this.Yb(d))this.index++;else{c=d+this.G();var e=b[d],f=b[c];if(f){a.push({index:this.index,text:c,b:f});this.index+=2}else if(e){a.push({index:this.index,text:d,b:e});this.index+=1}else throw"Lexer Error: Unexpected next character ["+this.text.substring(this.index)+"] in expression '"+this.text+"' at column '"+(this.index+1)+"'.";c=true}}return a},ia:function(a){return"0"<=a&&a<="9"},Yb:function(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"},
-W:function(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"},wc:function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.ia(c))a+=c;else break;this.index++}a=1*a;this.h.push({index:b,text:a,b:function(){return a}})},Wa:function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.W(c)||this.ia(c))a+=c;else break;this.index++}c=G.va[a];if(!c){c=function(d){return d.scope.get(a)};
-c.V=a}this.h.push({index:b,text:a,b:c})},yc:function(a){var b=this.index,c=this.Ib;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=G.jb[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+"'.";},xc: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.W(this.text.charAt(this.index))){this.Wa();c=this.h.pop().text}var e=new RegExp(b,c);this.h.push({index:a,text:b,xd: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+"'.";}};E.mb=L(0);E.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)+"'.";},$:function(){if(this.h.length===0)throw"Unexpected end of expression: "+this.text;return this.h[0]},G: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.G(a,b,c,d)){this.h.shift();return this.rd=a}return false},k:function(a){if(!this.a(a)){var b=this.G();throw"Expecting '"+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}},nb:function(a,b){return function(c){return a(c,b(c))}},s:function(a,b,c){return function(d){return b(d,a(d),c(d))}},Ha:function(){return this.h.length>0},I:function(){if(this.h.length!==0)throw"Did not understand '"+this.text.substring(this.h[0].index)+"' while evaluating '"+
-this.text+"'.";},pa:function(){for(var a=[];;){this.h.length>0&&!this.G("}",")",";","]")&&a.push(this.Da());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}}},Da:function(){for(var a=this.o(),b;;)if(b=this.a("|"))a=this.s(a,b.b,this.filter());else return a},filter:function(){return this.xa(m.filter)},O:function(){return this.xa(m.validator)},xa:function(a){for(var b=this.Ub(a),c=[];;)if(this.a(":"))c.push(this.o());else{var d=function(e,f){f=[f];for(var g=
-0;g<c.length;g++)f.push(c[g](e));return b.apply(e,f)};return function(){return d}}},o:function(){return this.Ec()},Ec:function(){if(this.a("throw")){var a=this.ea();return function(b){throw a(b);}}else return this.ea()},ea:function(){var a=this.Pa(),b;if(b=this.a("=")){if(!a.V)throw"Left hand side '"+this.text.substring(0,b.index)+"' of assignment '"+this.text.substring(b.index)+"' is not assignable.";return this.s(function(){return a.V},b.b,this.Pa())}else return a},Pa:function(){for(var a=this.Oa(),
-b;;)if(b=this.a("||"))a=this.s(a,b.b,this.Oa());else return a},Oa:function(){for(var a=this.Qa(),b;;)if(b=this.a("&&"))a=this.s(a,b.b,this.Qa());else return a},Qa:function(){var a;return(a=this.a("!"))?this.nb(a.b,this.ea()):this.Pb()},Pb:function(){for(var a=this.Xa(),b;;)if(b=this.a("==","!="))a=this.s(a,b.b,this.Xa());else return a},Xa:function(){for(var a=this.ya(),b;;)if(b=this.a("<",">","<=",">="))a=this.s(a,b.b,this.ya());else return a},ya:function(){for(var a=this.ma(),b;b=this.a("+","-");)a=
-this.s(a,b.b,this.ma());return a},ma:function(){for(var a=this.$a(),b;b=this.a("*","/","%");)a=this.s(a,b.b,this.$a());return a},$a:function(){var a;return this.a("+")?this.aa():(a=this.a("-"))?this.s(E.mb,a.b,this.ma()):this.aa()},Ub: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},aa:function(){var a;if(this.a("(")){a=this.Da();
-this.k(")");a=a}else if(this.a("["))a=this.tb();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.Tb(a);else if(b.text==="[")a=this.qc(a);else if(b.text===".")a=this.Rb(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.pa();this.k("}");return function(d){return function(e){var f=new v(d.scope.q);f.i("$",e);for(var g=0;g<b.length;g++)f.i(b[g],arguments[g]);return c({scope:f})}}},Rb:function(a){var b=this.a().text;function c(d){return v.M(a(d),b)}c.V=b;return c},qc:function(a){var b=this.o();this.k("]");if(this.a("=")){var c=this.o();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}},Tb:function(a){var b=[];if(this.$().text!=")"){do b.push(this.o());
-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.V+"' is not a function.";}},tb:function(){var a=[];if(this.$().text!="]"){do a.push(this.o());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.$().text!="}"){do{var b=this.a().text;this.k(":");var c=this.o();a.push({Zb: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.Zb]=h}return e}},Ob:function(){for(var a=[];this.Ha();){a.push(this.Nb());this.a(";")||this.I()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}},Nb:function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c=this.aa()(null);return function(d){var e=d.scope.get("$datastore").K(a,c);d.scope.i(a,e);if(b){e=e();e.ta=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.Ha();){a.push(this.Mc());this.a(";")||this.I()}this.I();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.qb(d.name,d.b)}}},Mc:function(){var a=this.a().text;this.k(":");var b;if(this.$().text=="{"){this.k("{");b=this.pa();this.k("}")}else b=this.o();return function(){return{name:a,b:b}}}};v.U={};v.M=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.Sc)return ga(e,a);return a};v.prototype={d:function(){var a=this;this.Sb();_.each(this.db,function(b){a.l(b,"",{},function(){this.d(a)})})},sb:function(a){a&&
-this.db.push(a)},Xb:function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!G.prototype.W(c))return false}return true},get:function(a){return v.M(this.q,a)},i:function(a,b){a=a.split(".");for(var c=this.q,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},m:function(a,b){this.eval(a+"="+z(b))},eval:function(a,b){var c=v.U[a];if(!c){var d=new E(a);c=d.pa();d.I();v.U[a]=c}b=b||{};b.scope=this;return c(b)},l:function(a,b,c,d,e){try{var f=this.eval(b,
-c);if(a.w){a.w=false;k(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){W("Eval Widget Error:",g);b=z(g,true);a.w=true;k(a.view).addClass("ng-exception").attr("ng-error",b);e&&e.apply(a,[g,b]);return false}},Kc:function(a,b){var c=v.U[a];if(!c){c=(new E(a)).O();v.U[a]=c}a={scope:this};return c(a)(a,b)},K:function(a){return(new E(a)).Ob()({scope:this})},dc:function(a){this.q.Tc.push(a)},watch:function(a){var b=this;(new E(a)).watch()({scope:this,qb:function(c,
-d){b.rb(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})},rb:function(a,b){var c=this.ra[a];if(!c){c={La:[],o:a};this.ra[a]=c}c.La.push(b)},Sb:function(){var a=this,b=false;q(this.ra,function(c){var d=a.eval(c.o);if(d!==c.c){q(c.La,function(e){e(d,c.c);b=true});c.c=d}});return b}};ka.prototype={vb:function(a){return ba.Lb(a)},N:function(a,b,c,d){var e=this.Jc+this.fc++;ca[e]=function(h){delete m[e];d(200,h)};a={Ld:b,Ad:a,Cd:c};a=this.vb(z(a));b=Math.ceil(a.length/this.la);c=this.url+
-"/$/"+e+"/"+b+"/";for(var f=0;f<b;f++){var g=a.substr(f*this.la,this.la);this.getScript(c+(f+1)+"?h="+g,n)}}};aa.Yc="$DATASET:";aa.prototype={N:K()};la.prototype={N:function(a,b,c,d){var e=this;this.status.wb(c);this.Kb.N(a,b,c,function(){e.status.Mb();try{d.apply(this,arguments)}catch(f){alert(z(f))}e.update()})}};ma.prototype={fetchCurrentUser:function(a){var b=this;this.H.N("GET","/account.json",{},function(c,d){b.Gb=d.Ic;a(d.Ic)})},logout:function(a){var b=this;this.fa.cc(function(){delete b.Gb;
-(a||n)()})},login:function(a){var b=this;this.fa.ka(function(){b.Qb(function(){(a||n)()})})},notAuthorized:function(){this.fa.Sa()}};q({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){b=Ca.number(a,
-b,c);if(b===null&&a!=Math.round(a))return"Value is not a whole number.";return b},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."},url:function(a){if(a.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/))return null;return"URL needs to be in http://server[:port]/path format."},json:function(a){try{O(a);return null}catch(b){return b.toString()}}},function(a,b){Ca[b]=a});na.prototype={Eb:function(a,b){var c,d=a.attr("type").toLowerCase(),
-e=a.attr("name");if(e)e=e.split(":").pop();var f="change",g=true;if(d=="button"||d=="submit"||d=="reset"||d=="image"){c=new Ja(a[0],e);f="click";g=false}else if(d=="text"||d=="textarea"||d=="hidden"||d=="password"){c=new oa(a[0],e);f="keyup change"}else if(d=="checkbox"){c=new pa(a[0],e);f="click"}else if(d=="radio"){c=new sa(a[0],e);f="click"}else if(d=="select-one")c=new qa(a[0],e);else if(d=="select-multiple")c=new ra(a[0],e);else if(d=="file")c=this.Fb(a,e);else throw"Unknown type: "+d;a.data("controller",
-c);var h=b.get("$binder");k(c.view,":input").bind(f,function(){if(c.e(b)){var i=k(c.view).attr("ng-action")||"";b.l(c,i)&&h.d(b)}return g});return c},Fb:function(a){var b="__uploadWidget_"+this.gc++,c=M.template(b);a.after(c);b=this.Aa({data:this.ca+"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",Nd:"transparent"},{yd:"uploadWidgetId="+b,Zc:"always"},b);a.remove();a=new M(c,a[0].name,b,this.ca+"/data/"+this.F);k(b).data("controller",a);return a}};M.dispatchEvent=function(a,b,c){a=y.getElementById(a);
-a=k(a).data("controller");M.prototype["_on_"+b].apply(a,c)};M.template=function(a){return k('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+a+'" /><a></a><span/></span>')};M.prototype={e:function(a){var b=this.view.find("input").attr("checked")?this.value:null;if(this.c===b)return false;else{a.i(this.Ya,b);return true}},d:function(a){if((a=a.get(this.Ya))&&this.value!==a){this.value=a;this.view.find("a").attr("href",this.value.url).text(this.value.text);
-this.view.find("span").text(m.filter.bytes(this.value.size))}this.view.find("input").attr("checked",!!a)}};Q.prototype={e:L(true),d:n};Q.Wb=new Q;var Ja=Q;oa.prototype={e:function(a){var b=this.view.value;if(this.c===b)return false;else{a.m(this.exp,b);this.c=b;return true}},d:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.p;a.m(this.exp,c)}c=c?c:"";if(this.c!=c)this.c=b.value=c;var d=false;b.removeAttribute("ng-error");if(this.zc)d=!(c&&c.length>0);var e=d?"Required Value":
-null;if(!d&&this.O&&c){e=a.Kc(this.O,c);d=!!e}if(this.Ja!==e){this.Ja=d;if(e!==null){b.setAttribute("ng-error",e);a.dc(this)}k(b).toggleClass("ng-validation-error",d)}}};pa.prototype={e:function(a){var b=this.view;b=b.checked?b.value:"";if(this.c===b)return false;else{a.m(this.exp,b);this.c=b;return true}},d:function(a){var b=this.view,c=a.eval(this.exp);if(typeof c==="undefined"){c=this.p;a.m(this.exp,c)}b.checked=b.value==""+c}};qa.prototype={e:function(a){if(this.view.selectedIndex<0)a.m(this.exp,
-null);else{var b=this.view.value;if(this.c===b)return false;else{a.m(this.exp,b);this.c=b;return true}}},d:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.p;a.m(this.exp,c)}if(c!==this.c){b.value=c?c:"";this.c=c}}};ra.prototype={selected:function(){for(var a=[],b=this.view.options,c=0;c<b.length;c++){var d=b[c];d.selected&&a.push(d.value)}return a},e:function(a){var b=this.selected();if(this.c===b)return false;else{a.m(this.exp,b);this.c=b;return true}},d:function(a){var b=
-this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.p;a.m(this.exp,c)}if(c!==this.c){a=b.options;for(b=0;b<a.length;b++){var d=a[b];d.selected=_.include(c,d.value)}this.c=c}}};sa.prototype={e:function(a){var b=this.view;if(this.ja)return false;else{b.checked=true;this.c=a.m(this.exp,this.Ia);return this.ja=true}},d:function(a){var b=this.view,c=a.get(this.exp);if(this.p&&typeof c==="undefined"){c=this.p;a.m(this.exp,c)}if(this.c!=c){this.ja=b.checked=this.Ia==""+c;this.c=c}}};N.Za=function(a){switch(typeof a){case "string":case "boolean":case "number":return D(a);
-case "function":return N.Za(a());case "object":if(a&&a.tagName&&a.nodeName&&a.ownerDocument&&a.removeAttribute)return ha(a);else if(a instanceof m.filter.g){switch(typeof a.html){case "string":case "number":return a.html;case "function":return a.html();case "object":if(a.html&&a.html.tagName&&a.html.nodeName&&a.html.ownerDocument&&a.html.removeAttribute)return ha(a.html);default:break}switch(typeof a.text){case "string":case "number":return D(a.text);case "function":return D(a.text());default:break}}if(a===
-null)return"";return D(z(a,true));default:return""}};N.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=x.J(f);if(g){a.l(this,g,this.Bc,function(h){b.push(N.Za(h))},function(h,i){fa(this.view,i)});if(this.w)return}else b.push(D(f))}fa(this.view,b.join(""))}};ta.prototype={e:n,d:function(a){var b=k(this.view),c=this.ub;if(this.w){this.w=false;b.removeClass("ng-exception").removeAttr("ng-error")}var d=b.is("img");for(var e in c){for(var f=x.Z(c[e]),g=[],h=0;h<
-f.length;h++){var i=x.J(f[h]);if(i)try{var j=a.eval(i,{element:b[0],attrName:e});if(j&&(j.constructor!==array||j.length!==0))g.push(j)}catch(l){this.w=true;W("BindAttrUpdater",l);i=z(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.server")+"/images/blank.gif";b.attr(e,f)}}};ua.prototype={e:n,d:function(a){a.l(this,this.exp)}};va.prototype={e:n,d:function(a){a.l(this,this.exp,{},function(b){var c=
-k(this.view);Y(b)?c.hide():c.show()})}};wa.prototype={e:n,d:function(a){a.l(this,this.exp,{},function(b){var c=k(this.view);Y(b)?c.show():c.hide()})}};xa.prototype={e:n,d:function(a){a.l(this,this.exp,{},function(b){if(b!==null&&b!==undefined)this.view.className=b})}};ya.prototype={e:n,d:function(a){a.l(this,this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,c%2===1)})}};za.prototype={e:n,d:function(a){a.l(this,this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,
-c%2===0)})}};Aa.prototype={e:n,d:function(a){a.l(this,this.exp,{},function(b){k(this.view).attr("style","").css(b)})}};Ba.prototype={e:n,d:function(a){a.l(this,this.X,{},function(b){var c=this;if(!b){b=[];a.Xb(this.X)&&a.i(this.X,b)}var d=b.length,e=this.children.length,f=this.view,g=0,h=null,i=this.$b,j=this.Lc,l=0;q(b,function(C,s){if(l<e){h=c.children[l];h.scope.i(j,C)}else{var t=new v(a.q,c.prefix+j+" in "+c.X+"["+l+"]");t.i("$index",l);i&&t.i(i,s);t.i(j,C);h={scope:t,element:c.template(t,c.prefix,
-l)};f.after(h.element);c.children.push(h)}f=h.element;C=(new Date).getTime();h.scope.d();g+=(new Date).getTime()-C;l++});for(b=e;b>d;--b){var p=this.children.pop().element[0];p.parentNode.removeChild(p)}if(h&&h.element[0].nodeName==="OPTION")if(d=k(h.element[0].parentNode).data("controller")){d.c=undefined;d.d(a)}})}};B.wa="mouseleave mouseout click dblclick keypress keyup";B.sc=function(){B.na();var a=k(this);a.bind(B.wa,B.na);var b=a.position(),c=y.documentElement,d=(self.innerWidth||c&&c.clientWidth||
-y.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};B.na=function(){k("#ng-callout").unbind(B.wa,
-B.na).remove();return true};B.prototype={bind:function(){this.B.find(".ng-validation-error,.ng-exception").live("mouseover",B.sc)}};U.ib='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';U.prototype={wb:function(){this.ba===0&&this.Na.show();this.ba++},Mb:function(){this.ba--;this.ba===0&&this.Na.hide("fold")}}})(window,document);
+function J(){return function(){}}function N(q){return function(){return q}}
+(function(q,y){function n(){}function K(a,b,c){var d=q.console;switch(arguments.length){case 1:d.log(a);break;case 2:d.log(a,b);break;default:d.log(a,b,c);break}}function W(a,b,c){var d=q.console;switch(arguments.length){case 1:d.error(a);break;case 2:d.error(a,b);break;default:d.error(a,b,c);break}}function da(a,b){var c=y.createElement("div");c.className=a;for(var d=a="",e=0;e<b.length;e++){var f=b[e];a+=d+(typeof f=="string"?f:w(f));d=" "}c.appendChild(y.createTextNode(a));O.appendChild(c)}function ea(a){switch(a.nodeName){case "OPTION":case "PRE":case "TITLE":return true;
+default:return false}}function fa(a,b){if(ea(a))if(X)a.innerText=b;else a.textContent=b;else a.innerHTML=b}function C(a){if(!a||!a.replace)return a;return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ca(a){if(!a||!a.replace)return a;return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;")}function Da(a,b){if(!a)throw"Missing this";if(!_.isFunction(b))throw"Missing function";return function(){return b.apply(a,arguments)}}function ga(a){var b=y.createElement("div");
+b.appendChild(a);var c=b.innerHTML;b.removeChild(a);return c}function Y(a){var b=(""+a).toLowerCase();if(b=="f"||b=="0"||b=="false"||b=="no")a=false;return!!a}function Z(a,b){for(var c in a){var d=b[c],e=typeof d;if(e=="undefined")b[c]=P(w(a[c]));else e=="object"&&d.constructor!=array&&c.substring(0,1)!="$"&&Z(a[c],d)}}function ha(a){this.location=a;this.delay=25;this.setTimeout=function(b,c){q.setTimeout(b,c)};this.Wb=function(b){return b};this.I=a.href}function Ea(){K("Angular.configureJQueryPlugins()");
+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")||Q.Rb}}function Fa(a){if(a.hd=="console"&&!O){O=y.createElement("div");O.id="ng-console";y.getElementsByTagName("body")[0].appendChild(O);K=function(){da("ng-console-info",arguments)};console.error=function(){da("ng-console-error",arguments)}}}function ia(a,b){var c={};o(b,function(d,e){c[e]=_(d).bind(a)});return c}function Ga(a,
+b){var c=new ja(b.server,b.database),d=new x(a[0],c,b.location,b);c=new R(a.find("body"),b.oa);var e=b.fa=="$MEMORY"?new $(this.window):new ka(b.oa,k.getScript);e=new la(e,new S(k(a.body)),function(){d.d()});var f=new ma(e,c),g="/data/"+b.fa,h=new T(function(l,p){e.K("POST",g,l,p)},f,d.anchor);d.$a.push(function(){h.ga()});var i=new v({$anchor:d.anchor,$updateView:_(d.d).bind(d),$config:b,$console:q.console,$datastore:ia(h,{load:h.load,loadMany:h.ja,loadOrCreate:h.Ja,loadAll:h.Ia,save:h.save,remove:h.remove,
+flush:h.ga,query:h.Ua,entity:h.C,entities:h.entities,documentCountsByUser:h.Fb,userDocumentIdsByEntity:h.yc,join:h.join}),$save:function(l){h.sc(i.p,l,d.anchor)},$window:q,$uid:function(){return""+(new Date).getTime()},$users:f},"ROOT");a.data("scope",i);d.C(i);d.compile();c.bind();(new A(a)).bind();var j=_(ia(i,{updateView:i.d,set:i.h,get:i.get,eval:i.eval})).extend({init:function(){b.location.listen(_(d.mc).bind(d));d.Ra();d.Lb();i.d();return j},element:a[0],config:b});return j}function G(a,b,c){var d=
+_.last(b);o(c,function(e){d[e]=_[e]});m[a]=m[a]||{};o(b,function(e){U(m[a],e)})}function x(a,b,c,d){this.B=a;this.location=c;this.anchor={};this.Dc=b;this.zb=d||{};this.$a=[]}function R(a,b){this.document=a;this.aa=b;this.window=q;this.D=[]}function T(a,b,c){this.post=a;this.bb=b;this.z={M:[]};this.anchor=c;this.P=[]}function w(a,b){var c=[];aa(c,a,b?"\n ":null,_([]));return c.join("")}function P(a){try{var b=new D(a,true),c=b.Z();b.G();return c()}catch(d){W("fromJson error: ",a,d);throw d;}}function aa(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"):aa(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(":");aa(a,f,g,d);e=true}}catch(l){}}a.push("}")}typeof b=="object"&&d.pop()}function E(a,b){this.$$entity=a;this.O(b||{});this.N=a.title;this.fb()}function F(a,
+b){this.text=a;this.Db=b?20:-1;this.i=[];this.index=0}function D(a,b){this.text=a;this.i=(new F(a,b)).parse();this.index=0}function v(a,b){this.cb=[];this.qa={};this.name=b;a=a||{};function c(){}c.prototype=a;this.p=new c;this.p.Jc=a;if(b=="ROOT")this.p.Kc=this.p}function ka(a,b){this.url=a;this.$b=0;this.getScript=b;this.zc="_"+(""+Math.random()).substr(2)+"_";this.ka=1800}function $(a){this.frame=a}function la(a,b,c){this.Eb=a;this.update=c;this.status=b}function ma(a,b){this.oa=a;this.da=b}function ja(a,
+b){this.ac=0;this.aa=a;this.fa=b;this.za=q.zd?swfobject.za:function(){alert("ERROR: swfobject not loaded!")}}function L(a,b,c,d){this.view=a;this.Cd=c;this.Xa=b;this.Pc=d+"/_attachments";this.value=null;this.c=undefined}function Q(a){this.view=a}function na(a,b){this.view=a;this.exp=b;this.L=a.getAttribute("ng-validate");this.rc=typeof a.attributes["ng-required"]!="undefined";this.Ga=null;this.c=undefined;this.o=a.value;a.getAttribute("ng-widget")==="datepicker"&&k(a).gd()}function oa(a,b){this.view=
+a;this.exp=b;this.c=undefined;this.o=a.checked?a.value:""}function pa(a,b){this.view=a;this.exp=b;this.c=undefined;this.o=a.value}function qa(a,b){this.view=a;this.exp=b;this.c=undefined;this.o=this.selected()}function ra(a,b){this.view=a;this.exp=b;this.c=this.ia=undefined;this.Fa=a.value;this.o=a.checked?a.value:null}function M(a,b){this.view=a;this.exp=x.X(b);this.u=false;this.tc={element:a}}function sa(a,b){this.view=a;this.tb=b}function ta(a,b){this.view=a;this.exp=b;this.u=false}function ua(a,
+b){this.view=a;this.exp=b}function va(a,b){this.view=a;this.exp=b}function wa(a,b){this.view=a;this.exp=b}function xa(a,b){this.view=a;this.exp=b}function ya(a,b){this.view=a;this.exp=b}function za(a,b){this.view=a;this.exp=b}function Aa(a,b,c,d){this.view=a;this.template=c;this.prefix=d;this.children=[];a=b.match(/^\s*(.+)\s+in\s+(.*)\s*$/);if(!a)throw"Expected ng-repeat in form of 'item in collection' but got '"+b+"'.";b=a[1];this.V=a[2];a=b.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);if(!a)throw"'item' in 'item in collection' should be identifier or (key, value) but get '"+
+b+"'.";this.Bc=a[3]||a[1];this.Vb=a[2]}function A(a){this.B=a}function S(a){this.Ka=a.append(S.hb).find("#ng-loading");this.$=0}var ba={s:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",Gb:function(a){var b="",c,d,e,f,g,h,i=0;for(a=ba.ob(a);i<a.length;){c=a.charCodeAt(i++);d=a.charCodeAt(i++);e=a.charCodeAt(i++);f=c>>2;c=(c&3)<<4|d>>4;g=(d&15)<<2|e>>6;h=e&63;if(isNaN(d))g=h=64;else if(isNaN(e))h=64;b=b+this.s.charAt(f)+this.s.charAt(c)+this.s.charAt(g)+this.s.charAt(h)}return b},
+jd:function(a){var b="",c,d,e,f,g,h=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h<a.length;){c=this.s.indexOf(a.charAt(h++));d=this.s.indexOf(a.charAt(h++));f=this.s.indexOf(a.charAt(h++));g=this.s.indexOf(a.charAt(h++));c=c<<2|d>>4;d=(d&15)<<4|f>>2;e=(f&3)<<6|g;b+=String.fromCharCode(c);if(f!=64)b+=String.fromCharCode(d);if(g!=64)b+=String.fromCharCode(e)}return b=ba.nb(b)},ob:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d<128)b+=String.fromCharCode(d);
+else{if(d>127&&d<2048)b+=String.fromCharCode(d>>6|192);else{b+=String.fromCharCode(d>>12|224);b+=String.fromCharCode(d>>6&63|128)}b+=String.fromCharCode(d&63|128)}}return b},nb:function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;){d=a.charCodeAt(c);if(d<128){b+=String.fromCharCode(d);c++}else if(d>191&&d<224){c2=a.charCodeAt(c+1);b+=String.fromCharCode((d&31)<<6|c2&63);c+=2}else{c2=a.charCodeAt(c+1);c3=a.charCodeAt(c+2);b+=String.fromCharCode((d&15)<<12|(c2&63)<<6|c3&63);c+=3}}return b}};if(typeof y.getAttribute==
+"undefined")y.getAttribute=J();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};q.console||(q.console={log:n,error:n});var O,o=_.each,U=_.extend,k=q.jQuery,X=k.browser.msie,m=q.angular||(q.angular={}),Ba=m.validator||(m.validator={}),r=m.filter||(m.filter={}),ca=m.callbacks||(m.callbacks=
+{});m.alert||(m.alert=function(){K(arguments);q.alert.apply(q,arguments)});ha.prototype={watch:function(){var a=this;function b(){if(a.I!==a.location.href){var c=a.location.hash.match(/^#\$iframe_notify=(.*)$/);if(c){a.I.match(/#/)||(a.I+="#");a.location.href=a.I;c="_iframe_notify_"+c[1];var d=ca[c];delete ca[c];try{(d||n)()}catch(e){alert(e)}}else{a.Wb(a.location.href);a.I=a.location.href}}a.setTimeout(b,a.delay)}b();return this},h:function(a){var b=this.location.href;b.match(/#/)||(b+="#");if(b!=
+a)this.location.href=a;this.md=a},get:function(){return q.location.href}};m.startUrlWatcher=function(){return(new ha(q.location)).watch()};m.compile=function(a,b){b=_({server:"",location:{get:n,set:n,listen:n}}).extend(b||{});Fa(b);Ea();return Ga(k(a),b)};var H={typeOf:function(a){if(a===null)return"null";var b=typeof a;if(b=="object"){if(a instanceof Array)return"array";if(a instanceof Date)return"date";if(a.nodeType==1)return"element"}return b}},V={},Ha={includeIf:function(a,b,c){var d=_.indexOf(a,
+b);if(c)d==-1&&a.push(b);else a.splice(d,1);return a},sum:function(a,b){b=m.Function.compile(b);for(var c=0,d=0;d<a.length;d++){var e=1*b(a[d]);isNaN(e)||(c+=e)}return c},remove:function(a,b){var c=_.indexOf(a,b);c>=0&&a.splice(c,1);return b},find:function(a,b,c){if(b){var d=m.Function.compile(b);_.detect(a,function(e){if(d(e)){c=e;return true}});return c}},findById:function(a,b){return m.Lc.find(a,function(c){return c.w==b},null)},filter:function(a,b){var c=[];c.wb=function(j){for(var l=0;l<c.length;l++)if(!c[l](j))return false;
+return true};var d=v.J;function e(j,l){if(l.charAt(0)==="!")return!e(j,l.substr(1));switch(typeof j){case "boolean":case "number":case "string":return(""+j).toLowerCase().indexOf(l)>-1;case "object":for(var p in j)if(p.charAt(0)!=="$"&&e(j[p],l))return true;return false;case "array":for(p=0;p<j.length;p++)if(e(j[p],l))return true;return false;default:return false}}switch(typeof b){case "boolean":case "number":case "string":b={Fc:b};case "object":for(var f in b)f=="$"?function(){var j=(""+b[f]).toLowerCase();
+j&&c.push(function(l){return e(l,j)})}():function(){var j=f,l=(""+b[f]).toLowerCase();l&&c.push(function(p){return e(d(p,j),l)})}();break;case "function":c.push(b);break;default:return a}for(var g=[],h=0;h<a.length;h++){var i=a[h];c.wb(i)&&g.push(i)}return g},add:function(a,b){a.push(_.isUndefined(b)?{}:b);return a},count:function(a,b){if(!b)return a.length;var c=m.Function.compile(b);return _.reduce(a,0,function(d,e){return d+(c(e)?1:0)})},orderBy:function(a,b,c){function d(f,g){return Y(g)?function(h,
+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}Z(c,d);return a}},Ia={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"}},Ka={compile:function(a){if(_.isFunction(a))return a;else if(a){var b=new v;return function(c){b.p=c;return b.eval(a)}}else return function(c){return c}}};
+G("Global",[H],["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);G("Collection",[H,V],["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);G("Array",[H,V,Ha],["first","last","compact","flatten","without","uniq","intersect","zip","indexOf","lastIndexOf"]);G("Object",[H,V,{}],["keys","values"]);G("String",[H,Ia],[]);G("Date",[H,Ja],[]);G("Function",[H,V,Ka],["bind","bindAll",
+"delay","defer","wrap","compose"]);x.X=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};x.Qb=function(a){a=x.X(a);return a.length>1||x.H(a[0])!==null};x.H=function(a){return(a=a.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?a[1]:null};x.prototype={nc:function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,
+e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b},Ra:function(){var a=this,b=this.location.get()||"",c=b.indexOf("#");if(!(c<0)){b=this.nc(b.substring(c+1));o(a.anchor,function(d,e){delete a.anchor[e]});o(b,function(d,e){a.anchor[e]=d})}},mc:function(){this.Ra();this.d()},xc: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];else{a+=b+
+encodeURIComponent(c);if(d!==true)a+="="+encodeURIComponent(d);b="&"}}this.location.h(a);return a},d:function(){(new Date).getTime();var a=k(this.B).scope();a.h("$invalidWidgets",[]);a.d();(new Date).getTime();this.xc();_.each(this.$a,function(b){b()})},R:function(a){var b=k(this.B),c=b.find(a);if(b.is(a))c=c.andSelf();return c},Lb:function(){this.R("[ng-init]").each(function(){var a=k(this),b=a.scope();try{b.eval(a.attr("ng-init"))}catch(c){alert("EVAL ERROR:\n"+a.attr("ng-init")+"\n"+w(c,true))}})},
+C:function(a){this.R("[ng-entity]").attr("ng-watch",function(){try{var b=k(this);return a.C(b.attr("ng-entity"))+(b.attr("ng-watch")||"")}catch(c){alert(c)}})},compile:function(){var a=k(this.B);if(this.zb.Qc){var b=this.R(":submit").not("[ng-action]");b.attr("ng-action","$save()");b.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.Sa(this.B)(this.B,a.scope(),"");this.R("a[ng-action]").live("click",function(){var c=k(this),d=c.scope();try{d.eval(c.attr("ng-action"));
+c.removeAttr("ng-error");c.removeClass("ng-exception")}catch(e){c.addClass("ng-exception");c.attr("ng-error",w(e,true))}d.get("$updateView")();return false})},wc:function(a,b,c){b=b.concat();var d=b.pop(),e=x.X(a.nodeValue);if(e.length>1||x.H(e[0])){var f=a.parentNode;if(ea(f)){f.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,b:function(l){return new M(l,l.getAttribute("ng-bind-template"))}})}else for(var g=0;g<e.length;g++){var h=e[g],i=x.H(h),j;if(i){j=y.createElement("span");k(j).attr("ng-bind",
+i);g===0&&c.push({path:b.concat(d+g),b:this.Pa})}else if(X&&h.charAt(0)==" "){j=y.createElement("span");j.innerHTML="&nbsp;"+h.substring(1)}else j=y.createTextNode(h);f.insertBefore(j,a)}f.removeChild(a)}},Sa:function(a){var b=[];this.Ta(a,[],b);return function(c,d,e){for(var f=b.length,g=0;g<f;g++){for(var h=b[g],i=c,j=h.path,l=0;l<j.length;l++)i=i.childNodes[j[l]];try{d.rb(h.b(i,d,e))}catch(p){alert(p)}}}},Ta:function(a,b,c){var d=a.nodeType;if(d==Node.TEXT_NODE)this.wc(a,b,c);else if(!(d!=Node.ELEMENT_NODE&&
+d!=Node.DOCUMENT_NODE))if(a.getAttribute){d=a.getAttribute("ng-non-bindable");if(!(d||d==="")){if(d=a.attributes){var e=a.getAttribute("ng-bind-attr");a.removeAttribute("ng-bind-attr");e=e?P(e):{};for(var f=d.length,g=0;g<f;g++){var h=d[g],i=h.name;h=X&&i=="href"?decodeURI(a.getAttribute(i,2)):h.value;if(x.Qb(h))e[i]=h}d=w(e);d.length>2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||K(a);var j=a.getAttribute("ng-repeat");if(j){a.removeAttribute("ng-repeat");var l=this.Sa(a);d=y.createComment("ng-repeat: "+
+j);e=a.parentNode;e.insertBefore(d,a);e.removeChild(a);function p(s,t,z){var I=k(a).clone();I.css("display","");I.attr("ng-repeat-index",""+z);I.data("scope",s);l(I[0],s,t+z+":");return I}c.push({path:b,b:function(s,t,z){return new Aa(k(s),j,p,z)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,b:this.fc});a.getAttribute("ng-bind")&&c.push({path:b,b:this.Pa});a.getAttribute("ng-bind-attr")&&c.push({path:b,b:this.bc});a.getAttribute("ng-hide")&&c.push({path:b,b:this.gc});a.getAttribute("ng-show")&&
+c.push({path:b,b:this.hc});a.getAttribute("ng-class")&&c.push({path:b,b:this.cc});a.getAttribute("ng-class-odd")&&c.push({path:b,b:this.ec});a.getAttribute("ng-class-even")&&c.push({path:b,b:this.dc});a.getAttribute("ng-style")&&c.push({path:b,b:this.ic});a.getAttribute("ng-watch")&&c.push({path:b,b:this.jc});d=a.nodeName;if(d=="INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var B=this;c.push({path:b,b:function(s,t,z){s.name=z+s.name.split(":").pop();return B.Dc.Ab(k(s),t)}})}if(d=="OPTION")if(!k("<select/>").append(k(a).clone()).html().match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi))a.value=
+a.text;d=a.childNodes;for(e=0;e<d.length;e++)this.Ta(d[e],b.concat(e),c)}}}},fc:function(a){return new ta(a,a.getAttribute("ng-eval"))},Pa:function(a){return new M(a,"{{"+a.getAttribute("ng-bind")+"}}")},bc:function(a){return new sa(a,P(a.getAttribute("ng-bind-attr")))},gc:function(a){return new ua(a,a.getAttribute("ng-hide"))},hc:function(a){return new va(a,a.getAttribute("ng-show"))},cc:function(a){return new wa(a,a.getAttribute("ng-class"))},dc:function(a){return new xa(a,a.getAttribute("ng-class-even"))},
+ec:function(a){return new ya(a,a.getAttribute("ng-class-odd"))},ic:function(a){return new za(a,a.getAttribute("ng-style"))},jc:function(a,b){b.watch(a.getAttribute("ng-watch"))}};R.Mc='<div><div class="ui-widget-overlay"></div><div id="ng-login" ng-non-bindable="true"><div class="ng-login-container"></div></div></div>';R.jb='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';R.prototype={bind:J(),Na:function(a){this.D.push(a);this.D.length==1&&
+this.Ba("/user_session/new.mini?return_url="+encodeURIComponent(this.ab()))},Xb:function(a){this.D.push(a);this.D.length==1&&this.Ba("/user_session/do_destroy.mini")},ab:function(){return this.window.location.href.split("#")[0]},Ba:function(a){var b=this,c=(new Date).getTime(),d=this.ab();d+="#$iframe_notify="+c;var e=k('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+d+'" src="'+this.aa+a+'" width="500" height="330"/></div>');this.document.append(e);e.Aa({height:363,width:500,wd:false,
+Zb:true,title:'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'});callbacks["_iframe_notify_"+c]=function(){e.Aa("destroy");e.remove();o(b.D,function(f){f()});b.D=[]}},Qa:function(){if(!this.Da){this.Da=k(R.jb);this.Da.Aa({Vc:true,height:70,Zb:true})}}};T.kb=U(J(),{all:function(){return[]},query:function(){return[]},load:function(){return{}},title:undefined});T.prototype={Q:function(a){if(!a instanceof E)throw"Parameter must be an instance of Entity! "+w(a);var b=
+a.N+"/"+a.w,c=this.z[b];if(c)E.ea(a,c);else c=this.z[b]=a;return c},load:function(a,b,c,d){if(b&&b!=="*"){var e=this;this.A(["GET",a.N+"/"+b],function(f){a.O(f);a.fb();f=a.Gc(a);e.Q(f);(c||n)(a)},d)}return a},ja:function(a,b,c){var d=this,e=[],f=0;o(b,function(g){e.push(d.load(a(),g,function(){f++;if(f==b.length)(c||n)(e)}))});return e},Ja:function(a,b,c){return this.load(a,b,c,function(d){if(d.ba==404){a.w=b;(c||n)(a)}else throw d;})},Ia:function(a,b){var c=this,d=[];d.ra=function(e){return e.N==
+a.title};this.z.M.push(d);this.A(["GET",a.title],function(e){for(var f=0;f<e.length;f++){var g=a();g.O(e[f]);d.push(c.Q(g))}(b||n)(d)});return d},save:function(a,b){var c=this,d={};a.gb(d);this.A(["POST","",d],function(e){a.O(e);var f=c.Q(a);_.each(c.z.M,function(g){g.ra(a)&&m.Array.includeIf(g,f,true)});if(a.sa)c.anchor[a.sa]=a.w;b&&b(a)})},remove:function(a,b){var c=this,d={};a.gb(d);this.A(["DELETE","",d],function(e){delete c.z[a.N+"/"+a.w];_.each(c.z.M,function(f){for(var g=0;g<f.length;g++)f[g].w==
+a.w&&f.splice(g,1)});(b||n)(e)})},A:function(a,b,c){a.db=b;a.eb=c||function(d){throw d;};this.P.push(a)},ga:function(){function a(d,e){K("RESPONSE["+d+"]: ",e);if(e.ba==401)b.bb.Na(function(){b.post(c,a)});else if(e.ba)alert(w(e));else for(d=0;d<e.length;d++){var f=e[d],g=c[d],h=f.ba;if(h)h==403?b.bb.Qa():g.eb(f);else g.db(f)}}if(this.P.length!==0){var b=this,c=this.P;this.P=[];K("REQUEST:",c);this.post(c,a)}},sc:function(a,b){function c(){d--;d===0&&b&&b()}var d=1;for(var e in a){var f=a[e];if(f&&
+f.ta==E.prototype.ta){d++;f.ta(c)}}c()},Ua:function(a,b,c,d){var e=this,f=[];f.ra=N(false);this.z.M.push(f);this.A(["GET",a.title+"/"+b+"="+c],function(g){for(var h=0;h<g.length;h++){var i=(new a).O(g[h]);f.push(e.Q(i))}d&&d(f)});return f},entities:function(a){var b=[],c=this;this.A(["GET","$entities"],function(d){for(var e in d)b.push(c.C(e));b.sort(function(f,g){return f.title>g.title?1:-1});a&&a(b)});return b},Fb:function(){var a={};this.post([["GET","$users"]],function(b,c){o(c[0],function(d,
+e){a[e]=d})});return a},yc:function(a){var b={};this.post([["GET","$users/"+a]],function(c,d){o(d[0],function(e,f){b[f]=e})});return b},C:function(a,b){if(!a)return T.kb;var c=this,d=U(function(e){return new E(d,e)},{title:a,$$factory:true,datastore:this,defaults:b||{},load:function(e,f){return c.load(d(),e,f)},loadMany:function(e,f){return c.ja(d,e,f)},loadOrCreate:function(e,f){return c.Ja(d(),e,f)},all:function(e){return c.Ia(d,e)},query:function(e,f,g){return c.Ua(d,e,f,g)},properties:function(e){c.A(["GET",
+a+"/$properties"],e)}});return d},join:function(a){function b(){throw"Joined entities can not be instantiated into a document.";}var c=_(a).Wc().map(function(d,e){return e}).sortBy(function(d){var e=[];do{if(_(e).include(d))throw"Infinite loop in join: "+e.join(" -> ");e.push(d);if(!a[d])throw _("Named entity '<%=name%>' is undefined.").template({name:d});d=a[d].W?a[d].W.substring(0,a[d].W.indexOf(".")):undefined}while(d);return e.length}).value();if(_(c).select(function(d){return a[d].W}).length!=
+c.length-1)throw"Exactly one entity needs to be primary.";b.query=function(d,e){var f=[],g=d?d.substring(0,d.indexOf(".")):undefined;if(g!=c[0])throw _("Named entity '<%=name%>' is not a primary entity.").template({name:g});var h=1;a[g].join.query(d.substring(d.indexOf(".")+1),e,function(i){var j=c[h++],l=a[j],p=l.W,B={};_(i).each(function(s){var t={};f.push(t);t[g]=s;s=v.J(t,p);B[s]=s});l.join.ja(_.toArray(B),function(s){var t={};_(s).each(function(z){t[z.w]=z});_(f).each(function(z){var I=v.J(z,
+p);z[j]=t[I]})})});return f};return b}};r.g=function(a){if(a)for(var b in a)this[b]=a[b]};r.g.get=function(a,b){b=b||"text";switch(typeof a){case "string":return b=="text"?a:undefined;case "object":if(a&&typeof a[b]!=="undefined")return a[b];return;default:return a}};var u;o({currency:function(a){k(this.element).toggleClass("ng-format-negative",a<0);return"$"+r.number.apply(this,[a,2])},number:function(a,b){if(isNaN(a)||!isFinite(a))return"";b=typeof b=="undefined"?2:b;var c=a<0;a=Math.abs(a);var d=
+Math.pow(10,b);a=""+Math.round(a*d);var e=a.substring(0,a.length-b);e=e||"0";d=a.substring(a.length-b);a=c?"-":"";for(c=0;c<e.length;c++){if((e.length-c)%3===0&&c!==0)a+=",";a+=e.charAt(c)}if(b>0){for(c=d.length;c<b;c++)d+="0";a+="."+d.substring(0,b)}return a},date:J(),json:function(a){k(this.element).addClass("ng-monospace");return w(a,true)},trackPackage:function(){var a=[{name:"UPS",url:"http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&track.x=0&track.y=0&InquiryNumber1=",
+na:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",na:[/^96\d{10}?$/i,/^96\d{17}?$/i,/^96\d{20}?$/i,/^\d{15}$/i,/^\d{12}$/i]},{name:"USPS",url:"http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=",na:[/^(91\d{20})$/i,/^(91\d{18})$/i]}];return function(b,c){b=b.replace(/^ */,"").replace(/ *$/,"");var d=b.replace(/ /g,""),e;o(a,function(f){o(f.na,function(g){if(g.test(d)){g=f.name+": "+b;var h=f.url+b;e=new r.g({text:g,url:h,html:'<a href="'+
+Ca(h)+'">'+g+"</a>",Ad:b});_.breakLoop()}});e&&_.breakLoop()});return e?e:b?c||new r.g({text:b+" is not recognized"}):null}}(),link:function(a,b){b=b||r.g.get(a);var c=r.g.get(a,"url")||r.g.get(a);if(c){if(m.L.ld(c)===null)c="mailto:"+c;a='<a href="'+C(c)+'">'+b+"</a>";return new r.g({text:b,url:c,html:a})}return a},bytes:function(){var a=["bytes","KB","MB","GB","TB","PB"];return function(b){if(b===null)return"";for(var c=0;b>1E3;){b/=1024;c++}b=""+b;var d=b.indexOf(".");if(d>-1&&d+2<b.length)b=b.substring(0,
+d+2);return b+" "+a[c]}}(),image:function(a,b,c){if(a&&a.url){var d="";if(b)d=' style="max-width: '+b+"px; max-height: "+(c||b)+'px;"';return new r.g({url:a.url,text:a.url,html:'<img src="'+a.url+'"'+d+"/>"})}return null},lowercase:function(a){return(a=r.g.get(a))?(""+a).toLowerCase():a},uppercase:function(a){return(a=r.g.get(a))?(""+a).toUpperCase():a},linecount:function(a){a=r.g.get(a);if(a===""||!a)return 1;return a.split(/\n|\f/).length},"if":function(a,b){return b?a:undefined},unless:function(a,
+b){return b?undefined:a},googleChartApi:U(function(a,b,c,d){b=b||{};a={xb:a,Xc:u.yb(b,"color"),cd:u.title(b),Zc:u.yb(b,"label"),Yc:u.values(b),$c:"bg,s,FFFFFF00"};if(_.isArray(b.Ec)){a.ed="x";a.dd="0:|"+b.Ec.join("|")}return u.encode(a,c,d)},{values:function(a){var b=[];o(a.uc||[],function(c){var d=[];o(c.values||[],function(e){d.push(e)});b.push(d.join(","))});a=b.join("|");return a===""?null:"t:"+a},title:function(a){var b=[];a=a.title||[];o(_.isArray(a)?a:[a],function(c){b.push(encodeURIComponent(c))});
+return b.join("|")},collect:function(a,b){var c=[],d=0;o(a.uc||[],function(e){var f=[];e=e[b]||[];o(_.isArray(e)?e:[e],function(g){f.push(encodeURIComponent(g));d++});c.push(f.join("|"))});return d?c.join(","):null},encode:function(a,b,c){b=b||200;c=c||b;var d="http://chart.apis.google.com/chart?",e=[];a.bd=b+"x"+c;o(a,function(f,g){f&&e.push(g+"="+f)});e.sort();d+=e.join("&");return new r.g({url:d,html:'<img width="'+b+'" height="'+c+'" src="'+d+'"/>'})}}),qrcode:function(a,b,c){return u.encode({xb:"qr",
+ad:encodeURIComponent(a)},b,c)},chart:{td:function(a,b,c){return u("p",a,b,c)},ud:function(a,b,c){return u("p3",a,b,c)},vd:function(a,b,c){return u("pc",a,b,c)},Sc:function(a,b,c){return u("bhs",a,b,c)},Rc:function(a,b,c){return u("bhg",a,b,c)},Uc:function(a,b,c){return u("bvs",a,b,c)},Tc:function(a,b,c){return u("bvg",a,b,c)},qd:function(a,b,c){return u("lc",a,b,c)},yd:function(a,b,c){return u("ls",a,b,c)},xd:function(a,b,c){return u("s",a,b,c)}},html:function(a){return new r.g({html:a})},linky:function(a){if(!a)return a;
+for(var b=/(ftp|http|https|mailto):\/\/([^\(\)|\s]+)/,c,d=a,e=[];c=d.match(b);){c=c[0].replace(/[\.\;\,\(\)\{\}\<\>]$/,"");var f=d.indexOf(c);e.push(C(d.substr(0,f)));e.push('<a href="'+c+'">');e.push(c);e.push("</a>");d=d.substring(f+c.length)}e.push(C(d));return new r.g({text:a,html:e.join("")})}},function(a,b){r[b]=a});u=r.googleChartApi;array=[].constructor;m.toJson=w;m.fromJson=P;E.ea=function(a,b){if(!(a===b||!a||!b)){var c=function(e,f,g){return g.substring(0,2)!=="$$"&&typeof e[g]!=="function"&&
+typeof f[g]!=="function"};for(var d in b)c(a,b,d)&&delete b[d];for(d in a)if(c(a,b,d))b[d]=a[d]}};E.prototype={$migrate:function(){Z(this.$$entity.kd,this);return this},$save:function(a){this.$$entity.Cb.save(this,a===true?undefined:a);a===true&&this.$$entity.Cb.ga();return this},$loadFrom:function(a){E.ea(a,this);return this},$saveTo:function(a){E.ea(this,a);return this}};F.ua={"null":N(null),"true":N(true),"false":N(false),"+":function(a,b,c){return(b||0)+(c||0)},"-":function(a,b,c){return(b||0)-
+(c||0)},"*":function(a,b,c){return b*c},"/":function(a,b,c){return b/c},"%":function(a,b,c){return b%c},"^":function(a,b,c){return b^c},"=":function(a,b,c){return a.scope.h(b,c)},"==":function(a,b,c){return b==c},"!=":function(a,b,c){return b!=c},"<":function(a,b,c){return b<c},">":function(a,b,c){return b>c},"<=":function(a,b,c){return b<=c},">=":function(a,b,c){return b>=c},"&&":function(a,b,c){return b&&c},"||":function(a,b,c){return b||c},"&":function(a,b,c){return b&c},"|":function(a,b,c){return c(a,
+b)},"!":function(a,b){return!b}};F.ib={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'};F.prototype={F:function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false},parse:function(){for(var a=this.i,b=F.ua,c=true;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=='"'||d=="'"){this.qc(d);c=true}else if(d=="("||d=="["){a.push({index:this.index,text:d});this.index++}else if(d=="{"){c=this.F();if(c==":"||c=="("){a.push({index:this.index,text:d+c});
+this.index++}else a.push({index:this.index,text:d});this.index++;c=true}else if(d==")"||d=="]"||d=="}"){a.push({index:this.index,text:d});this.index++;c=false}else if(d==":"||d=="."||d==","||d==";"){a.push({index:this.index,text:d});this.index++;c=true}else if(c&&d=="/"){this.pc();c=false}else if(this.ha(d)){this.oc();c=false}else if(this.U(d)){this.Va();c=false}else if(this.Tb(d))this.index++;else{c=d+this.F();var e=b[d],f=b[c];if(f){a.push({index:this.index,text:c,b:f});this.index+=2}else if(e){a.push({index:this.index,
+text:d,b:e});this.index+=1}else throw"Lexer Error: Unexpected next character ["+this.text.substring(this.index)+"] in expression '"+this.text+"' at column '"+(this.index+1)+"'.";c=true}}return a},ha:function(a){return"0"<=a&&a<="9"},Tb:function(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"},U:function(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"},oc:function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.ha(c))a+=
+c;else break;this.index++}a=1*a;this.i.push({index:b,text:a,b:function(){return a}})},Va:function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.U(c)||this.ha(c))a+=c;else break;this.index++}c=F.ua[a];if(!c){c=function(d){return d.scope.get(a)};c.T=a}this.i.push({index:b,text:a,b:c})},qc:function(a){var b=this.index,c=this.Db;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=F.ib[f];d+=e?e:f}e=false}else if(f=="\\")e=true;else if(f==a){this.index++;this.i.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+"'.";},pc: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.U(this.text.charAt(this.index))){this.Va();c=this.i.pop().text}var e=new RegExp(b,c);this.i.push({index:a,text:b,od: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.lb=N(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)+"'.";},Y:function(){if(this.i.length===0)throw"Unexpected end of expression: "+this.text;return this.i[0]},F:function(a,b,c,d){var e=this.i;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.F(a,b,c,d)){this.i.shift();return this.fd=a}return false},j:function(a){if(!this.a(a)){var b=this.F();throw"Expecting '"+
+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}},mb:function(a,b){return function(c){return a(c,b(c))}},q:function(a,b,c){return function(d){return b(d,a(d),c(d))}},Ea:function(){return this.i.length>0},G:function(){if(this.i.length!==0)throw"Did not understand '"+this.text.substring(this.i[0].index)+"' while evaluating '"+this.text+"'.";},pa:function(){for(var a=[];;){this.i.length>0&&!this.F("}",")",";","]")&&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.m(),b;;)if(b=this.a("|"))a=this.q(a,b.b,this.filter());else return a},filter:function(){return this.wa(m.filter)},L:function(){return this.wa(m.validator)},wa:function(a){for(var b=this.Pb(a),c=[];;)if(this.a(":"))c.push(this.m());else{var d=function(e,f){f=[f];for(var g=0;g<c.length;g++)f.push(c[g](e));return b.apply(e,f)};return function(){return d}}},m:function(){return this.vc()},vc:function(){if(this.a("throw")){var a=
+this.ca();return function(b){throw a(b);}}else return this.ca()},ca:function(){var a=this.Ma(),b;if(b=this.a("=")){if(!a.T)throw"Left hand side '"+this.text.substring(0,b.index)+"' of assignment '"+this.text.substring(b.index)+"' is not assignable.";return this.q(function(){return a.T},b.b,this.Ma())}else return a},Ma:function(){for(var a=this.La(),b;;)if(b=this.a("||"))a=this.q(a,b.b,this.La());else return a},La:function(){for(var a=this.Oa(),b;;)if(b=this.a("&&"))a=this.q(a,b.b,this.Oa());else return a},
+Oa:function(){var a;return(a=this.a("!"))?this.mb(a.b,this.ca()):this.Kb()},Kb:function(){for(var a=this.Wa(),b;;)if(b=this.a("==","!="))a=this.q(a,b.b,this.Wa());else return a},Wa:function(){for(var a=this.xa(),b;;)if(b=this.a("<",">","<=",">="))a=this.q(a,b.b,this.xa());else return a},xa:function(){for(var a=this.la(),b;b=this.a("+","-");)a=this.q(a,b.b,this.la());return a},la:function(){for(var a=this.Za(),b;b=this.a("*","/","%");)a=this.q(a,b.b,this.Za());return a},Za:function(){var a;return this.a("+")?
+this.Z():(a=this.a("-"))?this.q(D.lb,a.b,this.la()):this.Z()},Pb: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},Z:function(){var a;if(this.a("(")){a=this.Ca();this.j(")");a=a}else if(this.a("["))a=this.sb();else if(this.a("{"))a=this.object();else if(this.a("{:"))a=this.ya(false);else if(this.a("{("))a=this.ya(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.Ob(a);else if(b.text==="[")a=this.kc(a);else if(b.text===".")a=this.Mb(a);else throw"IMPOSSIBLE";return a},ya: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.pa();this.j("}");return function(d){return function(e){var f=new v(d.scope.p);f.h("$",e);for(var g=0;g<b.length;g++)f.h(b[g],arguments[g]);return c({scope:f})}}},
+Mb:function(a){var b=this.a().text;function c(d){return v.J(a(d),b)}c.T=b;return c},kc:function(a){var b=this.m();this.j("]");if(this.a("=")){var c=this.m();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}},Ob:function(a){var b=[];if(this.Y().text!=")"){do b.push(this.m());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.T+"' is not a function.";}},sb:function(){var a=[];if(this.Y().text!="]"){do a.push(this.m());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.Y().text!="}"){do{var b=this.a().text;this.j(":");var c=this.m();a.push({Ub: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.Ub]=h}return e}},Jb:function(){for(var a=[];this.Ea();){a.push(this.Ib());
+this.a(";")||this.G()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}},Ib:function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c=this.Z()(null);return function(d){var e=d.scope.get("$datastore").C(a,c);d.scope.h(a,e);if(b){e=e();e.sa=b;d.scope.h(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.Cc());this.a(";")||this.G()}this.G();
+return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.pb(d.name,d.b)}}},Cc:function(){var a=this.a().text;this.j(":");var b;if(this.Y().text=="{"){this.j("{");b=this.pa();this.j("}")}else b=this.m();return function(){return{name:a,b:b}}}};v.S={};v.J=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.Hc)return Da(e,a);return a};v.prototype={d:function(){var a=this;this.Nb();_.each(this.cb,function(b){a.k(b,"",{},function(){this.d(a)})})},rb:function(a){a&&this.cb.push(a)},Sb:function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!F.prototype.U(c))return false}return true},get:function(a){return v.J(this.p,a)},h:function(a,
+b){a=a.split(".");for(var c=this.p,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},l:function(a,b){this.eval(a+"="+w(b))},eval:function(a,b){var c=v.S[a];if(!c){var d=new D(a);c=d.pa();d.G();v.S[a]=c}b=b||{};b.scope=this;return c(b)},k:function(a,b,c,d,e){try{var f=this.eval(b,c);if(a.u){a.u=false;k(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){W("Eval Widget Error:",g);b=w(g,true);a.u=true;k(a.view).addClass("ng-exception").attr("ng-error",
+b);e&&e.apply(a,[g,b]);return false}},Ac:function(a,b){var c=v.S[a];if(!c){c=(new D(a)).L();v.S[a]=c}a={scope:this};return c(a)(a,b)},C:function(a){return(new D(a)).Jb()({scope:this})},Yb:function(a){this.p.Ic.push(a)},watch:function(a){var b=this;(new D(a)).watch()({scope:this,pb:function(c,d){b.qb(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})},qb:function(a,b){var c=this.qa[a];if(!c){c={Ha:[],m:a};this.qa[a]=c}c.Ha.push(b)},Nb:function(){var a=this,b=false;o(this.qa,function(c){var d=
+a.eval(c.m);if(d!==c.c){o(c.Ha,function(e){e(d,c.c);b=true});c.c=d}});return b}};ka.prototype={ub:function(a){return ba.Gb(a)},K:function(a,b,c,d){var e=this.zc+this.$b++;ca[e]=function(h){delete m[e];d(200,h)};a={Bd:b,rd:a,sd:c};a=this.ub(w(a));b=Math.ceil(a.length/this.ka);c=this.url+"/$/"+e+"/"+b+"/";for(var f=0;f<b;f++){var g=a.substr(f*this.ka,this.ka);this.getScript(c+(f+1)+"?h="+g,n)}}};$.Nc="$DATASET:";$.prototype={K:J()};la.prototype={K:function(a,b,c,d){var e=this;this.status.vb(c);this.Eb.K(a,
+b,c,function(){e.status.Hb();try{d.apply(this,arguments)}catch(f){alert(w(f))}e.update()})}};ma.prototype={fetchCurrentUser:function(a){var b=this;this.oa.K("GET","/account.json",{},function(c,d){b.current=d.user;a(d.Dd)})},logout:function(a){var b=this;this.da.Xb(function(){delete b.current;(a||n)()})},login:function(a){var b=this;this.da.Na(function(){b.nd(function(){(a||n)()})})},notAuthorized:function(){this.da.Qa()}};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){b=Ba.number(a,b,c);if(b===null&&a!=Math.round(a))return"Value is not a whole number.";return b},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."},url:function(a){if(a.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/))return null;
+return"URL needs to be in http://server[:port]/path format."},json:function(a){try{P(a);return null}catch(b){return b.toString()}}},function(a,b){Ba[b]=a});ja.prototype={Ab:function(a,b){var c,d=a.attr("type").toLowerCase(),e=a.attr("name");if(e)e=e.split(":").pop();var f="change",g=true;if(d=="button"||d=="submit"||d=="reset"||d=="image"){c=new La(a[0],e);f="click";g=false}else if(d=="text"||d=="textarea"||d=="hidden"||d=="password"){c=new na(a[0],e);f="keyup change"}else if(d=="checkbox"){c=new oa(a[0],
+e);f="click"}else if(d=="radio"){c=new ra(a[0],e);f="click"}else if(d=="select-one")c=new pa(a[0],e);else if(d=="select-multiple")c=new qa(a[0],e);else if(d=="file")c=this.Bb(a,e);else throw"Unknown type: "+d;a.data("controller",c);var h=b.get("$updateView");k(c.view,":input").bind(f,function(){if(c.e(b)){var i=k(c.view).attr("ng-action")||"";b.k(c,i)&&h(b)}return g});return c},Bb:function(a){var b="__uploadWidget_"+this.ac++,c=L.template(b);a.after(c);b=this.za({data:this.aa+"/admin/ServerAPI.swf",
+width:"95",height:"20",align:"top",Ed:"transparent"},{pd:"uploadWidgetId="+b,Oc:"always"},b);a.remove();a=new L(c,a[0].name,b,this.aa+"/data/"+this.fa);k(b).data("controller",a);return a}};L.dispatchEvent=function(a,b,c){a=y.getElementById(a);a=k(a).data("controller");L.prototype["_on_"+b].apply(a,c)};L.template=function(a){return k('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+a+'" /><a></a><span/></span>')};L.prototype={e:function(a){var b=this.view.find("input").attr("checked")?
+this.value:null;if(this.c===b)return false;else{a.h(this.Xa,b);return true}},d:function(a){if((a=a.get(this.Xa))&&this.value!==a){this.value=a;this.view.find("a").attr("href",this.value.url).text(this.value.text);this.view.find("span").text(m.filter.bytes(this.value.size))}this.view.find("input").attr("checked",!!a)}};Q.prototype={e:N(true),d:n};Q.Rb=new Q;var La=Q;na.prototype={e:function(a){var b=this.view.value;if(this.c===b)return false;else{a.l(this.exp,b);this.c=b;return true}},d:function(a){var b=
+this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.o;a.l(this.exp,c)}c=c?c:"";if(this.c!=c)this.c=b.value=c;var d=false;b.removeAttribute("ng-error");if(this.rc)d=!(c&&c.length>0);var e=d?"Required Value":null;if(!d&&this.L&&c){e=a.Ac(this.L,c);d=!!e}if(this.Ga!==e){this.Ga=d;if(e!==null){b.setAttribute("ng-error",e);a.Yb(this)}k(b).toggleClass("ng-validation-error",d)}}};oa.prototype={e:function(a){var b=this.view;b=b.checked?b.value:"";if(this.c===b)return false;else{a.l(this.exp,b);
+this.c=b;return true}},d:function(a){var b=this.view,c=a.eval(this.exp);if(typeof c==="undefined"){c=this.o;a.l(this.exp,c)}b.checked=b.value==""+c}};pa.prototype={e:function(a){if(this.view.selectedIndex<0)a.l(this.exp,null);else{var b=this.view.value;if(this.c===b)return false;else{a.l(this.exp,b);this.c=b;return true}}},d:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.o;a.l(this.exp,c)}if(c!==this.c){b.value=c?c:"";this.c=c}}};qa.prototype={selected:function(){for(var a=
+[],b=this.view.options,c=0;c<b.length;c++){var d=b[c];d.selected&&a.push(d.value)}return a},e:function(a){var b=this.selected();if(this.c===b)return false;else{a.l(this.exp,b);this.c=b;return true}},d:function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.o;a.l(this.exp,c)}if(c!==this.c){a=b.options;for(b=0;b<a.length;b++){var d=a[b];d.selected=_.include(c,d.value)}this.c=c}}};ra.prototype={e:function(a){var b=this.view;if(this.ia)return false;else{b.checked=true;this.c=a.l(this.exp,
+this.Fa);return this.ia=true}},d:function(a){var b=this.view,c=a.get(this.exp);if(this.o&&typeof c==="undefined"){c=this.o;a.l(this.exp,c)}if(this.c!=c){this.ia=b.checked=this.Fa==""+c;this.c=c}}};M.Ya=function(a){switch(typeof a){case "string":case "boolean":case "number":return C(a);case "function":return M.Ya(a());case "object":if(a&&a.tagName&&a.nodeName&&a.ownerDocument&&a.removeAttribute)return ga(a);else if(a instanceof m.filter.g){switch(typeof a.html){case "string":case "number":return a.html;
+case "function":return a.html();case "object":if(a.html&&a.html.tagName&&a.html.nodeName&&a.html.ownerDocument&&a.html.removeAttribute)return ga(a.html);default:break}switch(typeof a.text){case "string":case "number":return C(a.text);case "function":return C(a.text());default:break}}if(a===null)return"";return C(w(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=x.H(f);if(g){a.k(this,g,this.tc,function(h){b.push(M.Ya(h))},function(h,
+i){fa(this.view,i)});if(this.u)return}else b.push(C(f))}fa(this.view,b.join(""))}};sa.prototype={e:n,d:function(a){var b=k(this.view),c=this.tb;if(this.u){this.u=false;b.removeClass("ng-exception").removeAttr("ng-error")}var d=b.is("img");for(var e in c){for(var f=x.X(c[e]),g=[],h=0;h<f.length;h++){var i=x.H(f[h]);if(i)try{var j=a.eval(i,{element:b[0],attrName:e});if(j&&(j.constructor!==array||j.length!==0))g.push(j)}catch(l){this.u=true;W("BindAttrUpdater",l);i=w(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.server")+"/images/blank.gif";b.attr(e,f)}}};ta.prototype={e:n,d:function(a){a.k(this,this.exp)}};ua.prototype={e:n,d:function(a){a.k(this,this.exp,{},function(b){var c=k(this.view);Y(b)?c.hide():c.show()})}};va.prototype={e:n,d:function(a){a.k(this,this.exp,{},function(b){var c=k(this.view);Y(b)?c.show():c.hide()})}};wa.prototype={e:n,d:function(a){a.k(this,this.exp,{},function(b){if(b!==null&&b!==undefined)this.view.className=
+b})}};xa.prototype={e:n,d:function(a){a.k(this,this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,c%2===1)})}};ya.prototype={e:n,d:function(a){a.k(this,this.exp,{},function(b){var c=a.get("$index");k(this.view).toggleClass(b,c%2===0)})}};za.prototype={e:n,d:function(a){a.k(this,this.exp,{},function(b){k(this.view).attr("style","").css(b)})}};Aa.prototype={e:n,d:function(a){a.k(this,this.V,{},function(b){var c=this;if(!b){b=[];a.Sb(this.V)&&a.h(this.V,b)}var d=b.length,e=this.children.length,
+f=this.view,g=0,h=null,i=this.Vb,j=this.Bc,l=0;o(b,function(B,s){if(l<e){h=c.children[l];h.scope.h(j,B)}else{var t=new v(a.p,c.prefix+j+" in "+c.V+"["+l+"]");t.h("$index",l);i&&t.h(i,s);t.h(j,B);h={scope:t,element:c.template(t,c.prefix,l)};f.after(h.element);c.children.push(h)}f=h.element;B=(new Date).getTime();h.scope.d();g+=(new Date).getTime()-B;l++});for(b=e;b>d;--b){var p=this.children.pop().element[0];p.parentNode.removeChild(p)}if(h&&h.element[0].nodeName==="OPTION")if(d=k(h.element[0].parentNode).data("controller")){d.c=
+undefined;d.d(a)}})}};A.va="mouseleave mouseout click dblclick keypress keyup";A.lc=function(){A.ma();var a=k(this);a.bind(A.va,A.ma);var b=a.position(),c=y.documentElement,d=(self.innerWidth||c&&c.clientWidth||y.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};A.ma=function(){k("#ng-callout").unbind(A.va,A.ma).remove();return true};A.prototype={bind:function(){this.B.find(".ng-validation-error,.ng-exception").live("mouseover",A.lc)}};S.hb='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';S.prototype={vb:function(){this.$===0&&this.Ka.show();this.$++},Hb:function(){this.$--;this.$===0&&
+this.Ka.hide("fold")}}})(window,document);
diff --git a/angular.js b/angular.js
index 9609929c..adfa3611 100644
--- a/angular.js
+++ b/angular.js
@@ -299,16 +299,6 @@ function bind(_this, _function) {
};
}
-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);
@@ -342,159 +332,9 @@ function merge(src, dst) {
}
// ////////////////////////////
-// Angular
+// UrlWatcher
// ////////////////////////////
-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 = this.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();
-
- 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;
@@ -508,6 +348,9 @@ function UrlWatcher(location) {
}
UrlWatcher.prototype = {
+ listen: function(fn){
+ this.listener = fn;
+ },
watch: function() {
var self = this;
var pull = function() {
@@ -534,50 +377,151 @@ UrlWatcher.prototype = {
self.setTimeout(pull, self.delay);
};
pull();
+ return this;
},
- setUrl: function(url) {
- //TODO: conditionaly?
- var existingURL = window.location.href;
+ set: function(url) {
+ var existingURL = this.location.href;
if (!existingURL.match(/#/))
existingURL += '#';
if (existingURL != url)
- window.location.href = url;
+ this.location.href = url;
this.existingURL = url;
},
- getUrl: function() {
+ get: 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();},
- 'watchUrl':function(){
- var binder = scope.get('$binder');
- var watcher = angular.watcher;
- watcher.listener = bind(binder, binder.onUrlChange, watcher);
- watcher.onUpdate = function(){alert("update");};
- watcher.watch();
+
+/////////////////////////////////////////////////
+function configureJQueryPlugins() {
+ log('Angular.configureJQueryPlugins()');
+ var fn = jQuery['fn'];
+ 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;
+ };
+ fn['controller'] = function() {
+ return this.data('controller') || NullController.instance;
+ };
+}
+
+function configureLogging(config) {
+ if (config.debug == 'console' && !consoleNode) {
+ 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 exposeMethods(obj, methods){
+ var bound = {};
+ foreach(methods, function(fn, name){
+ bound[name] = _(fn).bind(obj);
+ });
+ return bound;
+}
+
+function wireAngular(element, config) {
+ var widgetFactory = new WidgetFactory(config['server'], config['database']);
+ var binder = new Binder(element[0], widgetFactory, config['location'], config);
+ var controlBar = new ControlBar(element.find('body'), config.server);
+ var onUpdate = function(){binder.updateView();};
+ var server = config.database=="$MEMORY" ?
+ new FrameServer(this.window) :
+ new Server(config.server, jQuery.getScript);
+ server = new VisualServer(server, new Status(jQuery(element.body)), onUpdate);
+ var users = new Users(server, controlBar);
+ var databasePath = '/data/' + 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,
+ '$updateView': _(binder.updateView).bind(binder),
+ '$config' : config,
+ '$console' : window.console,
+ '$datastore' : exposeMethods(datastore, {
+ 'load': datastore.load,
+ 'loadMany': datastore.loadMany,
+ 'loadOrCreate': datastore.loadOrCreate,
+ 'loadAll': datastore.loadAll,
+ 'save': datastore.save,
+ 'remove': datastore.remove,
+ 'flush': datastore.flush,
+ 'query': datastore.query,
+ 'entity': datastore.entity,
+ 'entities': datastore.entities,
+ 'documentCountsByUser': datastore.documentCountsByUser,
+ 'userDocumentIdsByEntity': datastore.userDocumentIdsByEntity,
+ 'join': datastore.join
+ }),
+ '$save' : function(callback) {
+ datastore.saveScope(scope.state, callback, binder.anchor);
+ },
+ '$window' : window,
+ '$uid' : function() {
+ return "" + new Date().getTime();
+ },
+ '$users' : users
+ }, "ROOT");
+
+ element.data('scope', scope);
+ binder.entity(scope);
+ binder.compile();
+ controlBar.bind();
+
+ //TODO: remove this code
+ new PopUp(element).bind();
+
+ var self = _(exposeMethods(scope, {
+ 'updateView': scope.updateView,
+ 'set': scope.set,
+ 'get': scope.get,
+ 'eval': scope.eval
+ })).extend({
+ 'init':function(){
+ config['location']['listen'](_(binder.onUrlChange).bind(binder));
+ binder.parseAnchor();
+ binder.executeInit();
+ scope.updateView();
+ return self;
+ },
+ 'element':element[0],
+ 'config':config
+ });
+ return self;
+}
+
+angular['startUrlWatcher'] = function(){
+ return new UrlWatcher(window['location']).watch();
+};
+
+angular['compile'] = function(element, config) {
+ config = _({
+ 'server': "",
+ 'location': {'get':noop, 'set':noop, 'listen':noop}
+ }).extend(config||{});
+
+ configureLogging(config);
+ configureJQueryPlugins();
+
+ return wireAngular(jQuery(element), config);
};var angularGlobal = {
'typeOf':function(obj){
if (obj === null) return "null";
@@ -901,9 +845,9 @@ defineApi('String', [angularGlobal, angularString], []);
defineApi('Date', [angularGlobal, angularDate], []);
defineApi('Function', [angularGlobal, angularCollection, angularFunction],
['bind', 'bindAll', 'delay', 'defer', 'wrap', 'compose']);
-function Binder(doc, widgetFactory, urlWatcher, config) {
+function Binder(doc, widgetFactory, location, config) {
this.doc = doc;
- this.urlWatcher = urlWatcher;
+ this.location = location;
this.anchor = {};
this.widgetFactory = widgetFactory;
this.config = config || {};
@@ -951,9 +895,8 @@ Binder.prototype = {
return params;
},
- parseAnchor: function(url) {
- var self = this;
- url = url || this.urlWatcher.getUrl();
+ parseAnchor: function() {
+ var self = this, url = this.location.get() || "";
var anchorIndex = url.indexOf('#');
if (anchorIndex < 0) return;
@@ -968,13 +911,13 @@ Binder.prototype = {
});
},
- onUrlChange: function (url) {
- this.parseAnchor(url);
+ onUrlChange: function() {
+ this.parseAnchor();
this.updateView();
},
updateAnchor: function() {
- var url = this.urlWatcher.getUrl();
+ var url = this.location.get();
var anchorIndex = url.indexOf('#');
if (anchorIndex > -1)
url = url.substring(0, anchorIndex);
@@ -991,7 +934,7 @@ Binder.prototype = {
sep = '&';
}
}
- this.urlWatcher.setUrl(url);
+ this.location.set(url);
return url;
},
@@ -1057,7 +1000,7 @@ Binder.prototype = {
jNode.addClass("ng-exception");
jNode.attr('ng-error', toJson(e, true));
}
- scope.eval('$binder.updateView()');
+ scope.get('$updateView')();
return false;
});
},
@@ -1980,7 +1923,7 @@ array = [].constructor;
function toJson(obj, pretty){
var buf = [];
- toJsonArray(buf, obj, pretty ? "\n " : null);
+ toJsonArray(buf, obj, pretty ? "\n " : null, _([]));
return buf.join('');
};
@@ -2003,7 +1946,14 @@ function fromJson(json) {
angular['toJson'] = toJson;
angular['fromJson'] = fromJson;
-function toJsonArray(buf, obj, pretty){
+function toJsonArray(buf, obj, pretty, stack){
+ if (typeof obj == "object") {
+ if (stack.include(obj)) {
+ buf.push("RECURSION");
+ return;
+ }
+ stack.push(obj);
+ }
var type = typeof obj;
if (obj === null) {
buf.push("null");
@@ -2030,7 +1980,7 @@ function toJsonArray(buf, obj, pretty){
if (typeof item == 'function' || typeof item == 'undefined') {
buf.push("null");
} else {
- toJsonArray(buf, item, pretty);
+ toJsonArray(buf, item, pretty, stack);
}
sep = true;
}
@@ -2060,7 +2010,7 @@ function toJsonArray(buf, obj, pretty){
}
buf.push(angular['String']['quote'](key));
buf.push(":");
- toJsonArray(buf, value, childPretty);
+ toJsonArray(buf, value, childPretty, stack);
comma = true;
}
} catch (e) {
@@ -2069,6 +2019,9 @@ function toJsonArray(buf, obj, pretty){
buf.push("}");
}
}
+ if (typeof obj == "object") {
+ stack.pop();
+ }
};
// Single $ is special and does not get searched
// Double $$ is special an is client only (does not get sent to server)
@@ -3153,7 +3106,7 @@ Users.prototype = {
'fetchCurrentUser':function(callback) {
var self = this;
this.server.request("GET", "/account.json", {}, function(code, response){
- self.current = response.user;
+ self['current'] = response['user'];
callback(response.user);
});
},
@@ -3161,7 +3114,7 @@ Users.prototype = {
'logout': function(callback) {
var self = this;
this.controlBar.logout(function(){
- delete self.current;
+ delete self['current'];
(callback||noop)();
});
},
@@ -3270,7 +3223,6 @@ function WidgetFactory(serverUrl, database) {
alert("ERROR: swfobject not loaded!");
};
}
- this.onChangeListener = function(){};
};
WidgetFactory.prototype = {
@@ -3304,12 +3256,12 @@ WidgetFactory.prototype = {
throw 'Unknown type: ' + type;
}
input.data('controller', controller);
- var binder = scope.get('$binder');
+ var updateView = scope.get('$updateView');
var action = function() {
if (controller.updateModel(scope)) {
var action = jQuery(controller.view).attr('ng-action') || "";
if (scope.evalWidget(controller, action)) {
- binder.updateView(scope);
+ updateView(scope);
}
}
return bubbleEvent;
@@ -3335,12 +3287,6 @@ WidgetFactory.prototype = {
var cntl = new FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
jQuery(swfNode).data('controller', cntl);
return cntl;
- },
-
- createTextWidget: function(textInput) {
- var controller = new TextController(textInput);
- controller.onChange(this.onChangeListener);
- return controller;
}
};
/////////////////////
diff --git a/example/tweeter/tweeterclient.js b/example/tweeter/tweeterclient.js
index 2fb60b0a..8c68fac0 100644
--- a/example/tweeter/tweeterclient.js
+++ b/example/tweeter/tweeterclient.js
@@ -1,6 +1,8 @@
function noop(){}
$(document).ready(function(){
- var scope = window.scope = angular.compile(document);
+ var scope = window.scope = angular.compile(document, {
+ location:angular.startUrlWatcher()
+ });
scope.getJSON = function(url, callback) {
var list = [];
var self = this;
@@ -32,6 +34,5 @@ $(document).ready(function(){
notes:'Author of <angular/> & Ruby guru see: http://www.angularjs.org.',
profile_image_url:'http://media.linkedin.com/mpr/mpr/shrink_80_80/p/2/000/005/0a8/044278d.jpg'}
]);
- scope.watchUrl();
scope.init();
});
diff --git a/jsTestDriver.conf b/jsTestDriver.conf
index 1fbe05a7..28958ee4 100644
--- a/jsTestDriver.conf
+++ b/jsTestDriver.conf
@@ -1,6 +1,8 @@
server: http://localhost:9876
load:
+ - lib/jasmine/jasmine-0.10.0.js
+ - lib/jasmine-jstd-adapter/JasmineAdapter.js
- lib/webtoolkit/webtoolkit.base64.js
- lib/jquery/jquery-1.3.2.js
- lib/jquery/jquery-ui-1.7.1.custom.min.js
diff --git a/src/Angular.js b/src/Angular.js
index 3dc72ff7..51fca458 100644
--- a/src/Angular.js
+++ b/src/Angular.js
@@ -134,16 +134,6 @@ function bind(_this, _function) {
};
}
-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);
@@ -177,159 +167,9 @@ function merge(src, dst) {
}
// ////////////////////////////
-// Angular
+// UrlWatcher
// ////////////////////////////
-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 = this.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();
-
- 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;
@@ -343,6 +183,9 @@ function UrlWatcher(location) {
}
UrlWatcher.prototype = {
+ listen: function(fn){
+ this.listener = fn;
+ },
watch: function() {
var self = this;
var pull = function() {
@@ -369,48 +212,149 @@ UrlWatcher.prototype = {
self.setTimeout(pull, self.delay);
};
pull();
+ return this;
},
- setUrl: function(url) {
- //TODO: conditionaly?
- var existingURL = window.location.href;
+ set: function(url) {
+ var existingURL = this.location.href;
if (!existingURL.match(/#/))
existingURL += '#';
if (existingURL != url)
- window.location.href = url;
+ this.location.href = url;
this.existingURL = url;
},
- getUrl: function() {
+ get: 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();},
- 'watchUrl':function(){
- var binder = scope.get('$binder');
- var watcher = angular.watcher;
- watcher.listener = bind(binder, binder.onUrlChange, watcher);
- watcher.onUpdate = function(){alert("update");};
- watcher.watch();
+
+/////////////////////////////////////////////////
+function configureJQueryPlugins() {
+ log('Angular.configureJQueryPlugins()');
+ var fn = jQuery['fn'];
+ 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;
+ };
+ fn['controller'] = function() {
+ return this.data('controller') || NullController.instance;
};
+}
+
+function configureLogging(config) {
+ if (config.debug == 'console' && !consoleNode) {
+ 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 exposeMethods(obj, methods){
+ var bound = {};
+ foreach(methods, function(fn, name){
+ bound[name] = _(fn).bind(obj);
+ });
+ return bound;
+}
+
+function wireAngular(element, config) {
+ var widgetFactory = new WidgetFactory(config['server'], config['database']);
+ var binder = new Binder(element[0], widgetFactory, config['location'], config);
+ var controlBar = new ControlBar(element.find('body'), config.server);
+ var onUpdate = function(){binder.updateView();};
+ var server = config.database=="$MEMORY" ?
+ new FrameServer(this.window) :
+ new Server(config.server, jQuery.getScript);
+ server = new VisualServer(server, new Status(jQuery(element.body)), onUpdate);
+ var users = new Users(server, controlBar);
+ var databasePath = '/data/' + 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,
+ '$updateView': _(binder.updateView).bind(binder),
+ '$config' : config,
+ '$console' : window.console,
+ '$datastore' : exposeMethods(datastore, {
+ 'load': datastore.load,
+ 'loadMany': datastore.loadMany,
+ 'loadOrCreate': datastore.loadOrCreate,
+ 'loadAll': datastore.loadAll,
+ 'save': datastore.save,
+ 'remove': datastore.remove,
+ 'flush': datastore.flush,
+ 'query': datastore.query,
+ 'entity': datastore.entity,
+ 'entities': datastore.entities,
+ 'documentCountsByUser': datastore.documentCountsByUser,
+ 'userDocumentIdsByEntity': datastore.userDocumentIdsByEntity,
+ 'join': datastore.join
+ }),
+ '$save' : function(callback) {
+ datastore.saveScope(scope.state, callback, binder.anchor);
+ },
+ '$window' : window,
+ '$uid' : function() {
+ return "" + new Date().getTime();
+ },
+ '$users' : users
+ }, "ROOT");
+
+ element.data('scope', scope);
+ binder.entity(scope);
+ binder.compile();
+ controlBar.bind();
+
+ //TODO: remove this code
+ new PopUp(element).bind();
+
+ var self = _(exposeMethods(scope, {
+ 'updateView': scope.updateView,
+ 'set': scope.set,
+ 'get': scope.get,
+ 'eval': scope.eval
+ })).extend({
+ 'init':function(){
+ config['location']['listen'](_(binder.onUrlChange).bind(binder));
+ binder.parseAnchor();
+ binder.executeInit();
+ scope.updateView();
+ return self;
+ },
+ 'element':element[0],
+ 'config':config
+ });
+ return self;
+}
+
+angular['startUrlWatcher'] = function(){
+ return new UrlWatcher(window['location']).watch();
+};
+
+angular['compile'] = function(element, config) {
+ config = _({
+ 'server': "",
+ 'location': {'get':noop, 'set':noop, 'listen':noop}
+ }).extend(config||{});
+
+ configureLogging(config);
+ configureJQueryPlugins();
+
+ return wireAngular(jQuery(element), config);
}; \ No newline at end of file
diff --git a/src/Binder.js b/src/Binder.js
index b687fb77..3fc45a20 100644
--- a/src/Binder.js
+++ b/src/Binder.js
@@ -1,6 +1,6 @@
-function Binder(doc, widgetFactory, urlWatcher, config) {
+function Binder(doc, widgetFactory, location, config) {
this.doc = doc;
- this.urlWatcher = urlWatcher;
+ this.location = location;
this.anchor = {};
this.widgetFactory = widgetFactory;
this.config = config || {};
@@ -48,9 +48,8 @@ Binder.prototype = {
return params;
},
- parseAnchor: function(url) {
- var self = this;
- url = url || this.urlWatcher.getUrl();
+ parseAnchor: function() {
+ var self = this, url = this.location.get() || "";
var anchorIndex = url.indexOf('#');
if (anchorIndex < 0) return;
@@ -65,13 +64,13 @@ Binder.prototype = {
});
},
- onUrlChange: function (url) {
- this.parseAnchor(url);
+ onUrlChange: function() {
+ this.parseAnchor();
this.updateView();
},
updateAnchor: function() {
- var url = this.urlWatcher.getUrl();
+ var url = this.location.get();
var anchorIndex = url.indexOf('#');
if (anchorIndex > -1)
url = url.substring(0, anchorIndex);
@@ -88,7 +87,7 @@ Binder.prototype = {
sep = '&';
}
}
- this.urlWatcher.setUrl(url);
+ this.location.set(url);
return url;
},
@@ -154,7 +153,7 @@ Binder.prototype = {
jNode.addClass("ng-exception");
jNode.attr('ng-error', toJson(e, true));
}
- scope.eval('$binder.updateView()');
+ scope.get('$updateView')();
return false;
});
},
diff --git a/src/JSON.js b/src/JSON.js
index 0c842865..98dfddd2 100644
--- a/src/JSON.js
+++ b/src/JSON.js
@@ -2,7 +2,7 @@ array = [].constructor;
function toJson(obj, pretty){
var buf = [];
- toJsonArray(buf, obj, pretty ? "\n " : null);
+ toJsonArray(buf, obj, pretty ? "\n " : null, _([]));
return buf.join('');
};
@@ -25,7 +25,14 @@ function fromJson(json) {
angular['toJson'] = toJson;
angular['fromJson'] = fromJson;
-function toJsonArray(buf, obj, pretty){
+function toJsonArray(buf, obj, pretty, stack){
+ if (typeof obj == "object") {
+ if (stack.include(obj)) {
+ buf.push("RECURSION");
+ return;
+ }
+ stack.push(obj);
+ }
var type = typeof obj;
if (obj === null) {
buf.push("null");
@@ -52,7 +59,7 @@ function toJsonArray(buf, obj, pretty){
if (typeof item == 'function' || typeof item == 'undefined') {
buf.push("null");
} else {
- toJsonArray(buf, item, pretty);
+ toJsonArray(buf, item, pretty, stack);
}
sep = true;
}
@@ -82,7 +89,7 @@ function toJsonArray(buf, obj, pretty){
}
buf.push(angular['String']['quote'](key));
buf.push(":");
- toJsonArray(buf, value, childPretty);
+ toJsonArray(buf, value, childPretty, stack);
comma = true;
}
} catch (e) {
@@ -91,4 +98,7 @@ function toJsonArray(buf, obj, pretty){
buf.push("}");
}
}
+ if (typeof obj == "object") {
+ stack.pop();
+ }
};
diff --git a/src/Users.js b/src/Users.js
index 47da4f73..79ed3129 100644
--- a/src/Users.js
+++ b/src/Users.js
@@ -7,7 +7,7 @@ Users.prototype = {
'fetchCurrentUser':function(callback) {
var self = this;
this.server.request("GET", "/account.json", {}, function(code, response){
- self.current = response.user;
+ self['current'] = response['user'];
callback(response.user);
});
},
@@ -15,7 +15,7 @@ Users.prototype = {
'logout': function(callback) {
var self = this;
this.controlBar.logout(function(){
- delete self.current;
+ delete self['current'];
(callback||noop)();
});
},
diff --git a/src/Widgets.js b/src/Widgets.js
index f93f2476..a012adf3 100644
--- a/src/Widgets.js
+++ b/src/Widgets.js
@@ -9,7 +9,6 @@ function WidgetFactory(serverUrl, database) {
alert("ERROR: swfobject not loaded!");
};
}
- this.onChangeListener = function(){};
};
WidgetFactory.prototype = {
@@ -43,12 +42,12 @@ WidgetFactory.prototype = {
throw 'Unknown type: ' + type;
}
input.data('controller', controller);
- var binder = scope.get('$binder');
+ var updateView = scope.get('$updateView');
var action = function() {
if (controller.updateModel(scope)) {
var action = jQuery(controller.view).attr('ng-action') || "";
if (scope.evalWidget(controller, action)) {
- binder.updateView(scope);
+ updateView(scope);
}
}
return bubbleEvent;
@@ -74,12 +73,6 @@ WidgetFactory.prototype = {
var cntl = new FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
jQuery(swfNode).data('controller', cntl);
return cntl;
- },
-
- createTextWidget: function(textInput) {
- var controller = new TextController(textInput);
- controller.onChange(this.onChangeListener);
- return controller;
}
};
/////////////////////
diff --git a/test/AngularTest.js b/test/AngularTest.js
index 9610ef76..a9146adf 100644
--- a/test/AngularTest.js
+++ b/test/AngularTest.js
@@ -1,20 +1,5 @@
AngularTest = TestCase('AngularTest');
-AngularTest.prototype.testDefaultDatabasePathFromSubdomain = function() {
- var loader = new Angular(null, null, {server:"http://account.getangular.com", database:"database"});
- loader.computeConfiguration();
- assertEquals("database", loader.config.database);
-
- loader = new Angular(null, null, {server:"http://account.getangular.com"});
- loader.computeConfiguration();
- assertEquals("account", loader.config.database);
-
- loader = new Angular(null, null, {server:"https://account.getangular.com"});
- loader.computeConfiguration();
- assertEquals("account", loader.config.database);
-};
-
-
UrlWatcherTest = TestCase('UrlWatcherTest');
diff --git a/test/BinderTest.js b/test/BinderTest.js
index 0ffd2120..bbb3eb8f 100644
--- a/test/BinderTest.js
+++ b/test/BinderTest.js
@@ -5,10 +5,10 @@ function compile(content, initialScope, config) {
config = config || {autoSubmit:true};
var scope = new Scope(initialScope, "ROOT");
h.data('scope', scope);
- var binder = new Binder(h[0], new WidgetFactory(), new MockUrlWatcher(), config);
+ var binder = new Binder(h[0], new WidgetFactory(), new MockLocation(), config);
var datastore = new DataStore();
scope.set("$datastore", datastore);
- scope.set("$binder", binder);
+ scope.set("$updateView", _(binder.updateView).bind(binder));
scope.set("$anchor", binder.anchor);
binder.entity(scope);
binder.compile();
@@ -120,7 +120,7 @@ BinderTest.prototype.testChangingTextareaUpdatesModel = function(){
var form = html('<textarea name="model.note">abc</textarea>');
var scope = new Scope({model:{}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
binder.compile();
binder.updateView();
assertEquals(scope.get('model').note, 'abc');
@@ -131,7 +131,7 @@ BinderTest.prototype.testChangingRadioUpdatesModel = function(){
'<input type="radio" name="model.price" value="B">');
var scope = new Scope({model:{}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
binder.compile();
binder.updateView();
assertEquals(scope.get('model').price, 'A');
@@ -141,7 +141,7 @@ BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){
var form = html('<input type="checkbox" name="model.price" value="A" checked>');
var scope = new Scope({model:{}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
binder.compile();
binder.updateView();
assertEquals('A', scope.get('model').price);
@@ -157,7 +157,7 @@ BinderTest.prototype.testChangingSelectNonSelectedUpdatesModel = function(){
var form = html('<select name="model.price"><option value="A">A</option><option value="B">B</option></select>');
var scope = new Scope({model:{}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
binder.compile();
binder.updateView();
assertEquals('A', scope.get('model').price);
@@ -171,7 +171,7 @@ BinderTest.prototype.testChangingMultiselectUpdatesModel = function(){
'</select>');
var scope = new Scope({Invoice:{}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
binder.compile();
binder.updateView();
assertJsonEquals(["A", "B"], scope.get('Invoice').options);
@@ -181,7 +181,7 @@ BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){
var form = html('<select name="model.price"><option>A</option><option selected value="b">B</option></select>');
var scope = new Scope({model:{}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
binder.compile();
binder.updateView();
assertEquals(scope.get('model').price, 'b');
@@ -210,7 +210,7 @@ BinderTest.prototype.testApplyTextBindings = function(){
var form = html('<div ng-bind="model.a">x</div>');
var scope = new Scope({model:{a:123}});
form.data('scope', scope);
- var binder = new Binder(form.get(0), null, new MockUrlWatcher());
+ var binder = new Binder(form.get(0), null, new MockLocation());
binder.compile();
binder.updateView();
assertEquals('123', form.text());
@@ -287,7 +287,7 @@ BinderTest.prototype.testExistingAttrbindingIsAppended = function() {
BinderTest.prototype.testAttributesAreEvaluated = function(){
var form = html('<a ng-bind-attr=\'{"a":"a", "b":"a+b={{a+b}}"}\'></a>');
form.data('scope', new Scope({a:1, b:2}));
- var binder = new Binder(form.get(0), null, new MockUrlWatcher());
+ var binder = new Binder(form.get(0), null, new MockLocation());
binder.compile();
binder.updateView();
var a = form.find("a");
@@ -304,7 +304,7 @@ BinderTest.prototype.testInputsAreUpdated = function(){
'<input name="A.checkbox" type="checkbox" value="c" />' +
'<input name="A.checkboxOff" type="checkbox" value="c" />' +
'<select name="A.select"><option>a</option><option value="S">b</option></select>');
- var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(form.get(0), new WidgetFactory(), new MockLocation());
form.data('scope', new Scope({A:{text:"t1", textarea:"t2", radio:"r", checkbox:"c", select:"S"}}));
binder.compile();
binder.updateView();
@@ -348,21 +348,27 @@ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){
};
BinderTest.prototype.testParseEmptyAnchor = function(){
- var binder = new Binder(null, null, new MockUrlWatcher());
+ var location = new MockLocation();
+ var binder = new Binder(null, null, location);
var anchor = binder.anchor;
- binder.parseAnchor("a#x=1");
+ location.url = "a#x=1";
+ binder.parseAnchor();
assertEquals(1, binder.anchor.x);
- binder.parseAnchor("a#");
+ location.url = "a#";
+ binder.parseAnchor();
assertTrue("old values did not get removed", !binder.anchor.x);
assertTrue("anchor gor replaced", anchor === binder.anchor);
assertEquals('undefined', typeof (anchor[""]));
};
BinderTest.prototype.testParseAnchor = function(){
- var binder = new Binder(null, null, new MockUrlWatcher());
- binder.parseAnchor("a#x=1");
+ var location = new MockLocation();
+ var binder = new Binder(null, null, location);
+ location.url = "a#x=1";
+ binder.parseAnchor();
assertEquals(binder.anchor.x, "1");
- binder.parseAnchor("a#a=b&c=%20&d");
+ location.url = "a#a=b&c=%20&d";
+ binder.parseAnchor();
assertEquals(binder.anchor.a, 'b');
assertEquals(binder.anchor.c, ' ');
assertTrue(binder.anchor.d !== null);
@@ -370,27 +376,27 @@ BinderTest.prototype.testParseAnchor = function(){
};
BinderTest.prototype.testWriteAnchor = function(){
- var binder = new Binder(null, null, new MockUrlWatcher());
- binder.urlWatcher.setUrl('a');
+ var binder = new Binder(null, null, new MockLocation());
+ binder.location.set('a');
binder.anchor.a = 'b';
binder.anchor.c = ' ';
binder.anchor.d = true;
binder.updateAnchor();
- assertEquals(binder.urlWatcher.getUrl(), "a#a=b&c=%20&d");
+ assertEquals(binder.location.get(), "a#a=b&c=%20&d");
};
BinderTest.prototype.testWriteAnchorAsPartOfTheUpdateView = function(){
- var binder = new Binder(html("<div/>")[0], null, new MockUrlWatcher());
- binder.urlWatcher.setUrl('a');
+ var binder = new Binder(html("<div/>")[0], null, new MockLocation());
+ binder.location.set('a');
$(binder.doc).data('scope', new Scope());
binder.anchor.a = 'b';
binder.updateView();
- assertEquals(binder.urlWatcher.getUrl(), "a#a=b");
+ assertEquals(binder.location.get(), "a#a=b");
};
BinderTest.prototype.testRepeaterUpdateBindings = function(){
var form = html('<ul><LI ng-repeat="item in model.items" ng-bind="item.a"/></ul>');
- var binder = new Binder(form.get(0), null, new MockUrlWatcher());
+ var binder = new Binder(form.get(0), null, new MockLocation());
var items = [{a:"A"}, {a:"B"}];
form.data('scope', new Scope({model:{items:items}}));
binder.compile();
@@ -423,7 +429,7 @@ BinderTest.prototype.testRepeaterUpdateBindings = function(){
BinderTest.prototype.testRepeaterContentDoesNotBind = function(){
var form = html('<ul><LI ng-repeat="item in model.items"><span ng-bind="item.a"/></li></ul>');
form.data('scope', new Scope({model:{items:[{a:"A"}]}}));
- var binder = new Binder(form.get(0), null, new MockUrlWatcher());
+ var binder = new Binder(form.get(0), null, new MockLocation());
binder.compile();
binder.updateView();
assertEquals('<ul>' +
@@ -449,7 +455,7 @@ BinderTest.prototype.testRepeaterInputContentDoesNotBind = function(){
var form =
html('<ul><LI repeater="item in model.items">' +
'<input type="text" name="item.a" value="OLD"/></li></ul>');
- var binder = new Binder(form.get(0), null, new MockUrlWatcher());
+ var binder = new Binder(form.get(0), null, new MockLocation());
var items = [{a:"A"}];
form.data('scope', new Scope({model:{items:items}}));
@@ -493,7 +499,7 @@ BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
var form = jQuery("body").append('<div id="testTag"><input type="file"></div>');
form.data('scope', new Scope());
var factory = {};
- var binder = new Binder(form.get(0), factory, new MockUrlWatcher());
+ var binder = new Binder(form.get(0), factory, new MockLocation());
factory.createController = function(node){
assertEquals(node.attr('type'), 'file');
return {updateModel:function(){}};
@@ -504,7 +510,7 @@ BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
BinderTest.prototype.testRepeaterAdd = function(){
var doc = $('<div><input type="text" name="item.x" ng-repeat="item in items"></div>');
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
doc.data('scope', new Scope({items:[{x:'a'}, {x:'b'}], $binder:binder}));
binder.compile();
binder.updateView();
@@ -521,7 +527,7 @@ BinderTest.prototype.testIfTextBindingThrowsErrorDecorateTheSpan = function(){
var doc = $('<div>{{error.throw()}}</div>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('error.throw', function(){throw "ErrorMsg1";});
@@ -549,7 +555,7 @@ BinderTest.prototype.testIfAttrBindingThrowsErrorDecorateTheSpan = function(){
var doc = $('<div attr="before {{error.throw()}} after"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('error.throw', function(){throw "ErrorMsg";});
@@ -571,7 +577,7 @@ BinderTest.prototype.testNestedRepeater = function() {
'</div>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('model', [{name:'a', item:['a1', 'a2']}, {name:'b', item:['b1', 'b2']}]);
@@ -595,7 +601,7 @@ BinderTest.prototype.testRadioButtonGetsPrefixed = function () {
var doc = html('<input ng-repeat="m in model" type="radio" name="m.a" value="on"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('model', ['a1', 'a2']);
@@ -612,7 +618,7 @@ BinderTest.prototype.testHideBindingExpression = function() {
var doc = html('<div ng-hide="hidden == 3"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('hidden', 3);
@@ -630,7 +636,7 @@ BinderTest.prototype.testHideBinding = function() {
var doc = html('<div ng-hide="hidden"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('hidden', 'true');
@@ -653,7 +659,7 @@ BinderTest.prototype.testShowBinding = function() {
var doc = html('<div ng-show="show"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('show', 'true');
@@ -685,7 +691,7 @@ BinderTest.prototype.testBindClass = function() {
var doc = html('<div ng-class="class"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.set('class', 'testClass');
@@ -714,7 +720,7 @@ BinderTest.prototype.testBindStyle = function() {
var doc = html('<div ng-style="style"/>');
var scope = new Scope();
doc.data('scope', scope);
- var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
+ var binder = new Binder(doc[0], new WidgetFactory(), new MockLocation());
binder.compile();
scope.eval('style={color:"red"}');
@@ -797,7 +803,7 @@ BinderTest.prototype.testDissableAutoSubmit = function() {
BinderTest.prototype.testSettingAnchorToNullOrUndefinedRemovesTheAnchorFromURL = function() {
var c = compile('');
- c.binder.urlWatcher.setUrl("http://server/#a=1&b=2");
+ c.binder.location.set("http://server/#a=1&b=2");
c.binder.parseAnchor();
assertEquals('1', c.binder.anchor.a);
assertEquals('2', c.binder.anchor.b);
@@ -805,7 +811,7 @@ BinderTest.prototype.testSettingAnchorToNullOrUndefinedRemovesTheAnchorFromURL =
c.binder.anchor.a = null;
c.binder.anchor.b = null;
c.binder.updateAnchor();
- assertEquals('http://server/#', c.binder.urlWatcher.getUrl());
+ assertEquals('http://server/#', c.binder.location.get());
};
BinderTest.prototype.testFillInOptionValueWhenMissing = function() {
@@ -875,15 +881,24 @@ BinderTest.prototype.testItShouldCallListenersWhenAnchorChanges = function() {
log += oldValue + "->" + newValue + ";";
});
assertEquals(0, c.scope.get("count"));
- c.binder.onUrlChange("#counter=1");
+ c.binder.location.url = "#counter=1";
+ c.binder.onUrlChange();
assertEquals(1, c.scope.get("count"));
- c.binder.onUrlChange("#counter=1");
+
+ c.binder.location.url = "#counter=1";
+ c.binder.onUrlChange();
assertEquals(1, c.scope.get("count"));
- c.binder.onUrlChange("#counter=2");
+
+ c.binder.location.url = "#counter=2";
+ c.binder.onUrlChange();
assertEquals(2, c.scope.get("count"));
- c.binder.onUrlChange("#counter=2");
+
+ c.binder.location.url = "#counter=2";
+ c.binder.onUrlChange();
assertEquals(2, c.scope.get("count"));
- c.binder.onUrlChange("#");
+
+ c.binder.location.url = "#";
+ c.binder.onUrlChange();
assertEquals("undefined->1;1->2;2->undefined;", log);
assertEquals(3, c.scope.get("count"));
};
@@ -904,7 +919,7 @@ BinderTest.prototype.testParseQueryString = function(){
BinderTest.prototype.testSetBinderAnchorTriggersListeners = function(){
expectAsserts(2);
var doc = html("<div/>")[0];
- var binder = new Binder(doc, null, new MockUrlWatcher());
+ var binder = new Binder(doc, null, new MockLocation());
var scope = new Scope({$binder:binder, $anchor:binder.anchor});
jQuery(doc).data('scope', scope);
diff --git a/test/ControlBarTest.js b/test/ControlBarTest.js
deleted file mode 100644
index c914c8ff..00000000
--- a/test/ControlBarTest.js
+++ /dev/null
@@ -1,2 +0,0 @@
-ControlBarTest = TestCase("ControlBarTest");
-
diff --git a/test/ExternalApiTest.js b/test/ExternalApiTest.js
deleted file mode 100644
index cc102ae0..00000000
--- a/test/ExternalApiTest.js
+++ /dev/null
@@ -1,15 +0,0 @@
-ExternalApiTest = TestCase("ExternalApiTest");
-
-ExternalApiTest.prototype = {
- testItShouldExposefactory:function(){
- var node = $('<div ng-init="a=1">{{b=a+1}}</div>')[0];
- var scope = angular.compile(node);
- scope.init();
- assertEquals(1, scope.get('a'));
- assertEquals(2, scope.get('b'));
- },
-
- testItShouldRegisterAnchorListener: function (){
-
- }
-};
diff --git a/test/JsonTest.js b/test/JsonTest.js
index cf49bec3..9b275248 100644
--- a/test/JsonTest.js
+++ b/test/JsonTest.js
@@ -67,3 +67,14 @@ JsonTest.prototype.testItShouldUTCDates = function() {
assertEquals(date.getTime(),
fromJson('"2009-10-09T01:02:03Z"').getTime());
};
+
+JsonTest.prototype.testItShouldPreventRecursion = function () {
+ var obj = {a:'b'};
+ obj.recursion = obj;
+ assertEquals('{"a":"b","recursion":RECURSION}', angular.toJson(obj));
+};
+
+JsonTest.prototype.testItShouldSerializeSameObjectsMultipleTimes = function () {
+ var obj = {a:'b'};
+ assertEquals('{"A":{"a":"b"},"B":{"a":"b"}}', angular.toJson({A:obj, B:obj}));
+};
diff --git a/test/ScenarioSpec.js b/test/ScenarioSpec.js
new file mode 100644
index 00000000..c3c29f02
--- /dev/null
+++ b/test/ScenarioSpec.js
@@ -0,0 +1,66 @@
+describe("ScenarioSpec: Compilation", function(){
+ it("should compile dom node and return scope", function(){
+ var node = $('<div ng-init="a=1">{{b=a+1}}</div>')[0];
+ var scope = angular.compile(node);
+ scope.init();
+ expect(scope.get('a')).toEqual(1);
+ expect(scope.get('b')).toEqual(2);
+ });
+
+ it("should compile jQuery node and return scope", function(){
+ var scope = angular.compile($('<div>{{a=123}}</div>')).init();
+ expect($(scope.element).text()).toEqual('123');
+ });
+
+ it("should compile text node and return scope", function(){
+ var scope = angular.compile('<div>{{a=123}}</div>').init();
+ expect($(scope.element).text()).toEqual('123');
+ });
+});
+
+describe("ScenarioSpec: Scope", function(){
+ it("should have set, get, eval, init, updateView methods", function(){
+ var scope = angular.compile('<div>{{a}}</div>').init();
+ expect(scope.set("a", 2)).toEqual(2);
+ expect(scope.get("a")).toEqual(2);
+ expect(scope.eval("a=3")).toEqual(3);
+ scope.updateView();
+ expect($(scope.element).text()).toEqual('3');
+ });
+
+ it("should have config", function(){
+ expect(angular.compile('', {a:'b'}).config.a).toEqual('b');
+ });
+
+ it("should have $ objects", function(){
+ var scope = angular.compile('<div></div>', {a:"b"});
+ expect(scope.get('$anchor')).toBeDefined();
+ expect(scope.get('$updateView')).toBeDefined();
+ expect(scope.get('$config')).toBeDefined();
+ expect(scope.get('$config.a')).toEqual("b");
+ expect(scope.get('$datastore')).toBeDefined();
+ });
+});
+
+describe("ScenarioSpec: configuration", function(){
+ it("should take location object", function(){
+ var url = "http://server/#book=moby";
+ var onUrlChange;
+ var location = {
+ listen:function(fn){onUrlChange=fn;},
+ set:function(u){url = u;},
+ get:function(){return url;}
+ };
+ var scope = angular.compile("<div>{{$anchor}}</div>", {location:location});
+ var $anchor = scope.get('$anchor');
+ expect($anchor.book).toBeUndefined();
+ expect(onUrlChange).toBeUndefined();
+ scope.init();
+ expect($anchor.book).toEqual('moby');
+ expect(onUrlChange).toBeDefined();
+
+ url = "http://server/#book=none";
+ onUrlChange();
+ expect($anchor.book).toEqual('none');
+ });
+});
diff --git a/test/ScopeTest.js b/test/ScopeTest.js
index e1c5c8ce..b066f0cb 100644
--- a/test/ScopeTest.js
+++ b/test/ScopeTest.js
@@ -38,7 +38,7 @@ ScopeTest.prototype.testScopeFromPrototype = function(){
ScopeTest.prototype.testSetScopeGet = function(){
var scope = new Scope();
- scope.set('a', 987);
+ assertEquals(987, scope.set('a', 987));
assertEquals(scope.get('a'), 987);
assertEquals(scope.eval('a'), 987);
};
diff --git a/test/formsTest.js b/test/formsTest.js
deleted file mode 100644
index ccade915..00000000
--- a/test/formsTest.js
+++ /dev/null
@@ -1,18 +0,0 @@
-nglrTest = TestCase('nglrTest');
-
-nglrTest.prototype.testShiftBind = function(){
- expectAsserts(3);
- shiftBind('this', function(target, arg) {
- assertEquals(this, 'this');
- assertEquals(target, 'target');
- assertEquals(arg, 'arg');
- }).apply('target', ['arg']);
-};
-
-nglrTest.prototype.testBind = function(){
- expectAsserts(2);
- bind('this', function(arg) {
- assertEquals(this, 'this');
- assertEquals(arg, 'arg');
- }).apply('XXX', ['arg']);
-};
diff --git a/test/testabilityPatch.js b/test/testabilityPatch.js
index 78ffd380..8fac7598 100644
--- a/test/testabilityPatch.js
+++ b/test/testabilityPatch.js
@@ -35,13 +35,13 @@ function report(reportTest){
});
}
-MockUrlWatcher = function() {
+MockLocation = function() {
this.url = "http://server";
};
-MockUrlWatcher.prototype.getUrl = function(){
+MockLocation.prototype.get = function(){
return this.url;
};
-MockUrlWatcher.prototype.setUrl = function(url){
+MockLocation.prototype.set = function(url){
this.url = url;
};
@@ -96,7 +96,7 @@ function decode64(base64){
return fromJson(Base64.decode(base64));
}
-Angular.prototype.configureJQueryPlugins();
+configureJQueryPlugins();
function assertHidden(node) {
var display = node.css('display');