aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2010-01-11 16:15:12 -0800
committerMisko Hevery2010-01-11 16:15:12 -0800
commit1a42a3fab99ca02af0476f5a87175c53104aa2e3 (patch)
treedef5eb17d459d8d3ace81fece12a087d0651c2bc
parent1aba6b53b88c70b61a0cc991b1371739305d117b (diff)
downloadangular.js-1a42a3fab99ca02af0476f5a87175c53104aa2e3.tar.bz2
green
-rw-r--r--angular-minified.js208
-rw-r--r--angular.js1218
-rw-r--r--example/calculator-manual_init.html1
-rw-r--r--src/API.js77
-rw-r--r--src/Binder.js8
-rw-r--r--src/ControlBar.js2
-rw-r--r--src/DataStore.js18
-rw-r--r--src/Filters.js511
-rw-r--r--src/JSON.js2
-rw-r--r--src/Loader.js491
-rw-r--r--src/Scope.js6
-rw-r--r--src/Server.js2
-rw-r--r--src/Validators.js152
-rw-r--r--src/Widgets.js4
-rw-r--r--src/angular.prefix3
-rw-r--r--test/LoaderTest.js4
-rw-r--r--test/ServerTest.js4
17 files changed, 1368 insertions, 1343 deletions
diff --git a/angular-minified.js b/angular-minified.js
index ce5155f2..9b4eec6e 100644
--- a/angular-minified.js
+++ b/angular-minified.js
@@ -1,109 +1,99 @@
-function m(){return function(){}}function u(n){return function(q){this[n]=q}}function w(n){return function(){return n}}
-(function(n,q){var z={z:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",$:function(a){var b="",c,d,e,f,g,h,i=0;for(a=z.Gb(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.z.charAt(f)+this.z.charAt(c)+this.z.charAt(g)+this.z.charAt(h)}return b},Gd: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.z.indexOf(a.charAt(h++));
-d=this.z.indexOf(a.charAt(h++));f=this.z.indexOf(a.charAt(h++));g=this.z.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=z.Fb(b)},Gb: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},Fb: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 q.getAttribute=="undefined")q.getAttribute=m();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};var x={},j=n.jQuery,A=j.browser.msie;if(!n.ld){angular={};n.angular=angular}if(!angular.h)angular.h={};if(!angular.filter)angular.filter={};if(!n.console)n.console={log:m(),error:m()};if(!angular.alert)angular.alert=function(){console.log(arguments);n.alert.apply(n,arguments)};var y;consoleLog=function(a,b){var c=
-q.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:toJson(f));d=" "}c.appendChild(q.createTextNode(a));y.appendChild(c)};isNode=function(a){return a&&a.tagName&&a.nodeName&&a.ownerDocument&&a.removeAttribute};isLeafNode=function(a){switch(a.nodeName){case "OPTION":case "PRE":case "TITLE":return true;default:return false}};noop=m();setHtml=function(a,b){if(isLeafNode(a))if(A)a.innerText=b;else a.textContent=b;else a.innerHTML=b};escapeHtml=
-function(a){if(!a||!a.replace)return a;return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")};escapeAttr=function(a){if(!a||!a.replace)return a;return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;")};bind=function(a,b){if(!a)throw"Missing this";if(!_.isFunction(b))throw"Missing function";return function(){return b.apply(a,arguments)}};shiftBind=function(a,b){return function(){for(var c=[this],d=0;d<arguments.length;d++)c.push(arguments[d]);return b.apply(a,c)}};
-outerHTML=function(a){var b=q.createElement("div");b.appendChild(a);var c=b.innerHTML;b.removeChild(a);return c};trim=function(a){return a.replace(/^ */,"").replace(/ *$/,"")};toBoolean=function(a){var b=(""+a).toLowerCase();if(b=="f"||b=="0"||b=="false"||b=="no")a=false;return!!a};merge=function(a,b){for(var c in a){var d=b[c],e=typeof d;if(e=="undefined")b[c]=fromJson(toJson(a[c]));else e=="object"&&d.constructor!=array&&c.substring(0,1)!="$"&&merge(a[c],d)}};Loader=function(a,b,c){this.document=
-j(a);this.head=j(b);this.k=c;this.location=n.location};Loader.prototype.load=function(){this.Tb();this.ab("/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css");this.ab("/stylesheets/css");console.log("Server: "+this.k.B);this.Sb();this.Rb();this.Ob()};Loader.prototype.Sb=function(){console.log("Loader.configureJQueryPlugins()");j.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};j.fn.controller=function(){return this.data("controller")||
-NullController.lc}};Loader.prototype.Uc=function(){return""+(new Date).getTime()};Loader.prototype.Rb=function(){var a=this.k;if(!a.I){var b=a.B.match(/https?:\/\/([\w]*)/);a.I=b?b[1]:"$MEMORY"}};Loader.prototype.Ob=function(){function a(){g.Ra(function(l){!l&&c.find("[ng-auth=eager]").length&&g.ea()})}console.log("Loader.bindHtml()");var b=new UrlWatcher(this.location),c=this.document,d=new WidgetFactory(this.k.B,this.k.I),e=new Binder(c[0],d,b,this.k);d.Gc=shiftBind(e,e.e);d=new ControlBar(c.find("body"),
-this.k.B);var f=this.k.I=="$MEMORY"?new FrameServer(this.window):new Server(this.k.B,j.getScript);f=new VisualServer(f,new Status(j(c.body)),function(){e.c()});var g=new Users(f,d),h="/data/"+this.k.I,i=new DataStore(function(l,o){f.T("POST",h,l,o)},g,e.anchor);e.rb.push(function(){i.Ta()});var k=new Scope({$anchor:e.anchor,$binder:e,$config:this.k,$console:n.console,$datastore:i,$save:function(l){i.Oc(k.u,l,e.anchor)},$window:n,$uid:this.Uc,$users:g},"ROOT");c.data("scope",k);console.log("$binder.entity()");
-e.O(k);console.log("$binder.compile()");e.compile();console.log("ControlBar.bind()");d.bind();console.log("$users.fetchCurrentUser()");a();console.log("PopUp.bind()");(new PopUp(c)).bind();console.log("$binder.parseAnchor()");e.ib();console.log("$binder.executeInit()");e.fc();console.log("$binder.updateView()");e.c();b.Za=bind(e,e.Ic,b);b.Pd=function(){alert("update")};b.watch();c.find("body").show();console.log("ready()")};Loader.prototype.Tb=function(){var a=n.location.href+"#";a=a.split("#")[1];
-var b={Zb:null};a=a.split("&");for(var c=0;c<a.length;c++){var d=(a[c]+"=").split("=");b[d[0]]=d[1]}if(b.Zb=="console"){y=q.createElement("div");y.id="ng-console";q.getElementsByTagName("body")[0].appendChild(y);console.log=function(){consoleLog("ng-console-info",arguments)};console.error=function(){consoleLog("ng-console-error",arguments)}}};Loader.prototype.ab=function(a){var b=q.createElement("link");b.rel="stylesheet";b.type="text/css";a.match(/^http:/)||(a=this.k.B+a);b.href=a;this.head[0].appendChild(b)};
-UrlWatcher=function(a){this.location=a;this.delay=25;this.setTimeout=function(b,c){n.setTimeout(b,c)};this.Za=function(b){return b};this.P=a.href};UrlWatcher.prototype.watch=function(){var a=this;function b(){if(a.P!==a.location.href){var c=a.location.hash.match(/^#\$iframe_notify=(.*)$/);if(c){a.P.match(/#/)||(a.P+="#");a.location.href=a.P;c="_iframe_notify_"+c[1];var d=x[c];delete x[c];try{(d||noop)()}catch(e){alert(e)}}else{a.Za(a.location.href);a.P=a.location.href}}a.setTimeout(b,a.delay)}b()};
-UrlWatcher.prototype.Rc=function(a){var b=n.location.href;b.match(/#/)||(b+="#");if(b!=a)n.location.href=a;this.Hd=a};UrlWatcher.prototype.Va=function(){return n.location.href};angular.compile=function(a,b){b=b||{};(new Loader(a,j("head"),_({B:""}).extend(b))).load();var c=j(a).scope();return{updateView:function(){return c.c.apply(c,arguments)},set:function(){return c.l.apply(c,arguments)},get:function(){return c.get.apply(c,arguments)}}};angular.Global={typeOf:function(a){var b=typeof a;switch(b){case "object":if(a===
-null)return"null";if(a instanceof Array)return"array";if(a instanceof Date)return"date";if(a.nodeType==1)return"element"}return b}};angular.Collection={};angular.Object={};angular.Array={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=angular.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=
-angular.Function.compile(b);_.detect(a,function(e){if(d(e)){c=e;return true}});return c}},findById:function(a,b){return angular.gd.find(a,function(c){return c.C==b},null)},filter:function(a,b){var c=[];c.Pb=function(k){for(var l=0;l<c.length;l++)if(!c[l](k))return false;return true};var d=Scope.Q;function e(k,l){if(l.charAt(0)==="!")return!e(k,l.substr(1));switch(typeof k){case "boolean":case "number":case "string":return(""+k).toLowerCase().indexOf(l)>-1;case "object":for(var o in k)if(o.charAt(0)!==
-"$"&&e(k[o],l))return true;return false;case "array":for(o=0;o<k.length;o++)if(e(k[o],l))return true;return false;default:return false}}switch(typeof b){case "boolean":case "number":case "string":b={cd:b};case "object":for(var f in b)f=="$"?function(){var k=(""+b[f]).toLowerCase();k&&c.push(function(l){return e(l,k)})}():function(){var k=f,l=(""+b[f]).toLowerCase();l&&c.push(function(o){return e(d(o,k),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.Pb(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=angular.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 toBoolean(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?angular.Function.compile(f):_.identity;return d(function(i,k){return e(h(i),h(k))},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}merge(c,d);return a}};angular.String={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=angular.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}};angular.Date=
-{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"}};angular.Function={compile:function(a){if(_.isFunction(a))return a;else if(a){var b=new Scope;return function(c){b.u=c;return b.eval(a)}}else return function(c){return c}}};(function(){function a(b,c,d){_.extend(b,c);_.each(d||[],function(e){b[e]=_[e]})}a(angular.Global,{},["extend","clone","isEqual",
-"isElement","isArray","isFunction","isUndefined"]);a(angular.Collection,angular.Global,["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);a(angular.Array,angular.Collection,["first","last","compact","flatten","without","uniq","intersect","zip","indexOf","lastIndexOf"]);a(angular.Object,angular.Collection,["keys","values"]);a(angular.String,angular.Global);a(angular.Function,angular.Global,["bind",
-"bindAll","delay","defer","wrap","compose"])})();Binder=function(a,b,c,d){this.F=a;this.ya=c;this.anchor={};this.ad=b;this.k=d||{};this.rb=[]};Binder.ga=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};Binder.kc=function(a){a=Binder.ga(a);return a.length>1||Binder.N(a[0])!==null};Binder.N=function(a){return(a=a.replace(/\n/gm,
-" ").match(/^\{\{(.*)\}\}$/))?a[1]:null};Binder.prototype.Jc=function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b};Binder.prototype.ib=function(a){var b=this;a=a||this.ya.Va();var c=a.indexOf("#");if(!(c<0)){a=this.Jc(a.substring(c+1));j.each(b.anchor,function(d){delete b.anchor[d]});j.each(a,function(d,e){b.anchor[d]=e})}};Binder.prototype.Ic=function(a){console.log("URL change detected",a);this.ib(a);this.c()};
-Binder.prototype.Vc=function(){var a=this.ya.Va(),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.ya.Rc(a);return a};Binder.prototype.c=function(){(new Date).getTime();var a=j(this.F).scope();a.l("$invalidWidgets",[]);a.c();(new Date).getTime();this.Vc();_.each(this.rb,function(b){b()})};Binder.prototype.Z=
-function(a){var b=j(this.F),c=b.find(a);if(b.is(a))c=c.andSelf();return c};Binder.prototype.fc=function(){this.Z("[ng-init]").each(function(){var a=j(this),b=a.scope();try{b.eval(a.attr("ng-init"))}catch(c){alert("EVAL ERROR:\n"+a.attr("ng-init")+"\n"+toJson(c,true))}})};Binder.prototype.O=function(a){this.Z("[ng-entity]").attr("ng-watch",function(){try{var b=j(this);return a.O(b.attr("ng-entity"))+(b.attr("ng-watch")||"")}catch(c){alert(c)}})};Binder.prototype.compile=function(){var a=j(this.F),
-b=this;if(this.k.nd){var c=this.Z(":submit").not("[ng-action]");c.attr("ng-action","$save()");c.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.jb(this.F)(this.F,a.scope(),"");this.Z("a[ng-action]").live("click",function(){var d=j(this);try{d.scope().eval(d.attr("ng-action"));d.removeAttr("ng-error");d.removeClass("ng-exception")}catch(e){d.addClass("ng-exception");d.attr("ng-error",toJson(e,true))}b.c();return false})};Binder.prototype.Tc=function(a,
-b,c){b=b.concat();var d=b.pop(),e=Binder.ga(a.nodeValue);if(e.length>1||Binder.N(e[0])){var f=a.parentNode;if(isLeafNode(f)){f.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,b:function(l){return new BindUpdater(l,l.getAttribute("ng-bind-template"))}})}else for(var g=0;g<e.length;g++){var h=e[g],i=Binder.N(h),k;if(i){k=q.createElement("span");j(k).attr("ng-bind",i);g===0&&c.push({path:b.concat(d+g),b:Binder.prototype.hb})}else if(A&&h.charAt(0)==" "){k=q.createElement("span");k.innerHTML=
-"&nbsp;"+h.substring(1)}else k=q.createTextNode(h);f.insertBefore(k,a)}f.removeChild(a)}};Binder.prototype.jb=function(a){var b=[];this.kb(a,[],b);return function(c,d,e){for(var f=b.length,g=0;g<f;g++){for(var h=b[g],i=c,k=h.path,l=0;l<k.length;l++)i=i.childNodes[k[l]];try{d.Jb(h.b(i,d,e))}catch(o){alert(o)}}}};Binder.prototype.kb=function(a,b,c){var d=a.nodeType;if(d==Node.TEXT_NODE)this.Tc(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?fromJson(e):{};for(var f=d.length,g=0;g<f;g++){var h=d[g],i=h.name;h=A&&i=="href"?decodeURI(a.getAttribute(i,2)):h.value;if(Binder.kc(h))e[i]=h}d=toJson(e);d.length>2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||console.log(a);var k=a.getAttribute("ng-repeat");if(k){a.removeAttribute("ng-repeat");var l=this.jb(a);d=q.createComment("ng-repeat: "+k);e=a.parentNode;e.insertBefore(d,a);
-e.removeChild(a);var o=function(p,r,s){var v=j(a).clone();v.css("display","");v.attr("ng-repeat-index",""+s);v.data("scope",p);l(v[0],p,r+s+":");return v};c.push({path:b,b:function(p,r,s){return new RepeaterUpdater(j(p),k,o,s)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,b:this.Ac});a.getAttribute("ng-bind")&&c.push({path:b,b:this.hb});a.getAttribute("ng-bind-attr")&&c.push({path:b,b:this.wc});a.getAttribute("ng-hide")&&c.push({path:b,b:this.Bc});a.getAttribute("ng-show")&&c.push({path:b,b:this.Cc});
-a.getAttribute("ng-class")&&c.push({path:b,b:this.xc});a.getAttribute("ng-class-odd")&&c.push({path:b,b:this.zc});a.getAttribute("ng-class-even")&&c.push({path:b,b:this.yc});a.getAttribute("ng-style")&&c.push({path:b,b:this.Dc});a.getAttribute("ng-watch")&&c.push({path:b,b:this.Ec});d=a.nodeName;if(d=="INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var t=this;c.push({path:b,b:function(p,r,s){p.name=s+p.name.split(":").pop();return t.ad.Ub(j(p),r)}})}if(d=="OPTION")if(!j("<select/>").append(j(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.kb(d[e],b.concat(e),c)}}}};Binder.prototype.Ac=function(a){return new EvalUpdater(a,a.getAttribute("ng-eval"))};Binder.prototype.hb=function(a){return new BindUpdater(a,"{{"+a.getAttribute("ng-bind")+"}}")};Binder.prototype.wc=function(a){return new BindAttrUpdater(a,fromJson(a.getAttribute("ng-bind-attr")))};Binder.prototype.Bc=function(a){return new HideUpdater(a,a.getAttribute("ng-hide"))};Binder.prototype.Cc=function(a){return new ShowUpdater(a,
-a.getAttribute("ng-show"))};Binder.prototype.xc=function(a){return new ClassUpdater(a,a.getAttribute("ng-class"))};Binder.prototype.yc=function(a){return new ClassEvenUpdater(a,a.getAttribute("ng-class-even"))};Binder.prototype.zc=function(a){return new ClassOddUpdater(a,a.getAttribute("ng-class-odd"))};Binder.prototype.Dc=function(a){return new StyleUpdater(a,a.getAttribute("ng-style"))};Binder.prototype.Ec=function(a,b){b.watch(a.getAttribute("ng-watch"))};ControlBar=function(a,b){this.document=
-a;this.ka=b;this.window=n;this.H=[]};ControlBar.prototype.bind=m();ControlBar.hd='<div><div class="ui-widget-overlay"></div><div id="ng-login" ng-non-bindable="true"><div class="ng-login-container"></div></div></div>';ControlBar.prototype.ea=function(a){this.H.push(a);this.H.length==1&&this.Pa("/user_session/new.mini?return_url="+encodeURIComponent(this.sb()))};ControlBar.prototype.fb=function(a){this.H.push(a);this.H.length==1&&this.Pa("/user_session/do_destroy.mini")};ControlBar.prototype.sb=function(){return this.window.location.href.split("#")[0]};
-ControlBar.prototype.Pa=function(a){var b=this,c=(new Date).getTime(),d=this.sb();d+="#$iframe_notify="+c;var e=j('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+d+'" src="'+this.ka+a+'" width="500" height="330"/></div>');this.document.append(e);e.Oa({height:363,width:500,Xd:false,tc:true,title:'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'});x["_iframe_notify_"+c]=function(){e.Oa("destroy");e.remove();j.each(b.H,function(f,g){g()});b.H=[]}};
-ControlBar.Ab='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';ControlBar.prototype.ua=function(){if(!this.Ua){this.Ua=j(ControlBar.Ab);this.Ua.Oa({sd:true,height:70,tc:true})}};DataStore=function(a,b,c){this.post=a;this.tb=b;this.D={V:[]};this.anchor=c;this.X=[]};DataStore.prototype.Y=function(a){if(a.constructor!=Model)throw"Parameter must be an instance of Entity! "+toJson(a);var b=a.W+"/"+a.C,c=this.D[b];if(c)Model.oa(a,c);else c=this.D[b]=
-a;return c};DataStore.prototype.load=function(a,b,c,d){if(b&&b!=="*"){var e=this;this.G(["GET",a.W+"/"+b],function(f){a.K(f);a.Ca();f=a.U(a);e.Y(f);(c||noop)(a)},d)}return a};DataStore.prototype.ra=function(a,b,c){var d=this,e=[],f=0;j.each(b,function(g,h){e.push(d.load(a(),h,function(){f++;if(f==b.length)(c||noop)(e)}))});return e};DataStore.prototype.bb=function(a,b,c){return this.load(a,b,c,function(d){if(d.ma==404){a.C=b;(c||noop)(a)}else throw d;})};DataStore.prototype.rc=function(a,b){var c=
-this,d=[];d.Aa=function(e){return e.W==a.title};this.D.V.push(d);this.G(["GET",a.title],function(e){for(var f=0;f<e.length;f++){var g=a();g.K(e[f]);d.push(c.Y(g))}(b||noop)(d)});return d};DataStore.prototype.save=function(a,b){var c=this,d={};a.Da(d);this.G(["POST","",d],function(e){a.K(e);var f=c.Y(a);_.each(c.D.V,function(g){g.Aa(a)&&angular.Array.includeIf(g,f,true)});if(a.Ba)c.anchor[a.Ba]=a.C;b&&b(a)})};DataStore.prototype.remove=function(a,b){var c=this,d={};a.Da(d);this.G(["DELETE","",d],function(e){delete c.D[a.W+
-"/"+a.C];_.each(c.D.V,function(f){for(var g=0;g<f.length;g++)f[g].C==a.C&&f.splice(g,1)});(b||noop)(e)})};DataStore.prototype.G=function(a,b,c){a.vb=b;a.xb=c||function(d){throw d;};this.X.push(a)};DataStore.prototype.Ta=function(){function a(d,e){console.log("RESPONSE["+d+"]: ",e);if(e.ma==401)b.tb.ea(function(){b.post(c,a)});else if(e.ma)alert(toJson(e));else for(var f=0;f<e.length;f++){var g=e[f],h=c[f];if(d=g.ma)d==403?b.tb.ua():h.xb(g);else h.vb(g)}}if(this.X.length!==0){var b=this,c=this.X;this.X=
-[];console.log("REQUEST:",c);this.post(c,a)}};DataStore.prototype.Oc=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.la==Model.prototype.la){d++;f.la(c)}}c()};DataStore.prototype.R=function(a,b,c,d){var e=this,f=[];f.Aa=w(false);this.D.V.push(f);this.G(["GET",a.title+"/"+b+"="+c],function(g){for(var h=0;h<g.length;h++){var i=(new a).K(g[h]);f.push(e.Y(i))}d&&d(f)});return f};DataStore.L=m();DataStore.L.all=function(){return[]};DataStore.L.R=function(){return[]};
-DataStore.L.load=function(){return{}};DataStore.L.title=undefined;DataStore.prototype.O=function(a,b){if(!a)return DataStore.L;var c=this;function d(e){return new Model(d,e)}d.title=a;d.wb=true;d.Na=this;d.$b=b||{};d.load=function(e,f){return c.load(d(),e,f)};d.ra=function(e,f){return c.ra(d,e,f)};d.bb=function(e,f){return c.bb(d(),e,f)};d.all=function(e){return c.rc(d,e)};d.R=function(e,f,g){return c.R(d,e,f,g)};d.Vd=function(e){c.G(["GET",a+"/$properties"],e)};return d};DataStore.prototype.join=
-function(a){function b(){throw"Joined entities can not be instantiated into a document.";}var c=_(a).td().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].fa?a[d].fa.substring(0,a[d].fa.indexOf(".")):undefined}while(d);return e.length}).value();if(_(c).select(function(d){return a[d].fa}).length!=c.length-1)throw"Exactly one entity needs to be primary.";
-b.R=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.R(d.substring(d.indexOf(".")+1),e,function(i){var k=c[h++],l=a[k],o=l.fa,t={};_(i).each(function(p){var r={};f.push(r);r[g]=p;p=Scope.Q(r,o);t[p]=p});l.join.ra(_.toArray(t),function(p){var r={};_(p).each(function(s){r[s.C]=s});_(f).each(function(s){var v=Scope.Q(s,o);s[k]=r[v]})})});return f};return b};angular.filter.j=
-function(a){if(a)for(var b in a)this[b]=a[b]};angular.filter.j.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}};angular.filter.currency=function(a){j(this.element).toggleClass("ng-format-negative",a<0);return"$"+angular.filter.va.apply(this,[a,2])};angular.filter.va=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};angular.filter.Xb=m();angular.filter.oc=function(a){j(this.element).addClass("ng-monospace");return toJson(a,true)};angular.filter.pb=function(a,b){a=trim(a);for(var c=a.replace(/ /g,""),d=angular.filter.pb.Bb,e=0;e<d.length;e++)for(var f=d[e],g=0;g<f.S.length;g++)if(f.S[g].test(c)){b=
-f.name+": "+a;f=f.url+a;return new angular.filter.j({text:b,url:f,html:'<a href="'+escapeAttr(f)+'">'+b+"</a>",be:a})}return a?b||new angular.filter.j({text:a+" is not recognized"}):null};angular.filter.pb.Bb=[{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=",S:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",S:[/^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=",S:[/^(91\d{20})$/i,/^(91\d{18})$/i]}];angular.filter.link=function(a,b){b=b||angular.filter.j.get(a);var c=angular.filter.j.get(a,"url")||angular.filter.j.get(a);if(c){if(angular.h.bc(c)===null)c="mailto:"+c;a='<a href="'+escapeHtml(c)+'">'+b+"</a>";return new angular.filter.j({text:b,url:c,html:a})}return a};angular.filter.Ja=function(a){if(a===null)return"";
-for(var b=0;a>1E3;){a/=1024;b++}a=""+a;var c=a.indexOf(".");if(c>-1&&c+2<a.length)a=a.substring(0,c+2);return a+" "+angular.filter.Ja.Cb[b]};angular.filter.Ja.Cb=["bytes","KB","MB","GB","TB","PB"];angular.filter.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 angular.filter.j({url:a.url,text:a.url,html:'<img src="'+a.url+'"'+d+"/>"})}return null};angular.filter.Nd=function(a){return(a=angular.filter.j.get(a))?(""+a).toLowerCase():
-a};angular.filter.fe=function(a){return(a=angular.filter.j.get(a))?(""+a).toUpperCase():a};angular.filter.Md=function(a){a=angular.filter.j.get(a);if(a===""||!a)return 1;return a.split(/\n|\f/).length};angular.filter["if"]=function(a,b){return b?a:undefined};angular.filter.de=function(a,b){return b?undefined:a};angular.filter.g=function(a,b,c,d){b=b||{};var e=angular.filter.g;a={Qb:a,vd:e.La(b,"color"),Bd:e.title(b),xd:e.La(b,"label"),wd:e.values(b),yd:"bg,s,FFFFFF00"};if(_.isArray(b.bd)){a.Dd="x";
-a.Cd="0:|"+b.bd.join("|")}return angular.filter.g.$(a,c,d)};angular.filter.g.values=function(a){var b=[];_.each(a.Qc||[],function(c){var d=[];_.each(c.values||[],function(e){d.push(e)});b.push(d.join(","))});a=b.join("|");return a===""?null:"t:"+a};angular.filter.g.title=function(a){var b=[];a=a.title||[];_.each(_.isArray(a)?a:[a],function(c){b.push(encodeURIComponent(c))});return b.join("|")};angular.filter.g.La=function(a,b){var c=[],d=0;_.each(a.Qc||[],function(e){var f=[];e=e[b]||[];_.each(_.isArray(e)?
-e:[e],function(g){f.push(encodeURIComponent(g));d++});c.push(f.join("|"))});return d?c.join(","):null};angular.filter.g.$=function(a,b,c){b=b||200;c=c||b;var d="http://chart.apis.google.com/chart?",e=[];a.Ad=b+"x"+c;for(var f in a){var g=a[f];g&&e.push(f+"="+g)}e.sort();d+=e.join("&");return new angular.filter.j({url:d,text:g,html:'<img width="'+b+'" height="'+c+'" src="'+d+'"/>'})};angular.filter.Wd=function(a,b,c){return angular.filter.g.$({Qb:"qr",zd:encodeURIComponent(a)},b,c)};angular.filter.ud=
-{Sd:function(a,b,c){return angular.filter.g("p",a,b,c)},Td:function(a,b,c){return angular.filter.g("p3",a,b,c)},Ud:function(a,b,c){return angular.filter.g("pc",a,b,c)},pd:function(a,b,c){return angular.filter.g("bhs",a,b,c)},od:function(a,b,c){return angular.filter.g("bhg",a,b,c)},rd:function(a,b,c){return angular.filter.g("bvs",a,b,c)},qd:function(a,b,c){return angular.filter.g("bvg",a,b,c)},Ld:function(a,b,c){return angular.filter.g("lc",a,b,c)},Zd:function(a,b,c){return angular.filter.g("ls",a,
-b,c)},Yd:function(a,b,c){return angular.filter.g("s",a,b,c)}};angular.filter.html=function(a){return new angular.filter.j({html:a})};array=[].constructor;toJson=function(a,b){var c=[];toJsonArray(c,a,b?"\n ":null);return c.join("")};toPrettyJson=function(a){return toJson(a,true)};fromJson=function(a){try{var b=new Parser(a,true),c=b.ia();b.M();return c()}catch(d){console.error("fromJson error: ",a,d);throw d;}};toJsonArray=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(angular.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"):toJsonArray(a,g,c);d=true}a.push("]")}else if(b instanceof Date)a.push(angular.String.quoteUnicode(angular.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(angular.String.quote(i));a.push(":");toJsonArray(a,e,f);d=true}}catch(k){}}a.push("}")}};Model=function(a,b){this.U=a;this.K(b||{});this.W=a.title;this.Ca()};Model.oa=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]}};Model.prototype.Ca=function(){merge(this.U.$b,this);return this};Model.prototype.la=function(a){this.U.Na.save(this,a===true?undefined:a);a===true&&this.U.Na.Ta();return this};Model.prototype.K=function(a){Model.oa(a,this);return this};Model.prototype.Da=function(a){Model.oa(this,a);return this};Lexer=function(a,b){this.text=a;this.Yb=b?20:-1;this.i=[];this.index=0};Lexer.Ea={"null":w(null),"true":w(true),"false":w(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.l(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}};Lexer.prototype.J=function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false};Lexer.prototype.parse=function(){for(var a=this.i,b=Lexer.Ea,c=true;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=='"'||d=="'"){this.Mc(d);c=true}else if(d=="("||d=="["){a.push({index:this.index,text:d});this.index++}else if(d=="{"){c=this.J();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.Lc();c=false}else if(this.pa(d)){this.Kc();c=false}else if(this.ca(d)){this.lb();c=false}else if(this.nc(d))this.index++;else{c=d+this.J();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};Lexer.prototype.pa=function(a){return"0"<=a&&a<="9"};Lexer.prototype.nc=function(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"};Lexer.prototype.ca=function(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"};Lexer.prototype.Kc=function(){for(var a="",b=this.index;this.index<this.text.length;){var c=
-this.text.charAt(this.index);if(c=="."||this.pa(c))a+=c;else break;this.index++}a=1*a;this.i.push({index:b,text:a,b:function(){return a}})};Lexer.prototype.lb=function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.ca(c)||this.pa(c))a+=c;else break;this.index++}c=Lexer.Ea[a];if(!c){c=function(d){return d.scope.get(a)};c.ba=a}this.i.push({index:b,text:a,b:c})};Lexer.zb={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'};Lexer.prototype.Mc=
-function(a){var b=this.index,c=this.Yb;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=Lexer.zb[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?angular.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+"'.";};Lexer.prototype.Lc=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.ca(this.text.charAt(this.index))){this.lb();c=this.i.pop().text}var e=new RegExp(b,c);this.i.push({index:a,text:b,Id: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+"'.";};Parser=function(a,b){this.text=a;this.i=(new Lexer(a,b)).parse();this.index=0};Parser.Db=w(0);Parser.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)+"'.";};Parser.prototype.ha=function(){if(this.i.length===0)throw"Unexpected end of expression: "+this.text;return this.i[0]};Parser.prototype.J=
-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};Parser.prototype.a=function(a,b,c,d){if(a=this.J(a,b,c,d)){this.i.shift();return this.Ed=a}return false};Parser.prototype.m=function(a){if(!this.a(a)){var b=this.J();throw"Expecting '"+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}};Parser.prototype.Eb=function(a,b){var c=b.apply(this);return function(d){return a(d,c(d))}};
-Parser.prototype.w=function(a,b,c){var d=c.apply(this);return function(e){return b(e,a(e),d(e))}};Parser.prototype.Wa=function(){return this.i.length>0};Parser.prototype.M=function(){if(this.i.length!==0)throw"Did not understand '"+this.text.substring(this.i[0].index)+"' while evaluating '"+this.text+"'.";};Parser.prototype.xa=function(){for(var a=[];;){this.i.length>0&&!this.J("}",")",";","]")&&a.push(this.Sa());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}}};
-Parser.prototype.Sa=function(){for(var a=this.q(),b;;)if(b=this.a("|"))a=this.w(a,b.b,this.filter);else return a};Parser.prototype.filter=function(){return this.Ga(angular.filter)};Parser.prototype.h=function(){return this.Ga(angular.validator)};Parser.prototype.Ga=function(a){for(var b=this.jc(a),c=[];;)if(this.a(":"))c.push(this.q());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}}};Parser.prototype.q=function(){return this.Sc()};
-Parser.prototype.Sc=function(){if(this.a("throw")){var a=this.Ia();return function(b){throw a(b);}}else return this.Ia()};Parser.prototype.Ia=function(){var a=this.eb(),b;if(b=this.a("=")){if(!a.ba)throw"Left hand side '"+this.text.substring(0,b.index)+"' of assignment '"+this.text.substring(b.index)+"' is not assignable.";return this.w(function(){return a.ba},b.b,this.eb)}else return a};Parser.prototype.eb=function(){for(var a=this.db(),b;;)if(b=this.a("||"))a=this.w(a,b.b,this.db);else return a};
-Parser.prototype.db=function(){for(var a=this.gb(),b;;)if(b=this.a("&&"))a=this.w(a,b.b,this.gb);else return a};Parser.prototype.gb=function(){var a;return(a=this.a("!"))?this.Eb(a.b,this.Qa):this.Qa()};Parser.prototype.Qa=function(){for(var a=this.mb(),b;;)if(b=this.a("==","!="))a=this.w(a,b.b,this.mb);else return a};Parser.prototype.mb=function(){for(var a=this.Ha(),b;;)if(b=this.a("<",">","<=",">="))a=this.w(a,b.b,this.Ha);else return a};Parser.prototype.Ha=function(){for(var a=this.ta(),b;b=this.a("+",
-"-");)a=this.w(a,b.b,this.ta);return a};Parser.prototype.ta=function(){for(var a=this.qb(),b;b=this.a("*","/","%");)a=this.w(a,b.b,this.qb);return a};Parser.prototype.qb=function(){var a;return this.a("+")?this.ia():(a=this.a("-"))?this.w(Parser.Db,a.b,this.ta):this.ia()};Parser.prototype.jc=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};Parser.prototype.ia=function(){var a;if(this.a("(")){a=this.Sa();this.m(")");a=a}else if(this.a("["))a=this.Kb();else if(this.a("{"))a=this.object();else if(this.a("{:"))a=this.Ka(false);else if(this.a("{("))a=this.Ka(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.ic(a);else if(b.text==="[")a=this.Fc(a);else if(b.text===".")a=this.gc(a);else throw"IMPOSSIBLE";return a};Parser.prototype.Ka=function(a){var b=[];
-if(a){if(!this.a(")")){for(b.push(this.a().text);this.a(",");)b.push(this.a().text);this.m(")")}this.m(":")}var c=this.xa();this.m("}");return function(d){return function(e){var f=new Scope(d.scope.u);f.l("$",e);for(var g=0;g<b.length;g++)f.l(b[g],arguments[g]);return c({scope:f})}}};Parser.prototype.gc=function(a){var b=this.a().text;function c(d){return Scope.Q(a(d),b)}c.ba=b;return c};Parser.prototype.Fc=function(a){var b=this.q();this.m("]");if(this.a("=")){var c=this.q();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}};Parser.prototype.ic=function(a){var b=[];if(this.ha().text!=")"){do b.push(this.q());while(this.a(","))}this.m(")");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.ba+"' is not a function.";}};Parser.prototype.Kb=function(){var a=[];if(this.ha().text!="]"){do a.push(this.q());while(this.a(","))}this.m("]");return function(b){for(var c=
-[],d=0;d<a.length;d++)c.push(a[d](b));return c}};Parser.prototype.object=function(){var a=[];if(this.ha().text!="}"){do{var b=this.a().text;this.m(":");var c=this.q();a.push({pc:b,value:c})}while(this.a(","))}this.m("}");return function(d){for(var e={},f=0;f<a.length;f++){var g=a[f],h=g.value(d);e[g.pc]=h}return e}};Parser.prototype.ec=function(){for(var a=[];this.Wa();){a.push(this.dc());this.a(";")||this.M()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}};Parser.prototype.dc=
-function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c=this.ia()(null);return function(d){var e=d.scope.get("$datastore").O(a,c);d.scope.l(a,e);if(b){e=e();e.Ba=b;d.scope.l(b,e);return"$anchor."+b+":{"+b+"="+a+".load($anchor."+b+");"+b+".$$anchor="+angular.String.quote(b)+";};"}else return""}};Parser.prototype.watch=function(){for(var a=[];this.Wa();){a.push(this.$c());this.a(";")||this.M()}this.M();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.Hb(d.name,
-d.b)}}};Parser.prototype.$c=function(){var a=this.a().text;this.m(":");var b;if(this.ha().text=="{"){this.m("{");b=this.xa();this.m("}")}else b=this.q();return function(){return{name:a,b:b}}};Scope=function(a,b){this.ub=[];this.za={};this.name=b;a=a||{};function c(){}c.prototype=a;this.u=new c;this.u.ed=a;if(b=="ROOT")this.u.fd=this.u};Scope.aa={};Scope.prototype.c=function(){var a=this;this.hc();_.each(this.ub,function(b){a.o(b,"",{},function(){this.c(a)})})};Scope.prototype.Jb=function(a){a&&this.ub.push(a)};
-Scope.prototype.mc=function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!Lexer.prototype.ca(c))return false}return true};Scope.Q=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=angular.Global.typeOf(e);if(d=(h=angular[h.charAt(0).toUpperCase()+h.substring(1)])?h[[d.substring(1)]]:
-undefined)return a=_.bind(d,e,e)}}if(typeof a==="function"&&!a.wb)return bind(e,a);return a};Scope.prototype.get=function(a){return Scope.Q(this.u,a)};Scope.prototype.l=function(a,b){a=a.split(".");for(var c=this.u,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};Scope.prototype.p=function(a,b){this.eval(a+"="+toJson(b))};Scope.prototype.eval=function(a,b){var c=Scope.aa[a];if(!c){var d=new Parser(a);c=d.xa();d.M();Scope.aa[a]=c}b=b||{};b.scope=this;return c(b)};
-Scope.prototype.o=function(a,b,c,d,e){try{var f=this.eval(b,c);if(a.A){a.A=false;j(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){console.error("Eval Widget Error:",g);b=toJson(g,true);a.A=true;j(a.view).addClass("ng-exception").attr("ng-error",b);e&&e.apply(a,[g,b]);return false}};Scope.prototype.Yc=function(a,b){var c=Scope.aa[a];if(!c){c=(new Parser(a)).h();Scope.aa[a]=c}a={scope:this};return c(a)(a,b)};Scope.prototype.O=function(a){return(new Parser(a)).ec()({scope:this})};
-Scope.prototype.sc=function(a){this.u.dd.push(a)};Scope.prototype.watch=function(a){var b=this;(new Parser(a)).watch()({scope:this,Hb:function(c,d){b.Ib(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})};Scope.prototype.Ib=function(a,b){var c=this.za[a];if(!c){c={$a:[],q:a};this.za[a]=c}c.$a.push(b)};Scope.prototype.hc=function(){var a=this,b=false;j.each(this.za,function(c,d){var e=a.eval(d.q);if(e!==d.d){j.each(d.$a,function(f,g){g(e,d.d);b=true});d.d=e}});return b};Server=function(a,
-b){this.url=a;this.uc=0;this.getScript=b;this.Xc="_"+(""+Math.random()).substr(2)+"_";this.sa=1800};Server.prototype.Mb=function(a){return z.$(a)};Server.prototype.T=function(a,b,c,d){var e=this.Xc+this.uc++;x[e]=function(h){delete angular[e];d(200,h)};a={ce:b,Od:a,Qd:c};a=this.Mb(toJson(a));b=Math.ceil(a.length/this.sa);c=this.url+"/$/"+e+"/"+b+"/";for(var f=0;f<b;f++){var g=a.substr(f*this.sa,this.sa);this.getScript(c+(f+1)+"?h="+g,noop)}};FrameServer=u("frame");FrameServer.jd="$DATASET:";FrameServer.prototype=
-{T:m()};VisualServer=function(a,b,c){this.ac=a;this.update=c;this.status=b};VisualServer.prototype={T:function(a,b,c,d){var e=this;this.status.Nb(c);this.ac.T(a,b,c,function(){e.status.cc();try{d.apply(this,arguments)}catch(f){alert(toJson(f))}e.update()})}};Users=function(a,b){this.B=a;this.na=b};Users.prototype={Ra:function(a){var b=this;this.B.T("GET","/account.json",{},function(c,d){b.Wb=d.Wc;a(d.Wc)})},fb:function(a){var b=this;this.na.fb(function(){delete b.Wb;(a||noop)()})},ea:function(a){var b=
-this;this.na.ea(function(){b.Ra(function(){(a||noop)()})})},ua:function(){this.na.ua()}};angular.h.S=function(a,b,c){return a.match(b)?null:c||"Value does not match expected format "+b+"."};angular.h.va=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."};angular.h.Kd=function(a,b,c){b=angular.h.va(a,b,c);if(b===null&&a!=
-Math.round(a))return"Value is not a whole number.";return b};angular.h.Xb=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)."};angular.h.$d=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."};angular.h.bc=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."};angular.h.Rd=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."};angular.h.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."};angular.h.oc=function(a){try{fromJson(a);return null}catch(b){return b.toString()}};WidgetFactory=function(a,b){this.vc=0;this.ka=
-a;this.I=b;this.Ma=n.ae?swfobject.Ma:function(){alert("ERROR: swfobject not loaded!")};this.Gc=m()};WidgetFactory.prototype.Ub=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 ButtonController(a[0],e);f="click";g=false}else if(d=="text"||d=="textarea"||d=="hidden"||d=="password"){c=new TextController(a[0],e);f="keyup change"}else if(d=="checkbox"){c=new CheckboxController(a[0],
-e);f="click"}else if(d=="radio"){c=new RadioController(a[0],e);f="click"}else if(d=="select-one")c=new SelectController(a[0],e);else if(d=="select-multiple")c=new MultiSelectController(a[0],e);else if(d=="file")c=this.Vb(a,e);else throw"Unknown type: "+d;a.data("controller",c);var h=b.get("$binder");j(c.view,":input").bind(f,function(){if(c.e(b)){var i=j(c.view).attr("ng-action")||"";b.o(c,i)&&h.c(b)}return g});return c};WidgetFactory.prototype.Vb=function(a){var b="__uploadWidget_"+this.vc++,c=FileController.template(b);
-a.after(c);b=this.Ma({data:this.ka+"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",ge:"transparent"},{Jd:"uploadWidgetId="+b,kd:"always"},b);a.remove();a=new FileController(c,a[0].name,b,this.ka+"/data/"+this.I);j(b).data("controller",a);return a};FileController=function(a,b,c,d){this.view=a;this.ee=c;this.nb=b;this.md=d+"/_attachments";this.value=null;this.d=undefined};FileController.dispatchEvent=function(a,b,c){a=q.getElementById(a);a=j(a).data("controller");FileController.prototype["_on_"+
-b].apply(a,c)};FileController.template=function(a){return j('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+a+'" /><a></a><span/></span>')};FileController.prototype.e=function(a){var b=this.view.find("input").attr("checked")?this.value:null;if(this.d===b)return false;else{a.l(this.nb,b);return true}};FileController.prototype.c=function(a){if((a=a.get(this.nb))&&this.value!==a){this.value=a;this.view.find("a").attr("href",this.value.url).text(this.value.text);
-this.view.find("span").text(angular.filter.bytes(this.value.size))}this.view.find("input").attr("checked",!!a)};NullController=u("view");NullController.prototype.e=w(true);NullController.prototype.c=m();NullController.lc=new NullController;ButtonController=u("view");ButtonController.prototype.e=w(true);ButtonController.prototype.c=m();TextController=function(a,b){this.view=a;this.exp=b;this.h=a.getAttribute("ng-validate");this.Nc=typeof a.attributes["ng-required"]!="undefined";this.Ya=null;this.d=
-undefined;this.s=a.value;a.getAttribute("ng-widget")==="datepicker"&&j(a).Fd()};TextController.prototype.e=function(a){var b=this.view.value;if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}};TextController.prototype.c=function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.s;a.p(this.exp,c)}c=c?c:"";if(this.d!=c)this.d=b.value=c;var d=false;b.removeAttribute("ng-error");if(this.Nc)d=!(c&&c.length>0);var e=d?"Required Value":null;if(!d&&this.h&&c){e=a.Yc(this.h,
-c);d=!!e}if(this.Ya!==e){this.Ya=d;if(e!==null){b.setAttribute("ng-error",e);a.sc(this)}j(b).toggleClass("ng-validation-error",d)}};CheckboxController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.s=a.checked?a.value:""};CheckboxController.prototype.e=function(a){var b=this.view;b=b.checked?b.value:"";if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}};CheckboxController.prototype.c=function(a){var b=this.view,c=a.eval(this.exp);if(typeof c==="undefined"){c=this.s;
-a.p(this.exp,c)}b.checked=b.value==""+c};SelectController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.s=a.value};SelectController.prototype.e=function(a){if(this.view.selectedIndex<0)a.p(this.exp,null);else{var b=this.view.value;if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}}};SelectController.prototype.c=function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.s;a.p(this.exp,c)}if(c!==this.d){b.value=c?c:"";this.d=c}};MultiSelectController=
-function(a,b){this.view=a;this.exp=b;this.d=undefined;this.s=this.selected()};MultiSelectController.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};MultiSelectController.prototype.e=function(a){var b=this.selected();if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}};MultiSelectController.prototype.c=function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.s;a.p(this.exp,c)}if(c!==
-this.d){a=b.options;for(b=0;b<a.length;b++){var d=a[b];d.selected=_.include(c,d.value)}this.d=c}};RadioController=function(a,b){this.view=a;this.exp=b;this.d=this.qa=undefined;this.Xa=a.value;this.s=a.checked?a.value:null};RadioController.prototype.e=function(a){var b=this.view;if(this.qa)return false;else{b.checked=true;this.d=a.p(this.exp,this.Xa);return this.qa=true}};RadioController.prototype.c=function(a){var b=this.view,c=a.get(this.exp);if(this.s&&typeof c==="undefined"){c=this.s;a.p(this.exp,
-c)}if(this.d!=c){this.qa=b.checked=this.Xa==""+c;this.d=c}};BindUpdater=function(a,b){this.view=a;this.exp=Binder.ga(b);this.A=false;this.Pc={element:a}};BindUpdater.ob=function(a){var b=escapeHtml;switch(typeof a){case "string":case "boolean":case "number":return b(a);case "function":return BindUpdater.ob(a());case "object":if(isNode(a))return outerHTML(a);else if(a instanceof angular.filter.j){switch(typeof a.html){case "string":case "number":return a.html;case "function":return a.html();case "object":if(isNode(a.html))return outerHTML(a.html);
-default:break}switch(typeof a.text){case "string":case "number":return b(a.text);case "function":return b(a.text());default:break}}if(a===null)return"";return b(toJson(a,true));default:return""}};BindUpdater.prototype.e=m();BindUpdater.prototype.c=function(a){for(var b=[],c=this.exp,d=c.length,e=0;e<d;e++){var f=c[e],g=Binder.N(f);if(g){a.o(this,g,this.Pc,function(h){b.push(BindUpdater.ob(h))},function(h,i){setHtml(this.view,i)});if(this.A)return}else b.push(escapeHtml(f))}setHtml(this.view,b.join(""))};
-BindAttrUpdater=function(a,b){this.view=a;this.Lb=b};BindAttrUpdater.prototype.e=m();BindAttrUpdater.prototype.c=function(a){var b=j(this.view),c=this.Lb;if(this.A){this.A=false;b.removeClass("ng-exception").removeAttr("ng-error")}var d=b.is("img");for(var e in c){for(var f=Binder.ga(c[e]),g=[],h=0;h<f.length;h++){var i=Binder.N(f[h]);if(i)try{var k=a.eval(i,{element:b[0],attrName:e});if(k&&(k.constructor!==array||k.length!==0))g.push(k)}catch(l){this.A=true;console.error("BindAttrUpdater",l);i=toJson(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)}};EvalUpdater=function(a,b){this.view=a;this.exp=b;this.A=false};EvalUpdater.prototype.e=m();EvalUpdater.prototype.c=function(a){a.o(this,this.exp)};HideUpdater=function(a,b){this.view=a;this.exp=b};HideUpdater.prototype.e=m();HideUpdater.prototype.c=function(a){a.o(this,this.exp,{},function(b){var c=j(this.view);
-toBoolean(b)?c.hide():c.show()})};ShowUpdater=function(a,b){this.view=a;this.exp=b};ShowUpdater.prototype.e=m();ShowUpdater.prototype.c=function(a){a.o(this,this.exp,{},function(b){var c=j(this.view);toBoolean(b)?c.show():c.hide()})};ClassUpdater=function(a,b){this.view=a;this.exp=b};ClassUpdater.prototype.e=m();ClassUpdater.prototype.c=function(a){a.o(this,this.exp,{},function(b){if(b!==null&&b!==undefined)this.view.className=b})};ClassEvenUpdater=function(a,b){this.view=a;this.exp=b};ClassEvenUpdater.prototype.e=
-m();ClassEvenUpdater.prototype.c=function(a){a.o(this,this.exp,{},function(b){var c=a.get("$index");j(this.view).toggleClass(b,c%2===1)})};ClassOddUpdater=function(a,b){this.view=a;this.exp=b};ClassOddUpdater.prototype.e=m();ClassOddUpdater.prototype.c=function(a){a.o(this,this.exp,{},function(b){var c=a.get("$index");j(this.view).toggleClass(b,c%2===0)})};StyleUpdater=function(a,b){this.view=a;this.exp=b};StyleUpdater.prototype.e=m();StyleUpdater.prototype.c=function(a){a.o(this,this.exp,{},function(b){j(this.view).attr("style",
-"").css(b)})};RepeaterUpdater=function(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.da=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.Zc=a[3]||a[1];this.qc=a[2]};RepeaterUpdater.prototype.e=m();RepeaterUpdater.prototype.c=function(a){a.o(this,
-this.da,{},function(b){var c=this;if(!b){b=[];a.mc(this.da)&&a.l(this.da,b)}var d=b.length,e=this.children.length,f=this.view,g=0,h=null,i=this.qc,k=this.Zc,l=0;j.each(b,function(t,p){if(l<e){h=c.children[l];h.scope.l(k,p)}else{var r=new Scope(a.u,c.prefix+k+" in "+c.da+"["+l+"]");r.l("$index",l);i&&r.l(i,t);r.l(k,p);h={scope:r,element:c.template(r,c.prefix,l)};f.after(h.element);c.children.push(h)}f=h.element;t=(new Date).getTime();h.scope.c();g+=(new Date).getTime()-t;l++});for(b=e;b>d;--b){var o=
-this.children.pop().element[0];o.parentNode.removeChild(o)}if(h&&h.element[0].nodeName==="OPTION")if(d=j(h.element[0].parentNode).data("controller")){d.d=undefined;d.c(a)}})};PopUp=u("F");PopUp.Fa="mouseleave mouseout click dblclick keypress keyup";PopUp.prototype.bind=function(){this.F.find(".ng-validation-error,.ng-exception").live("mouseover",PopUp.Hc)};PopUp.Hc=function(){PopUp.wa();var a=j(this);a.bind(PopUp.Fa,PopUp.wa);var b=a.position(),c=q.documentElement,d=(self.innerWidth||c&&c.clientWidth||
-q.body.clientWidth)-b.left;c=a.hasClass("ng-exception")?"EXCEPTION:":"Validation error...";a=a.attr("ng-error");d=d>375?"left":"right";c=j("<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>");j("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};PopUp.wa=function(){j("#ng-callout").unbind(PopUp.Fa,
-PopUp.wa).remove();return true};Status=function(a){this.cb=a.append(Status.yb).find("#ng-loading");this.ja=0};Status.yb='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';Status.prototype.Nb=function(){this.ja===0&&this.cb.show();this.ja++};Status.prototype.cc=function(){this.ja--;this.ja===0&&this.cb.hide("fold")}})(window,document);
+function p(){return function(){}}function A(n){return function(r){this[n]=r}}function E(n){return function(){return n}}
+(function(n,r){function x(){}function M(a,b){var c=r.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:toJson(f));d=" "}c.appendChild(r.createTextNode(a));F.appendChild(c)}function N(a){switch(a.nodeName){case "OPTION":case "PRE":case "TITLE":return true;default:return false}}function O(a,b){if(N(a))if(G)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 X(a){if(!a||!a.replace)return a;return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;")}function P(a,b){if(!a)throw"Missing this";if(!_.isFunction(b))throw"Missing function";return function(){return b.apply(a,arguments)}}function Y(a,b){return function(){for(var c=[this],d=0;d<arguments.length;d++)c.push(arguments[d]);return b.apply(a,c)}}function Q(a){var b=r.createElement("div");b.appendChild(a);var c=b.innerHTML;b.removeChild(a);return c}
+function R(a){var b=(""+a).toLowerCase();if(b=="f"||b=="0"||b=="false"||b=="no")a=false;return!!a}function S(a,b){for(var c in a){var d=b[c],e=typeof d;if(e=="undefined")b[c]=fromJson(toJson(a[c]));else e=="object"&&d.constructor!=array&&c.substring(0,1)!="$"&&S(a[c],d)}}function T(a,b,c){this.document=i(a);this.head=i(b);this.i=c;this.location=n.location}function U(a){this.location=a;this.delay=25;this.setTimeout=function(b,c){n.setTimeout(b,c)};this.Ua=function(b){return b};this.N=a.href}var H=
+{u:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",Tb:function(a){var b="",c,d,e,f,g,h,j=0;for(a=H.yb(a);j<a.length;){c=a.charCodeAt(j++);d=a.charCodeAt(j++);e=a.charCodeAt(j++);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},sd: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=H.xb(b)},yb: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},xb: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 r.getAttribute=="undefined")r.getAttribute=p();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};var F,o=_.each,V=_.extend,I=n.console||{log:x,error:x},i=n.jQuery,G=i.browser.msie;function q(){I.log.apply(this,arguments)}function J(){I.error.apply(this,arguments)}var m=n.angular||(n.angular={}),W=m.validator||(m.validator={}),s=m.filter||(m.filter={}),K=m.callbacks||(m.callbacks={});m.alert||(m.alert=function(){q(arguments);n.alert.apply(n,arguments)});
+T.prototype={load:function(){this.Lb();this.Wa("/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css");this.Wa("/stylesheets/css");q("Server: "+this.i.z);this.Kb();this.Jb();this.Gb()},Kb:function(){q("Loader.configureJQueryPlugins()");i.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};i.fn.controller=function(){return this.data("controller")||NullController.cc}},Kc:function(){return""+(new Date).getTime()},Jb:function(){var a=this.i;
+if(!a.G){var b=a.z.match(/https?:\/\/([\w]*)/);a.G=b?b[1]:"$MEMORY"}},Gb:function(){function a(){g.Ma(function(l){!l&&c.find("[ng-auth=eager]").length&&g.ba()})}q("Loader.bindHtml()");var b=new U(this.location),c=this.document,d=new WidgetFactory(this.i.z,this.i.G),e=new Binder(c[0],d,b,this.i);d.wc=Y(e,e.e);d=new ControlBar(c.find("body"),this.i.z);var f=this.i.G=="$MEMORY"?new FrameServer(this.window):new Server(this.i.z,i.getScript);f=new VisualServer(f,new Status(i(c.body)),function(){e.c()});
+var g=new Users(f,d),h="/data/"+this.i.G,j=new DataStore(function(l,y){f.P("POST",h,l,y)},g,e.anchor);e.lb.push(function(){j.Oa()});var k=new Scope({$anchor:e.anchor,$binder:e,$config:this.i,$console:n.console,$datastore:j,$save:function(l){j.Ec(k.s,l,e.anchor)},$window:n,$uid:this.Kc,$users:g},"ROOT");c.data("scope",k);q("$binder.entity()");e.M(k);q("$binder.compile()");e.compile();q("ControlBar.bind()");d.bind();q("$users.fetchCurrentUser()");a();q("PopUp.bind()");(new PopUp(c)).bind();q("$binder.parseAnchor()");
+e.db();q("$binder.executeInit()");e.Xb();q("$binder.updateView()");e.c();b.Ua=P(e,e.yc,b);b.zd=function(){alert("update")};b.watch();c.find("body").show();q("ready()")},Lb:function(){var a=n.location.href+"#";a=a.split("#")[1];var b={Qb:null};a=a.split("&");for(var c=0;c<a.length;c++){var d=(a[c]+"=").split("=");b[d[0]]=d[1]}if(b.Qb=="console"){F=r.createElement("div");F.id="ng-console";r.getElementsByTagName("body")[0].appendChild(F);q=function(){M("ng-console-info",arguments)};I.error=function(){M("ng-console-error",
+arguments)}}},Wa:function(a){var b=r.createElement("link");b.rel="stylesheet";b.type="text/css";a.match(/^http:/)||(a=this.i.z+a);b.href=a;this.head[0].appendChild(b)}};U.prototype={watch:function(){var a=this;function b(){if(a.N!==a.location.href){var c=a.location.hash.match(/^#\$iframe_notify=(.*)$/);if(c){a.N.match(/#/)||(a.N+="#");a.location.href=a.N;c="_iframe_notify_"+c[1];var d=K[c];delete K[c];try{(d||x)()}catch(e){alert(e)}}else{a.Ua(a.location.href);a.N=a.location.href}}a.setTimeout(b,a.delay)}
+b()},Hc:function(a){var b=n.location.href;b.match(/#/)||(b+="#");if(b!=a)n.location.href=a;this.ud=a},Qa:function(){return n.location.href}};m.compile=function(a,b){b=b||{};(new T(a,i("head"),_({z:""}).extend(b))).load();var c=i(a).scope();return{updateView:function(){return c.c.apply(c,arguments)},set:function(){return c.j.apply(c,arguments)},get:function(){return c.get.apply(c,arguments)}}};var D={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}},L={};(function(){function a(b,c,d){o(c,function(e){V(m[b],e)});o(d,function(e){m[b][e]=_[e]})}a("Global",[D],["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);a("Collection",[D,L],["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);a("Array",[D,L],["first","last","compact","flatten","without",
+"uniq","intersect","zip","indexOf","lastIndexOf"]);a("Object",[D,L],["keys","values"]);a("String",[D]);a("Function",[D],["bind","bindAll","delay","defer","wrap","compose"])})();Binder=function(a,b,c,d){this.B=a;this.va=c;this.anchor={};this.Rc=b;this.i=d||{};this.lb=[]};Binder.da=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};Binder.bc=function(a){a=Binder.da(a);return a.length>1||Binder.L(a[0])!==null};Binder.L=function(a){return(a=a.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?a[1]:null};Binder.prototype.zc=function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b};Binder.prototype.db=function(a){var b=this;a=a||this.va.Qa();var c=a.indexOf("#");if(!(c<0)){a=this.zc(a.substring(c+1));o(b.anchor,function(d,e){delete b.anchor[e]});
+o(a,function(d,e){b.anchor[e]=d})}};Binder.prototype.yc=function(a){q("URL change detected",a);this.db(a);this.c()};Binder.prototype.Lc=function(){var a=this.va.Qa(),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.va.Hc(a);return a};Binder.prototype.c=function(){(new Date).getTime();var a=i(this.B).scope();
+a.j("$invalidWidgets",[]);a.c();(new Date).getTime();this.Lc();_.each(this.lb,function(b){b()})};Binder.prototype.W=function(a){var b=i(this.B),c=b.find(a);if(b.is(a))c=c.andSelf();return c};Binder.prototype.Xb=function(){this.W("[ng-init]").each(function(){var a=i(this),b=a.scope();try{b.eval(a.attr("ng-init"))}catch(c){alert("EVAL ERROR:\n"+a.attr("ng-init")+"\n"+toJson(c,true))}})};Binder.prototype.M=function(a){this.W("[ng-entity]").attr("ng-watch",function(){try{var b=i(this);return a.M(b.attr("ng-entity"))+
+(b.attr("ng-watch")||"")}catch(c){alert(c)}})};Binder.prototype.compile=function(){var a=i(this.B),b=this;if(this.i.$c){var c=this.W(":submit").not("[ng-action]");c.attr("ng-action","$save()");c.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.eb(this.B)(this.B,a.scope(),"");this.W("a[ng-action]").live("click",function(){var d=i(this);try{d.scope().eval(d.attr("ng-action"));d.removeAttr("ng-error");d.removeClass("ng-exception")}catch(e){d.addClass("ng-exception");
+d.attr("ng-error",toJson(e,true))}b.c();return false})};Binder.prototype.Jc=function(a,b,c){b=b.concat();var d=b.pop(),e=Binder.da(a.nodeValue);if(e.length>1||Binder.L(e[0])){var f=a.parentNode;if(N(f)){f.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,b:function(l){return new BindUpdater(l,l.getAttribute("ng-bind-template"))}})}else for(var g=0;g<e.length;g++){var h=e[g],j=Binder.L(h),k;if(j){k=r.createElement("span");i(k).attr("ng-bind",j);g===0&&c.push({path:b.concat(d+g),b:Binder.prototype.cb})}else if(G&&
+h.charAt(0)==" "){k=r.createElement("span");k.innerHTML="&nbsp;"+h.substring(1)}else k=r.createTextNode(h);f.insertBefore(k,a)}f.removeChild(a)}};Binder.prototype.eb=function(a){var b=[];this.fb(a,[],b);return function(c,d,e){for(var f=b.length,g=0;g<f;g++){for(var h=b[g],j=c,k=h.path,l=0;l<k.length;l++)j=j.childNodes[k[l]];try{d.Bb(h.b(j,d,e))}catch(y){alert(y)}}}};Binder.prototype.fb=function(a,b,c){var d=a.nodeType;if(d==Node.TEXT_NODE)this.Jc(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?fromJson(e):{};for(var f=d.length,g=0;g<f;g++){var h=d[g],j=h.name;h=G&&j=="href"?decodeURI(a.getAttribute(j,2)):h.value;if(Binder.bc(h))e[j]=h}d=toJson(e);d.length>2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||q(a);var k=a.getAttribute("ng-repeat");if(k){a.removeAttribute("ng-repeat");var l=this.eb(a);d=r.createComment("ng-repeat: "+k);e=a.parentNode;
+e.insertBefore(d,a);e.removeChild(a);var y=function(t,u,w){var B=i(a).clone();B.css("display","");B.attr("ng-repeat-index",""+w);B.data("scope",t);l(B[0],t,u+w+":");return B};c.push({path:b,b:function(t,u,w){return new RepeaterUpdater(i(t),k,y,w)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,b:this.qc});a.getAttribute("ng-bind")&&c.push({path:b,b:this.cb});a.getAttribute("ng-bind-attr")&&c.push({path:b,b:this.mc});a.getAttribute("ng-hide")&&c.push({path:b,b:this.rc});a.getAttribute("ng-show")&&
+c.push({path:b,b:this.sc});a.getAttribute("ng-class")&&c.push({path:b,b:this.nc});a.getAttribute("ng-class-odd")&&c.push({path:b,b:this.pc});a.getAttribute("ng-class-even")&&c.push({path:b,b:this.oc});a.getAttribute("ng-style")&&c.push({path:b,b:this.tc});a.getAttribute("ng-watch")&&c.push({path:b,b:this.uc});d=a.nodeName;if(d=="INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var z=this;c.push({path:b,b:function(t,u,w){t.name=w+t.name.split(":").pop();return z.Rc.Mb(i(t),u)}})}if(d=="OPTION")if(!i("<select/>").append(i(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.fb(d[e],b.concat(e),c)}}}};Binder.prototype.qc=function(a){return new EvalUpdater(a,a.getAttribute("ng-eval"))};Binder.prototype.cb=function(a){return new BindUpdater(a,"{{"+a.getAttribute("ng-bind")+"}}")};Binder.prototype.mc=function(a){return new BindAttrUpdater(a,fromJson(a.getAttribute("ng-bind-attr")))};Binder.prototype.rc=function(a){return new HideUpdater(a,a.getAttribute("ng-hide"))};Binder.prototype.sc=function(a){return new ShowUpdater(a,
+a.getAttribute("ng-show"))};Binder.prototype.nc=function(a){return new ClassUpdater(a,a.getAttribute("ng-class"))};Binder.prototype.oc=function(a){return new ClassEvenUpdater(a,a.getAttribute("ng-class-even"))};Binder.prototype.pc=function(a){return new ClassOddUpdater(a,a.getAttribute("ng-class-odd"))};Binder.prototype.tc=function(a){return new StyleUpdater(a,a.getAttribute("ng-style"))};Binder.prototype.uc=function(a,b){b.watch(a.getAttribute("ng-watch"))};ControlBar=function(a,b){this.document=
+a;this.ha=b;this.window=n;this.F=[]};ControlBar.prototype.bind=p();ControlBar.Wc='<div><div class="ui-widget-overlay"></div><div id="ng-login" ng-non-bindable="true"><div class="ng-login-container"></div></div></div>';ControlBar.prototype.ba=function(a){this.F.push(a);this.F.length==1&&this.Ka("/user_session/new.mini?return_url="+encodeURIComponent(this.mb()))};ControlBar.prototype.ab=function(a){this.F.push(a);this.F.length==1&&this.Ka("/user_session/do_destroy.mini")};ControlBar.prototype.mb=function(){return this.window.location.href.split("#")[0]};
+ControlBar.prototype.Ka=function(a){var b=this,c=(new Date).getTime(),d=this.mb();d+="#$iframe_notify="+c;var e=i('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+d+'" src="'+this.ha+a+'" width="500" height="330"/></div>');this.document.append(e);e.Ja({height:363,width:500,Fd:false,jc:true,title:'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'});callbacks["_iframe_notify_"+c]=function(){e.Ja("destroy");e.remove();o(b.F,function(f){f()});b.F=[]}};
+ControlBar.ub='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';ControlBar.prototype.ra=function(){if(!this.Pa){this.Pa=i(ControlBar.ub);this.Pa.Ja({ed:true,height:70,jc:true})}};DataStore=function(a,b,c){this.post=a;this.nb=b;this.A={S:[]};this.anchor=c;this.U=[]};DataStore.prototype.V=function(a){if(a.constructor!=Model)throw"Parameter must be an instance of Entity! "+toJson(a);var b=a.T+"/"+a.C,c=this.A[b];if(c)Model.la(a,c);else c=this.A[b]=
+a;return c};DataStore.prototype.load=function(a,b,c,d){if(b&&b!=="*"){var e=this;this.D(["GET",a.T+"/"+b],function(f){a.I(f);a.za();f=a.R(a);e.V(f);(c||x)(a)},d)}return a};DataStore.prototype.oa=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||x)(e)}))});return e};DataStore.prototype.Xa=function(a,b,c){return this.load(a,b,c,function(d){if(d.ja==404){a.C=b;(c||x)(a)}else throw d;})};DataStore.prototype.hc=function(a,b){var c=this,d=[];d.xa=
+function(e){return e.T==a.title};this.A.S.push(d);this.D(["GET",a.title],function(e){for(var f=0;f<e.length;f++){var g=a();g.I(e[f]);d.push(c.V(g))}(b||x)(d)});return d};DataStore.prototype.save=function(a,b){var c=this,d={};a.Aa(d);this.D(["POST","",d],function(e){a.I(e);var f=c.V(a);_.each(c.A.S,function(g){g.xa(a)&&m.Array.includeIf(g,f,true)});if(a.ya)c.anchor[a.ya]=a.C;b&&b(a)})};DataStore.prototype.remove=function(a,b){var c=this,d={};a.Aa(d);this.D(["DELETE","",d],function(e){delete c.A[a.T+
+"/"+a.C];_.each(c.A.S,function(f){for(var g=0;g<f.length;g++)f[g].C==a.C&&f.splice(g,1)});(b||x)(e)})};DataStore.prototype.D=function(a,b,c){a.pb=b;a.rb=c||function(d){throw d;};this.U.push(a)};DataStore.prototype.Oa=function(){function a(d,e){q("RESPONSE["+d+"]: ",e);if(e.ja==401)b.nb.ba(function(){b.post(c,a)});else if(e.ja)alert(toJson(e));else for(var f=0;f<e.length;f++){var g=e[f],h=c[f];if(d=g.ja)d==403?b.nb.ra():h.rb(g);else h.pb(g)}}if(this.U.length!==0){var b=this,c=this.U;this.U=[];q("REQUEST:",
+c);this.post(c,a)}};DataStore.prototype.Ec=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.ia==Model.prototype.ia){d++;f.ia(c)}}c()};DataStore.prototype.O=function(a,b,c,d){var e=this,f=[];f.xa=E(false);this.A.S.push(f);this.D(["GET",a.title+"/"+b+"="+c],function(g){for(var h=0;h<g.length;h++){var j=(new a).I(g[h]);f.push(e.V(j))}d&&d(f)});return f};DataStore.J=p();DataStore.J.all=function(){return[]};DataStore.J.O=function(){return[]};DataStore.J.load=function(){return{}};
+DataStore.J.title=undefined;DataStore.prototype.M=function(a,b){if(!a)return DataStore.J;var c=this;function d(e){return new Model(d,e)}d.title=a;d.qb=true;d.Ia=this;d.Rb=b||{};d.load=function(e,f){return c.load(d(),e,f)};d.oa=function(e,f){return c.oa(d,e,f)};d.Xa=function(e,f){return c.Xa(d(),e,f)};d.all=function(e){return c.hc(d,e)};d.O=function(e,f,g){return c.O(d,e,f,g)};d.Ed=function(e){c.D(["GET",a+"/$properties"],e)};return d};DataStore.prototype.join=function(a){function b(){throw"Joined entities can not be instantiated into a document.";
+}var c=_(a).fd().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].ca?a[d].ca.substring(0,a[d].ca.indexOf(".")):undefined}while(d);return e.length}).value();if(_(c).select(function(d){return a[d].ca}).length!=c.length-1)throw"Exactly one entity needs to be primary.";b.O=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.O(d.substring(d.indexOf(".")+1),e,function(j){var k=c[h++],l=a[k],y=l.ca,z={};_(j).each(function(t){var u={};f.push(u);u[g]=t;t=Scope.Y(u,y);z[t]=t});l.join.oa(_.toArray(z),function(t){var u={};_(t).each(function(w){u[w.C]=w});_(f).each(function(w){var B=Scope.Y(w,y);w[k]=u[B]})})});return f};return b};s.h=function(a){if(a)for(var b in a)this[b]=a[b]};s.h.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 v;o({currency:function(a){i(this.element).toggleClass("ng-format-negative",a<0);return"$"+s.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:p(),json:function(a){i(this.element).addClass("ng-monospace");return toJson(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=",ta:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",ta:[/^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=",ta:[/^(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.ta,function(g){if(g.test(d)){g=f.name+": "+b;var h=f.url+b;e=new s.h({text:g,url:h,html:'<a href="'+X(h)+'">'+g+"</a>",Jd:b});_.breakLoop()}});e&&_.breakLoop()});return e?e:b?c||new s.h({text:b+" is not recognized"}):
+null}}(),link:function(a,b){b=b||s.h.get(a);var c=s.h.get(a,"url")||s.h.get(a);if(c){if(m.Q.td(c)===null)c="mailto:"+c;a='<a href="'+C(c)+'">'+b+"</a>";return new s.h({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 s.h({url:a.url,text:a.url,html:'<img src="'+a.url+'"'+d+"/>"})}return null},lowercase:function(a){return(a=s.h.get(a))?(""+a).toLowerCase():a},uppercase:function(a){return(a=s.h.get(a))?(""+a).toUpperCase():a},linecount:function(a){a=s.h.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:V(function(a,b,c,d){b=b||{};a={Hb:a,gd:v.Ib(b,"color"),nd:v.title(b),jd:v.Ib(b,
+"label"),hd:v.values(b),kd:"bg,s,FFFFFF00"};if(_.isArray(b.Sc)){a.pd="x";a.od="0:|"+b.Sc.join("|")}return v.encode(a,c,d)},{values:function(a){var b=[];o(a.Gc||[],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.Gc||[],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.md=b+"x"+c;o(a,function(f,g){f&&e.push(g+"="+f)});e.sort();d+=e.join("&");return new s.h({url:d,html:'<img width="'+b+'" height="'+c+'" src="'+d+'"/>'})}}),qrcode:function(a,b,c){return v.encode({Hb:"qr",ld:encodeURIComponent(a)},b,c)},chart:{Bd:function(a,b,c){return v("p",a,b,c)},Cd:function(a,b,c){return v("p3",
+a,b,c)},Dd:function(a,b,c){return v("pc",a,b,c)},bd:function(a,b,c){return v("bhs",a,b,c)},ad:function(a,b,c){return v("bhg",a,b,c)},dd:function(a,b,c){return v("bvs",a,b,c)},cd:function(a,b,c){return v("bvg",a,b,c)},xd:function(a,b,c){return v("lc",a,b,c)},Hd:function(a,b,c){return v("ls",a,b,c)},Gd:function(a,b,c){return v("s",a,b,c)}},html:function(a){return new s.h({html:a})}},function(a,b){s[b]=a});v=s.googleChartApi;array=[].constructor;toJson=function(a,b){var c=[];toJsonArray(c,a,b?"\n ":
+null);return c.join("")};toPrettyJson=function(a){return toJson(a,true)};fromJson=function(a){try{var b=new Parser(a,true),c=b.fa();b.K();return c()}catch(d){J("fromJson error: ",a,d);throw d;}};toJsonArray=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"):toJsonArray(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 j=g[h];try{e=b[j];if(typeof e!="function"){if(d){a.push(",");c&&a.push(c)}a.push(m.String.quote(j));a.push(":");toJsonArray(a,e,f);
+d=true}}catch(k){}}a.push("}")}};Model=function(a,b){this.R=a;this.I(b||{});this.T=a.title;this.za()};Model.la=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]}};Model.prototype.za=function(){S(this.R.Rb,this);return this};Model.prototype.ia=function(a){this.R.Ia.save(this,a===true?undefined:a);a===true&&this.R.Ia.Oa();return this};Model.prototype.I=
+function(a){Model.la(a,this);return this};Model.prototype.Aa=function(a){Model.la(this,a);return this};Lexer=function(a,b){this.text=a;this.Pb=b?20:-1;this.g=[];this.index=0};Lexer.Ba={"null":E(null),"true":E(true),"false":E(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.j(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}};Lexer.prototype.H=function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false};Lexer.prototype.parse=function(){for(var a=this.g,
+b=Lexer.Ba,c=true;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=='"'||d=="'"){this.Cc(d);c=true}else if(d=="("||d=="["){a.push({index:this.index,text:d});this.index++}else if(d=="{"){c=this.H();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.Bc();c=false}else if(this.ma(d)){this.Ac();c=false}else if(this.$(d)){this.gb();c=false}else if(this.ec(d))this.index++;else{c=d+this.H();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};Lexer.prototype.ma=
+function(a){return"0"<=a&&a<="9"};Lexer.prototype.ec=function(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"};Lexer.prototype.$=function(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"};Lexer.prototype.Ac=function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.ma(c))a+=c;else break;this.index++}a=1*a;this.g.push({index:b,text:a,b:function(){return a}})};Lexer.prototype.gb=function(){for(var a="",b=this.index;this.index<
+this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.$(c)||this.ma(c))a+=c;else break;this.index++}c=Lexer.Ba[a];if(!c){c=function(d){return d.scope.get(a)};c.Z=a}this.g.push({index:b,text:a,b:c})};Lexer.tb={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'};Lexer.prototype.Cc=function(a){var b=this.index,c=this.Pb;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=Lexer.tb[f];d+=e?e:f}e=false}else if(f=="\\")e=true;else if(f==a){this.index++;this.g.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+"'.";};Lexer.prototype.Bc=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.$(this.text.charAt(this.index))){this.gb();c=this.g.pop().text}var e=new RegExp(b,c);this.g.push({index:a,text:b,vd: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+"'.";};Parser=function(a,b){this.text=a;this.g=(new Lexer(a,b)).parse();this.index=
+0};Parser.vb=E(0);Parser.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)+"'.";};Parser.prototype.ea=function(){if(this.g.length===0)throw"Unexpected end of expression: "+this.text;return this.g[0]};Parser.prototype.H=function(a,b,c,d){var e=this.g;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};Parser.prototype.a=function(a,b,c,d){if(a=
+this.H(a,b,c,d)){this.g.shift();return this.qd=a}return false};Parser.prototype.k=function(a){if(!this.a(a)){var b=this.H();throw"Expecting '"+a+"' at column '"+(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}};Parser.prototype.wb=function(a,b){var c=b.apply(this);return function(d){return a(d,c(d))}};Parser.prototype.q=function(a,b,c){var d=c.apply(this);return function(e){return b(e,a(e),d(e))}};Parser.prototype.Ra=function(){return this.g.length>0};Parser.prototype.K=
+function(){if(this.g.length!==0)throw"Did not understand '"+this.text.substring(this.g[0].index)+"' while evaluating '"+this.text+"'.";};Parser.prototype.ua=function(){for(var a=[];;){this.g.length>0&&!this.H("}",")",";","]")&&a.push(this.Na());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}}};Parser.prototype.Na=function(){for(var a=this.o(),b;;)if(b=this.a("|"))a=this.q(a,b.b,this.filter);else return a};Parser.prototype.filter=function(){return this.Da(m.filter)};
+Parser.prototype.Q=function(){return this.Da(m.validator)};Parser.prototype.Da=function(a){for(var b=this.ac(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}}};Parser.prototype.o=function(){return this.Ic()};Parser.prototype.Ic=function(){if(this.a("throw")){var a=this.Fa();return function(b){throw a(b);}}else return this.Fa()};Parser.prototype.Fa=function(){var a=this.$a(),b;if(b=this.a("=")){if(!a.Z)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.Z},b.b,this.$a)}else return a};Parser.prototype.$a=function(){for(var a=this.Za(),b;;)if(b=this.a("||"))a=this.q(a,b.b,this.Za);else return a};Parser.prototype.Za=function(){for(var a=this.bb(),b;;)if(b=this.a("&&"))a=this.q(a,b.b,this.bb);else return a};Parser.prototype.bb=function(){var a;return(a=this.a("!"))?this.wb(a.b,this.La):this.La()};Parser.prototype.La=
+function(){for(var a=this.hb(),b;;)if(b=this.a("==","!="))a=this.q(a,b.b,this.hb);else return a};Parser.prototype.hb=function(){for(var a=this.Ea(),b;;)if(b=this.a("<",">","<=",">="))a=this.q(a,b.b,this.Ea);else return a};Parser.prototype.Ea=function(){for(var a=this.qa(),b;b=this.a("+","-");)a=this.q(a,b.b,this.qa);return a};Parser.prototype.qa=function(){for(var a=this.kb(),b;b=this.a("*","/","%");)a=this.q(a,b.b,this.kb);return a};Parser.prototype.kb=function(){var a;return this.a("+")?this.fa():
+(a=this.a("-"))?this.q(Parser.vb,a.b,this.qa):this.fa()};Parser.prototype.ac=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};Parser.prototype.fa=function(){var a;if(this.a("(")){a=this.Na();this.k(")");a=a}else if(this.a("["))a=this.Cb();else if(this.a("{"))a=this.object();else if(this.a("{:"))a=this.Ga(false);else if(this.a("{("))a=
+this.Ga(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.$b(a);else if(b.text==="[")a=this.vc(a);else if(b.text===".")a=this.Yb(a);else throw"IMPOSSIBLE";return a};Parser.prototype.Ga=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.ua();this.k("}");return function(d){return function(e){var f=new Scope(d.scope.s);f.j("$",e);for(var g=
+0;g<b.length;g++)f.j(b[g],arguments[g]);return c({scope:f})}}};Parser.prototype.Yb=function(a){var b=this.a().text;function c(d){return Scope.Y(a(d),b)}c.Z=b;return c};Parser.prototype.vc=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}};Parser.prototype.$b=function(a){var b=[];if(this.ea().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.Z+"' is not a function.";}};Parser.prototype.Cb=function(){var a=[];if(this.ea().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}};Parser.prototype.object=function(){var a=[];if(this.ea().text!="}"){do{var b=this.a().text;this.k(":");var c=this.o();a.push({fc: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.fc]=h}return e}};Parser.prototype.Wb=function(){for(var a=[];this.Ra();){a.push(this.Vb());this.a(";")||this.K()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}};Parser.prototype.Vb=function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c=this.fa()(null);return function(d){var e=d.scope.get("$datastore").M(a,c);d.scope.j(a,e);if(b){e=e();e.ya=b;d.scope.j(b,e);return"$anchor."+
+b+":{"+b+"="+a+".load($anchor."+b+");"+b+".$$anchor="+m.String.quote(b)+";};"}else return""}};Parser.prototype.watch=function(){for(var a=[];this.Ra();){a.push(this.Qc());this.a(";")||this.K()}this.K();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.zb(d.name,d.b)}}};Parser.prototype.Qc=function(){var a=this.a().text;this.k(":");var b;if(this.ea().text=="{"){this.k("{");b=this.ua();this.k("}")}else b=this.o();return function(){return{name:a,b:b}}};Scope=function(a,b){this.ob=[];this.wa=
+{};this.name=b;a=a||{};function c(){}c.prototype=a;this.s=new c;this.s.Uc=a;if(b=="ROOT")this.s.Vc=this.s};Scope.X={};Scope.prototype.c=function(){var a=this;this.Zb();_.each(this.ob,function(b){a.l(b,"",{},function(){this.c(a)})})};Scope.prototype.Bb=function(a){a&&this.ob.push(a)};Scope.prototype.dc=function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!Lexer.prototype.$(c))return false}return true};Scope.Y=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.qb)return P(e,a);return a};Scope.prototype.get=function(a){return Scope.Y(this.s,a)};Scope.prototype.j=function(a,b){a=a.split(".");for(var c=this.s,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};Scope.prototype.m=function(a,b){this.eval(a+"="+toJson(b))};Scope.prototype.eval=function(a,b){var c=Scope.X[a];if(!c){var d=new Parser(a);c=d.ua();d.K();Scope.X[a]=c}b=b||{};b.scope=this;return c(b)};Scope.prototype.l=function(a,b,c,d,e){try{var f=this.eval(b,c);if(a.w){a.w=false;i(a.view).removeClass("ng-exception").removeAttr("ng-error")}d&&d.apply(a,[f]);return true}catch(g){J("Eval Widget Error:",g);b=toJson(g,true);
+a.w=true;i(a.view).addClass("ng-exception").attr("ng-error",b);e&&e.apply(a,[g,b]);return false}};Scope.prototype.Oc=function(a,b){var c=Scope.X[a];if(!c){c=(new Parser(a)).Q();Scope.X[a]=c}a={scope:this};return c(a)(a,b)};Scope.prototype.M=function(a){return(new Parser(a)).Wb()({scope:this})};Scope.prototype.ic=function(a){this.s.Tc.push(a)};Scope.prototype.watch=function(a){var b=this;(new Parser(a)).watch()({scope:this,zb:function(c,d){b.Ab(c,function(e,f){try{return d({scope:b},e,f)}catch(g){alert(g)}})}})};
+Scope.prototype.Ab=function(a,b){var c=this.wa[a];if(!c){c={Va:[],o:a};this.wa[a]=c}c.Va.push(b)};Scope.prototype.Zb=function(){var a=this,b=false;o(this.wa,function(c){var d=a.eval(c.o);if(d!==c.d){o(c.Va,function(e){e(d,c.d);b=true});c.d=d}});return b};Server=function(a,b){this.url=a;this.kc=0;this.getScript=b;this.Nc="_"+(""+Math.random()).substr(2)+"_";this.pa=1800};Server.prototype.Eb=function(a){return H.Tb(a)};Server.prototype.P=function(a,b,c,d){var e=this.Nc+this.kc++;K[e]=function(h){delete m[e];
+d(200,h)};a={Kd:b,yd:a,Ad:c};a=this.Eb(toJson(a));b=Math.ceil(a.length/this.pa);c=this.url+"/$/"+e+"/"+b+"/";for(var f=0;f<b;f++){var g=a.substr(f*this.pa,this.pa);this.getScript(c+(f+1)+"?h="+g,x)}};FrameServer=A("frame");FrameServer.Xc="$DATASET:";FrameServer.prototype={P:p()};VisualServer=function(a,b,c){this.Sb=a;this.update=c;this.status=b};VisualServer.prototype={P:function(a,b,c,d){var e=this;this.status.Fb(c);this.Sb.P(a,b,c,function(){e.status.Ub();try{d.apply(this,arguments)}catch(f){alert(toJson(f))}e.update()})}};
+Users=function(a,b){this.z=a;this.ka=b};Users.prototype={Ma:function(a){var b=this;this.z.P("GET","/account.json",{},function(c,d){b.Ob=d.Mc;a(d.Mc)})},ab:function(a){var b=this;this.ka.ab(function(){delete b.Ob;(a||x)()})},ba:function(a){var b=this;this.ka.ba(function(){b.Ma(function(){(a||x)()})})},ra:function(){this.ka.ra()}};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=W.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{fromJson(a);
+return null}catch(b){return b.toString()}}},function(a,b){W[b]=a});WidgetFactory=function(a,b){this.lc=0;this.ha=a;this.G=b;this.Ha=n.Id?swfobject.Ha:function(){alert("ERROR: swfobject not loaded!")};this.wc=p()};WidgetFactory.prototype.Mb=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 ButtonController(a[0],e);f="click";g=false}else if(d=="text"||d=="textarea"||d=="hidden"||
+d=="password"){c=new TextController(a[0],e);f="keyup change"}else if(d=="checkbox"){c=new CheckboxController(a[0],e);f="click"}else if(d=="radio"){c=new RadioController(a[0],e);f="click"}else if(d=="select-one")c=new SelectController(a[0],e);else if(d=="select-multiple")c=new MultiSelectController(a[0],e);else if(d=="file")c=this.Nb(a,e);else throw"Unknown type: "+d;a.data("controller",c);var h=b.get("$binder");i(c.view,":input").bind(f,function(){if(c.e(b)){var j=i(c.view).attr("ng-action")||"";
+b.l(c,j)&&h.c(b)}return g});return c};WidgetFactory.prototype.Nb=function(a){var b="__uploadWidget_"+this.lc++,c=FileController.template(b);a.after(c);b=this.Ha({data:this.ha+"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",Md:"transparent"},{wd:"uploadWidgetId="+b,Yc:"always"},b);a.remove();a=new FileController(c,a[0].name,b,this.ha+"/data/"+this.G);i(b).data("controller",a);return a};FileController=function(a,b,c,d){this.view=a;this.Ld=c;this.ib=b;this.Zc=d+"/_attachments";this.value=null;
+this.d=undefined};FileController.dispatchEvent=function(a,b,c){a=r.getElementById(a);a=i(a).data("controller");FileController.prototype["_on_"+b].apply(a,c)};FileController.template=function(a){return i('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+a+'" /><a></a><span/></span>')};FileController.prototype.e=function(a){var b=this.view.find("input").attr("checked")?this.value:null;if(this.d===b)return false;else{a.j(this.ib,b);return true}};FileController.prototype.c=
+function(a){if((a=a.get(this.ib))&&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)};NullController=A("view");NullController.prototype.e=E(true);NullController.prototype.c=p();NullController.cc=new NullController;ButtonController=A("view");ButtonController.prototype.e=E(true);ButtonController.prototype.c=p();TextController=function(a,b){this.view=
+a;this.exp=b;this.Q=a.getAttribute("ng-validate");this.Dc=typeof a.attributes["ng-required"]!="undefined";this.Ta=null;this.d=undefined;this.p=a.value;a.getAttribute("ng-widget")==="datepicker"&&i(a).rd()};TextController.prototype.e=function(a){var b=this.view.value;if(this.d===b)return false;else{a.m(this.exp,b);this.d=b;return true}};TextController.prototype.c=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.d!=c)this.d=b.value=c;
+var d=false;b.removeAttribute("ng-error");if(this.Dc)d=!(c&&c.length>0);var e=d?"Required Value":null;if(!d&&this.Q&&c){e=a.Oc(this.Q,c);d=!!e}if(this.Ta!==e){this.Ta=d;if(e!==null){b.setAttribute("ng-error",e);a.ic(this)}i(b).toggleClass("ng-validation-error",d)}};CheckboxController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.p=a.checked?a.value:""};CheckboxController.prototype.e=function(a){var b=this.view;b=b.checked?b.value:"";if(this.d===b)return false;else{a.m(this.exp,b);this.d=
+b;return true}};CheckboxController.prototype.c=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};SelectController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.p=a.value};SelectController.prototype.e=function(a){if(this.view.selectedIndex<0)a.m(this.exp,null);else{var b=this.view.value;if(this.d===b)return false;else{a.m(this.exp,b);this.d=b;return true}}};SelectController.prototype.c=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.d){b.value=c?c:"";this.d=c}};MultiSelectController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.p=this.selected()};MultiSelectController.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};MultiSelectController.prototype.e=function(a){var b=this.selected();if(this.d===b)return false;else{a.m(this.exp,b);this.d=b;return true}};
+MultiSelectController.prototype.c=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.d){a=b.options;for(b=0;b<a.length;b++){var d=a[b];d.selected=_.include(c,d.value)}this.d=c}};RadioController=function(a,b){this.view=a;this.exp=b;this.d=this.na=undefined;this.Sa=a.value;this.p=a.checked?a.value:null};RadioController.prototype.e=function(a){var b=this.view;if(this.na)return false;else{b.checked=true;this.d=a.m(this.exp,this.Sa);return this.na=
+true}};RadioController.prototype.c=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.d!=c){this.na=b.checked=this.Sa==""+c;this.d=c}};BindUpdater=function(a,b){this.view=a;this.exp=Binder.da(b);this.w=false;this.Fc={element:a}};BindUpdater.jb=function(a){switch(typeof a){case "string":case "boolean":case "number":return C(a);case "function":return BindUpdater.jb(a());case "object":if(a&&a.tagName&&a.nodeName&&a.ownerDocument&&a.removeAttribute)return Q(a);
+else if(a instanceof m.filter.h){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 Q(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(toJson(a,true));default:return""}};BindUpdater.prototype.e=p();BindUpdater.prototype.c=function(a){for(var b=
+[],c=this.exp,d=c.length,e=0;e<d;e++){var f=c[e],g=Binder.L(f);if(g){a.l(this,g,this.Fc,function(h){b.push(BindUpdater.jb(h))},function(h,j){O(this.view,j)});if(this.w)return}else b.push(C(f))}O(this.view,b.join(""))};BindAttrUpdater=function(a,b){this.view=a;this.Db=b};BindAttrUpdater.prototype.e=p();BindAttrUpdater.prototype.c=function(a){var b=i(this.view),c=this.Db;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=Binder.da(c[e]),
+g=[],h=0;h<f.length;h++){var j=Binder.L(f[h]);if(j)try{var k=a.eval(j,{element:b[0],attrName:e});if(k&&(k.constructor!==array||k.length!==0))g.push(k)}catch(l){this.w=true;J("BindAttrUpdater",l);j=toJson(l,true);g.push("["+j+"]");b.addClass("ng-exception").attr("ng-error",j)}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)}};EvalUpdater=function(a,b){this.view=a;this.exp=b;this.w=false};EvalUpdater.prototype.e=p();EvalUpdater.prototype.c=
+function(a){a.l(this,this.exp)};HideUpdater=function(a,b){this.view=a;this.exp=b};HideUpdater.prototype.e=p();HideUpdater.prototype.c=function(a){a.l(this,this.exp,{},function(b){var c=i(this.view);R(b)?c.hide():c.show()})};ShowUpdater=function(a,b){this.view=a;this.exp=b};ShowUpdater.prototype.e=p();ShowUpdater.prototype.c=function(a){a.l(this,this.exp,{},function(b){var c=i(this.view);R(b)?c.show():c.hide()})};ClassUpdater=function(a,b){this.view=a;this.exp=b};ClassUpdater.prototype.e=p();ClassUpdater.prototype.c=
+function(a){a.l(this,this.exp,{},function(b){if(b!==null&&b!==undefined)this.view.className=b})};ClassEvenUpdater=function(a,b){this.view=a;this.exp=b};ClassEvenUpdater.prototype.e=p();ClassEvenUpdater.prototype.c=function(a){a.l(this,this.exp,{},function(b){var c=a.get("$index");i(this.view).toggleClass(b,c%2===1)})};ClassOddUpdater=function(a,b){this.view=a;this.exp=b};ClassOddUpdater.prototype.e=p();ClassOddUpdater.prototype.c=function(a){a.l(this,this.exp,{},function(b){var c=a.get("$index");
+i(this.view).toggleClass(b,c%2===0)})};StyleUpdater=function(a,b){this.view=a;this.exp=b};StyleUpdater.prototype.e=p();StyleUpdater.prototype.c=function(a){a.l(this,this.exp,{},function(b){i(this.view).attr("style","").css(b)})};RepeaterUpdater=function(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.aa=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.Pc=a[3]||a[1];this.gc=a[2]};RepeaterUpdater.prototype.e=p();RepeaterUpdater.prototype.c=function(a){a.l(this,this.aa,{},function(b){var c=this;if(!b){b=[];a.dc(this.aa)&&a.j(this.aa,b)}var d=b.length,e=this.children.length,f=this.view,g=0,h=null,j=this.gc,k=this.Pc,l=0;o(b,function(z,t){if(l<e){h=c.children[l];h.scope.j(k,z)}else{var u=new Scope(a.s,c.prefix+k+" in "+c.aa+"["+l+"]");u.j("$index",
+l);j&&u.j(j,t);u.j(k,z);h={scope:u,element:c.template(u,c.prefix,l)};f.after(h.element);c.children.push(h)}f=h.element;z=(new Date).getTime();h.scope.c();g+=(new Date).getTime()-z;l++});for(b=e;b>d;--b){var y=this.children.pop().element[0];y.parentNode.removeChild(y)}if(h&&h.element[0].nodeName==="OPTION")if(d=i(h.element[0].parentNode).data("controller")){d.d=undefined;d.c(a)}})};PopUp=A("B");PopUp.Ca="mouseleave mouseout click dblclick keypress keyup";PopUp.prototype.bind=function(){this.B.find(".ng-validation-error,.ng-exception").live("mouseover",
+PopUp.xc)};PopUp.xc=function(){PopUp.sa();var a=i(this);a.bind(PopUp.Ca,PopUp.sa);var b=a.position(),c=r.documentElement,d=(self.innerWidth||c&&c.clientWidth||r.body.clientWidth)-b.left;c=a.hasClass("ng-exception")?"EXCEPTION:":"Validation error...";a=a.attr("ng-error");d=d>375?"left":"right";c=i("<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>");i("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};PopUp.sa=function(){i("#ng-callout").unbind(PopUp.Ca,PopUp.sa).remove();return true};Status=function(a){this.Ya=a.append(Status.sb).find("#ng-loading");this.ga=0};Status.sb='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';Status.prototype.Fb=function(){this.ga===0&&this.Ya.show();this.ga++};Status.prototype.Ub=function(){this.ga--;this.ga===0&&this.Ya.hide("fold")}})(window,
+document);
diff --git a/angular.js b/angular.js
index c113d56b..bea8200d 100644
--- a/angular.js
+++ b/angular.js
@@ -1,5 +1,5 @@
-
-(function(window, document){/**
+(function(window, document){
+/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
@@ -145,8 +145,7 @@ var Base64 = {
// IE compatibility
if (typeof document.getAttribute == 'undefined')
- document.getAttribute = function() {
- };
+ document.getAttribute = function() {};
if (typeof Node == 'undefined') {
Node = {
ELEMENT_NODE : 1,
@@ -164,25 +163,25 @@ if (typeof Node == 'undefined') {
};
}
-var callbacks = {};
-var jQuery = window['jQuery'];
-var msie = jQuery['browser']['msie'];
-
-if (!window.angular){ angular = {}; window['angular'] = angular; }
-if (!angular.validator) angular.validator = {};
-if (!angular.filter) angular.filter = {};
-if (!window.console)
- window.console = {
- log:function() {},
- error:function() {}
- };
-if (!angular.alert) {
- angular.alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
-}
-
-var consoleNode;
+function noop() {};
+
+var consoleNode,
+ foreach = _.each,
+ extend = _.extend,
+ console = window['console'] || ({'log':noop, 'error':noop }),
+ jQuery = window['jQuery'],
+ msie = jQuery['browser']['msie'],
+ log = function(){console.log.apply(this, arguments);},
+ error = function(){console.error.apply(this, arguments);},
+ angular = window['angular'] || (window['angular'] = {}),
+ angularValidator = angular['validator'] || (angular['validator'] = {}),
+ angularFilter = angular['filter'] || (angular['filter'] = {}),
+ angularCallbacks = angular['callbacks'] || (angular['callbacks'] = {}),
+ angularAlert = angular['alert'] || (angular['alert'] = function(){
+ log(arguments); window.alert.apply(window, arguments);
+ });
-consoleLog = function(level, objs) {
+function consoleLog(level, objs) {
var log = document.createElement("div");
log.className = level;
var msg = "";
@@ -194,17 +193,17 @@ consoleLog = function(level, objs) {
}
log.appendChild(document.createTextNode(msg));
consoleNode.appendChild(log);
-};
+}
-isNode = function(inp) {
+function isNode(inp) {
return inp &&
inp.tagName &&
inp.nodeName &&
inp.ownerDocument &&
inp.removeAttribute;
-};
+}
-isLeafNode = function(node) {
+function isLeafNode (node) {
switch (node.nodeName) {
case "OPTION":
case "PRE":
@@ -215,9 +214,7 @@ isLeafNode = function(node) {
}
};
-noop = function() {
-};
-setHtml = function(node, html) {
+function setHtml(node, html) {
if (isLeafNode(node)) {
if (msie) {
node.innerText = html;
@@ -227,9 +224,9 @@ setHtml = function(node, html) {
} else {
node.innerHTML = html;
}
-};
+}
-escapeHtml = function(html) {
+function escapeHtml(html) {
if (!html || !html.replace)
return html;
return html.
@@ -238,14 +235,14 @@ escapeHtml = function(html) {
replace(/>/g, '&gt;');
};
-escapeAttr = function(html) {
+function escapeAttr(html) {
if (!html || !html.replace)
return html;
return html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g,
'&quot;');
};
-bind = function(_this, _function) {
+function bind(_this, _function) {
if (!_this)
throw "Missing this";
if (!_.isFunction(_function))
@@ -255,7 +252,7 @@ bind = function(_this, _function) {
};
};
-shiftBind = function(_this, _function) {
+function shiftBind(_this, _function) {
return function() {
var args = [ this ];
for ( var i = 0; i < arguments.length; i++) {
@@ -265,7 +262,7 @@ shiftBind = function(_this, _function) {
};
};
-outerHTML = function(node) {
+function outerHTML(node) {
var temp = document.createElement('div');
temp.appendChild(node);
var outerHTML = temp.innerHTML;
@@ -273,18 +270,18 @@ outerHTML = function(node) {
return outerHTML;
};
-trim = function(str) {
+function trim(str) {
return str.replace(/^ */, '').replace(/ *$/, '');
};
-toBoolean = function(value) {
+function toBoolean(value) {
var v = ("" + value).toLowerCase();
if (v == 'f' || v == '0' || v == 'false' || v == 'no')
value = false;
return !!value;
};
-merge = function(src, dst) {
+function merge(src, dst) {
for ( var key in src) {
var value = dst[key];
var type = typeof value;
@@ -301,176 +298,178 @@ merge = function(src, dst) {
// Loader
// ////////////////////////////
-Loader = function(document, head, config) {
+function Loader(document, head, config) {
this.document = jQuery(document);
this.head = jQuery(head);
this.config = config;
this.location = window.location;
};
-Loader.prototype.load = function() {
- this.configureLogging();
- this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
- this.loadCss('/stylesheets/css');
- console.log("Server: " + this.config.server);
- this.configureJQueryPlugins();
- this.computeConfiguration();
- this.bindHtml();
-};
-
-Loader.prototype.configureJQueryPlugins = function() {
- console.log('Loader.configureJQueryPlugins()');
- jQuery['fn']['scope'] = function() {
- var element = this;
- while (element && element.get(0)) {
- var scope = element.data("scope");
- if (scope)
- return scope;
- element = element.parent();
- }
- return null;
- };
- jQuery['fn']['controller'] = function() {
- return this.data('controller') || NullController.instance;
- };
-};
-
-Loader.prototype.uid = function() {
- return "" + new Date().getTime();
-};
-
-Loader.prototype.computeConfiguration = function() {
- var config = this.config;
- if (!config.database) {
- var match = config.server.match(/https?:\/\/([\w]*)/);
- config.database = match ? match[1] : "$MEMORY";
- }
-};
-
-Loader.prototype.bindHtml = function() {
- console.log('Loader.bindHtml()');
- var watcher = new UrlWatcher(this.location);
- var document = this.document;
- var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
- var binder = new Binder(document[0], widgetFactory, watcher, this.config);
- widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel);
- var controlBar = new ControlBar(document.find('body'), this.config.server);
- var onUpdate = function(){binder.updateView();};
- var server = this.config.database=="$MEMORY" ?
- new FrameServer(this.window) :
- new Server(this.config.server, jQuery.getScript);
- server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate);
- var users = new Users(server, controlBar);
- var databasePath = '/data/' + this.config.database;
- var post = function(request, callback){
- server.request("POST", databasePath, request, callback);
- };
- var datastore = new DataStore(post, users, binder.anchor);
- binder.updateListeners.push(function(){datastore.flush();});
- var scope = new Scope( {
- '$anchor' : binder.anchor,
- '$binder' : binder,
- '$config' : this.config,
- '$console' : window.console,
- '$datastore' : datastore,
- '$save' : function(callback) {
- datastore.saveScope(scope.state, callback, binder.anchor);
- },
- '$window' : window,
- '$uid' : this.uid,
- '$users' : users
- }, "ROOT");
-
- document.data('scope', scope);
- console.log('$binder.entity()');
- binder.entity(scope);
-
- console.log('$binder.compile()');
- binder.compile();
-
- console.log('ControlBar.bind()');
- controlBar.bind();
-
- console.log('$users.fetchCurrentUser()');
- function fetchCurrentUser() {
- users.fetchCurrentUser(function(u) {
- if (!u && document.find("[ng-auth=eager]").length) {
- users.login();
- }
- });
- }
- fetchCurrentUser();
-
- console.log('PopUp.bind()');
- new PopUp(document).bind();
-
- console.log('$binder.parseAnchor()');
- binder.parseAnchor();
-
- console.log('$binder.executeInit()');
- binder.executeInit();
-
- console.log('$binder.updateView()');
- binder.updateView();
-
- watcher.listener = bind(binder, binder.onUrlChange, watcher);
- watcher.onUpdate = function(){alert("update");};
- watcher.watch();
- document.find("body").show();
- console.log('ready()');
-};
-
-Loader.prototype.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));
+Loader.prototype = {
+ load: function() {
+ this.configureLogging();
+ this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
+ this.loadCss('/stylesheets/css');
+ log("Server: " + this.config.server);
+ this.configureJQueryPlugins();
+ this.computeConfiguration();
+ this.bindHtml();
+ },
+
+ configureJQueryPlugins: function() {
+ log('Loader.configureJQueryPlugins()');
+ jQuery['fn']['scope'] = function() {
+ var element = this;
+ while (element && element.get(0)) {
+ var scope = element.data("scope");
+ if (scope)
+ return scope;
+ element = element.parent();
}
+ return null;
};
- delegate(request, callback);
- };
-};
-
-Loader.prototype.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);
- console.log = function() {
- consoleLog('ng-console-info', arguments);
+ jQuery['fn']['controller'] = function() {
+ return this.data('controller') || NullController.instance;
+ };
+ },
+
+ uid: function() {
+ return "" + new Date().getTime();
+ },
+
+ computeConfiguration: function() {
+ var config = this.config;
+ if (!config.database) {
+ var match = config.server.match(/https?:\/\/([\w]*)/);
+ config.database = match ? match[1] : "$MEMORY";
+ }
+ },
+
+ bindHtml: function() {
+ log('Loader.bindHtml()');
+ var watcher = new UrlWatcher(this.location);
+ var document = this.document;
+ var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
+ var binder = new Binder(document[0], widgetFactory, watcher, this.config);
+ widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel);
+ var controlBar = new ControlBar(document.find('body'), this.config.server);
+ var onUpdate = function(){binder.updateView();};
+ var server = this.config.database=="$MEMORY" ?
+ new FrameServer(this.window) :
+ new Server(this.config.server, jQuery.getScript);
+ server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate);
+ var users = new Users(server, controlBar);
+ var databasePath = '/data/' + this.config.database;
+ var post = function(request, callback){
+ server.request("POST", databasePath, request, callback);
+ };
+ var datastore = new DataStore(post, users, binder.anchor);
+ binder.updateListeners.push(function(){datastore.flush();});
+ var scope = new Scope( {
+ '$anchor' : binder.anchor,
+ '$binder' : binder,
+ '$config' : this.config,
+ '$console' : window.console,
+ '$datastore' : datastore,
+ '$save' : function(callback) {
+ datastore.saveScope(scope.state, callback, binder.anchor);
+ },
+ '$window' : window,
+ '$uid' : this.uid,
+ '$users' : users
+ }, "ROOT");
+
+ document.data('scope', scope);
+ log('$binder.entity()');
+ binder.entity(scope);
+
+ log('$binder.compile()');
+ binder.compile();
+
+ log('ControlBar.bind()');
+ controlBar.bind();
+
+ log('$users.fetchCurrentUser()');
+ function fetchCurrentUser() {
+ users.fetchCurrentUser(function(u) {
+ if (!u && document.find("[ng-auth=eager]").length) {
+ users.login();
+ }
+ });
+ }
+ fetchCurrentUser();
+
+ log('PopUp.bind()');
+ new PopUp(document).bind();
+
+ log('$binder.parseAnchor()');
+ binder.parseAnchor();
+
+ log('$binder.executeInit()');
+ binder.executeInit();
+
+ log('$binder.updateView()');
+ binder.updateView();
+
+ watcher.listener = bind(binder, binder.onUrlChange, watcher);
+ watcher.onUpdate = function(){alert("update");};
+ watcher.watch();
+ document.find("body").show();
+ log('ready()');
+ },
+
+ visualPost: function(delegate) {
+ var status = new Status(jQuery(document.body));
+ return function(request, delegateCallback) {
+ status.beginRequest(request);
+ var callback = function() {
+ status.endRequest();
+ try {
+ delegateCallback.apply(this, arguments);
+ } catch (e) {
+ alert(toJson(e));
+ }
+ };
+ delegate(request, callback);
};
- console.error = function() {
- consoleLog('ng-console-error', arguments);
+ },
+
+ configureLogging: function() {
+ var url = window.location.href + '#';
+ url = url.split('#')[1];
+ var config = {
+ debug : null
};
+ var configs = url.split('&');
+ for ( var i = 0; i < configs.length; i++) {
+ var part = (configs[i] + '=').split('=');
+ config[part[0]] = part[1];
+ }
+ if (config.debug == 'console') {
+ consoleNode = document.createElement("div");
+ consoleNode.id = 'ng-console';
+ document.getElementsByTagName('body')[0].appendChild(consoleNode);
+ log = function() {
+ consoleLog('ng-console-info', arguments);
+ };
+ console.error = function() {
+ consoleLog('ng-console-error', arguments);
+ };
+ }
+ },
+
+ loadCss: function(css) {
+ var cssTag = document.createElement('link');
+ cssTag.rel = "stylesheet";
+ cssTag.type = "text/css";
+ if (!css.match(/^http:/))
+ css = this.config.server + css;
+ cssTag.href = css;
+ this.head[0].appendChild(cssTag);
}
};
-Loader.prototype.loadCss = function(css) {
- var cssTag = document.createElement('link');
- cssTag.rel = "stylesheet";
- cssTag.type = "text/css";
- if (!css.match(/^http:/))
- css = this.config.server + css;
- cssTag.href = css;
- this.head[0].appendChild(cssTag);
-};
-
-UrlWatcher = function(location) {
+function UrlWatcher(location) {
this.location = location;
this.delay = 25;
this.setTimeout = function(fn, delay) {
@@ -482,47 +481,49 @@ UrlWatcher = function(location) {
this.expectedUrl = location.href;
};
-UrlWatcher.prototype.watch = function() {
- var self = this;
- var pull = function() {
- if (self.expectedUrl !== self.location.href) {
- var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/);
- if (notify) {
- if (!self.expectedUrl.match(/#/)) {
- self.expectedUrl += "#";
- }
- self.location.href = self.expectedUrl;
- var id = '_iframe_notify_' + notify[1];
- var notifyFn = callbacks[id];
- delete callbacks[id];
- try {
- (notifyFn||noop)();
- } catch (e) {
- alert(e);
+UrlWatcher.prototype = {
+ watch: function() {
+ var self = this;
+ var pull = function() {
+ if (self.expectedUrl !== self.location.href) {
+ var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/);
+ if (notify) {
+ if (!self.expectedUrl.match(/#/)) {
+ self.expectedUrl += "#";
+ }
+ self.location.href = self.expectedUrl;
+ var id = '_iframe_notify_' + notify[1];
+ var notifyFn = angularCallbacks[id];
+ delete angularCallbacks[id];
+ try {
+ (notifyFn||noop)();
+ } catch (e) {
+ alert(e);
+ }
+ } else {
+ self.listener(self.location.href);
+ self.expectedUrl = self.location.href;
}
- } else {
- self.listener(self.location.href);
- self.expectedUrl = self.location.href;
}
- }
- self.setTimeout(pull, self.delay);
- };
- pull();
-};
-
-UrlWatcher.prototype.setUrl = function(url) {
- var existingURL = window.location.href;
- if (!existingURL.match(/#/))
- existingURL += '#';
- if (existingURL != url)
- window.location.href = url;
- this.existingURL = url;
-};
-
-UrlWatcher.prototype.getUrl = function() {
- return window.location.href;
+ self.setTimeout(pull, self.delay);
+ };
+ pull();
+ },
+
+ setUrl: function(url) {
+ var existingURL = window.location.href;
+ if (!existingURL.match(/#/))
+ existingURL += '#';
+ if (existingURL != url)
+ window.location.href = url;
+ this.existingURL = url;
+ },
+
+ getUrl: function() {
+ return window.location.href;
+ }
};
-
+
angular['compile'] = function(root, config) {
config = config || {};
var defaults = {
@@ -539,14 +540,11 @@ angular['compile'] = function(root, config) {
'set':function(){return scope.set.apply(scope, arguments);},
'get':function(){return scope.get.apply(scope, arguments);}
};
-};
-
-angular['Global'] = {
+};var angularGlobal = {
'typeOf':function(obj){
+ if (obj === null) return "null";
var type = typeof obj;
- switch(type) {
- case "object":
- if (obj === null) return "null";
+ if (type == "object") {
if (obj instanceof Array) return "array";
if (obj instanceof Date) return "date";
if (obj.nodeType == 1) return "element";
@@ -555,9 +553,9 @@ angular['Global'] = {
}
};
-angular['Collection'] = {};
-angular['Object'] = {};
-angular['Array'] = {
+var angularCollection = {};
+var angularObject = {};
+var angularArray = {
'includeIf':function(array, value, condition) {
var index = _.indexOf(array, value);
if (condition) {
@@ -720,7 +718,7 @@ angular['Array'] = {
var comparator = function(o1, o2){
for ( var i = 0; i < expression.length; i++) {
var comp = expression[i](o1, o2);
- if (comp != 0) return comp;
+ if (comp !== 0) return comp;
}
return 0;
};
@@ -740,7 +738,7 @@ angular['Array'] = {
ascending = $.charAt(0) == '+';
index = i;
return true;
- };
+ }
});
if (index >= 0) {
predicate.splice(index, 1);
@@ -771,7 +769,8 @@ angular['Array'] = {
return array;
}
};
-angular['String'] = {
+
+var angularString = {
'quote':function(string) {
return '"' + string.replace(/\\/g, '\\\\').
replace(/"/g, '\\"').
@@ -808,7 +807,8 @@ angular['String'] = {
return string;
}
};
-angular['Date'] = {
+
+var angularDate = {
'toString':function(date){
function pad(n) { return n < 10 ? "0" + n : n; }
return (date.getUTCFullYear()) + '-' +
@@ -819,7 +819,8 @@ angular['Date'] = {
pad(date.getUTCSeconds()) + 'Z';
}
};
-angular['Function'] = {
+
+var angularFunction = {
'compile':function(expression) {
if (_.isFunction(expression)){
return expression;
@@ -836,27 +837,29 @@ angular['Function'] = {
};
(function(){
- function extend(dst, src, names){
- _.extend(dst, src);
- _.each((names||[]), function(name){
- dst[name] = _[name];
+ function define(dst, chain, names){
+ foreach(chain, function(parent){
+ extend(angular[dst], parent);
});
- };
- extend(angular['Global'], {},
+ foreach(names, function(name){
+ angular[dst][name] = _[name];
+ });
+ }
+ define('Global', [angularGlobal],
['extend', 'clone','isEqual',
'isElement', 'isArray', 'isFunction', 'isUndefined']);
- extend(angular['Collection'], angular['Global'],
+ define('Collection', [angularGlobal, angularCollection],
['each', 'map', 'reduce', 'reduceRight', 'detect',
'select', 'reject', 'all', 'any', 'include',
'invoke', 'pluck', 'max', 'min', 'sortBy',
'sortedIndex', 'toArray', 'size']);
- extend(angular['Array'], angular['Collection'],
+ define('Array', [angularGlobal, angularCollection],
['first', 'last', 'compact', 'flatten', 'without',
'uniq', 'intersect', 'zip', 'indexOf', 'lastIndexOf']);
- extend(angular['Object'], angular['Collection'],
+ define('Object', [angularGlobal, angularCollection],
['keys', 'values']);
- extend(angular['String'], angular['Global']);
- extend(angular['Function'], angular['Global'],
+ define('String', [angularGlobal]);
+ define('Function', [angularGlobal],
['bind', 'bindAll', 'delay', 'defer', 'wrap', 'compose']);
})();// Copyright (C) 2009 BRAT Tech LLC
Binder = function(doc, widgetFactory, urlWatcher, config) {
@@ -917,16 +920,16 @@ Binder.prototype.parseAnchor = function(url) {
var anchor = url.substring(anchorIndex + 1);
var anchorQuery = this.parseQueryString(anchor);
- jQuery.each(self.anchor, function(key, newValue) {
+ foreach(self.anchor, function(newValue, key) {
delete self.anchor[key];
});
- jQuery.each(anchorQuery, function(key, newValue) {
+ foreach(anchorQuery, function(newValue, key) {
self.anchor[key] = newValue;
});
};
Binder.prototype.onUrlChange = function (url) {
- console.log("URL change detected", url);
+ log("URL change detected", url);
this.parseAnchor(url);
this.updateView();
};
@@ -1112,7 +1115,7 @@ Binder.prototype.precompileNode = function(node, path, factories) {
}
}
- if (!node.getAttribute) console.log(node);
+ if (!node.getAttribute) log(node);
var repeaterExpression = node.getAttribute('ng-repeat');
if (repeaterExpression) {
node.removeAttribute('ng-repeat');
@@ -1262,7 +1265,7 @@ ControlBar.prototype.doTemplate = function (path) {
callbacks["_iframe_notify_" + id] = function() {
loginView.dialog("destroy");
loginView.remove();
- jQuery.each(self.callbacks, function(i, callback){
+ foreach(self.callbacks, function(callback){
callback();
});
self.callbacks = [];
@@ -1322,7 +1325,7 @@ DataStore.prototype.loadMany = function(entity, ids, callback) {
var self=this;
var list = [];
var callbackCount = 0;
- jQuery.each(ids, function(i, id){
+ foreach(ids, function(id){
list.push(self.load(entity(), id, function(){
callbackCount++;
if (callbackCount == ids.length) {
@@ -1415,9 +1418,9 @@ DataStore.prototype.flush = function() {
var self = this;
var bulkRequest = this.bulkRequest;
this.bulkRequest = [];
- console.log('REQUEST:', bulkRequest);
+ log('REQUEST:', bulkRequest);
function callback(code, bulkResponse){
- console.log('RESPONSE[' + code + ']: ', bulkResponse);
+ log('RESPONSE[' + code + ']: ', bulkResponse);
if(bulkResponse.$status_code == 401) {
self.users.login(function(){
self.post(bulkRequest, callback);
@@ -1498,7 +1501,7 @@ DataStore.prototype.documentCountsByUser = function(){
var counts = {};
var self = this;
self.post([["GET", "$users"]], function(code, response){
- jQuery.each(response[0], function(key, value){
+ foreach(response[0], function(value, key){
counts[key] = value;
});
});
@@ -1509,7 +1512,7 @@ DataStore.prototype.userDocumentIdsByEntity = function(user){
var ids = {};
var self = this;
self.post([["GET", "$users/" + user]], function(code, response){
- jQuery.each(response[0], function(key, value){
+ foreach(response[0], function(value, key){
ids[key] = value;
});
});
@@ -1613,14 +1616,14 @@ DataStore.prototype.join = function(join){
};
// Copyright (C) 2009 BRAT Tech LLC
-angular.filter.Meta = function(obj){
+angularFilter.Meta = function(obj){
if (obj) {
for ( var key in obj) {
this[key] = obj[key];
}
}
};
-angular.filter.Meta.get = function(obj, attr){
+angularFilter.Meta.get = function(obj, attr){
attr = attr || 'text';
switch(typeof obj) {
case "string":
@@ -1635,272 +1638,283 @@ angular.filter.Meta.get = function(obj, attr){
}
};
-angular.filter['currency'] = function(amount){
- jQuery(this.element).toggleClass('ng-format-negative', amount < 0);
- return '$' + angular.filter.number.apply(this, [amount, 2]);
-};
-
-angular.filter.number = function(amount, fractionSize){
- if (isNaN(amount) || !isFinite(amount)) {
- return '';
- }
- fractionSize = typeof fractionSize == 'undefined' ? 2 : fractionSize;
- var isNegative = amount < 0;
- amount = Math.abs(amount);
- var pow = Math.pow(10, fractionSize);
- var text = "" + Math.round(amount * pow);
- var whole = text.substring(0, text.length - fractionSize);
- whole = whole || '0';
- var frc = text.substring(text.length - fractionSize);
- text = isNegative ? '-' : '';
- for (var i = 0; i < whole.length; i++) {
- if ((whole.length - i)%3 === 0 && i !== 0) {
- text += ',';
- }
- text += whole.charAt(i);
- }
- if (fractionSize > 0) {
- for (var j = frc.length; j < fractionSize; j++) {
- frc += '0';
- }
- text += '.' + frc.substring(0, fractionSize);
- }
- return text;
-};
-
-angular.filter.date = function(amount) {
-};
-
-angular.filter.json = function(object) {
- jQuery(this.element).addClass("ng-monospace");
- return toJson(object, true);
-};
+var angularFilterGoogleChartApi;
-angular.filter.trackPackage = function(trackingNo, noMatch) {
- trackingNo = trim(trackingNo);
- var tNo = trackingNo.replace(/ /g, '');
- var MATCHERS = angular.filter.trackPackage.MATCHERS;
- for ( var i = 0; i < MATCHERS.length; i++) {
- var carrier = MATCHERS[i];
- for ( var j = 0; j < carrier.regexp.length; j++) {
- var regexp = carrier.regexp[j];
- if (regexp.test(tNo)) {
- var text = carrier.name + ": " + trackingNo;
- var url = carrier.url + trackingNo;
- return new angular.filter.Meta({
- text:text,
- url:url,
- html: '<a href="' + escapeAttr(url) + '">' + text + '</a>',
- trackingNo:trackingNo});
+foreach({
+ 'currency': function(amount){
+ jQuery(this.element).toggleClass('ng-format-negative', amount < 0);
+ return '$' + angularFilter['number'].apply(this, [amount, 2]);
+ },
+
+ 'number': function(amount, fractionSize){
+ if (isNaN(amount) || !isFinite(amount)) {
+ return '';
+ }
+ fractionSize = typeof fractionSize == 'undefined' ? 2 : fractionSize;
+ var isNegative = amount < 0;
+ amount = Math.abs(amount);
+ var pow = Math.pow(10, fractionSize);
+ var text = "" + Math.round(amount * pow);
+ var whole = text.substring(0, text.length - fractionSize);
+ whole = whole || '0';
+ var frc = text.substring(text.length - fractionSize);
+ text = isNegative ? '-' : '';
+ for (var i = 0; i < whole.length; i++) {
+ if ((whole.length - i)%3 === 0 && i !== 0) {
+ text += ',';
}
+ text += whole.charAt(i);
}
- }
- if (trackingNo)
- return noMatch ||
- new angular.filter.Meta({text:trackingNo + " is not recognized"});
- else
- return null;
-};
-
-angular.filter.trackPackage.MATCHERS = [
- { 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=",
- regexp: [
- /^1Z[0-9A-Z]{16}$/i]},
- { name: "FedEx",
- url: "http://www.fedex.com/Tracking?tracknumbers=",
- regexp: [
- /^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=",
- regexp: [
- /^(91\d{20})$/i,
- /^(91\d{18})$/i]}];
-
-angular.filter.link = function(obj, title) {
- var text = title || angular.filter.Meta.get(obj);
- var url = angular.filter.Meta.get(obj, "url") || angular.filter.Meta.get(obj);
- if (url) {
- if (angular.validator.email(url) === null) {
- url = "mailto:" + url;
- }
- var html = '<a href="' + escapeHtml(url) + '">' + text + '</a>';
- return new angular.filter.Meta({text:text, url:url, html:html});
- }
- return obj;
-};
-
-
-angular.filter.bytes = function(size) {
- if(size === null) return "";
-
- var suffix = 0;
- while (size > 1000) {
- size = size / 1024;
- suffix++;
- }
- var txt = "" + size;
- var dot = txt.indexOf('.');
- if (dot > -1 && dot + 2 < txt.length) {
- txt = txt.substring(0, dot + 2);
- }
- return txt + " " + angular.filter.bytes.SUFFIX[suffix];
-};
-angular.filter.bytes.SUFFIX = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
-
-angular.filter.image = function(obj, width, height) {
- if (obj && obj.url) {
- var style = "";
- if (width) {
- style = ' style="max-width: ' + width +
- 'px; max-height: ' + (height || width) + 'px;"';
+ if (fractionSize > 0) {
+ for (var j = frc.length; j < fractionSize; j++) {
+ frc += '0';
+ }
+ text += '.' + frc.substring(0, fractionSize);
}
- return new angular.filter.Meta({url:obj.url, text:obj.url,
- html:'<img src="'+obj.url+'"' + style + '/>'});
- }
- return null;
-};
-
-angular.filter.lowercase = function (obj) {
- var text = angular.filter.Meta.get(obj);
- return text ? ("" + text).toLowerCase() : text;
-};
-
-angular.filter.uppercase = function (obj) {
- var text = angular.filter.Meta.get(obj);
- return text ? ("" + text).toUpperCase() : text;
-};
-
-angular.filter.linecount = function (obj) {
- var text = angular.filter.Meta.get(obj);
- if (text==='' || !text) return 1;
- return text.split(/\n|\f/).length;
-};
-
-angular.filter['if'] = function (result, expression) {
- return expression ? result : undefined;
-};
-
-angular.filter.unless = function (result, expression) {
- return expression ? undefined : result;
-};
-
-angular.filter.googleChartApi = function(type, data, width, height) {
- data = data || {};
- var api = angular.filter.googleChartApi;
- var chart = {
- cht:type,
- chco:api.collect(data, 'color'),
- chtt:api.title(data),
- chdl:api.collect(data, 'label'),
- chd:api.values(data),
- chf:'bg,s,FFFFFF00'
- };
- if (_.isArray(data.xLabels)) {
- chart.chxt='x';
- chart.chxl='0:|' + data.xLabels.join('|');
- }
- return angular.filter.googleChartApi.encode(chart, width, height);
-};
-
-angular.filter.googleChartApi.values = function(data){
- var seriesValues = [];
- _.each(data.series||[], function(serie){
- var values = [];
- _.each(serie.values||[], function(value){
- values.push(value);
- });
- seriesValues.push(values.join(','));
- });
- var values = seriesValues.join('|');
- return values === "" ? null : "t:" + values;
-};
-
-angular.filter.googleChartApi.title = function(data){
- var titles = [];
- var title = data.title || [];
- _.each(_.isArray(title)?title:[title], function(text){
- titles.push(encodeURIComponent(text));
- });
- return titles.join('|');
-};
-
-angular.filter.googleChartApi.collect = function(data, key){
- var outterValues = [];
- var count = 0;
- _.each(data.series||[], function(serie){
- var innerValues = [];
- var value = serie[key] || [];
- _.each(_.isArray(value)?value:[value], function(color){
- innerValues.push(encodeURIComponent(color));
- count++;
+ return text;
+ },
+
+ 'date': function(amount) {
+ },
+
+ 'json': function(object) {
+ jQuery(this.element).addClass("ng-monospace");
+ return toJson(object, true);
+ },
+
+ 'trackPackage': (function(){
+ var MATCHERS = [
+ { 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=",
+ regexp: [
+ /^1Z[0-9A-Z]{16}$/i]},
+ { name: "FedEx",
+ url: "http://www.fedex.com/Tracking?tracknumbers=",
+ regexp: [
+ /^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=",
+ regexp: [
+ /^(91\d{20})$/i,
+ /^(91\d{18})$/i]}];
+ return function(trackingNo, noMatch) {
+ trackingNo = trim(trackingNo);
+ var tNo = trackingNo.replace(/ /g, '');
+ var returnValue;
+ foreach(MATCHERS, function(carrier){
+ foreach(carrier.regexp, function(regexp){
+ if (regexp.test(tNo)) {
+ var text = carrier.name + ": " + trackingNo;
+ var url = carrier.url + trackingNo;
+ returnValue = new angularFilter.Meta({
+ text:text,
+ url:url,
+ html: '<a href="' + escapeAttr(url) + '">' + text + '</a>',
+ trackingNo:trackingNo});
+ _.breakLoop();
+ }
+ });
+ if (returnValue) _.breakLoop();
});
- outterValues.push(innerValues.join('|'));
- });
- return count?outterValues.join(','):null;
-};
-
-angular.filter.googleChartApi.encode= function(params, width, height) {
- width = width || 200;
- height = height || width;
- var url = "http://chart.apis.google.com/chart?";
- var urlParam = [];
- params.chs = width + "x" + height;
- for ( var key in params) {
- var value = params[key];
- if (value) {
- urlParam.push(key + "=" + value);
+ if (returnValue)
+ return returnValue;
+ else if (trackingNo)
+ return noMatch || new angularFilter.Meta({text:trackingNo + " is not recognized"});
+ else
+ return null;
+ };})(),
+
+ 'link': function(obj, title) {
+ var text = title || angularFilter.Meta.get(obj);
+ var url = angularFilter.Meta.get(obj, "url") || angularFilter.Meta.get(obj);
+ if (url) {
+ if (angular.validator.email(url) === null) {
+ url = "mailto:" + url;
+ }
+ var html = '<a href="' + escapeHtml(url) + '">' + text + '</a>';
+ return new angularFilter.Meta({text:text, url:url, html:html});
}
- }
- urlParam.sort();
- url += urlParam.join("&");
- return new angular.filter.Meta({url:url, text:value,
- html:'<img width="' + width + '" height="' + height + '" src="'+url+'"/>'});
-};
-
-angular.filter.qrcode = function(value, width, height) {
- return angular.filter.googleChartApi.encode({cht:'qr', chl:encodeURIComponent(value)}, width, height);
-};
-angular.filter.chart = {
- pie:function(data, width, height) {
- return angular.filter.googleChartApi('p', data, width, height);
+ return obj;
},
- pie3d:function(data, width, height) {
- return angular.filter.googleChartApi('p3', data, width, height);
+
+
+ 'bytes': (function(){
+ var SUFFIX = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
+ return function(size) {
+ if(size === null) return "";
+
+ var suffix = 0;
+ while (size > 1000) {
+ size = size / 1024;
+ suffix++;
+ }
+ var txt = "" + size;
+ var dot = txt.indexOf('.');
+ if (dot > -1 && dot + 2 < txt.length) {
+ txt = txt.substring(0, dot + 2);
+ }
+ return txt + " " + SUFFIX[suffix];
+ };
+ })(),
+
+ 'image': function(obj, width, height) {
+ if (obj && obj.url) {
+ var style = "";
+ if (width) {
+ style = ' style="max-width: ' + width +
+ 'px; max-height: ' + (height || width) + 'px;"';
+ }
+ return new angularFilter.Meta({url:obj.url, text:obj.url,
+ html:'<img src="'+obj.url+'"' + style + '/>'});
+ }
+ return null;
},
- pieConcentric:function(data, width, height) {
- return angular.filter.googleChartApi('pc', data, width, height);
+
+ 'lowercase': function (obj) {
+ var text = angularFilter.Meta.get(obj);
+ return text ? ("" + text).toLowerCase() : text;
},
- barHorizontalStacked:function(data, width, height) {
- return angular.filter.googleChartApi('bhs', data, width, height);
+
+ 'uppercase': function (obj) {
+ var text = angularFilter.Meta.get(obj);
+ return text ? ("" + text).toUpperCase() : text;
},
- barHorizontalGrouped:function(data, width, height) {
- return angular.filter.googleChartApi('bhg', data, width, height);
+
+ 'linecount': function (obj) {
+ var text = angularFilter.Meta.get(obj);
+ if (text==='' || !text) return 1;
+ return text.split(/\n|\f/).length;
},
- barVerticalStacked:function(data, width, height) {
- return angular.filter.googleChartApi('bvs', data, width, height);
+
+ 'if': function (result, expression) {
+ return expression ? result : undefined;
},
- barVerticalGrouped:function(data, width, height) {
- return angular.filter.googleChartApi('bvg', data, width, height);
+
+ 'unless': function (result, expression) {
+ return expression ? undefined : result;
},
- line:function(data, width, height) {
- return angular.filter.googleChartApi('lc', data, width, height);
+
+ 'googleChartApi': extend(
+ function(type, data, width, height) {
+ data = data || {};
+ var chart = {
+ cht:type,
+ chco:angularFilterGoogleChartApi.collect(data, 'color'),
+ chtt:angularFilterGoogleChartApi.title(data),
+ chdl:angularFilterGoogleChartApi.collect(data, 'label'),
+ chd:angularFilterGoogleChartApi.values(data),
+ chf:'bg,s,FFFFFF00'
+ };
+ if (_.isArray(data.xLabels)) {
+ chart.chxt='x';
+ chart.chxl='0:|' + data.xLabels.join('|');
+ }
+ return angularFilterGoogleChartApi['encode'](chart, width, height);
+ },
+ {
+ 'values': function(data){
+ var seriesValues = [];
+ foreach(data.series||[], function(serie){
+ var values = [];
+ foreach(serie.values||[], function(value){
+ values.push(value);
+ });
+ seriesValues.push(values.join(','));
+ });
+ var values = seriesValues.join('|');
+ return values === "" ? null : "t:" + values;
+ },
+
+ 'title': function(data){
+ var titles = [];
+ var title = data.title || [];
+ foreach(_.isArray(title)?title:[title], function(text){
+ titles.push(encodeURIComponent(text));
+ });
+ return titles.join('|');
+ },
+
+ 'collect': function(data, key){
+ var outterValues = [];
+ var count = 0;
+ foreach(data.series||[], function(serie){
+ var innerValues = [];
+ var value = serie[key] || [];
+ foreach(_.isArray(value)?value:[value], function(color){
+ innerValues.push(encodeURIComponent(color));
+ count++;
+ });
+ outterValues.push(innerValues.join('|'));
+ });
+ return count?outterValues.join(','):null;
+ },
+
+ 'encode': function(params, width, height) {
+ width = width || 200;
+ height = height || width;
+ var url = "http://chart.apis.google.com/chart?";
+ var urlParam = [];
+ params.chs = width + "x" + height;
+ foreach(params, function(value, key){
+ if (value) {
+ urlParam.push(key + "=" + value);
+ }
+ });
+ urlParam.sort();
+ url += urlParam.join("&");
+ return new angularFilter.Meta({url:url,
+ html:'<img width="' + width + '" height="' + height + '" src="'+url+'"/>'});
+ }
+ }
+ ),
+
+
+ 'qrcode': function(value, width, height) {
+ return angularFilterGoogleChartApi['encode']({cht:'qr', chl:encodeURIComponent(value)}, width, height);
},
- sparkline:function(data, width, height) {
- return angular.filter.googleChartApi('ls', data, width, height);
+ 'chart': {
+ pie:function(data, width, height) {
+ return angularFilterGoogleChartApi('p', data, width, height);
+ },
+ pie3d:function(data, width, height) {
+ return angularFilterGoogleChartApi('p3', data, width, height);
+ },
+ pieConcentric:function(data, width, height) {
+ return angularFilterGoogleChartApi('pc', data, width, height);
+ },
+ barHorizontalStacked:function(data, width, height) {
+ return angularFilterGoogleChartApi('bhs', data, width, height);
+ },
+ barHorizontalGrouped:function(data, width, height) {
+ return angularFilterGoogleChartApi('bhg', data, width, height);
+ },
+ barVerticalStacked:function(data, width, height) {
+ return angularFilterGoogleChartApi('bvs', data, width, height);
+ },
+ barVerticalGrouped:function(data, width, height) {
+ return angularFilterGoogleChartApi('bvg', data, width, height);
+ },
+ line:function(data, width, height) {
+ return angularFilterGoogleChartApi('lc', data, width, height);
+ },
+ sparkline:function(data, width, height) {
+ return angularFilterGoogleChartApi('ls', data, width, height);
+ },
+ scatter:function(data, width, height) {
+ return angularFilterGoogleChartApi('s', data, width, height);
+ }
},
- scatter:function(data, width, height) {
- return angular.filter.googleChartApi('s', data, width, height);
+
+ 'html': function(html){
+ return new angularFilter.Meta({html:html});
}
-};
+}, function(v,k){angularFilter[k] = v;});
-angular.filter.html = function(html){
- return new angular.filter.Meta({html:html});
-};
+angularFilterGoogleChartApi = angularFilter['googleChartApi'];
array = [].constructor;
toJson = function(obj, pretty){
@@ -1920,7 +1934,7 @@ fromJson = function(json) {
parser.assertAllConsumed();
return expression();
} catch (e) {
- console.error("fromJson error: ", json, e);
+ error("fromJson error: ", json, e);
throw e;
}
};
@@ -2925,7 +2939,7 @@ Scope.prototype.evalWidget = function(widget, expression, context, onSuccess, on
}
return true;
} catch (e){
- console.error('Eval Widget Error:', e);
+ error('Eval Widget Error:', e);
var jsonError = toJson(e, true);
widget.hasError = true;
jQuery(widget.view).
@@ -2985,10 +2999,10 @@ Scope.prototype.addWatchListener = function(watchExpression, listener) {
Scope.prototype.fireWatchers = function() {
var self = this;
var fired = false;
- jQuery.each(this.watchListeners, function(name, watcher) {
+ foreach(this.watchListeners, function(watcher) {
var value = self.eval(watcher.expression);
if (value !== watcher.lastValue) {
- jQuery.each(watcher.listeners, function(i, listener){
+ foreach(watcher.listeners, function(listener){
listener(value, watcher.lastValue);
fired = true;
});
@@ -3013,7 +3027,7 @@ Server.prototype.base64url = function(txt) {
Server.prototype.request = function(method, url, request, callback) {
var requestId = this.uuid + (this.nextId++);
- callbacks[requestId] = function(response) {
+ angularCallbacks[requestId] = function(response) {
delete angular[requestId];
callback(200, response);
};
@@ -3104,84 +3118,86 @@ Users.prototype = {
};
// Copyright (C) 2009 BRAT Tech LLC
-angular.validator.regexp = function(value, regexp, msg) {
- if (!value.match(regexp)) {
- return msg ||
- "Value does not match expected format " + regexp + ".";
- } else {
- return null;
- }
-};
-
-angular.validator.number = function(value, min, max) {
- var num = 1 * value;
- if (num == value) {
- if (typeof min != 'undefined' && num < min) {
- return "Value can not be less than " + min + ".";
+foreach({
+ 'regexp': function(value, regexp, msg) {
+ if (!value.match(regexp)) {
+ return msg ||
+ "Value does not match expected format " + regexp + ".";
+ } else {
+ return null;
}
- if (typeof min != 'undefined' && num > max) {
- return "Value can not be greater than " + max + ".";
+ },
+
+ 'number': function(value, min, max) {
+ var num = 1 * value;
+ if (num == value) {
+ if (typeof min != 'undefined' && num < min) {
+ return "Value can not be less than " + min + ".";
+ }
+ if (typeof min != 'undefined' && num > max) {
+ return "Value can not be greater than " + max + ".";
+ }
+ return null;
+ } else {
+ return "Value is not a number.";
+ }
+ },
+
+ 'integer': function(value, min, max) {
+ var number = angularValidator['number'](value, min, max);
+ if (number === null && value != Math.round(value)) {
+ return "Value is not a whole number.";
+ }
+ return number;
+ },
+
+ 'date': function(value, min, max) {
+ if (value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/)) {
+ return null;
+ }
+ return "Value is not a date. (Expecting format: 12/31/2009).";
+ },
+
+ 'ssn': function(value) {
+ if (value.match(/^\d\d\d-\d\d-\d\d\d\d$/)) {
+ return null;
+ }
+ return "SSN needs to be in 999-99-9999 format.";
+ },
+
+ 'email': function(value) {
+ if (value.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(value) {
+ if (value.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/)) {
+ return null;
+ }
+ if (value.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(value) {
+ if (value.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(value) {
+ try {
+ fromJson(value);
+ return null;
+ } catch (e) {
+ return e.toString();
}
- return null;
- } else {
- return "Value is not a number.";
- }
-};
-
-angular.validator.integer = function(value, min, max) {
- var number = angular.validator.number(value, min, max);
- if (number === null && value != Math.round(value)) {
- return "Value is not a whole number.";
- }
- return number;
-};
-
-angular.validator.date = function(value, min, max) {
- if (value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/)) {
- return null;
- }
- return "Value is not a date. (Expecting format: 12/31/2009).";
-};
-
-angular.validator.ssn = function(value) {
- if (value.match(/^\d\d\d-\d\d-\d\d\d\d$/)) {
- return null;
- }
- return "SSN needs to be in 999-99-9999 format.";
-};
-
-angular.validator.email = function(value) {
- if (value.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.";
-};
-
-angular.validator.phone = function(value) {
- if (value.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/)) {
- return null;
- }
- if (value.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.";
-};
-
-angular.validator.url = function(value) {
- if (value.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.";
-};
-
-angular.validator.json = function(value) {
- try {
- fromJson(value);
- return null;
- } catch (e) {
- return e.toString();
}
-};
+}, function(v,k) {angularValidator[k] = v;});
// Copyright (C) 2009 BRAT Tech LLC
@@ -3709,7 +3725,7 @@ BindAttrUpdater.prototype.updateView = function(scope) {
attrValues.push(value);
} catch (e) {
this.hasError = true;
- console.error('BindAttrUpdater', e);
+ error('BindAttrUpdater', e);
var jsonError = toJson(e, true);
attrValues.push('[' + jsonError + ']');
jNode.
@@ -3841,7 +3857,7 @@ RepeaterUpdater.prototype.updateView = function(scope) {
var keyExp = this.keyExp;
var valueExp = this.valueExp;
var i = 0;
- jQuery.each(iterator, function(key, value){
+ foreach(iterator, function(value, key){
if (i < childrenLength) {
// reuse children
child = self.children[i];
diff --git a/example/calculator-manual_init.html b/example/calculator-manual_init.html
index 1a6571c2..43d013fc 100644
--- a/example/calculator-manual_init.html
+++ b/example/calculator-manual_init.html
@@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
+ <script type="text/javascript" src="../lib/underscore/underscore.js"></script>
<script type="text/javascript" src="../lib/jquery/jquery-1.3.2.js"></script>
<script type="text/javascript" src="../angular.js"></script>
<script type="text/javascript">
diff --git a/src/API.js b/src/API.js
index 49089da0..d795f4c3 100644
--- a/src/API.js
+++ b/src/API.js
@@ -1,9 +1,8 @@
-angular['Global'] = {
+var angularGlobal = {
'typeOf':function(obj){
+ if (obj === null) return "null";
var type = typeof obj;
- switch(type) {
- case "object":
- if (obj === null) return "null";
+ if (type == "object") {
if (obj instanceof Array) return "array";
if (obj instanceof Date) return "date";
if (obj.nodeType == 1) return "element";
@@ -12,9 +11,9 @@ angular['Global'] = {
}
};
-angular['Collection'] = {};
-angular['Object'] = {};
-angular['Array'] = {
+var angularCollection = {};
+var angularObject = {};
+var angularArray = {
'includeIf':function(array, value, condition) {
var index = _.indexOf(array, value);
if (condition) {
@@ -177,7 +176,7 @@ angular['Array'] = {
var comparator = function(o1, o2){
for ( var i = 0; i < expression.length; i++) {
var comp = expression[i](o1, o2);
- if (comp != 0) return comp;
+ if (comp !== 0) return comp;
}
return 0;
};
@@ -197,7 +196,7 @@ angular['Array'] = {
ascending = $.charAt(0) == '+';
index = i;
return true;
- };
+ }
});
if (index >= 0) {
predicate.splice(index, 1);
@@ -228,7 +227,8 @@ angular['Array'] = {
return array;
}
};
-angular['String'] = {
+
+var angularString = {
'quote':function(string) {
return '"' + string.replace(/\\/g, '\\\\').
replace(/"/g, '\\"').
@@ -265,7 +265,8 @@ angular['String'] = {
return string;
}
};
-angular['Date'] = {
+
+var angularDate = {
'toString':function(date){
function pad(n) { return n < 10 ? "0" + n : n; }
return (date.getUTCFullYear()) + '-' +
@@ -276,7 +277,8 @@ angular['Date'] = {
pad(date.getUTCSeconds()) + 'Z';
}
};
-angular['Function'] = {
+
+var angularFunction = {
'compile':function(expression) {
if (_.isFunction(expression)){
return expression;
@@ -292,27 +294,30 @@ angular['Function'] = {
}
};
-(function(){
- function extend(dst, src, names){
- _.extend(dst, src);
- _.each((names||[]), function(name){
- dst[name] = _[name];
- });
- };
- extend(angular['Global'], {},
- ['extend', 'clone','isEqual',
- 'isElement', 'isArray', 'isFunction', 'isUndefined']);
- extend(angular['Collection'], angular['Global'],
- ['each', 'map', 'reduce', 'reduceRight', 'detect',
- 'select', 'reject', 'all', 'any', 'include',
- 'invoke', 'pluck', 'max', 'min', 'sortBy',
- 'sortedIndex', 'toArray', 'size']);
- extend(angular['Array'], angular['Collection'],
- ['first', 'last', 'compact', 'flatten', 'without',
- 'uniq', 'intersect', 'zip', 'indexOf', 'lastIndexOf']);
- extend(angular['Object'], angular['Collection'],
- ['keys', 'values']);
- extend(angular['String'], angular['Global']);
- extend(angular['Function'], angular['Global'],
- ['bind', 'bindAll', 'delay', 'defer', 'wrap', 'compose']);
-})(); \ No newline at end of file
+function defineApi(dst, chain, underscoreNames){
+ var lastChain = _.last(chain);
+ foreach(underscoreNames, function(name){
+ lastChain[name] = _[name];
+ });
+ angular[dst] = angular[dst] || {};
+ foreach(chain, function(parent){
+ extend(angular[dst], parent);
+ });
+}
+defineApi('Global', [angularGlobal],
+ ['extend', 'clone','isEqual',
+ 'isElement', 'isArray', 'isFunction', 'isUndefined']);
+defineApi('Collection', [angularGlobal, angularCollection],
+ ['each', 'map', 'reduce', 'reduceRight', 'detect',
+ 'select', 'reject', 'all', 'any', 'include',
+ 'invoke', 'pluck', 'max', 'min', 'sortBy',
+ 'sortedIndex', 'toArray', 'size']);
+defineApi('Array', [angularGlobal, angularCollection, angularArray],
+ ['first', 'last', 'compact', 'flatten', 'without',
+ 'uniq', 'intersect', 'zip', 'indexOf', 'lastIndexOf']);
+defineApi('Object', [angularGlobal, angularCollection, angularObject],
+ ['keys', 'values']);
+defineApi('String', [angularGlobal, angularString], []);
+defineApi('Date', [angularGlobal, angularDate], []);
+defineApi('Function', [angularGlobal, angularCollection, angularFunction],
+ ['bind', 'bindAll', 'delay', 'defer', 'wrap', 'compose']);
diff --git a/src/Binder.js b/src/Binder.js
index 3589cb88..4c5299ed 100644
--- a/src/Binder.js
+++ b/src/Binder.js
@@ -57,16 +57,16 @@ Binder.prototype.parseAnchor = function(url) {
var anchor = url.substring(anchorIndex + 1);
var anchorQuery = this.parseQueryString(anchor);
- jQuery.each(self.anchor, function(key, newValue) {
+ foreach(self.anchor, function(newValue, key) {
delete self.anchor[key];
});
- jQuery.each(anchorQuery, function(key, newValue) {
+ foreach(anchorQuery, function(newValue, key) {
self.anchor[key] = newValue;
});
};
Binder.prototype.onUrlChange = function (url) {
- console.log("URL change detected", url);
+ log("URL change detected", url);
this.parseAnchor(url);
this.updateView();
};
@@ -252,7 +252,7 @@ Binder.prototype.precompileNode = function(node, path, factories) {
}
}
- if (!node.getAttribute) console.log(node);
+ if (!node.getAttribute) log(node);
var repeaterExpression = node.getAttribute('ng-repeat');
if (repeaterExpression) {
node.removeAttribute('ng-repeat');
diff --git a/src/ControlBar.js b/src/ControlBar.js
index b66a1464..fb8147d5 100644
--- a/src/ControlBar.js
+++ b/src/ControlBar.js
@@ -52,7 +52,7 @@ ControlBar.prototype.doTemplate = function (path) {
callbacks["_iframe_notify_" + id] = function() {
loginView.dialog("destroy");
loginView.remove();
- jQuery.each(self.callbacks, function(i, callback){
+ foreach(self.callbacks, function(callback){
callback();
});
self.callbacks = [];
diff --git a/src/DataStore.js b/src/DataStore.js
index 6eeabb21..f99e5824 100644
--- a/src/DataStore.js
+++ b/src/DataStore.js
@@ -41,7 +41,7 @@ DataStore.prototype.loadMany = function(entity, ids, callback) {
var self=this;
var list = [];
var callbackCount = 0;
- jQuery.each(ids, function(i, id){
+ foreach(ids, function(id){
list.push(self.load(entity(), id, function(){
callbackCount++;
if (callbackCount == ids.length) {
@@ -50,7 +50,7 @@ DataStore.prototype.loadMany = function(entity, ids, callback) {
}));
});
return list;
-}
+};
DataStore.prototype.loadOrCreate = function(instance, id, callback) {
var self=this;
@@ -134,9 +134,9 @@ DataStore.prototype.flush = function() {
var self = this;
var bulkRequest = this.bulkRequest;
this.bulkRequest = [];
- console.log('REQUEST:', bulkRequest);
+ log('REQUEST:', bulkRequest);
function callback(code, bulkResponse){
- console.log('RESPONSE[' + code + ']: ', bulkResponse);
+ log('RESPONSE[' + code + ']: ', bulkResponse);
if(bulkResponse.$status_code == 401) {
self.users.login(function(){
self.post(bulkRequest, callback);
@@ -147,9 +147,9 @@ DataStore.prototype.flush = function() {
for ( var i = 0; i < bulkResponse.length; i++) {
var response = bulkResponse[i];
var request = bulkRequest[i];
- var code = response.$status_code;
- if(code) {
- if(code == 403) {
+ var responseCode = response.$status_code;
+ if(responseCode) {
+ if(responseCode == 403) {
self.users.notAuthorized();
} else {
request.$$failure(response);
@@ -217,7 +217,7 @@ DataStore.prototype.documentCountsByUser = function(){
var counts = {};
var self = this;
self.post([["GET", "$users"]], function(code, response){
- jQuery.each(response[0], function(key, value){
+ foreach(response[0], function(value, key){
counts[key] = value;
});
});
@@ -228,7 +228,7 @@ DataStore.prototype.userDocumentIdsByEntity = function(user){
var ids = {};
var self = this;
self.post([["GET", "$users/" + user]], function(code, response){
- jQuery.each(response[0], function(key, value){
+ foreach(response[0], function(value, key){
ids[key] = value;
});
});
diff --git a/src/Filters.js b/src/Filters.js
index b3f56e75..67fcffa1 100644
--- a/src/Filters.js
+++ b/src/Filters.js
@@ -1,13 +1,13 @@
// Copyright (C) 2009 BRAT Tech LLC
-angular.filter.Meta = function(obj){
+angularFilter.Meta = function(obj){
if (obj) {
for ( var key in obj) {
this[key] = obj[key];
}
}
};
-angular.filter.Meta.get = function(obj, attr){
+angularFilter.Meta.get = function(obj, attr){
attr = attr || 'text';
switch(typeof obj) {
case "string":
@@ -22,269 +22,280 @@ angular.filter.Meta.get = function(obj, attr){
}
};
-angular.filter['currency'] = function(amount){
- jQuery(this.element).toggleClass('ng-format-negative', amount < 0);
- return '$' + angular.filter.number.apply(this, [amount, 2]);
-};
+var angularFilterGoogleChartApi;
-angular.filter.number = function(amount, fractionSize){
- if (isNaN(amount) || !isFinite(amount)) {
- return '';
- }
- fractionSize = typeof fractionSize == 'undefined' ? 2 : fractionSize;
- var isNegative = amount < 0;
- amount = Math.abs(amount);
- var pow = Math.pow(10, fractionSize);
- var text = "" + Math.round(amount * pow);
- var whole = text.substring(0, text.length - fractionSize);
- whole = whole || '0';
- var frc = text.substring(text.length - fractionSize);
- text = isNegative ? '-' : '';
- for (var i = 0; i < whole.length; i++) {
- if ((whole.length - i)%3 === 0 && i !== 0) {
- text += ',';
- }
- text += whole.charAt(i);
- }
- if (fractionSize > 0) {
- for (var j = frc.length; j < fractionSize; j++) {
- frc += '0';
+foreach({
+ 'currency': function(amount){
+ jQuery(this.element).toggleClass('ng-format-negative', amount < 0);
+ return '$' + angularFilter['number'].apply(this, [amount, 2]);
+ },
+
+ 'number': function(amount, fractionSize){
+ if (isNaN(amount) || !isFinite(amount)) {
+ return '';
}
- text += '.' + frc.substring(0, fractionSize);
- }
- return text;
-};
-
-angular.filter.date = function(amount) {
-};
-
-angular.filter.json = function(object) {
- jQuery(this.element).addClass("ng-monospace");
- return toJson(object, true);
-};
-
-angular.filter.trackPackage = function(trackingNo, noMatch) {
- trackingNo = trim(trackingNo);
- var tNo = trackingNo.replace(/ /g, '');
- var MATCHERS = angular.filter.trackPackage.MATCHERS;
- for ( var i = 0; i < MATCHERS.length; i++) {
- var carrier = MATCHERS[i];
- for ( var j = 0; j < carrier.regexp.length; j++) {
- var regexp = carrier.regexp[j];
- if (regexp.test(tNo)) {
- var text = carrier.name + ": " + trackingNo;
- var url = carrier.url + trackingNo;
- return new angular.filter.Meta({
- text:text,
- url:url,
- html: '<a href="' + escapeAttr(url) + '">' + text + '</a>',
- trackingNo:trackingNo});
+ fractionSize = typeof fractionSize == 'undefined' ? 2 : fractionSize;
+ var isNegative = amount < 0;
+ amount = Math.abs(amount);
+ var pow = Math.pow(10, fractionSize);
+ var text = "" + Math.round(amount * pow);
+ var whole = text.substring(0, text.length - fractionSize);
+ whole = whole || '0';
+ var frc = text.substring(text.length - fractionSize);
+ text = isNegative ? '-' : '';
+ for (var i = 0; i < whole.length; i++) {
+ if ((whole.length - i)%3 === 0 && i !== 0) {
+ text += ',';
}
+ text += whole.charAt(i);
}
- }
- if (trackingNo)
- return noMatch ||
- new angular.filter.Meta({text:trackingNo + " is not recognized"});
- else
- return null;
-};
-
-angular.filter.trackPackage.MATCHERS = [
- { 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=",
- regexp: [
- /^1Z[0-9A-Z]{16}$/i]},
- { name: "FedEx",
- url: "http://www.fedex.com/Tracking?tracknumbers=",
- regexp: [
- /^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=",
- regexp: [
- /^(91\d{20})$/i,
- /^(91\d{18})$/i]}];
-
-angular.filter.link = function(obj, title) {
- var text = title || angular.filter.Meta.get(obj);
- var url = angular.filter.Meta.get(obj, "url") || angular.filter.Meta.get(obj);
- if (url) {
- if (angular.validator.email(url) === null) {
- url = "mailto:" + url;
- }
- var html = '<a href="' + escapeHtml(url) + '">' + text + '</a>';
- return new angular.filter.Meta({text:text, url:url, html:html});
- }
- return obj;
-};
-
-
-angular.filter.bytes = function(size) {
- if(size === null) return "";
-
- var suffix = 0;
- while (size > 1000) {
- size = size / 1024;
- suffix++;
- }
- var txt = "" + size;
- var dot = txt.indexOf('.');
- if (dot > -1 && dot + 2 < txt.length) {
- txt = txt.substring(0, dot + 2);
- }
- return txt + " " + angular.filter.bytes.SUFFIX[suffix];
-};
-angular.filter.bytes.SUFFIX = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
-
-angular.filter.image = function(obj, width, height) {
- if (obj && obj.url) {
- var style = "";
- if (width) {
- style = ' style="max-width: ' + width +
- 'px; max-height: ' + (height || width) + 'px;"';
+ if (fractionSize > 0) {
+ for (var j = frc.length; j < fractionSize; j++) {
+ frc += '0';
+ }
+ text += '.' + frc.substring(0, fractionSize);
}
- return new angular.filter.Meta({url:obj.url, text:obj.url,
- html:'<img src="'+obj.url+'"' + style + '/>'});
- }
- return null;
-};
-
-angular.filter.lowercase = function (obj) {
- var text = angular.filter.Meta.get(obj);
- return text ? ("" + text).toLowerCase() : text;
-};
-
-angular.filter.uppercase = function (obj) {
- var text = angular.filter.Meta.get(obj);
- return text ? ("" + text).toUpperCase() : text;
-};
-
-angular.filter.linecount = function (obj) {
- var text = angular.filter.Meta.get(obj);
- if (text==='' || !text) return 1;
- return text.split(/\n|\f/).length;
-};
-
-angular.filter['if'] = function (result, expression) {
- return expression ? result : undefined;
-};
-
-angular.filter.unless = function (result, expression) {
- return expression ? undefined : result;
-};
-
-angular.filter.googleChartApi = function(type, data, width, height) {
- data = data || {};
- var api = angular.filter.googleChartApi;
- var chart = {
- cht:type,
- chco:api.collect(data, 'color'),
- chtt:api.title(data),
- chdl:api.collect(data, 'label'),
- chd:api.values(data),
- chf:'bg,s,FFFFFF00'
- };
- if (_.isArray(data.xLabels)) {
- chart.chxt='x';
- chart.chxl='0:|' + data.xLabels.join('|');
- }
- return angular.filter.googleChartApi.encode(chart, width, height);
-};
-
-angular.filter.googleChartApi.values = function(data){
- var seriesValues = [];
- _.each(data.series||[], function(serie){
- var values = [];
- _.each(serie.values||[], function(value){
- values.push(value);
- });
- seriesValues.push(values.join(','));
- });
- var values = seriesValues.join('|');
- return values === "" ? null : "t:" + values;
-};
-
-angular.filter.googleChartApi.title = function(data){
- var titles = [];
- var title = data.title || [];
- _.each(_.isArray(title)?title:[title], function(text){
- titles.push(encodeURIComponent(text));
- });
- return titles.join('|');
-};
-
-angular.filter.googleChartApi.collect = function(data, key){
- var outterValues = [];
- var count = 0;
- _.each(data.series||[], function(serie){
- var innerValues = [];
- var value = serie[key] || [];
- _.each(_.isArray(value)?value:[value], function(color){
- innerValues.push(encodeURIComponent(color));
- count++;
+ return text;
+ },
+
+ 'date': function(amount) {
+ },
+
+ 'json': function(object) {
+ jQuery(this.element).addClass("ng-monospace");
+ return toJson(object, true);
+ },
+
+ 'trackPackage': (function(){
+ var MATCHERS = [
+ { 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=",
+ regexp: [
+ /^1Z[0-9A-Z]{16}$/i]},
+ { name: "FedEx",
+ url: "http://www.fedex.com/Tracking?tracknumbers=",
+ regexp: [
+ /^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=",
+ regexp: [
+ /^(91\d{20})$/i,
+ /^(91\d{18})$/i]}];
+ return function(trackingNo, noMatch) {
+ trackingNo = trim(trackingNo);
+ var tNo = trackingNo.replace(/ /g, '');
+ var returnValue;
+ foreach(MATCHERS, function(carrier){
+ foreach(carrier.regexp, function(regexp){
+ if (regexp.test(tNo)) {
+ var text = carrier.name + ": " + trackingNo;
+ var url = carrier.url + trackingNo;
+ returnValue = new angularFilter.Meta({
+ text:text,
+ url:url,
+ html: '<a href="' + escapeAttr(url) + '">' + text + '</a>',
+ trackingNo:trackingNo});
+ _.breakLoop();
+ }
+ });
+ if (returnValue) _.breakLoop();
});
- outterValues.push(innerValues.join('|'));
- });
- return count?outterValues.join(','):null;
-};
-
-angular.filter.googleChartApi.encode= function(params, width, height) {
- width = width || 200;
- height = height || width;
- var url = "http://chart.apis.google.com/chart?";
- var urlParam = [];
- params.chs = width + "x" + height;
- for ( var key in params) {
- var value = params[key];
- if (value) {
- urlParam.push(key + "=" + value);
+ if (returnValue)
+ return returnValue;
+ else if (trackingNo)
+ return noMatch || new angularFilter.Meta({text:trackingNo + " is not recognized"});
+ else
+ return null;
+ };})(),
+
+ 'link': function(obj, title) {
+ var text = title || angularFilter.Meta.get(obj);
+ var url = angularFilter.Meta.get(obj, "url") || angularFilter.Meta.get(obj);
+ if (url) {
+ if (angular.validator.email(url) === null) {
+ url = "mailto:" + url;
+ }
+ var html = '<a href="' + escapeHtml(url) + '">' + text + '</a>';
+ return new angularFilter.Meta({text:text, url:url, html:html});
}
- }
- urlParam.sort();
- url += urlParam.join("&");
- return new angular.filter.Meta({url:url, text:value,
- html:'<img width="' + width + '" height="' + height + '" src="'+url+'"/>'});
-};
-
-angular.filter.qrcode = function(value, width, height) {
- return angular.filter.googleChartApi.encode({cht:'qr', chl:encodeURIComponent(value)}, width, height);
-};
-angular.filter.chart = {
- pie:function(data, width, height) {
- return angular.filter.googleChartApi('p', data, width, height);
+ return obj;
},
- pie3d:function(data, width, height) {
- return angular.filter.googleChartApi('p3', data, width, height);
+
+
+ 'bytes': (function(){
+ var SUFFIX = ['bytes', 'KB', 'MB', 'GB', 'TB', 'PB'];
+ return function(size) {
+ if(size === null) return "";
+
+ var suffix = 0;
+ while (size > 1000) {
+ size = size / 1024;
+ suffix++;
+ }
+ var txt = "" + size;
+ var dot = txt.indexOf('.');
+ if (dot > -1 && dot + 2 < txt.length) {
+ txt = txt.substring(0, dot + 2);
+ }
+ return txt + " " + SUFFIX[suffix];
+ };
+ })(),
+
+ 'image': function(obj, width, height) {
+ if (obj && obj.url) {
+ var style = "";
+ if (width) {
+ style = ' style="max-width: ' + width +
+ 'px; max-height: ' + (height || width) + 'px;"';
+ }
+ return new angularFilter.Meta({url:obj.url, text:obj.url,
+ html:'<img src="'+obj.url+'"' + style + '/>'});
+ }
+ return null;
},
- pieConcentric:function(data, width, height) {
- return angular.filter.googleChartApi('pc', data, width, height);
+
+ 'lowercase': function (obj) {
+ var text = angularFilter.Meta.get(obj);
+ return text ? ("" + text).toLowerCase() : text;
},
- barHorizontalStacked:function(data, width, height) {
- return angular.filter.googleChartApi('bhs', data, width, height);
+
+ 'uppercase': function (obj) {
+ var text = angularFilter.Meta.get(obj);
+ return text ? ("" + text).toUpperCase() : text;
},
- barHorizontalGrouped:function(data, width, height) {
- return angular.filter.googleChartApi('bhg', data, width, height);
+
+ 'linecount': function (obj) {
+ var text = angularFilter.Meta.get(obj);
+ if (text==='' || !text) return 1;
+ return text.split(/\n|\f/).length;
},
- barVerticalStacked:function(data, width, height) {
- return angular.filter.googleChartApi('bvs', data, width, height);
+
+ 'if': function (result, expression) {
+ return expression ? result : undefined;
},
- barVerticalGrouped:function(data, width, height) {
- return angular.filter.googleChartApi('bvg', data, width, height);
+
+ 'unless': function (result, expression) {
+ return expression ? undefined : result;
},
- line:function(data, width, height) {
- return angular.filter.googleChartApi('lc', data, width, height);
+
+ 'googleChartApi': extend(
+ function(type, data, width, height) {
+ data = data || {};
+ var chart = {
+ cht:type,
+ chco:angularFilterGoogleChartApi.collect(data, 'color'),
+ chtt:angularFilterGoogleChartApi.title(data),
+ chdl:angularFilterGoogleChartApi.collect(data, 'label'),
+ chd:angularFilterGoogleChartApi.values(data),
+ chf:'bg,s,FFFFFF00'
+ };
+ if (_.isArray(data.xLabels)) {
+ chart.chxt='x';
+ chart.chxl='0:|' + data.xLabels.join('|');
+ }
+ return angularFilterGoogleChartApi['encode'](chart, width, height);
+ },
+ {
+ 'values': function(data){
+ var seriesValues = [];
+ foreach(data.series||[], function(serie){
+ var values = [];
+ foreach(serie.values||[], function(value){
+ values.push(value);
+ });
+ seriesValues.push(values.join(','));
+ });
+ var values = seriesValues.join('|');
+ return values === "" ? null : "t:" + values;
+ },
+
+ 'title': function(data){
+ var titles = [];
+ var title = data.title || [];
+ foreach(_.isArray(title)?title:[title], function(text){
+ titles.push(encodeURIComponent(text));
+ });
+ return titles.join('|');
+ },
+
+ 'collect': function(data, key){
+ var outterValues = [];
+ var count = 0;
+ foreach(data.series||[], function(serie){
+ var innerValues = [];
+ var value = serie[key] || [];
+ foreach(_.isArray(value)?value:[value], function(color){
+ innerValues.push(encodeURIComponent(color));
+ count++;
+ });
+ outterValues.push(innerValues.join('|'));
+ });
+ return count?outterValues.join(','):null;
+ },
+
+ 'encode': function(params, width, height) {
+ width = width || 200;
+ height = height || width;
+ var url = "http://chart.apis.google.com/chart?";
+ var urlParam = [];
+ params.chs = width + "x" + height;
+ foreach(params, function(value, key){
+ if (value) {
+ urlParam.push(key + "=" + value);
+ }
+ });
+ urlParam.sort();
+ url += urlParam.join("&");
+ return new angularFilter.Meta({url:url,
+ html:'<img width="' + width + '" height="' + height + '" src="'+url+'"/>'});
+ }
+ }
+ ),
+
+
+ 'qrcode': function(value, width, height) {
+ return angularFilterGoogleChartApi['encode']({cht:'qr', chl:encodeURIComponent(value)}, width, height);
},
- sparkline:function(data, width, height) {
- return angular.filter.googleChartApi('ls', data, width, height);
+ 'chart': {
+ pie:function(data, width, height) {
+ return angularFilterGoogleChartApi('p', data, width, height);
+ },
+ pie3d:function(data, width, height) {
+ return angularFilterGoogleChartApi('p3', data, width, height);
+ },
+ pieConcentric:function(data, width, height) {
+ return angularFilterGoogleChartApi('pc', data, width, height);
+ },
+ barHorizontalStacked:function(data, width, height) {
+ return angularFilterGoogleChartApi('bhs', data, width, height);
+ },
+ barHorizontalGrouped:function(data, width, height) {
+ return angularFilterGoogleChartApi('bhg', data, width, height);
+ },
+ barVerticalStacked:function(data, width, height) {
+ return angularFilterGoogleChartApi('bvs', data, width, height);
+ },
+ barVerticalGrouped:function(data, width, height) {
+ return angularFilterGoogleChartApi('bvg', data, width, height);
+ },
+ line:function(data, width, height) {
+ return angularFilterGoogleChartApi('lc', data, width, height);
+ },
+ sparkline:function(data, width, height) {
+ return angularFilterGoogleChartApi('ls', data, width, height);
+ },
+ scatter:function(data, width, height) {
+ return angularFilterGoogleChartApi('s', data, width, height);
+ }
},
- scatter:function(data, width, height) {
- return angular.filter.googleChartApi('s', data, width, height);
+
+ 'html': function(html){
+ return new angularFilter.Meta({html:html});
}
-};
+}, function(v,k){angularFilter[k] = v;});
-angular.filter.html = function(html){
- return new angular.filter.Meta({html:html});
-};
+angularFilterGoogleChartApi = angularFilter['googleChartApi'];
diff --git a/src/JSON.js b/src/JSON.js
index 238ed489..14fce1fb 100644
--- a/src/JSON.js
+++ b/src/JSON.js
@@ -17,7 +17,7 @@ fromJson = function(json) {
parser.assertAllConsumed();
return expression();
} catch (e) {
- console.error("fromJson error: ", json, e);
+ error("fromJson error: ", json, e);
throw e;
}
};
diff --git a/src/Loader.js b/src/Loader.js
index 19840567..104dfec8 100644
--- a/src/Loader.js
+++ b/src/Loader.js
@@ -3,8 +3,7 @@
// IE compatibility
if (typeof document.getAttribute == 'undefined')
- document.getAttribute = function() {
- };
+ document.getAttribute = function() {};
if (typeof Node == 'undefined') {
Node = {
ELEMENT_NODE : 1,
@@ -22,25 +21,26 @@ if (typeof Node == 'undefined') {
};
}
-var callbacks = {};
-var jQuery = window['jQuery'];
-var msie = jQuery['browser']['msie'];
-
-if (!window.angular){ angular = {}; window['angular'] = angular; }
-if (!angular.validator) angular.validator = {};
-if (!angular.filter) angular.filter = {};
-if (!window.console)
- window.console = {
- log:function() {},
- error:function() {}
- };
-if (!angular.alert) {
- angular.alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
-}
-
-var consoleNode;
-
-consoleLog = function(level, objs) {
+function noop() {}
+if (!window['console']) window['console']={'log':noop, 'error':noop};
+
+var consoleNode,
+ foreach = _.each,
+ extend = _.extend,
+ jQuery = window['jQuery'],
+ msie = jQuery['browser']['msie'],
+ log = function(){window['console']['log'].apply(this, arguments);},
+ error = function(){window['console']['error'].apply(this, arguments);},
+ angular = window['angular'] || (window['angular'] = {}),
+ angularValidator = angular['validator'] || (angular['validator'] = {}),
+ angularFilter = angular['filter'] || (angular['filter'] = {}),
+ angularCallbacks = angular['callbacks'] || (angular['callbacks'] = {}),
+ angularAlert = angular['alert'] || (angular['alert'] = function(){
+ log(arguments); window.alert.apply(window, arguments);
+ });
+
+
+function consoleLog(level, objs) {
var log = document.createElement("div");
log.className = level;
var msg = "";
@@ -52,17 +52,17 @@ consoleLog = function(level, objs) {
}
log.appendChild(document.createTextNode(msg));
consoleNode.appendChild(log);
-};
+}
-isNode = function(inp) {
+function isNode(inp) {
return inp &&
inp.tagName &&
inp.nodeName &&
inp.ownerDocument &&
inp.removeAttribute;
-};
+}
-isLeafNode = function(node) {
+function isLeafNode (node) {
switch (node.nodeName) {
case "OPTION":
case "PRE":
@@ -71,11 +71,9 @@ isLeafNode = function(node) {
default:
return false;
}
-};
+}
-noop = function() {
-};
-setHtml = function(node, html) {
+function setHtml(node, html) {
if (isLeafNode(node)) {
if (msie) {
node.innerText = html;
@@ -85,25 +83,25 @@ setHtml = function(node, html) {
} else {
node.innerHTML = html;
}
-};
+}
-escapeHtml = function(html) {
+function escapeHtml(html) {
if (!html || !html.replace)
return html;
return html.
replace(/&/g, '&amp;').
replace(/</g, '&lt;').
replace(/>/g, '&gt;');
-};
+}
-escapeAttr = function(html) {
+function escapeAttr(html) {
if (!html || !html.replace)
return html;
return html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g,
'&quot;');
-};
+}
-bind = function(_this, _function) {
+function bind(_this, _function) {
if (!_this)
throw "Missing this";
if (!_.isFunction(_function))
@@ -111,9 +109,9 @@ bind = function(_this, _function) {
return function() {
return _function.apply(_this, arguments);
};
-};
+}
-shiftBind = function(_this, _function) {
+function shiftBind(_this, _function) {
return function() {
var args = [ this ];
for ( var i = 0; i < arguments.length; i++) {
@@ -121,28 +119,28 @@ shiftBind = function(_this, _function) {
}
return _function.apply(_this, args);
};
-};
+}
-outerHTML = function(node) {
+function outerHTML(node) {
var temp = document.createElement('div');
temp.appendChild(node);
var outerHTML = temp.innerHTML;
temp.removeChild(node);
return outerHTML;
-};
+}
-trim = function(str) {
+function trim(str) {
return str.replace(/^ */, '').replace(/ *$/, '');
-};
+}
-toBoolean = function(value) {
+function toBoolean(value) {
var v = ("" + value).toLowerCase();
if (v == 'f' || v == '0' || v == 'false' || v == 'no')
value = false;
return !!value;
-};
+}
-merge = function(src, dst) {
+function merge(src, dst) {
for ( var key in src) {
var value = dst[key];
var type = typeof value;
@@ -153,182 +151,184 @@ merge = function(src, dst) {
merge(src[key], value);
}
}
-};
+}
// ////////////////////////////
// Loader
// ////////////////////////////
-Loader = function(document, head, config) {
+function Loader(document, head, config) {
this.document = jQuery(document);
this.head = jQuery(head);
this.config = config;
this.location = window.location;
-};
-
-Loader.prototype.load = function() {
- this.configureLogging();
- this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
- this.loadCss('/stylesheets/css');
- console.log("Server: " + this.config.server);
- this.configureJQueryPlugins();
- this.computeConfiguration();
- this.bindHtml();
-};
-
-Loader.prototype.configureJQueryPlugins = function() {
- console.log('Loader.configureJQueryPlugins()');
- jQuery['fn']['scope'] = function() {
- var element = this;
- while (element && element.get(0)) {
- var scope = element.data("scope");
- if (scope)
- return scope;
- element = element.parent();
- }
- return null;
- };
- jQuery['fn']['controller'] = function() {
- return this.data('controller') || NullController.instance;
- };
-};
-
-Loader.prototype.uid = function() {
- return "" + new Date().getTime();
-};
-
-Loader.prototype.computeConfiguration = function() {
- var config = this.config;
- if (!config.database) {
- var match = config.server.match(/https?:\/\/([\w]*)/);
- config.database = match ? match[1] : "$MEMORY";
- }
-};
-
-Loader.prototype.bindHtml = function() {
- console.log('Loader.bindHtml()');
- var watcher = new UrlWatcher(this.location);
- var document = this.document;
- var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
- var binder = new Binder(document[0], widgetFactory, watcher, this.config);
- widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel);
- var controlBar = new ControlBar(document.find('body'), this.config.server);
- var onUpdate = function(){binder.updateView();};
- var server = this.config.database=="$MEMORY" ?
- new FrameServer(this.window) :
- new Server(this.config.server, jQuery.getScript);
- server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate);
- var users = new Users(server, controlBar);
- var databasePath = '/data/' + this.config.database;
- var post = function(request, callback){
- server.request("POST", databasePath, request, callback);
- };
- var datastore = new DataStore(post, users, binder.anchor);
- binder.updateListeners.push(function(){datastore.flush();});
- var scope = new Scope( {
- '$anchor' : binder.anchor,
- '$binder' : binder,
- '$config' : this.config,
- '$console' : window.console,
- '$datastore' : datastore,
- '$save' : function(callback) {
- datastore.saveScope(scope.state, callback, binder.anchor);
- },
- '$window' : window,
- '$uid' : this.uid,
- '$users' : users
- }, "ROOT");
-
- document.data('scope', scope);
- console.log('$binder.entity()');
- binder.entity(scope);
-
- console.log('$binder.compile()');
- binder.compile();
-
- console.log('ControlBar.bind()');
- controlBar.bind();
-
- console.log('$users.fetchCurrentUser()');
- function fetchCurrentUser() {
- users.fetchCurrentUser(function(u) {
- if (!u && document.find("[ng-auth=eager]").length) {
- users.login();
- }
- });
- }
- fetchCurrentUser();
-
- console.log('PopUp.bind()');
- new PopUp(document).bind();
-
- console.log('$binder.parseAnchor()');
- binder.parseAnchor();
-
- console.log('$binder.executeInit()');
- binder.executeInit();
-
- console.log('$binder.updateView()');
- binder.updateView();
-
- watcher.listener = bind(binder, binder.onUrlChange, watcher);
- watcher.onUpdate = function(){alert("update");};
- watcher.watch();
- document.find("body").show();
- console.log('ready()');
-};
+}
-Loader.prototype.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));
+Loader.prototype = {
+ load: function() {
+ this.configureLogging();
+ this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
+ this.loadCss('/stylesheets/css');
+ log("Server: " + this.config.server);
+ this.configureJQueryPlugins();
+ this.computeConfiguration();
+ this.bindHtml();
+ },
+
+ configureJQueryPlugins: function() {
+ log('Loader.configureJQueryPlugins()');
+ jQuery['fn']['scope'] = function() {
+ var element = this;
+ while (element && element.get(0)) {
+ var scope = element.data("scope");
+ if (scope)
+ return scope;
+ element = element.parent();
}
+ return null;
};
- delegate(request, callback);
- };
-};
-
-Loader.prototype.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);
- console.log = function() {
- consoleLog('ng-console-info', arguments);
+ jQuery['fn']['controller'] = function() {
+ return this.data('controller') || NullController.instance;
+ };
+ },
+
+ uid: function() {
+ return "" + new Date().getTime();
+ },
+
+ computeConfiguration: function() {
+ var config = this.config;
+ if (!config.database) {
+ var match = config.server.match(/https?:\/\/([\w]*)/);
+ config.database = match ? match[1] : "$MEMORY";
+ }
+ },
+
+ bindHtml: function() {
+ log('Loader.bindHtml()');
+ var watcher = new UrlWatcher(this.location);
+ var document = this.document;
+ var widgetFactory = new WidgetFactory(this.config.server, this.config.database);
+ var binder = new Binder(document[0], widgetFactory, watcher, this.config);
+ widgetFactory.onChangeListener = shiftBind(binder, binder.updateModel);
+ var controlBar = new ControlBar(document.find('body'), this.config.server);
+ var onUpdate = function(){binder.updateView();};
+ var server = this.config.database=="$MEMORY" ?
+ new FrameServer(this.window) :
+ new Server(this.config.server, jQuery.getScript);
+ server = new VisualServer(server, new Status(jQuery(document.body)), onUpdate);
+ var users = new Users(server, controlBar);
+ var databasePath = '/data/' + this.config.database;
+ var post = function(request, callback){
+ server.request("POST", databasePath, request, callback);
+ };
+ var datastore = new DataStore(post, users, binder.anchor);
+ binder.updateListeners.push(function(){datastore.flush();});
+ var scope = new Scope( {
+ '$anchor' : binder.anchor,
+ '$binder' : binder,
+ '$config' : this.config,
+ '$console' : window.console,
+ '$datastore' : datastore,
+ '$save' : function(callback) {
+ datastore.saveScope(scope.state, callback, binder.anchor);
+ },
+ '$window' : window,
+ '$uid' : this.uid,
+ '$users' : users
+ }, "ROOT");
+
+ document.data('scope', scope);
+ log('$binder.entity()');
+ binder.entity(scope);
+
+ log('$binder.compile()');
+ binder.compile();
+
+ log('ControlBar.bind()');
+ controlBar.bind();
+
+ log('$users.fetchCurrentUser()');
+ function fetchCurrentUser() {
+ users.fetchCurrentUser(function(u) {
+ if (!u && document.find("[ng-auth=eager]").length) {
+ users.login();
+ }
+ });
+ }
+ fetchCurrentUser();
+
+ log('PopUp.bind()');
+ new PopUp(document).bind();
+
+ log('$binder.parseAnchor()');
+ binder.parseAnchor();
+
+ log('$binder.executeInit()');
+ binder.executeInit();
+
+ log('$binder.updateView()');
+ binder.updateView();
+
+ watcher.listener = bind(binder, binder.onUrlChange, watcher);
+ watcher.onUpdate = function(){alert("update");};
+ watcher.watch();
+ document.find("body").show();
+ log('ready()');
+ },
+
+ visualPost: function(delegate) {
+ var status = new Status(jQuery(document.body));
+ return function(request, delegateCallback) {
+ status.beginRequest(request);
+ var callback = function() {
+ status.endRequest();
+ try {
+ delegateCallback.apply(this, arguments);
+ } catch (e) {
+ alert(toJson(e));
+ }
+ };
+ delegate(request, callback);
};
- console.error = function() {
- consoleLog('ng-console-error', arguments);
+ },
+
+ configureLogging: function() {
+ var url = window.location.href + '#';
+ url = url.split('#')[1];
+ var config = {
+ debug : null
};
+ var configs = url.split('&');
+ for ( var i = 0; i < configs.length; i++) {
+ var part = (configs[i] + '=').split('=');
+ config[part[0]] = part[1];
+ }
+ if (config.debug == 'console') {
+ consoleNode = document.createElement("div");
+ consoleNode.id = 'ng-console';
+ document.getElementsByTagName('body')[0].appendChild(consoleNode);
+ log = function() {
+ consoleLog('ng-console-info', arguments);
+ };
+ console.error = function() {
+ consoleLog('ng-console-error', arguments);
+ };
+ }
+ },
+
+ loadCss: function(css) {
+ var cssTag = document.createElement('link');
+ cssTag.rel = "stylesheet";
+ cssTag.type = "text/css";
+ if (!css.match(/^http:/))
+ css = this.config.server + css;
+ cssTag.href = css;
+ this.head[0].appendChild(cssTag);
}
};
-Loader.prototype.loadCss = function(css) {
- var cssTag = document.createElement('link');
- cssTag.rel = "stylesheet";
- cssTag.type = "text/css";
- if (!css.match(/^http:/))
- css = this.config.server + css;
- cssTag.href = css;
- this.head[0].appendChild(cssTag);
-};
-
-UrlWatcher = function(location) {
+function UrlWatcher(location) {
this.location = location;
this.delay = 25;
this.setTimeout = function(fn, delay) {
@@ -338,49 +338,51 @@ UrlWatcher = function(location) {
return url;
};
this.expectedUrl = location.href;
-};
+}
-UrlWatcher.prototype.watch = function() {
- var self = this;
- var pull = function() {
- if (self.expectedUrl !== self.location.href) {
- var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/);
- if (notify) {
- if (!self.expectedUrl.match(/#/)) {
- self.expectedUrl += "#";
- }
- self.location.href = self.expectedUrl;
- var id = '_iframe_notify_' + notify[1];
- var notifyFn = callbacks[id];
- delete callbacks[id];
- try {
- (notifyFn||noop)();
- } catch (e) {
- alert(e);
+UrlWatcher.prototype = {
+ watch: function() {
+ var self = this;
+ var pull = function() {
+ if (self.expectedUrl !== self.location.href) {
+ var notify = self.location.hash.match(/^#\$iframe_notify=(.*)$/);
+ if (notify) {
+ if (!self.expectedUrl.match(/#/)) {
+ self.expectedUrl += "#";
+ }
+ self.location.href = self.expectedUrl;
+ var id = '_iframe_notify_' + notify[1];
+ var notifyFn = angularCallbacks[id];
+ delete angularCallbacks[id];
+ try {
+ (notifyFn||noop)();
+ } catch (e) {
+ alert(e);
+ }
+ } else {
+ self.listener(self.location.href);
+ self.expectedUrl = self.location.href;
}
- } else {
- self.listener(self.location.href);
- self.expectedUrl = self.location.href;
}
- }
- self.setTimeout(pull, self.delay);
- };
- pull();
-};
-
-UrlWatcher.prototype.setUrl = function(url) {
- var existingURL = window.location.href;
- if (!existingURL.match(/#/))
- existingURL += '#';
- if (existingURL != url)
- window.location.href = url;
- this.existingURL = url;
-};
-
-UrlWatcher.prototype.getUrl = function() {
- return window.location.href;
+ self.setTimeout(pull, self.delay);
+ };
+ pull();
+ },
+
+ setUrl: function(url) {
+ var existingURL = window.location.href;
+ if (!existingURL.match(/#/))
+ existingURL += '#';
+ if (existingURL != url)
+ window.location.href = url;
+ this.existingURL = url;
+ },
+
+ getUrl: function() {
+ return window.location.href;
+ }
};
-
+
angular['compile'] = function(root, config) {
config = config || {};
var defaults = {
@@ -397,5 +399,4 @@ angular['compile'] = function(root, config) {
'set':function(){return scope.set.apply(scope, arguments);},
'get':function(){return scope.get.apply(scope, arguments);}
};
-};
-
+}; \ No newline at end of file
diff --git a/src/Scope.js b/src/Scope.js
index dff3bfbd..f4b34c3c 100644
--- a/src/Scope.js
+++ b/src/Scope.js
@@ -124,7 +124,7 @@ Scope.prototype.evalWidget = function(widget, expression, context, onSuccess, on
}
return true;
} catch (e){
- console.error('Eval Widget Error:', e);
+ error('Eval Widget Error:', e);
var jsonError = toJson(e, true);
widget.hasError = true;
jQuery(widget.view).
@@ -184,10 +184,10 @@ Scope.prototype.addWatchListener = function(watchExpression, listener) {
Scope.prototype.fireWatchers = function() {
var self = this;
var fired = false;
- jQuery.each(this.watchListeners, function(name, watcher) {
+ foreach(this.watchListeners, function(watcher) {
var value = self.eval(watcher.expression);
if (value !== watcher.lastValue) {
- jQuery.each(watcher.listeners, function(i, listener){
+ foreach(watcher.listeners, function(listener){
listener(value, watcher.lastValue);
fired = true;
});
diff --git a/src/Server.js b/src/Server.js
index d00f893b..8f682038 100644
--- a/src/Server.js
+++ b/src/Server.js
@@ -14,7 +14,7 @@ Server.prototype.base64url = function(txt) {
Server.prototype.request = function(method, url, request, callback) {
var requestId = this.uuid + (this.nextId++);
- callbacks[requestId] = function(response) {
+ angularCallbacks[requestId] = function(response) {
delete angular[requestId];
callback(200, response);
};
diff --git a/src/Validators.js b/src/Validators.js
index 7cfaa2b4..eb8cff59 100644
--- a/src/Validators.js
+++ b/src/Validators.js
@@ -1,80 +1,82 @@
// Copyright (C) 2009 BRAT Tech LLC
-angular.validator.regexp = function(value, regexp, msg) {
- if (!value.match(regexp)) {
- return msg ||
- "Value does not match expected format " + regexp + ".";
- } else {
- return null;
- }
-};
-
-angular.validator.number = function(value, min, max) {
- var num = 1 * value;
- if (num == value) {
- if (typeof min != 'undefined' && num < min) {
- return "Value can not be less than " + min + ".";
+foreach({
+ 'regexp': function(value, regexp, msg) {
+ if (!value.match(regexp)) {
+ return msg ||
+ "Value does not match expected format " + regexp + ".";
+ } else {
+ return null;
}
- if (typeof min != 'undefined' && num > max) {
- return "Value can not be greater than " + max + ".";
+ },
+
+ 'number': function(value, min, max) {
+ var num = 1 * value;
+ if (num == value) {
+ if (typeof min != 'undefined' && num < min) {
+ return "Value can not be less than " + min + ".";
+ }
+ if (typeof min != 'undefined' && num > max) {
+ return "Value can not be greater than " + max + ".";
+ }
+ return null;
+ } else {
+ return "Value is not a number.";
+ }
+ },
+
+ 'integer': function(value, min, max) {
+ var number = angularValidator['number'](value, min, max);
+ if (number === null && value != Math.round(value)) {
+ return "Value is not a whole number.";
+ }
+ return number;
+ },
+
+ 'date': function(value, min, max) {
+ if (value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/)) {
+ return null;
+ }
+ return "Value is not a date. (Expecting format: 12/31/2009).";
+ },
+
+ 'ssn': function(value) {
+ if (value.match(/^\d\d\d-\d\d-\d\d\d\d$/)) {
+ return null;
+ }
+ return "SSN needs to be in 999-99-9999 format.";
+ },
+
+ 'email': function(value) {
+ if (value.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(value) {
+ if (value.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/)) {
+ return null;
+ }
+ if (value.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(value) {
+ if (value.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(value) {
+ try {
+ fromJson(value);
+ return null;
+ } catch (e) {
+ return e.toString();
}
- return null;
- } else {
- return "Value is not a number.";
- }
-};
-
-angular.validator.integer = function(value, min, max) {
- var number = angular.validator.number(value, min, max);
- if (number === null && value != Math.round(value)) {
- return "Value is not a whole number.";
- }
- return number;
-};
-
-angular.validator.date = function(value, min, max) {
- if (value.match(/^\d\d?\/\d\d?\/\d\d\d\d$/)) {
- return null;
- }
- return "Value is not a date. (Expecting format: 12/31/2009).";
-};
-
-angular.validator.ssn = function(value) {
- if (value.match(/^\d\d\d-\d\d-\d\d\d\d$/)) {
- return null;
- }
- return "SSN needs to be in 999-99-9999 format.";
-};
-
-angular.validator.email = function(value) {
- if (value.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.";
-};
-
-angular.validator.phone = function(value) {
- if (value.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/)) {
- return null;
- }
- if (value.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.";
-};
-
-angular.validator.url = function(value) {
- if (value.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.";
-};
-
-angular.validator.json = function(value) {
- try {
- fromJson(value);
- return null;
- } catch (e) {
- return e.toString();
}
-};
+}, function(v,k) {angularValidator[k] = v;});
diff --git a/src/Widgets.js b/src/Widgets.js
index 4e4facf8..5dcb84c4 100644
--- a/src/Widgets.js
+++ b/src/Widgets.js
@@ -525,7 +525,7 @@ BindAttrUpdater.prototype.updateView = function(scope) {
attrValues.push(value);
} catch (e) {
this.hasError = true;
- console.error('BindAttrUpdater', e);
+ error('BindAttrUpdater', e);
var jsonError = toJson(e, true);
attrValues.push('[' + jsonError + ']');
jNode.
@@ -657,7 +657,7 @@ RepeaterUpdater.prototype.updateView = function(scope) {
var keyExp = this.keyExp;
var valueExp = this.valueExp;
var i = 0;
- jQuery.each(iterator, function(key, value){
+ foreach(iterator, function(value, key){
if (i < childrenLength) {
// reuse children
child = self.children[i];
diff --git a/src/angular.prefix b/src/angular.prefix
index 522c17bf..dbd4959a 100644
--- a/src/angular.prefix
+++ b/src/angular.prefix
@@ -1,2 +1 @@
-
-(function(window, document){ \ No newline at end of file
+(function(window, document){
diff --git a/test/LoaderTest.js b/test/LoaderTest.js
index 88ae3efa..a474c8a4 100644
--- a/test/LoaderTest.js
+++ b/test/LoaderTest.js
@@ -50,8 +50,8 @@ UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = functi
expectAsserts(2);
var location = {href:"http://server", hash:"#$iframe_notify=1234"};
var watcher = new UrlWatcher(location);
- callbacks._iframe_notify_1234 = function () {
- assertEquals("undefined", typeof callbacks._iframe_notify_1234);
+ angular.callbacks._iframe_notify_1234 = function () {
+ assertEquals("undefined", typeof angularCallbacks._iframe_notify_1234);
assertEquals("http://server2#", location.href);
};
watcher.delay = 1;
diff --git a/test/ServerTest.js b/test/ServerTest.js
index e367c90a..02fab84c 100644
--- a/test/ServerTest.js
+++ b/test/ServerTest.js
@@ -10,7 +10,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
assertEquals(200, code);
assertEquals("response", r);
});
- callbacks.uuid0("response");
+ angularCallbacks.uuid0("response");
assertEquals(
"|http://server/$/uuid0/2/1?h=eyJtIjoiUE9TVCIsInAiOnt9LCJ1Ij" +
"|http://server/$/uuid0/2/2?h=oiL2RhdGEvZGF0YWJhc2UifQ==",
@@ -35,7 +35,7 @@ FrameServerTest.prototype = {
testWrite:function(){
var window = {};
var server = new FrameServer(window);
- server.data = "TestData"
+ server.data = "TestData";
server.write();
assertEquals('$DATASET:"TestData"', window.name);
}