removed nglr namespace

This commit is contained in:
Misko Hevery 2010-01-09 15:02:43 -08:00
parent 88eca572fd
commit 9b9a0dadcc
45 changed files with 5514 additions and 1911 deletions

View file

@ -2,9 +2,11 @@ include FileUtils
desc 'Compile JavaScript'
task :compile do
compiled = %x(java -jar lib/shrinksafe/shrinksafe.jar \
lib/webtoolkit/webtoolkit.base64.js \
concat = %x(cat \
lib/underscore/underscore.js \
src/angular.prefix \
lib/webtoolkit/webtoolkit.base64.js \
lib/swfobject.js/swfobject.js \
src/Loader.js \
src/API.js \
src/Binder.js \
@ -19,35 +21,16 @@ task :compile do
src/Users.js \
src/Validators.js \
src/Widgets.js \
src/angular-bootstrap.js \
src/angular.suffix \
)
f = File.new("angular.js", 'w')
f.write(compiled)
f.write(concat)
f.close
end
desc 'Compile JavaScript with Google Closure Compiler'
task :compileclosure do
# --compilation_level ADVANCED_OPTIMIZATIONS \
%x(java -jar lib/compiler-closure/compiler.jar \
--js lib/webtoolkit/webtoolkit.base64.js \
--js lib/underscore/underscore.js \
--js src/Loader.js \
--js src/API.js \
--js src/Binder.js \
--js src/ControlBar.js \
--js src/DataStore.js \
--js src/Filters.js \
--js src/JSON.js \
--js src/Model.js \
--js src/Parser.js \
--js src/Scope.js \
--js src/Server.js \
--js src/Users.js \
--js src/Validators.js \
--js src/Widgets.js \
--js src/angular-bootstrap.js \
--js_output_file angular.js)
--compilation_level ADVANCED_OPTIMIZATIONS \
--js angular.js \
--js_output_file angular-minified.js)
end
namespace :server do

View file

@ -3,4 +3,4 @@
- angular.defaults = {}
- var scope = angular.compile(element, options);
* angular.js is not self boot straping by default.
*
* Remove SWFObject

122
angular-minified.js vendored Normal file
View file

@ -0,0 +1,122 @@
function u(){return function(s){return s}}function x(){return function(){}}function y(s){return function(v){this[s]=v}}function z(s){return function(){return s}}
(function(){var s=this,v=s.Ma;function w(f){this.$=f}var a=typeof StopIteration!=="undefined"?StopIteration:"__break__",b=s.Ma=function(f){return new w(f)};if(typeof exports!=="undefined")exports.Ma=b;var c=Array.prototype.slice,d=Array.prototype.unshift,e=Object.prototype.toString,g=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable;b.Ce="0.5.1";b.b=function(f,h,j){try{if(f.forEach)f.forEach(h,j);else if(b.q(f)||b.Lb(f))for(var k=0,m=f.length;k<m;k++)h.call(j,f[k],k,f);else{var q=
b.ia(f);m=q.length;for(k=0;k<m;k++)h.call(j,f[q[k]],q[k],f)}}catch(t){if(t!=a)throw t;}return f};b.map=function(f,h,j){if(f&&b.K(f.map))return f.map(h,j);var k=[];b.b(f,function(m,q,t){k.push(h.call(j,m,q,t))});return k};b.reduce=function(f,h,j,k){if(f&&b.K(f.reduce))return f.reduce(b.B(j,k),h);b.b(f,function(m,q,t){h=j.call(k,h,m,q,t)});return h};b.reduceRight=function(f,h,j,k){if(f&&b.K(f.reduceRight))return f.reduceRight(b.B(j,k),h);var m=b.ua(b.A(f)).reverse();b.b(m,function(q,t){h=j.call(k,h,
q,t,f)});return h};b.xb=function(f,h,j){var k;b.b(f,function(m,q,t){if(h.call(j,m,q,t)){k=m;b.qa()}});return k};b.select=function(f,h,j){if(f&&b.K(f.filter))return f.filter(h,j);var k=[];b.b(f,function(m,q,t){h.call(j,m,q,t)&&k.push(m)});return k};b.Pf=function(f,h,j){var k=[];b.b(f,function(m,q,t){!h.call(j,m,q,t)&&k.push(m)});return k};b.all=function(f,h,j){h=h||b.ga;if(f&&b.K(f.every))return f.every(h,j);var k=true;b.b(f,function(m,q,t){(k=k&&h.call(j,m,q,t))||b.qa()});return k};b.Hc=function(f,
h,j){h=h||b.ga;if(f&&b.K(f.some))return f.some(h,j);var k=false;b.b(f,function(m,q,t){if(k=h.call(j,m,q,t))b.qa()});return k};b.ya=function(f,h){if(b.q(f))return b.indexOf(f,h)!=-1;var j=false;b.b(f,function(k){if(j=k===h)b.qa()});return j};b.rf=function(f,h){var j=b.L(arguments,2);return b.map(f,function(k){return(h?k[h]:k).apply(k,j)})};b.bb=function(f,h){return b.map(f,function(j){return j[h]})};b.max=function(f,h,j){if(!h&&b.q(f))return Math.max.apply(Math,f);var k={ca:-Infinity};b.b(f,function(m,
q,t){q=h?h.call(j,m,q,t):m;q>=k.ca&&(k={value:m,ca:q})});return k.value};b.min=function(f,h,j){if(!h&&b.q(f))return Math.min.apply(Math,f);var k={ca:Infinity};b.b(f,function(m,q,t){q=h?h.call(j,m,q,t):m;q<k.ca&&(k={value:m,ca:q})});return k.value};b.$d=function(f,h,j){return b.bb(b.map(f,function(k,m,q){return{value:k,vb:h.call(j,k,m,q)}}).sort(function(k,m){k=k.vb;m=m.vb;return k<m?-1:k>m?1:0}),"value")};b.Sf=function(f,h,j){j=j||b.ga;for(var k=0,m=f.length;k<m;){var q=k+m>>1;j(f[q])<j(h)?(k=q+1):
(m=q)}return k};b.A=function(f){if(!f)return[];if(f.A)return f.A();if(b.q(f))return f;if(b.Lb(f))return c.call(f);return b.map(f,u())};b.size=function(f){return b.A(f).length};b.gd=function(f,h,j){return h&&!j?c.call(f,0,h):f[0]};b.L=function(f,h,j){return c.call(f,b.H(h)||j?1:h)};b.wd=function(f){return f[f.length-1]};b.compact=function(f){return b.select(f,function(h){return!!h})};b.hd=function(f){return b.reduce(f,[],function(h,j){if(b.q(j))return h.concat(b.hd(j));h.push(j);return h})};b.dg=function(f){var h=
b.L(arguments);return b.select(f,function(j){return!b.ya(h,j)})};b.fe=function(f,h){return b.reduce(f,[],function(j,k,m){if(0==m||(h===true?b.wd(j)!=k:!b.ya(j,k)))j.push(k);return j})};b.qf=function(f){var h=b.L(arguments);return b.select(b.fe(f),function(j){return b.all(h,function(k){return b.indexOf(k,j)>=0})})};b.gg=function(){for(var f=b.A(arguments),h=b.max(b.bb(f,"length")),j=new Array(h),k=0;k<h;k++)j[k]=b.bb(f,String(k));return j};b.indexOf=function(f,h){if(f.indexOf)return f.indexOf(h);for(var j=
0,k=f.length;j<k;j++)if(f[j]===h)return j;return-1};b.lastIndexOf=function(f,h){if(f.lastIndexOf)return f.lastIndexOf(h);for(var j=f.length;j--;)if(f[j]===h)return j;return-1};b.Rd=function(f,h,j){var k=b.A(arguments),m=k.length<=1;f=m?0:k[0];h=m?k[0]:k[1];j=k[2]||1;k=Math.ceil((h-f)/j);if(k<=0)return[];k=new Array(k);m=f;for(var q=0;;m+=j){if((j>0?m-h:h-m)>=0)return k;k[q++]=m}};b.B=function(f,h){var j=b.L(arguments,2);return function(){return f.apply(h||s,j.concat(b.A(arguments)))}};b.Ne=function(f){var h=
b.L(arguments);if(h.length==0)h=b.Ua(f);b.b(h,function(j){f[j]=b.B(f[j],f)});return f};b.Ta=function(f,h){var j=b.L(arguments,2);return setTimeout(function(){return f.apply(f,j)},h)};b.defer=function(f){return b.Ta.apply(b,[f,1].concat(b.L(arguments)))};b.fg=function(f,h){return function(){var j=[f].concat(b.A(arguments));return h.apply(h,j)}};b.Ze=function(){var f=b.A(arguments);return function(){for(var h=b.A(arguments),j=f.length-1;j>=0;j--)h=[f[j].apply(this,h)];return h[0]}};b.ia=function(f){if(b.q(f))return b.Rd(0,
f.length);var h=[];for(var j in f)g.call(f,j)&&h.push(j);return h};b.gb=function(f){return b.map(f,b.ga)};b.Ua=function(f){return b.select(b.ia(f),function(h){return b.K(f[h])}).sort()};b.extend=function(f,h){for(var j in h)f[j]=h[j];return f};b.ua=function(f){if(b.q(f))return f.slice(0);return b.extend({},f)};b.isEqual=function(f,h){if(f===h)return true;var j=typeof f;if(j!=typeof h)return false;if(f==h)return true;if(!f&&h||f&&!h)return false;if(f.isEqual)return f.isEqual(h);if(b.pd(f)&&b.pd(h))return f.getTime()===
h.getTime();if(b.Mb(f)&&b.Mb(h))return true;if(b.rd(f)&&b.rd(h))return f.source===h.source&&f.global===h.global&&f.ignoreCase===h.ignoreCase&&f.multiline===h.multiline;if(j!=="object")return false;if(f.length&&f.length!==h.length)return false;j=b.ia(f);var k=b.ia(h);if(j.length!=k.length)return false;for(var m in f)if(!b.isEqual(f[m],h[m]))return false;return true};b.tf=function(f){return b.ia(f).length==0};b.sf=function(f){return!!(f&&f.nodeType==1)};b.Lb=function(f){return f&&b.ha(f.length)&&!b.q(f)&&
!i.call(f,"length")};b.Mb=function(f){return b.ha(f)&&isNaN(f)};b.uf=function(f){return f===null};b.H=function(f){return typeof f=="undefined"};for(var l=["Array","Date","Function","Number","RegExp","String"],n=0,o=l.length;n<o;n++)(function(){var f="[object "+l[n]+"]";b["is"+l[n]]=function(h){return e.call(h)==f}})();b.Df=function(){s.Ma=v;return this};b.ga=u();b.qa=function(){throw a;};var p=0;b.$f=function(f){var h=p++;return f?f+h:h};b.V=function(f,h){f=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+
f.replace(/[\r\t\n]/g," ").split("<%").join("\t").replace(/((^|%>)[^\t]*)'/g,"$1\r").replace(/\t=(.*?)%>/g,"',$1,'").split("\t").join("');").split("%>").join("p.push('").split("\r").join("\\'")+"');}return p.join('');");return h?f(h):f};b.forEach=b.b;b.kf=b.of=b.reduce;b.lf=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.Hc;b.Ib=b.gd;b.Wf=b.L;b.Af=b.Ua;function r(f,h){return h?b(f).rb():f}b.b(b.Ua(b),function(f){var h=b[f];w.prototype[f]=function(){d.call(arguments,this.$);return r(h.apply(b,
arguments),this.Na)}});b.b(["pop","push","reverse","shift","sort","splice","unshift"],function(f){var h=Array.prototype[f];w.prototype[f]=function(){h.apply(this.$,arguments);return r(this.$,this.Na)}});b.b(["concat","join","slice"],function(f){var h=Array.prototype[f];w.prototype[f]=function(){return r(h.apply(this.$,arguments),this.Na)}});w.prototype.rb=function(){this.Na=true;return this};w.prototype.value=function(){return this.$}})();
(function(s,v){var w={I:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",wa:function(a){var b="",c,d,e,g,i,l,n=0;for(a=w.Cc(a);n<a.length;){c=a.charCodeAt(n++);d=a.charCodeAt(n++);e=a.charCodeAt(n++);g=c>>2;c=(c&3)<<4|d>>4;i=(d&15)<<2|e>>6;l=e&63;if(isNaN(d))i=l=64;else if(isNaN(e))l=64;b=b+this.I.charAt(g)+this.I.charAt(c)+this.I.charAt(i)+this.I.charAt(l)}return b},ef:function(a){var b="",c,d,e,g,i,l=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");l<a.length;){c=this.I.indexOf(a.charAt(l++));
d=this.I.indexOf(a.charAt(l++));g=this.I.indexOf(a.charAt(l++));i=this.I.indexOf(a.charAt(l++));c=c<<2|d>>4;d=(d&15)<<4|g>>2;e=(g&3)<<6|i;b+=String.fromCharCode(c);if(g!=64)b+=String.fromCharCode(d);if(i!=64)b+=String.fromCharCode(e)}return b=w.Bc(b)},Cc: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},Bc: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 v.getAttribute=="undefined")v.getAttribute=x();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};if(_.H(s.Cf))nglr={};if(_.H(s.Fe))angular={};if(_.H(angular.j))angular.j={};if(_.H(angular.filter))angular.filter={};if(_.H(s.console))s.console={log:x(),error:x()};if(_.H(alert))alert=function(){console.log(arguments);s.alert.apply(s,arguments)};consoleLog=function(a,b){var c=v.createElement("div");c.className=a;
for(var d=a="",e=0;e<b.length;e++){var g=b[e];a+=d+(typeof g=="string"?g:toJson(g));d=" "}c.appendChild(v.createTextNode(a));consoleNode.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=x();setHtml=function(a,b){if(isLeafNode(a))if(msie)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(!_.K(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=v.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=jQuery(a);this.Ib=jQuery(b);this.o=c;this.location=
s.location};Loader.prototype.load=function(){this.Rc();this.Qb("/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css");this.Qb("/stylesheets/css");console.log("Server: "+this.o.M);msie=jQuery.Oe.Bf;this.Qc();this.Pc();this.Mc()};Loader.prototype.Qc=function(){console.log("Loader.configureJQueryPlugins()");jQuery.c.removeNode=function(){var a=this.h(0);a.parentNode.removeChild(a)};jQuery.c.scope=function(){for(var a=this;a&&a.h(0);){var b=a.data("scope");if(b)return b;a=a.parent()}return null};jQuery.c.$e=
function(){return this.data("controller")||NullController.nd}};Loader.prototype.ee=function(){return""+(new Date).getTime()};Loader.prototype.Pc=function(){var a=this.o;if(!a.T){var b=a.M.match(/https?:\/\/([\w]*)/);a.T=b?b[1]:"$MEMORY"}};Loader.prototype.Mc=function(){function a(){i.Bb(function(p){!p&&c.find("[ng-auth=eager]").length&&i.Ca()})}console.log("Loader.bindHtml()");var b=new UrlWatcher(this.location),c=this.document,d=new WidgetFactory(this.o.M,this.o.T),e=new Binder(c[0],d,b,this.o);
d.Nd=shiftBind(e,e.i);d=new ControlBar(c.find("body"),this.o.M);var g=this.o.T=="$MEMORY"?new FrameServer(this.window):new Server(this.o.M,jQuery.Fb);g=new VisualServer(g,new Status(jQuery(c.body)),function(){e.d()});var i=new Users(g,d),l="/data/"+this.o.T,n=new DataStore(function(p,r){g.la("POST",l,p,r)},i,e.anchor);e.lc.push(function(){n.Db()});var o=new Scope({pe:e.anchor,qe:e,re:this.o,se:s.console,te:n,pa:function(p){n.Wd(o.F,p,e.anchor)},ze:s,xe:this.ee,ye:i},"ROOT");jQuery.b(["get","set",
"eval","addWatchListener","updateView"],function(p,r){angular[r]=bind(o,o[r])});c.data("scope",o);console.log("$binder.entity()");e.da(o);console.log("$binder.compile()");e.compile();console.log("ControlBar.bind()");d.B();console.log("$users.fetchCurrentUser()");a();console.log("PopUp.bind()");(new PopUp(c)).B();console.log("$binder.parseAnchor()");e.Zb();console.log("$binder.executeInit()");e.dd();console.log("$binder.updateView()");e.d();b.Ob=bind(e,e.Pd,b);b.Ef=function(){alert("update")};b.watch();
c.find("body").cb();console.log("ready()")};Loader.prototype.Rc=function(){var a=s.location.href+"#";a=a.split("#")[1];var b={Xc:null};a=a.split("&");for(var c=0;c<a.length;c++){var d=(a[c]+"=").split("=");b[d[0]]=d[1]}if(b.Xc=="console"){consoleNode=v.createElement("div");consoleNode.id="ng-console";v.getElementsByTagName("body")[0].appendChild(consoleNode);console.log=function(){consoleLog("ng-console-info",arguments)};console.error=function(){consoleLog("ng-console-error",arguments)}}};Loader.prototype.Qb=
function(a){var b=v.createElement("link");b.rel="stylesheet";b.type="text/css";a.match(/^http:/)||(a=this.o.M+a);b.href=a;this.Ib[0].appendChild(b)};UrlWatcher=function(a){this.location=a;this.Ta=25;this.setTimeout=function(b,c){s.setTimeout(b,c)};this.Ob=u();this.ea=a.href};UrlWatcher.prototype.watch=function(){var a=this;function b(){if(a.ea!==a.location.href){var c=a.location.hash.match(/^#\$iframe_notify=(.*)$/);if(c){a.ea.match(/#/)||(a.ea+="#");a.location.href=a.ea;c="_iframe_notify_"+c[1];
var d=nglr[c];delete nglr[c];try{(d||noop)()}catch(e){alert(e)}}else{a.Ob(a.location.href);a.ea=a.location.href}}a.setTimeout(b,a.Ta)}b()};UrlWatcher.prototype.Zd=function(a){var b=s.location.href;b.match(/#/)||(b+="#");if(b!=a)s.location.href=a;self.ff=a};UrlWatcher.prototype.Gb=function(){return s.location.href};angular.compile=function(a,b){b=b||{};(new Loader(a,jQuery("head"),_({M:""}).extend(b))).load();return jQuery(a).scope()};angular.Y={de: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.La={};angular.xc={};angular.Ka={md:function(a,b,c){var d=_.indexOf(a,b);if(c)d==-1&&a.push(b);else a.splice(d,1);return a},Vf:function(a,b){b=angular.X.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.X.compile(b);
_.xb(a,function(e){if(d(e)){c=e;return true}});return c}},gf:function(a,b){return angular.Ka.find(a,function(c){return c.N==b},null)},filter:function(a,b){var c=[];c.Nc=function(o){for(var p=0;p<c.length;p++)if(!c[p](o))return false;return true};var d=Scope.fa;function e(o,p){if(p.charAt(0)==="!")return!e(o,p.substr(1));switch(typeof o){case "boolean":case "number":case "string":return(""+o).toLowerCase().indexOf(p)>-1;case "object":for(var r in o)if(r.charAt(0)!=="$"&&e(o[r],p))return true;return false;
case "array":for(r=0;r<o.length;r++)if(e(o[r],p))return true;return false;default:return false}}switch(typeof b){case "boolean":case "number":case "string":b={oe:b};case "object":for(var g in b)g=="$"?function(){var o=(""+b[g]).toLowerCase();o&&c.push(function(p){return e(p,o)})}():function(){var o=g,p=(""+b[g]).toLowerCase();p&&c.push(function(r){return e(d(r,o),p)})}();break;case "function":c.push(b);break;default:return a}for(var i=[],l=0;l<a.length;l++){var n=a[l];c.Nc(n)&&i.push(n)}return i},
add:function(a,b){a.push(_.H(b)?{}:b);return a},af:function(a,b){if(!b)return a.length;var c=angular.X.compile(b);return _.reduce(a,0,function(d,e){return d+(c(e)?1:0)})},Ff:function(a,b,c){function d(g,i){return toBoolean(i)?function(l,n){return g(n,l)}:g}function e(g,i){var l=typeof g,n=typeof i;if(l==n){if(l=="string")g=g.toLowerCase();if(l=="string")i=i.toLowerCase();if(g===i)return 0;return g<i?-1:1}else return l<n?-1:1}b=_.q(b)?b:[b];b=_.map(b,function(g){var i=false;if(typeof g=="string"&&
(g.charAt(0)=="+"||g.charAt(0)=="-")){i=g.charAt(0)=="-";g=g.substring(1)}var l=g?angular.X.compile(g):_.ga;return d(function(n,o){return e(l(n),l(o))},i)});return _.ua(a).sort(d(function(g,i){for(var l=0;l<b.length;l++){var n=b[l](g,i);if(n!=0)return n}return 0},c))},Hf:function(a,b){var c=false,d=-1;_.xb(a,function(e,g){if(e==b){c=true;d=g;return true}if((e.charAt(0)=="+"||e.charAt(0)=="-")&&e.substring(1)==b){c=e.charAt(0)=="+";d=g;return true}});d>=0&&a.splice(d,1);a.unshift((c?"-":"+")+b);return a},
Gf: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:""},zf:function(a,b,c){var d=a[b];if(!d){d={};a[b]=d}merge(c,d);return a}};angular.O={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")+'"'},cc:function(a){a=angular.O.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("")},be: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.tc={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.X={compile:function(a){if(_.K(a))return a;else if(a){var b=new Scope;return function(c){b.F=c;return b.eval(a)}}else return u()}};(function(){function a(b,c,d){_.extend(b,c);_.b(d||[],function(e){b[e]=_[e]})}a(angular.Y,{},["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);a(angular.La,angular.Y,["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke",
"pluck","max","min","sortBy","sortedIndex","toArray","size"]);a(angular.Ka,angular.La,["first","last","compact","flatten","without","uniq","intersect","zip","indexOf","lastIndexOf"]);a(angular.xc,angular.La,["keys","values"]);a(angular.O,angular.Y);a(angular.X,angular.Y,["bind","bindAll","delay","defer","wrap","compose"])})();Binder=function(a,b,c,d){this.Q=a;this.fb=c;this.anchor={};this.me=b;this.o=d||{};this.lc=[]};Binder.Ea=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.ld=function(a){a=Binder.Ea(a);return a.length>1||Binder.ba(a[0])!==null};Binder.ba=function(a){return(a=a.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?a[1]:null};Binder.prototype.Qd=function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b};Binder.prototype.Zb=function(a){var b=
this;a=a||this.fb.Gb();var c=a.indexOf("#");if(!(c<0)){a=this.Qd(a.substring(c+1));jQuery.b(b.anchor,function(d){delete b.anchor[d]});jQuery.b(a,function(d,e){b.anchor[d]=e})}};Binder.prototype.Pd=function(a){console.log("URL change detected",a);this.Zb(a);this.d()};Binder.prototype.ge=function(){var a=this.fb.Gb(),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.fb.Zd(a);return a};Binder.prototype.d=function(){(new Date).getTime();var a=jQuery(this.Q).scope();a.s("$invalidWidgets",[]);a.d();(new Date).getTime();this.ge();_.b(this.lc,function(b){b()})};Binder.prototype.va=function(a){var b=jQuery(this.Q),c=b.find(a);if(b.od(a))c=c.Ee();return c};Binder.prototype.dd=function(){this.va("[ng-init]").b(function(){var a=jQuery(this),b=a.scope();try{b.eval(a.g("ng-init"))}catch(c){alert("EVAL ERROR:\n"+a.g("ng-init")+
"\n"+toJson(c,true))}})};Binder.prototype.da=function(a){this.va("[ng-entity]").g("ng-watch",function(){try{var b=jQuery(this);return a.da(b.g("ng-entity"))+(b.g("ng-watch")||"")}catch(c){alert(c)}})};Binder.prototype.compile=function(){var a=jQuery(this.Q),b=this;if(this.o.He){var c=this.va(":submit").Yb("[ng-action]");c.g("ng-action","$save()");c.Yb(":disabled").Yb("ng-bind-attr").g("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.ac(this.Q)(this.Q,a.scope(),"");this.va("a[ng-action]").xd("click",
function(){var d=jQuery(this);try{d.scope().eval(d.g("ng-action"));d.fc("ng-error");d.gc("ng-exception")}catch(e){d.Oa("ng-exception");d.g("ng-error",toJson(e,true))}b.d();return false})};Binder.prototype.ce=function(a,b,c){b=b.concat();var d=b.pop(),e=Binder.Ea(a.nodeValue);if(e.length>1||Binder.ba(e[0])){var g=a.parentNode;if(isLeafNode(g)){g.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,c:function(p){return new BindUpdater(p,p.getAttribute("ng-bind-template"))}})}else for(var i=0;i<
e.length;i++){var l=e[i],n=Binder.ba(l),o;if(n){o=v.createElement("span");jQuery(o).g("ng-bind",n);i===0&&c.push({path:b.concat(d+i),c:Binder.prototype.Xb})}else if(msie&&l.charAt(0)==" "){o=v.createElement("span");o.innerHTML="&nbsp;"+l.substring(1)}else o=v.createTextNode(l);g.insertBefore(o,a)}g.removeChild(a)}};Binder.prototype.ac=function(a){var b=[];this.bc(a,[],b);return function(c,d,e){for(var g=b.length,i=0;i<g;i++){for(var l=b[i],n=c,o=l.path,p=0;p<o.length;p++)n=n.childNodes[o[p]];try{d.Fc(l.c(n,
d,e))}catch(r){alert(r)}}}};Binder.prototype.bc=function(a,b,c){var d=a.nodeType;if(d==Node.TEXT_NODE)this.ce(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 g=d.length,i=0;i<g;i++){var l=d[i],n=l.name;l=msie&&n=="href"?decodeURI(a.getAttribute(n,2)):l.value;if(Binder.ld(l))e[n]=l}d=toJson(e);d.length>
2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||console.log(a);var o=a.getAttribute("ng-repeat");if(o){a.removeAttribute("ng-repeat");var p=this.ac(a);d=v.createComment("ng-repeat: "+o);e=a.parentNode;e.insertBefore(d,a);e.removeChild(a);var r=function(h,j,k){var m=jQuery(a).ua();m.Sa("display","");m.g("ng-repeat-index",""+k);m.data("scope",h);p(m[0],h,j+k+":");return m};c.push({path:b,c:function(h,j,k){return new RepeaterUpdater(jQuery(h),o,r,k)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,
c:this.Hd});a.getAttribute("ng-bind")&&c.push({path:b,c:this.Xb});a.getAttribute("ng-bind-attr")&&c.push({path:b,c:this.Dd});a.getAttribute("ng-hide")&&c.push({path:b,c:this.Id});a.getAttribute("ng-show")&&c.push({path:b,c:this.Jd});a.getAttribute("ng-class")&&c.push({path:b,c:this.Ed});a.getAttribute("ng-class-odd")&&c.push({path:b,c:this.Gd});a.getAttribute("ng-class-even")&&c.push({path:b,c:this.Fd});a.getAttribute("ng-style")&&c.push({path:b,c:this.Kd});a.getAttribute("ng-watch")&&c.push({path:b,
c:this.Ld});d=a.nodeName;if(d=="INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var f=this;c.push({path:b,c:function(h,j,k){h.name=k+h.name.split(":").pop();return f.me.Sc(jQuery(h),j)}})}if(d=="OPTION")if(!jQuery("<select/>").append(jQuery(a).ua()).w().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.bc(d[e],b.concat(e),c)}}}};Binder.prototype.Hd=function(a){return new EvalUpdater(a,a.getAttribute("ng-eval"))};Binder.prototype.Xb=
function(a){return new BindUpdater(a,"{{"+a.getAttribute("ng-bind")+"}}")};Binder.prototype.Dd=function(a){return new BindAttrUpdater(a,fromJson(a.getAttribute("ng-bind-attr")))};Binder.prototype.Id=function(a){return new HideUpdater(a,a.getAttribute("ng-hide"))};Binder.prototype.Jd=function(a){return new ShowUpdater(a,a.getAttribute("ng-show"))};Binder.prototype.Ed=function(a){return new ClassUpdater(a,a.getAttribute("ng-class"))};Binder.prototype.Fd=function(a){return new ClassEvenUpdater(a,a.getAttribute("ng-class-even"))};
Binder.prototype.Gd=function(a){return new ClassOddUpdater(a,a.getAttribute("ng-class-odd"))};Binder.prototype.Kd=function(a){return new StyleUpdater(a,a.getAttribute("ng-style"))};Binder.prototype.Ld=function(a,b){b.watch(a.getAttribute("ng-watch"))};ControlBar=function(a,b){this.document=a;this.Ia=b;this.window=s;this.S=[]};ControlBar.prototype.B=x();ControlBar.Ae='<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.Ca=function(a){this.S.push(a);this.S.length==1&&this.zb("/user_session/new.mini?return_url="+encodeURIComponent(this.mc()))};ControlBar.prototype.Vb=function(a){this.S.push(a);this.S.length==1&&this.zb("/user_session/do_destroy.mini")};ControlBar.prototype.mc=function(){return this.window.location.href.split("#")[0]};ControlBar.prototype.zb=function(a){var b=this,c=(new Date).getTime(),d=this.mc();d+="#$iframe_notify="+c;var e=jQuery('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+
d+'" src="'+this.Ia+a+'" width="500" height="330"/></div>');this.document.append(e);e.yb({height:363,width:500,Qf:false,Ad:true,title:'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'});nglr["_iframe_notify_"+c]=function(){e.yb("destroy");e.remove();jQuery.b(b.S,function(g,i){i()});b.S=[]}};ControlBar.vc='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';ControlBar.prototype.Za=function(){if(!this.Eb){this.Eb=
jQuery(ControlBar.vc);this.Eb.yb({Me:true,height:70,Ad:true})}};DataStore=function(a,b,c){this.$b=a;this.nc=b;this.P={na:[]};this.anchor=c;this.ra=[]};DataStore.prototype.sa=function(a){if(a.constructor!=Model)throw"Parameter must be an instance of Entity! "+toJson(a);var b=a.oa+"/"+a.N,c=this.P[b];if(c)Model.Ra(a,c);else c=this.P[b]=a;return c};DataStore.prototype.load=function(a,b,c,d){if(b&&b!=="*"){var e=this;this.R(["GET",a.oa+"/"+b],function(g){a.W(g);a.kb();g=a.ma(a);e.sa(g);(c||noop)(a)},
d)}return a};DataStore.prototype.Wa=function(a,b,c){var d=this,e=[],g=0;jQuery.b(b,function(i,l){e.push(d.load(a(),l,function(){g++;if(g==b.length)(c||noop)(e)}))});return e};DataStore.prototype.Rb=function(a,b,c){return this.load(a,b,c,function(d){if(d.Ja==404){a.N=b;(c||noop)(a)}else throw d;})};DataStore.prototype.yd=function(a,b){var c=this,d=[];d.ib=function(e){return e.oa==a.title};this.P.na.push(d);this.R(["GET",a.title],function(e){for(var g=0;g<e.length;g++){var i=a();i.W(e[g]);d.push(c.sa(i))}(b||
noop)(d)});return d};DataStore.prototype.save=function(a,b){var c=this,d={};a.lb(d);this.R(["POST","",d],function(e){a.W(e);var g=c.sa(a);_.b(c.P.na,function(i){i.ib(a)&&angular.Ka.md(i,g,true)});if(a.jb)c.anchor[a.jb]=a.N;b&&b(a)})};DataStore.prototype.remove=function(a,b){var c=this,d={};a.lb(d);this.R(["DELETE","",d],function(e){delete c.P[a.oa+"/"+a.N];_.b(c.P.na,function(g){for(var i=0;i<g.length;i++)g[i].N==a.N&&g.splice(i,1)});(b||noop)(e)})};DataStore.prototype.R=function(a,b,c){a.pc=b;a.rc=
c||function(d){throw d;};this.ra.push(a)};DataStore.prototype.Db=function(){function a(d,e){console.log("RESPONSE["+d+"]: ",e);if(e.Ja==401)b.nc.Ca(function(){b.$b(c,a)});else if(e.Ja)alert(toJson(e));else for(var g=0;g<e.length;g++){var i=e[g],l=c[g];if(d=i.Ja)d==403?b.nc.Za():l.rc(i);else l.pc(i)}}if(this.ra.length!==0){var b=this,c=this.ra;this.ra=[];console.log("REQUEST:",c);this.$b(c,a)}};DataStore.prototype.Wd=function(a,b){function c(){d--;d===0&&b&&b()}var d=1;for(var e in a){var g=a[e];if(g&&
g.pa==Model.prototype.pa){d++;g.pa(c)}}c()};DataStore.prototype.ja=function(a,b,c,d){var e=this,g=[];g.ib=z(false);this.P.na.push(g);this.R(["GET",a.title+"/"+b+"="+c],function(i){for(var l=0;l<i.length;l++){var n=(new a).W(i[l]);g.push(e.sa(n))}d&&d(g)});return g};DataStore.Z=x();DataStore.Z.all=function(){return[]};DataStore.Z.ja=function(){return[]};DataStore.Z.load=function(){return{}};DataStore.Z.title=undefined;DataStore.prototype.da=function(a,b){if(!a)return DataStore.Z;var c=this;function d(e){return new Model(d,
e)}d.title=a;d.qc=true;d.wb=this;d.Yc=b||{};d.load=function(e,g){return c.load(d(),e,g)};d.Wa=function(e,g){return c.Wa(d,e,g)};d.Rb=function(e,g){return c.Rb(d(),e,g)};d.all=function(e){return c.yd(d,e)};d.ja=function(e,g,i){return c.ja(d,e,g,i)};d.Nf=function(e){c.R(["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).rb().map(function(d,e){return e}).$d(function(d){var e=[];do{if(_(e).ya(d))throw"Infinite loop in join: "+
e.join(" -> ");e.push(d);if(!a[d])throw _("Named entity '<%=name%>' is undefined.").V({name:d});d=a[d].Da?a[d].Da.substring(0,a[d].Da.indexOf(".")):undefined}while(d);return e.length}).value();if(_(c).select(function(d){return a[d].Da}).length!=c.length-1)throw"Exactly one entity needs to be primary.";b.ja=function(d,e){var g=[],i=d?d.substring(0,d.indexOf(".")):undefined;if(i!=c[0])throw _("Named entity '<%=name%>' is not a primary entity.").V({name:i});var l=1;a[i].join.ja(d.substring(d.indexOf(".")+
1),e,function(n){var o=c[l++],p=a[o],r=p.Da,f={};_(n).b(function(h){var j={};g.push(j);j[i]=h;h=Scope.fa(j,r);f[h]=h});p.join.Wa(_.A(f),function(h){var j={};_(h).b(function(k){j[k.N]=k});_(g).b(function(k){var m=Scope.fa(k,r);k[o]=j[m]})})});return g};return b};angular.filter.m=function(a){if(a)for(var b in a)this[b]=a[b]};angular.filter.m.h=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.bf=function(a){jQuery(this.element).eb("ng-format-negative",a<0);return"$"+angular.filter.$a.apply(this,[a,2])};angular.filter.$a=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.Vc=x();angular.filter.td=function(a){jQuery(this.element).Oa("ng-monospace");return toJson(a,true)};angular.filter.jc=function(a,b){a=trim(a);for(var c=a.replace(/ /g,""),d=angular.filter.jc.wc,e=0;e<d.length;e++)for(var g=d[e],i=0;i<g.ka.length;i++)if(g.ka[i].test(c)){b=g.name+": "+a;g=g.url+a;return new angular.filter.m({text:b,url:g,w:'<a href="'+escapeAttr(g)+'">'+b+"</a>",Xf:a})}return a?b||new angular.filter.m({text:a+" is not recognized"}):null};angular.filter.jc.wc=[{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=",ka:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",ka:[/^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=",ka:[/^(91\d{20})$/i,/^(91\d{18})$/i]}];angular.filter.link=function(a,b){b=
b||angular.filter.m.h(a);var c=angular.filter.m.h(a,"url")||angular.filter.m.h(a);if(c){if(angular.j.$c(c)===null)c="mailto:"+c;a='<a href="'+escapeHtml(c)+'">'+b+"</a>";return new angular.filter.m({text:b,url:c,w:a})}return a};angular.filter.Pa=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.Pa.yc[b]};angular.filter.Pa.yc=["bytes","KB","MB","GB","TB","PB"];angular.filter.nf=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.m({url:a.url,text:a.url,w:'<img src="'+a.url+'"'+d+"/>"})}return null};angular.filter.xf=function(a){return(a=angular.filter.m.h(a))?(""+a).toLowerCase():a};angular.filter.cg=function(a){return(a=angular.filter.m.h(a))?(""+a).toUpperCase():a};angular.filter.wf=function(a){a=angular.filter.m.h(a);if(a===""||!a)return 1;return a.split(/\n|\f/).length};angular.filter["if"]=function(a,
b){return b?a:undefined};angular.filter.ag=function(a,b){return b?undefined:a};angular.filter.k=function(a,b,c,d){b=b||{};var e=angular.filter.k;a={Oc:a,Qe:e.tb(b,"color"),We:e.title(b),Se:e.tb(b,"label"),Re:e.gb(b),Te:"bg,s,FFFFFF00"};if(_.q(b.ne)){a.Ye="x";a.Xe="0:|"+b.ne.join("|")}return angular.filter.k.wa(a,c,d)};angular.filter.k.gb=function(a){var b=[];_.b(a.Yd||[],function(c){var d=[];_.b(c.gb||[],function(e){d.push(e)});b.push(d.join(","))});a=b.join("|");return a===""?null:"t:"+a};angular.filter.k.title=
function(a){var b=[];a=a.title||[];_.b(_.q(a)?a:[a],function(c){b.push(encodeURIComponent(c))});return b.join("|")};angular.filter.k.tb=function(a,b){var c=[],d=0;_.b(a.Yd||[],function(e){var g=[];e=e[b]||[];_.b(_.q(e)?e:[e],function(i){g.push(encodeURIComponent(i));d++});c.push(g.join("|"))});return d?c.join(","):null};angular.filter.k.wa=function(a,b,c){b=b||200;c=c||b;var d="http://chart.apis.google.com/chart?",e=[];a.Ve=b+"x"+c;for(var g in a){var i=a[g];i&&e.push(g+"="+i)}e.sort();d+=e.join("&");
return new angular.filter.m({url:d,text:i,w:'<img width="'+b+'" height="'+c+'" src="'+d+'"/>'})};angular.filter.Of=function(a,b,c){return angular.filter.k.wa({Oc:"qr",Ue:encodeURIComponent(a)},b,c)};angular.filter.Pe={Kf:function(a,b,c){return angular.filter.k("p",a,b,c)},Lf:function(a,b,c){return angular.filter.k("p3",a,b,c)},Mf:function(a,b,c){return angular.filter.k("pc",a,b,c)},Je:function(a,b,c){return angular.filter.k("bhs",a,b,c)},Ie:function(a,b,c){return angular.filter.k("bhg",a,b,c)},Le:function(a,
b,c){return angular.filter.k("bvs",a,b,c)},Ke:function(a,b,c){return angular.filter.k("bvg",a,b,c)},vf:function(a,b,c){return angular.filter.k("lc",a,b,c)},Tf:function(a,b,c){return angular.filter.k("ls",a,b,c)},Rf:function(a,b,c){return angular.filter.k("s",a,b,c)}};angular.filter.w=function(a){return new angular.filter.m({w: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.Ga();b.aa();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.O.cc(b));else if(d==="object")if(b instanceof Array){a.push("[");var e=b.length;d=false;for(var g=0;g<e;g++){var i=b[g];d&&a.push(",");typeof i=="function"||typeof i=="undefined"?
a.push("null"):toJsonArray(a,i,c);d=true}a.push("]")}else if(b instanceof Date)a.push(angular.O.cc(angular.tc.toString(b)));else{a.push("{");c&&a.push(c);d=false;g=c?c+" ":false;i=[];for(var l in b)l.indexOf("$$")!==0&&i.push(l);i.sort();for(l=0;l<i.length;l++){var n=i[l];try{e=b[n];if(typeof e!="function"){if(d){a.push(",");c&&a.push(c)}a.push(angular.O.quote(n));a.push(":");toJsonArray(a,e,g);d=true}}catch(o){}}a.push("}")}};Model=function(a,b){this.ma=a;this.W(b||{});this.oa=a.title;this.kb()};
Model.Ra=function(a,b){if(!(a===b||!a||!b)){var c=function(e,g,i){return i.substring(0,2)!=="$$"&&typeof e[i]!=="function"&&typeof g[i]!=="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.kb=function(){merge(this.ma.Yc,this);return this};Model.prototype.pa=function(a){this.ma.wb.save(this,a===true?undefined:a);a===true&&this.ma.wb.Db();return this};Model.prototype.W=function(a){Model.Ra(a,this);return this};Model.prototype.lb=function(a){Model.Ra(this,
a);return this};Lexer=function(a,b){this.text=a;this.Wc=b?20:-1;this.l=[];this.index=0};Lexer.mb={"null":z(null),"true":z(true),"false":z(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.s(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.U=function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false};Lexer.prototype.parse=function(){for(var a=this.l,b=Lexer.mb,c=true;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=='"'||d=="'"){this.Ud(d);
c=true}else if(d=="("||d=="["){a.push({index:this.index,text:d});this.index++}else if(d=="{"){c=this.U();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.Td();c=false}else if(this.ha(d)){this.Sd();c=false}else if(this.Aa(d)){this.dc();
c=false}else if(this.sd(d))this.index++;else{c=d+this.U();var e=b[d],g=b[c];if(g){a.push({index:this.index,text:c,c:g});this.index+=2}else if(e){a.push({index:this.index,text:d,c: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.ha=function(a){return"0"<=a&&a<="9"};Lexer.prototype.sd=function(a){return a==" "||a=="\r"||a=="\t"||a=="\n"||a=="\u000b"};
Lexer.prototype.Aa=function(a){return"a"<=a&&a<="z"||"A"<=a&&a<="Z"||"_"==a||a=="$"};Lexer.prototype.Sd=function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.ha(c))a+=c;else break;this.index++}a=1*a;this.l.push({index:b,text:a,c:function(){return a}})};Lexer.prototype.dc=function(){for(var a="",b=this.index;this.index<this.text.length;){var c=this.text.charAt(this.index);if(c=="."||this.Aa(c)||this.ha(c))a+=c;else break;this.index++}c=
Lexer.mb[a];if(!c){c=function(d){return d.scope.h(a)};c.za=a}this.l.push({index:b,text:a,c:c})};Lexer.uc={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'};Lexer.prototype.Ud=function(a){var b=this.index,c=this.Wc;this.index++;for(var d="",e=false;this.index<this.text.length;){var g=this.text.charAt(this.index);if(e){if(g=="u"){g=this.text.substring(this.index+1,this.index+5);this.index+=4;d+=String.fromCharCode(parseInt(g,16))}else{e=Lexer.uc[g];d+=e?e:g}e=false}else if(g=="\\")e=true;
else if(g==a){this.index++;this.l.push({index:b,text:d,c:function(){return d.length==c?angular.O.be(d):d}});return}else d+=g;this.index++}throw"Lexer Error: Unterminated quote ["+this.text.substring(b)+"] starting at column '"+(b+1)+"' in expression '"+this.text+"'.";};Lexer.prototype.Td=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.Aa(this.text.charAt(this.index))){this.dc();
c=this.l.pop().text}var e=new RegExp(b,c);this.l.push({index:a,text:b,hf:c,c: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.l=(new Lexer(a,b)).parse();this.index=0};Parser.zc=z(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.Fa=function(){if(this.l.length===0)throw"Unexpected end of expression: "+this.text;return this.l[0]};Parser.prototype.U=function(a,b,c,d){var e=this.l;if(e.length>0){e=e[0];var g=e.text;if(g==a||g==b||g==c||g==d||!a&&!b&&!c&&!d)return e}return false};Parser.prototype.a=function(a,b,c,d){if(a=this.U(a,b,c,d)){this.l.shift();return this.cf=a}return false};Parser.prototype.p=function(a){if(!this.a(a)){var b=this.U();throw"Expecting '"+a+"' at column '"+
(b.index+1)+"' in '"+this.text+"' got '"+this.text.substring(b.index)+"'.";}};Parser.prototype.Ac=function(a,b){var c=b.apply(this);return function(d){return a(d,c(d))}};Parser.prototype.G=function(a,b,c){var d=c.apply(this);return function(e){return b(e,a(e),d(e))}};Parser.prototype.Hb=function(){return this.l.length>0};Parser.prototype.aa=function(){if(this.l.length!==0)throw"Did not understand '"+this.text.substring(this.l[0].index)+"' while evaluating '"+this.text+"'.";};Parser.prototype.db=function(){for(var a=
[];;){this.l.length>0&&!this.U("}",")",";","]")&&a.push(this.Cb());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.Cb=function(){for(var a=this.C(),b;;)if(b=this.a("|"))a=this.G(a,b.c,this.filter);else return a};Parser.prototype.filter=function(){return this.ob(angular.filter)};Parser.prototype.j=function(){return this.ob(angular.j)};Parser.prototype.ob=function(a){for(var b=this.kd(a),c=[];;)if(this.a(":"))c.push(this.C());else{var d=
function(e,g){g=[g];for(var i=0;i<c.length;i++)g.push(c[i](e));return b.apply(e,g)};return function(){return d}}};Parser.prototype.C=function(){return this.ae()};Parser.prototype.ae=function(){if(this.a("throw")){var a=this.qb();return function(b){throw a(b);}}else return this.qb()};Parser.prototype.qb=function(){var a=this.Ub(),b;if(b=this.a("=")){if(!a.za)throw"Left hand side '"+this.text.substring(0,b.index)+"' of assignment '"+this.text.substring(b.index)+"' is not assignable.";return this.G(function(){return a.za},
b.c,this.Ub)}else return a};Parser.prototype.Ub=function(){for(var a=this.Tb(),b;;)if(b=this.a("||"))a=this.G(a,b.c,this.Tb);else return a};Parser.prototype.Tb=function(){for(var a=this.Wb(),b;;)if(b=this.a("&&"))a=this.G(a,b.c,this.Wb);else return a};Parser.prototype.Wb=function(){var a;return(a=this.a("!"))?this.Ac(a.c,this.Ab):this.Ab()};Parser.prototype.Ab=function(){for(var a=this.ec(),b;;)if(b=this.a("==","!="))a=this.G(a,b.c,this.ec);else return a};Parser.prototype.ec=function(){for(var a=
this.pb(),b;;)if(b=this.a("<",">","<=",">="))a=this.G(a,b.c,this.pb);else return a};Parser.prototype.pb=function(){for(var a=this.Ya(),b;b=this.a("+","-");)a=this.G(a,b.c,this.Ya);return a};Parser.prototype.Ya=function(){for(var a=this.kc(),b;b=this.a("*","/","%");)a=this.G(a,b.c,this.kc);return a};Parser.prototype.kc=function(){var a;return this.a("+")?this.Ga():(a=this.a("-"))?this.G(Parser.zc,a.c,this.Ya):this.Ga()};Parser.prototype.kd=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.Ga=function(){var a;if(this.a("(")){a=this.Cb();this.p(")");a=a}else if(this.a("["))a=this.Ic();else if(this.a("{"))a=this.object();else if(this.a("{:"))a=this.sb(false);else if(this.a("{("))a=this.sb(true);else{var b=this.a();(a=b.c)||this.error("not a primary expression",b)}for(;b=this.a("(","[",".");)if(b.text==="(")a=
this.jd(a);else if(b.text==="[")a=this.Md(a);else if(b.text===".")a=this.ed(a);else throw"IMPOSSIBLE";return a};Parser.prototype.sb=function(a){var b=[];if(a){if(!this.a(")")){for(b.push(this.a().text);this.a(",");)b.push(this.a().text);this.p(")")}this.p(":")}var c=this.db();this.p("}");return function(d){return function(e){var g=new Scope(d.scope.F);g.s("$",e);for(var i=0;i<b.length;i++)g.s(b[i],arguments[i]);return c({scope:g})}}};Parser.prototype.ed=function(a){var b=this.a().text;function c(d){return Scope.fa(a(d),
b)}c.za=b;return c};Parser.prototype.Md=function(a){var b=this.C();this.p("]");if(this.a("=")){var c=this.C();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.jd=function(a){var b=[];if(this.Fa().text!=")"){do b.push(this.C());while(this.a(","))}this.p(")");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.za+"' is not a function.";
}};Parser.prototype.Ic=function(){var a=[];if(this.Fa().text!="]"){do a.push(this.C());while(this.a(","))}this.p("]");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.Fa().text!="}"){do{var b=this.a().text;this.p(":");var c=this.C();a.push({ud:b,value:c})}while(this.a(","))}this.p("}");return function(d){for(var e={},g=0;g<a.length;g++){var i=a[g],l=i.value(d);e[i.ud]=l}return e}};Parser.prototype.cd=function(){for(var a=
[];this.Hb();){a.push(this.bd());this.a(";")||this.aa()}return function(b){for(var c="",d=0;d<a.length;d++)c+=a[d](b);return c}};Parser.prototype.bd=function(){var a=this.a().text,b,c;if(this.a("=")){b=a;a=this.a().text}if(this.a(":"))c=this.Ga()(null);return function(d){var e=d.scope.h("$datastore").da(a,c);d.scope.s(a,e);if(b){e=e();e.jb=b;d.scope.s(b,e);return"$anchor."+b+":{"+b+"="+a+".load($anchor."+b+");"+b+".$$anchor="+angular.O.quote(b)+";};"}else return""}};Parser.prototype.watch=function(){for(var a=
[];this.Hb();){a.push(this.le());this.a(";")||this.aa()}this.aa();return function(b){for(var c=0;c<a.length;c++){var d=a[c](b);b.Dc(d.name,d.c)}}};Parser.prototype.le=function(){var a=this.a().text;this.p(":");var b;if(this.Fa().text=="{"){this.p("{");b=this.db();this.p("}")}else b=this.C();return function(){return{name:a,c:b}}};Scope=function(a,b){this.oc=[];this.hb={};this.name=b;a=a||{};function c(){}c.prototype=a;this.F=new c;this.F.ve=a;if(b=="ROOT")this.F.we=this.F};Scope.xa={};Scope.prototype.d=
function(){var a=this;this.fd();_.b(this.oc,function(b){a.u(b,"",{},function(){this.d(a)})})};Scope.prototype.Fc=function(a){a&&this.oc.push(a)};Scope.prototype.qd=function(a){for(var b=0;b<a.length;b++){var c=a.charAt(b);if(c!="."&&!Lexer.prototype.Aa(c))return false}return true};Scope.fa=function(a,b){if(!b)return a;for(var c=b.split("."),d,e=a,g=c.length,i=0;i<g;i++){d=c[i];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(_.H(a)&&d.charAt(0)=="$"){var l=angular.Y.de(e);if(d=(l=angular[l.charAt(0).toUpperCase()+l.substring(1)])?l[[d.substring(1)]]:undefined)return a=_.B(d,e,e)}}if(typeof a==="function"&&!a.qc)return bind(e,a);return a};Scope.prototype.h=function(a){return Scope.fa(this.F,a)};Scope.prototype.s=function(a,b){a=a.split(".");for(var c=this.F,d=0;a.length>1;d++){var e=a.shift(),g=c[e];if(!g){g={};c[e]=g}c=g}return c[a.shift()]=b};Scope.prototype.z=function(a,b){this.eval(a+"="+toJson(b))};Scope.prototype.eval=
function(a,b){var c=Scope.xa[a];if(!c){var d=new Parser(a);c=d.db();d.aa();Scope.xa[a]=c}b=b||{};b.scope=this;return c(b)};Scope.prototype.u=function(a,b,c,d,e){try{var g=this.eval(b,c);if(a.J){a.J=false;jQuery(a.view).gc("ng-exception").fc("ng-error")}d&&d.apply(a,[g]);return true}catch(i){console.error("Eval Widget Error:",i);b=toJson(i,true);a.J=true;jQuery(a.view).Oa("ng-exception").g("ng-error",b);e&&e.apply(a,[i,b]);return false}};Scope.prototype.je=function(a,b){var c=Scope.xa[a];if(!c){c=
(new Parser(a)).j();Scope.xa[a]=c}a={scope:this};return c(a)(a,b)};Scope.prototype.da=function(a){return(new Parser(a)).cd()({scope:this})};Scope.prototype.zd=function(a){this.F.ue.push(a)};Scope.prototype.watch=function(a){var b=this;(new Parser(a)).watch()({scope:this,Dc:function(c,d){b.Ec(c,function(e,g){try{return d({scope:b},e,g)}catch(i){alert(i)}})}})};Scope.prototype.Ec=function(a,b){var c=this.hb[a];if(!c){c={Pb:[],C:a};this.hb[a]=c}c.Pb.push(b)};Scope.prototype.fd=function(){var a=this,
b=false;jQuery.b(this.hb,function(c,d){var e=a.eval(d.C);if(e!==d.e){jQuery.b(d.Pb,function(g,i){i(e,d.e);b=true});d.e=e}});return b};Server=function(a,b){this.url=a;this.Bd=0;this.Fb=b;this.ie="_"+(""+Math.random()).substr(2)+"_";this.Xa=1800};Server.prototype.Kc=function(a){return w.wa(a)};Server.prototype.la=function(a,b,c,d){var e=this.ie+this.Bd++;nglr[e]=function(l){delete nglr[e];d(200,l)};a={Yf:b,yf:a,If:c};a=this.Kc(toJson(a));b=Math.ceil(a.length/this.Xa);c=this.url+"/$/"+e+"/"+b+"/";for(var g=
0;g<b;g++){var i=a.substr(g*this.Xa,this.Xa);this.Fb(c+(g+1)+"?h="+i,noop)}};FrameServer=y("frame");FrameServer.Be="$DATASET:";FrameServer.prototype={la:x()};VisualServer=function(a,b,c){this.Zc=a;this.update=c;this.status=b};VisualServer.prototype={la:function(a,b,c,d){var e=this;this.status.Lc(c);this.Zc.la(a,b,c,function(){e.status.ad();try{d.apply(this,arguments)}catch(g){alert(toJson(g))}e.update()})}};Users=function(a,b){this.M=a;this.Qa=b};Users.prototype={Bb:function(a){var b=this;this.M.la("GET",
"/account.json",{},function(c,d){b.Uc=d.he;a(d.he)})},Vb:function(a){var b=this;this.Qa.Vb(function(){delete b.Uc;(a||noop)()})},Ca:function(a){var b=this;this.Qa.Ca(function(){b.Bb(function(){(a||noop)()})})},Za:function(){this.Qa.Za()}};angular.j.ka=function(a,b,c){return a.match(b)?null:c||"Value does not match expected format "+b+"."};angular.j.$a=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.j.pf=function(a,b,c){b=angular.j.$a(a,b,c);if(b===null&&a!=Math.round(a))return"Value is not a whole number.";return b};angular.j.Vc=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.j.Uf=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.j.$c=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.j.Jf=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.j.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.j.td=function(a){try{fromJson(a);return null}catch(b){return b.toString()}};WidgetFactory=function(a,b){this.Cd=0;this.Ia=a;this.T=b;this.ub=swfobject.ub;this.Nd=x()};WidgetFactory.prototype.Sc=function(a,b){var c,d=a.g("type").toLowerCase(),e=a.g("name");if(e)e=e.split(":").pop();var g="change",i=true;if(d=="button"||d=="submit"||d=="reset"||d=="image"){c=new ButtonController(a[0],e);g="click";i=false}else if(d=="text"||d=="textarea"||d=="hidden"||d=="password"){c=new TextController(a[0],
e);g="keyup change"}else if(d=="checkbox"){c=new CheckboxController(a[0],e);g="click"}else if(d=="radio"){c=new RadioController(a[0],e);g="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.Tc(a,e);else throw"Unknown type: "+d;a.data("controller",c);var l=b.h("$binder");jQuery(c.view,":input").B(g,function(){if(c.i(b)){var n=jQuery(c.view).g("ng-action")||"";b.u(c,n)&&l.d(b)}return i});return c};WidgetFactory.prototype.Tc=
function(a){var b="__uploadWidget_"+this.Cd++,c=FileController.V(b);a.Gc(c);b=this.ub({data:this.Ia+"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",eg:"transparent"},{jf:"uploadWidgetId="+b,De:"always"},b);a.remove();a=new FileController(c,a[0].name,b,this.Ia+"/data/"+this.T);jQuery(b).data("controller",a);return a};FileController=function(a,b,c,d){this.view=a;this.bg=c;this.hc=b;this.Ge=d+"/_attachments";this.value=null;this.e=undefined};FileController.dispatchEvent=function(a,b,c){a=v.getElementById(a);
a=jQuery(a).data("controller");FileController.prototype["_on_"+b].apply(a,c)};FileController.V=function(a){return jQuery('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+a+'" /><a></a><span/></span>')};FileController.prototype.i=function(a){var b=this.view.find("input").g("checked")?this.value:null;if(this.e===b)return false;else{a.s(this.hc,b);return true}};FileController.prototype.d=function(a){if((a=a.h(this.hc))&&this.value!==a){this.value=a;this.view.find("a").g("href",
this.value.url).text(this.value.text);this.view.find("span").text(angular.filter.Pa(this.value.size))}this.view.find("input").g("checked",!!a)};NullController=y("view");NullController.prototype.i=z(true);NullController.prototype.d=x();NullController.nd=new NullController;ButtonController=y("view");ButtonController.prototype.i=z(true);ButtonController.prototype.d=x();TextController=function(a,b){this.view=a;this.exp=b;this.j=a.getAttribute("ng-validate");this.Vd=typeof a.attributes["ng-required"]!=
"undefined";this.Nb=null;this.e=undefined;this.D=a.value;a.getAttribute("ng-widget")==="datepicker"&&jQuery(a).df()};TextController.prototype.i=function(a){var b=this.view.value;if(this.e===b)return false;else{a.z(this.exp,b);this.e=b;return true}};TextController.prototype.d=function(a){var b=this.view,c=a.h(this.exp);if(typeof c==="undefined"){c=this.D;a.z(this.exp,c)}c=c?c:"";if(this.e!=c)this.e=b.value=c;var d=false;b.removeAttribute("ng-error");if(this.Vd)d=!(c&&c.length>0);var e=d?"Required Value":
null;if(!d&&this.j&&c){e=a.je(this.j,c);d=!!e}if(this.Nb!==e){this.Nb=d;if(e!==null){b.setAttribute("ng-error",e);a.zd(this)}jQuery(b).eb("ng-validation-error",d)}};CheckboxController=function(a,b){this.view=a;this.exp=b;this.e=undefined;this.D=a.checked?a.value:""};CheckboxController.prototype.i=function(a){var b=this.view;b=b.checked?b.value:"";if(this.e===b)return false;else{a.z(this.exp,b);this.e=b;return true}};CheckboxController.prototype.d=function(a){var b=this.view,c=a.eval(this.exp);if(typeof c===
"undefined"){c=this.D;a.z(this.exp,c)}b.checked=b.value==""+c};SelectController=function(a,b){this.view=a;this.exp=b;this.e=undefined;this.D=a.value};SelectController.prototype.i=function(a){if(this.view.selectedIndex<0)a.z(this.exp,null);else{var b=this.view.value;if(this.e===b)return false;else{a.z(this.exp,b);this.e=b;return true}}};SelectController.prototype.d=function(a){var b=this.view,c=a.h(this.exp);if(typeof c==="undefined"){c=this.D;a.z(this.exp,c)}if(c!==this.e){b.value=c?c:"";this.e=c}};
MultiSelectController=function(a,b){this.view=a;this.exp=b;this.e=undefined;this.D=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.i=function(a){var b=this.selected();if(this.e===b)return false;else{a.z(this.exp,b);this.e=b;return true}};MultiSelectController.prototype.d=function(a){var b=this.view,c=a.h(this.exp);if(typeof c==="undefined"){c=this.D;
a.z(this.exp,c)}if(c!==this.e){a=b.options;for(b=0;b<a.length;b++){var d=a[b];d.selected=_.ya(c,d.value)}this.e=c}};RadioController=function(a,b){this.view=a;this.exp=b;this.e=this.Va=undefined;this.Kb=a.value;this.D=a.checked?a.value:null};RadioController.prototype.i=function(a){var b=this.view;if(this.Va)return false;else{b.checked=true;this.e=a.z(this.exp,this.Kb);return this.Va=true}};RadioController.prototype.d=function(a){var b=this.view,c=a.h(this.exp);if(this.D&&typeof c==="undefined"){c=
this.D;a.z(this.exp,c)}if(this.e!=c){this.Va=b.checked=this.Kb==""+c;this.e=c}};BindUpdater=function(a,b){this.view=a;this.exp=Binder.Ea(b);this.J=false;this.Xd={element:a}};BindUpdater.ic=function(a){var b=escapeHtml;switch(typeof a){case "string":case "boolean":case "number":return b(a);case "function":return BindUpdater.ic(a());case "object":if(isNode(a))return outerHTML(a);else if(a instanceof angular.filter.m){switch(typeof a.w){case "string":case "number":return a.w;case "function":return a.w();
case "object":if(isNode(a.w))return outerHTML(a.w);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.i=x();BindUpdater.prototype.d=function(a){for(var b=[],c=this.exp,d=c.length,e=0;e<d;e++){var g=c[e],i=Binder.ba(g);if(i){a.u(this,i,this.Xd,function(l){b.push(BindUpdater.ic(l))},function(l,n){setHtml(this.view,n)});if(this.J)return}else b.push(escapeHtml(g))}setHtml(this.view,
b.join(""))};BindAttrUpdater=function(a,b){this.view=a;this.Jc=b};BindAttrUpdater.prototype.i=x();BindAttrUpdater.prototype.d=function(a){var b=jQuery(this.view),c=this.Jc;if(this.J){this.J=false;b.gc("ng-exception").fc("ng-error")}var d=b.od("img");for(var e in c){for(var g=Binder.Ea(c[e]),i=[],l=0;l<g.length;l++){var n=Binder.ba(g[l]);if(n)try{var o=a.eval(n,{element:b[0],attrName:e});if(o&&(o.constructor!==array||o.length!==0))i.push(o)}catch(p){this.J=true;console.error("BindAttrUpdater",p);n=
toJson(p,true);i.push("["+n+"]");b.Oa("ng-exception").g("ng-error",n)}else i.push(g[l])}g=i.length?i.join(""):null;if(d&&e=="src"&&!g)g=a.h("config.server")+"/images/blank.gif";b.g(e,g)}};EvalUpdater=function(a,b){this.view=a;this.exp=b;this.J=false};EvalUpdater.prototype.i=x();EvalUpdater.prototype.d=function(a){a.u(this,this.exp)};HideUpdater=function(a,b){this.view=a;this.exp=b};HideUpdater.prototype.i=x();HideUpdater.prototype.d=function(a){a.u(this,this.exp,{},function(b){var c=jQuery(this.view);
toBoolean(b)?c.Jb():c.cb()})};ShowUpdater=function(a,b){this.view=a;this.exp=b};ShowUpdater.prototype.i=x();ShowUpdater.prototype.d=function(a){a.u(this,this.exp,{},function(b){var c=jQuery(this.view);toBoolean(b)?c.cb():c.Jb()})};ClassUpdater=function(a,b){this.view=a;this.exp=b};ClassUpdater.prototype.i=x();ClassUpdater.prototype.d=function(a){a.u(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.i=
x();ClassEvenUpdater.prototype.d=function(a){a.u(this,this.exp,{},function(b){var c=a.h("$index");jQuery(this.view).eb(b,c%2===1)})};ClassOddUpdater=function(a,b){this.view=a;this.exp=b};ClassOddUpdater.prototype.i=x();ClassOddUpdater.prototype.d=function(a){a.u(this,this.exp,{},function(b){var c=a.h("$index");jQuery(this.view).eb(b,c%2===0)})};StyleUpdater=function(a,b){this.view=a;this.exp=b};StyleUpdater.prototype.i=x();StyleUpdater.prototype.d=function(a){a.u(this,this.exp,{},function(b){jQuery(this.view).g("style",
"").Sa(b)})};RepeaterUpdater=function(a,b,c,d){this.view=a;this.V=c;this.prefix=d;this.ta=[];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.Ba=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.ke=a[3]||a[1];this.vd=a[2]};RepeaterUpdater.prototype.i=x();RepeaterUpdater.prototype.d=function(a){a.u(this,this.Ba,
{},function(b){var c=this;if(!b){b=[];a.qd(this.Ba)&&a.s(this.Ba,b)}var d=b.length,e=this.ta.length,g=this.view,i=0,l=null,n=this.vd,o=this.ke,p=0;jQuery.b(b,function(r,f){if(p<e){l=c.ta[p];l.scope.s(o,f)}else{var h=new Scope(a.F,c.prefix+o+" in "+c.Ba+"["+p+"]");h.s("$index",p);n&&h.s(n,r);h.s(o,f);l={scope:h,element:c.V(h,c.prefix,p)};g.Gc(l.element);c.ta.push(l)}g=l.element;r=(new Date).getTime();l.scope.d();i+=(new Date).getTime()-r;p++});for(b=e;b>d;--b)this.ta.pop().element.removeNode();if(l&&
l.element[0].nodeName==="OPTION")if(d=jQuery(l.element[0].parentNode).data("controller")){d.e=undefined;d.d(a)}})};PopUp=y("Q");PopUp.nb="mouseleave mouseout click dblclick keypress keyup";PopUp.prototype.B=function(){this.Q.find(".ng-validation-error,.ng-exception").xd("mouseover",PopUp.Od)};PopUp.Od=function(){PopUp.ab();var a=jQuery(this);a.B(PopUp.nb,PopUp.ab);var b=a.position(),c=v.documentElement,d=(self.innerWidth||c&&c.clientWidth||v.body.clientWidth)-b.left;c=a.mf("ng-exception")?"EXCEPTION:":
"Validation error...";a=a.g("ng-error");d=d>375?"left":"right";c=jQuery("<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>");jQuery("body").append(c);if(d==="left")a=b.left+this.offsetWidth+11;else{a=b.left-315;c.find(".ng-arrow-right").Sa({left:301})}c.Sa({left:a+"px",top:b.top-3+"px"});return true};PopUp.ab=function(){jQuery("#ng-callout").Zf(PopUp.nb,PopUp.ab).remove();return true};Status=function(a){this.Sb=
a.append(Status.sc).find("#ng-loading");this.Ha=0};Status.sc='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';Status.prototype.Lc=function(){this.Ha===0&&this.Sb.cb();this.Ha++};Status.prototype.ad=function(){this.Ha--;this.Ha===0&&this.Sb.Jb("fold")}})(window,document);

4732
angular.js vendored

File diff suppressed because it is too large Load diff

View file

@ -15,3 +15,6 @@ load:
exclude:
- src/angular-bootstrap.js
- src/angular.prefix
- src/angular.suffix

Binary file not shown.

Binary file not shown.

View file

@ -66,7 +66,7 @@ angular.Array = {
}
return true;
};
var getter = nglr.Scope.getter;
var getter = Scope.getter;
var search = function(obj, text){
if (text.charAt(0) === '!') {
return !search(obj, text.substr(1));
@ -147,7 +147,7 @@ angular.Array = {
},
orderBy:function(array, expression, descend) {
function reverse(comp, descending) {
return nglr.toBoolean(descending) ?
return toBoolean(descending) ?
function(a,b){return comp(b,a);} : comp;
}
function compare(v1, v2){
@ -224,7 +224,7 @@ angular.Array = {
value = {};
array[index] = value;
}
nglr.merge(mergeValue, value);
merge(mergeValue, value);
return array;
}
};
@ -281,7 +281,7 @@ angular.Function = {
if (_.isFunction(expression)){
return expression;
} else if (expression){
var scope = new nglr.Scope();
var scope = new Scope();
return function($) {
scope.state = $;
return scope.eval(expression);

View file

@ -1,5 +1,5 @@
// Copyright (C) 2009 BRAT Tech LLC
nglr.Binder = function(doc, widgetFactory, urlWatcher, config) {
Binder = function(doc, widgetFactory, urlWatcher, config) {
this.doc = doc;
this.urlWatcher = urlWatcher;
this.anchor = {};
@ -8,7 +8,7 @@ nglr.Binder = function(doc, widgetFactory, urlWatcher, config) {
this.updateListeners = [];
};
nglr.Binder.parseBindings = function(string) {
Binder.parseBindings = function(string) {
var results = [];
var lastIndex = 0;
var index;
@ -28,18 +28,18 @@ nglr.Binder.parseBindings = function(string) {
return results.length === 0 ? [ string ] : results;
};
nglr.Binder.hasBinding = function(string) {
var bindings = nglr.Binder.parseBindings(string);
return bindings.length > 1 || nglr.Binder.binding(bindings[0]) !== null;
Binder.hasBinding = function(string) {
var bindings = Binder.parseBindings(string);
return bindings.length > 1 || Binder.binding(bindings[0]) !== null;
};
nglr.Binder.binding = function(string) {
Binder.binding = function(string) {
var binding = string.replace(/\n/gm, ' ').match(/^\{\{(.*)\}\}$/);
return binding ? binding[1] : null;
};
nglr.Binder.prototype.parseQueryString = function(query) {
Binder.prototype.parseQueryString = function(query) {
var params = {};
query.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,
function (match, left, right) {
@ -48,7 +48,7 @@ nglr.Binder.prototype.parseQueryString = function(query) {
return params;
};
nglr.Binder.prototype.parseAnchor = function(url) {
Binder.prototype.parseAnchor = function(url) {
var self = this;
url = url || this.urlWatcher.getUrl();
@ -65,13 +65,13 @@ nglr.Binder.prototype.parseAnchor = function(url) {
});
};
nglr.Binder.prototype.onUrlChange = function (url) {
Binder.prototype.onUrlChange = function (url) {
console.log("URL change detected", url);
this.parseAnchor(url);
this.updateView();
};
nglr.Binder.prototype.updateAnchor = function() {
Binder.prototype.updateAnchor = function() {
var url = this.urlWatcher.getUrl();
var anchorIndex = url.indexOf('#');
if (anchorIndex > -1)
@ -93,7 +93,7 @@ nglr.Binder.prototype.updateAnchor = function() {
return url;
};
nglr.Binder.prototype.updateView = function() {
Binder.prototype.updateView = function() {
var start = new Date().getTime();
var scope = jQuery(this.doc).scope();
scope.set("$invalidWidgets", []);
@ -103,7 +103,7 @@ nglr.Binder.prototype.updateView = function() {
_.each(this.updateListeners, function(fn) {fn();});
};
nglr.Binder.prototype.docFindWithSelf = function(exp){
Binder.prototype.docFindWithSelf = function(exp){
var doc = jQuery(this.doc);
var selection = doc.find(exp);
if (doc.is(exp)){
@ -112,31 +112,31 @@ nglr.Binder.prototype.docFindWithSelf = function(exp){
return selection;
};
nglr.Binder.prototype.executeInit = function() {
Binder.prototype.executeInit = function() {
this.docFindWithSelf("[ng-init]").each(function() {
var jThis = jQuery(this);
var scope = jThis.scope();
try {
scope.eval(jThis.attr('ng-init'));
} catch (e) {
nglr.alert("EVAL ERROR:\n" + jThis.attr('ng-init') + '\n' + nglr.toJson(e, true));
alert("EVAL ERROR:\n" + jThis.attr('ng-init') + '\n' + toJson(e, true));
}
});
};
nglr.Binder.prototype.entity = function (scope) {
Binder.prototype.entity = function (scope) {
this.docFindWithSelf("[ng-entity]").attr("ng-watch", function() {
try {
var jNode = jQuery(this);
var decl = scope.entity(jNode.attr("ng-entity"));
return decl + (jNode.attr('ng-watch') || "");
} catch (e) {
nglr.alert(e);
alert(e);
}
});
};
nglr.Binder.prototype.compile = function() {
Binder.prototype.compile = function() {
var jNode = jQuery(this.doc);
var self = this;
if (this.config.autoSubmit) {
@ -153,37 +153,37 @@ nglr.Binder.prototype.compile = function() {
jNode.removeClass("ng-exception");
} catch (e) {
jNode.addClass("ng-exception");
jNode.attr('ng-error', nglr.toJson(e, true));
jNode.attr('ng-error', toJson(e, true));
}
self.updateView();
return false;
});
};
nglr.Binder.prototype.translateBinding = function(node, parentPath, factories) {
Binder.prototype.translateBinding = function(node, parentPath, factories) {
var path = parentPath.concat();
var offset = path.pop();
var parts = nglr.Binder.parseBindings(node.nodeValue);
if (parts.length > 1 || nglr.Binder.binding(parts[0])) {
var parts = Binder.parseBindings(node.nodeValue);
if (parts.length > 1 || Binder.binding(parts[0])) {
var parent = node.parentNode;
if (nglr.isLeafNode(parent)) {
if (isLeafNode(parent)) {
parent.setAttribute('ng-bind-template', node.nodeValue);
factories.push({path:path, fn:function(node, scope, prefix) {
return new nglr.BindUpdater(node, node.getAttribute('ng-bind-template'));
return new BindUpdater(node, node.getAttribute('ng-bind-template'));
}});
} else {
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
var binding = nglr.Binder.binding(part);
var binding = Binder.binding(part);
var newNode;
if (binding) {
newNode = document.createElement("span");
var jNewNode = jQuery(newNode);
jNewNode.attr("ng-bind", binding);
if (i === 0) {
factories.push({path:path.concat(offset + i), fn:nglr.Binder.prototype.ng_bind});
factories.push({path:path.concat(offset + i), fn:Binder.prototype.ng_bind});
}
} else if (nglr.msie && part.charAt(0) == ' ') {
} else if (msie && part.charAt(0) == ' ') {
newNode = document.createElement("span");
newNode.innerHTML = '&nbsp;' + part.substring(1);
} else {
@ -196,7 +196,7 @@ nglr.Binder.prototype.translateBinding = function(node, parentPath, factories) {
}
};
nglr.Binder.prototype.precompile = function(root) {
Binder.prototype.precompile = function(root) {
var factories = [];
this.precompileNode(root, [], factories);
return function (template, scope, prefix) {
@ -211,13 +211,13 @@ nglr.Binder.prototype.precompile = function(root) {
try {
scope.addWidget(factory.fn(node, scope, prefix));
} catch (e) {
nglr.alert(e);
alert(e);
}
}
};
};
nglr.Binder.prototype.precompileNode = function(node, path, factories) {
Binder.prototype.precompileNode = function(node, path, factories) {
var nodeType = node.nodeType;
if (nodeType == Node.TEXT_NODE) {
this.translateBinding(node, path, factories);
@ -234,19 +234,19 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
if (attributes) {
var bindings = node.getAttribute('ng-bind-attr');
node.removeAttribute('ng-bind-attr');
bindings = bindings ? nglr.fromJson(bindings) : {};
bindings = bindings ? fromJson(bindings) : {};
var attrLen = attributes.length;
for (var i = 0; i < attrLen; i++) {
var attr = attributes[i];
var attrName = attr.name;
// http://www.glennjones.net/Post/809/getAttributehrefbug.htm
var attrValue = nglr.msie && attrName == 'href' ?
var attrValue = msie && attrName == 'href' ?
decodeURI(node.getAttribute(attrName, 2)) : attr.value;
if (nglr.Binder.hasBinding(attrValue)) {
if (Binder.hasBinding(attrValue)) {
bindings[attrName] = attrValue;
}
}
var json = nglr.toJson(bindings);
var json = toJson(bindings);
if (json.length > 2) {
node.setAttribute("ng-bind-attr", json);
}
@ -270,7 +270,7 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
return clone;
};
factories.push({path:path, fn:function(node, scope, prefix) {
return new nglr.RepeaterUpdater(jQuery(node), repeaterExpression, template, prefix);
return new RepeaterUpdater(jQuery(node), repeaterExpression, template, prefix);
}});
return;
}
@ -309,42 +309,42 @@ nglr.Binder.prototype.precompileNode = function(node, path, factories) {
}
};
nglr.Binder.prototype.ng_eval = function(node) {
return new nglr.EvalUpdater(node, node.getAttribute('ng-eval'));
Binder.prototype.ng_eval = function(node) {
return new EvalUpdater(node, node.getAttribute('ng-eval'));
};
nglr.Binder.prototype.ng_bind = function(node) {
return new nglr.BindUpdater(node, "{{" + node.getAttribute('ng-bind') + "}}");
Binder.prototype.ng_bind = function(node) {
return new BindUpdater(node, "{{" + node.getAttribute('ng-bind') + "}}");
};
nglr.Binder.prototype.ng_bind_attr = function(node) {
return new nglr.BindAttrUpdater(node, nglr.fromJson(node.getAttribute('ng-bind-attr')));
Binder.prototype.ng_bind_attr = function(node) {
return new BindAttrUpdater(node, fromJson(node.getAttribute('ng-bind-attr')));
};
nglr.Binder.prototype.ng_hide = function(node) {
return new nglr.HideUpdater(node, node.getAttribute('ng-hide'));
Binder.prototype.ng_hide = function(node) {
return new HideUpdater(node, node.getAttribute('ng-hide'));
};
nglr.Binder.prototype.ng_show = function(node) {
return new nglr.ShowUpdater(node, node.getAttribute('ng-show'));
Binder.prototype.ng_show = function(node) {
return new ShowUpdater(node, node.getAttribute('ng-show'));
};
nglr.Binder.prototype.ng_class = function(node) {
return new nglr.ClassUpdater(node, node.getAttribute('ng-class'));
Binder.prototype.ng_class = function(node) {
return new ClassUpdater(node, node.getAttribute('ng-class'));
};
nglr.Binder.prototype.ng_class_even = function(node) {
return new nglr.ClassEvenUpdater(node, node.getAttribute('ng-class-even'));
Binder.prototype.ng_class_even = function(node) {
return new ClassEvenUpdater(node, node.getAttribute('ng-class-even'));
};
nglr.Binder.prototype.ng_class_odd = function(node) {
return new nglr.ClassOddUpdater(node, node.getAttribute('ng-class-odd'));
Binder.prototype.ng_class_odd = function(node) {
return new ClassOddUpdater(node, node.getAttribute('ng-class-odd'));
};
nglr.Binder.prototype.ng_style = function(node) {
return new nglr.StyleUpdater(node, node.getAttribute('ng-style'));
Binder.prototype.ng_style = function(node) {
return new StyleUpdater(node, node.getAttribute('ng-style'));
};
nglr.Binder.prototype.ng_watch = function(node, scope) {
Binder.prototype.ng_watch = function(node, scope) {
scope.watch(node.getAttribute('ng-watch'));
};

View file

@ -1,16 +1,16 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
nglr.ControlBar = function (document, serverUrl) {
ControlBar = function (document, serverUrl) {
this.document = document;
this.serverUrl = serverUrl;
this.window = window;
this.callbacks = [];
};
nglr.ControlBar.prototype.bind = function () {
ControlBar.prototype.bind = function () {
};
nglr.ControlBar.HTML =
ControlBar.HTML =
'<div>' +
'<div class="ui-widget-overlay"></div>' +
'<div id="ng-login" ng-non-bindable="true">' +
@ -18,25 +18,25 @@ nglr.ControlBar.HTML =
'</div>' +
'</div>';
nglr.ControlBar.prototype.login = function (loginSubmitFn) {
ControlBar.prototype.login = function (loginSubmitFn) {
this.callbacks.push(loginSubmitFn);
if (this.callbacks.length == 1) {
this.doTemplate("/user_session/new.mini?return_url=" + encodeURIComponent(this.urlWithoutAnchor()));
}
};
nglr.ControlBar.prototype.logout = function (loginSubmitFn) {
ControlBar.prototype.logout = function (loginSubmitFn) {
this.callbacks.push(loginSubmitFn);
if (this.callbacks.length == 1) {
this.doTemplate("/user_session/do_destroy.mini");
}
};
nglr.ControlBar.prototype.urlWithoutAnchor = function (path) {
ControlBar.prototype.urlWithoutAnchor = function (path) {
return this.window.location.href.split("#")[0];
};
nglr.ControlBar.prototype.doTemplate = function (path) {
ControlBar.prototype.doTemplate = function (path) {
var self = this;
var id = new Date().getTime();
var url = this.urlWithoutAnchor();
@ -49,7 +49,7 @@ nglr.ControlBar.prototype.doTemplate = function (path) {
resizable: false, modal:true,
title: 'Authentication: <a href="http://www.getangular.com"><tt>&lt;angular/&gt;</tt></a>'
});
nglr["_iframe_notify_" + id] = function() {
callbacks["_iframe_notify_" + id] = function() {
loginView.dialog("destroy");
loginView.remove();
jQuery.each(self.callbacks, function(i, callback){
@ -59,13 +59,13 @@ nglr.ControlBar.prototype.doTemplate = function (path) {
};
};
nglr.ControlBar.FORBIDEN =
ControlBar.FORBIDEN =
'<div ng-non-bindable="true" title="Permission Error:">' +
'Sorry, you do not have permission for this!'+
'</div>';
nglr.ControlBar.prototype.notAuthorized = function () {
ControlBar.prototype.notAuthorized = function () {
if (this.forbidenView) return;
this.forbidenView = jQuery(nglr.ControlBar.FORBIDEN);
this.forbidenView = jQuery(ControlBar.FORBIDEN);
this.forbidenView.dialog({bgiframe:true, height:70, modal:true});
};

View file

@ -1,6 +1,6 @@
// Copyright (C) 2009 BRAT Tech LLC
nglr.DataStore = function(post, users, anchor) {
DataStore = function(post, users, anchor) {
this.post = post;
this.users = users;
this._cache = {$collections:[]};
@ -8,14 +8,14 @@ nglr.DataStore = function(post, users, anchor) {
this.bulkRequest = [];
};
nglr.DataStore.prototype.cache = function(document) {
if (document.constructor != nglr.Model) {
throw "Parameter must be an instance of Entity! " + nglr.toJson(document);
DataStore.prototype.cache = function(document) {
if (document.constructor != Model) {
throw "Parameter must be an instance of Entity! " + toJson(document);
}
var key = document.$entity + '/' + document.$id;
var cachedDocument = this._cache[key];
if (cachedDocument) {
nglr.Model.copyDirectFields(document, cachedDocument);
Model.copyDirectFields(document, cachedDocument);
} else {
this._cache[key] = document;
cachedDocument = document;
@ -23,7 +23,7 @@ nglr.DataStore.prototype.cache = function(document) {
return cachedDocument;
};
nglr.DataStore.prototype.load = function(instance, id, callback, failure) {
DataStore.prototype.load = function(instance, id, callback, failure) {
if (id && id !== '*') {
var self = this;
this._jsonRequest(["GET", instance.$entity + "/" + id], function(response) {
@ -31,13 +31,13 @@ nglr.DataStore.prototype.load = function(instance, id, callback, failure) {
instance.$migrate();
var clone = instance.$$entity(instance);
self.cache(clone);
(callback||nglr.noop)(instance);
(callback||noop)(instance);
}, failure);
}
return instance;
};
nglr.DataStore.prototype.loadMany = function(entity, ids, callback) {
DataStore.prototype.loadMany = function(entity, ids, callback) {
var self=this;
var list = [];
var callbackCount = 0;
@ -45,26 +45,26 @@ nglr.DataStore.prototype.loadMany = function(entity, ids, callback) {
list.push(self.load(entity(), id, function(){
callbackCount++;
if (callbackCount == ids.length) {
(callback||nglr.noop)(list);
(callback||noop)(list);
}
}));
});
return list;
}
nglr.DataStore.prototype.loadOrCreate = function(instance, id, callback) {
DataStore.prototype.loadOrCreate = function(instance, id, callback) {
var self=this;
return this.load(instance, id, callback, function(response){
if (response.$status_code == 404) {
instance.$id = id;
(callback||nglr.noop)(instance);
(callback||noop)(instance);
} else {
throw response;
}
});
};
nglr.DataStore.prototype.loadAll = function(entity, callback) {
DataStore.prototype.loadAll = function(entity, callback) {
var self = this;
var list = [];
list.$$accept = function(doc){
@ -78,12 +78,12 @@ nglr.DataStore.prototype.loadAll = function(entity, callback) {
document.$loadFrom(rows[i]);
list.push(self.cache(document));
}
(callback||nglr.noop)(list);
(callback||noop)(list);
});
return list;
};
nglr.DataStore.prototype.save = function(document, callback) {
DataStore.prototype.save = function(document, callback) {
var self = this;
var data = {};
document.$saveTo(data);
@ -103,7 +103,7 @@ nglr.DataStore.prototype.save = function(document, callback) {
});
};
nglr.DataStore.prototype.remove = function(document, callback) {
DataStore.prototype.remove = function(document, callback) {
var self = this;
var data = {};
document.$saveTo(data);
@ -117,11 +117,11 @@ nglr.DataStore.prototype.remove = function(document, callback) {
}
}
});
(callback||nglr.noop)(response);
(callback||noop)(response);
});
};
nglr.DataStore.prototype._jsonRequest = function(request, callback, failure) {
DataStore.prototype._jsonRequest = function(request, callback, failure) {
request.$$callback = callback;
request.$$failure = failure||function(response){
throw response;
@ -129,7 +129,7 @@ nglr.DataStore.prototype._jsonRequest = function(request, callback, failure) {
this.bulkRequest.push(request);
};
nglr.DataStore.prototype.flush = function() {
DataStore.prototype.flush = function() {
if (this.bulkRequest.length === 0) return;
var self = this;
var bulkRequest = this.bulkRequest;
@ -142,7 +142,7 @@ nglr.DataStore.prototype.flush = function() {
self.post(bulkRequest, callback);
});
} else if(bulkResponse.$status_code) {
nglr.alert(nglr.toJson(bulkResponse));
alert(toJson(bulkResponse));
} else {
for ( var i = 0; i < bulkResponse.length; i++) {
var response = bulkResponse[i];
@ -163,7 +163,7 @@ nglr.DataStore.prototype.flush = function() {
this.post(bulkRequest, callback);
};
nglr.DataStore.prototype.saveScope = function(scope, callback) {
DataStore.prototype.saveScope = function(scope, callback) {
var saveCounter = 1;
function onSaveDone() {
saveCounter--;
@ -172,7 +172,7 @@ nglr.DataStore.prototype.saveScope = function(scope, callback) {
}
for(var key in scope) {
var item = scope[key];
if (item && item.$save == nglr.Model.prototype.$save) {
if (item && item.$save == Model.prototype.$save) {
saveCounter++;
item.$save(onSaveDone);
}
@ -180,7 +180,7 @@ nglr.DataStore.prototype.saveScope = function(scope, callback) {
onSaveDone();
};
nglr.DataStore.prototype.query = function(type, query, arg, callback){
DataStore.prototype.query = function(type, query, arg, callback){
var self = this;
var queryList = [];
queryList.$$accept = function(doc){
@ -200,7 +200,7 @@ nglr.DataStore.prototype.query = function(type, query, arg, callback){
return queryList;
};
nglr.DataStore.prototype.entities = function(callback) {
DataStore.prototype.entities = function(callback) {
var entities = [];
var self = this;
this._jsonRequest(["GET", "$entities"], function(response) {
@ -213,7 +213,7 @@ nglr.DataStore.prototype.entities = function(callback) {
return entities;
};
nglr.DataStore.prototype.documentCountsByUser = function(){
DataStore.prototype.documentCountsByUser = function(){
var counts = {};
var self = this;
self.post([["GET", "$users"]], function(code, response){
@ -224,7 +224,7 @@ nglr.DataStore.prototype.documentCountsByUser = function(){
return counts;
};
nglr.DataStore.prototype.userDocumentIdsByEntity = function(user){
DataStore.prototype.userDocumentIdsByEntity = function(user){
var ids = {};
var self = this;
self.post([["GET", "$users/" + user]], function(code, response){
@ -235,19 +235,19 @@ nglr.DataStore.prototype.userDocumentIdsByEntity = function(user){
return ids;
};
nglr.DataStore.NullEntity = function(){};
nglr.DataStore.NullEntity.all = function(){return [];};
nglr.DataStore.NullEntity.query = function(){return [];};
nglr.DataStore.NullEntity.load = function(){return {};};
nglr.DataStore.NullEntity.title = undefined;
DataStore.NullEntity = function(){};
DataStore.NullEntity.all = function(){return [];};
DataStore.NullEntity.query = function(){return [];};
DataStore.NullEntity.load = function(){return {};};
DataStore.NullEntity.title = undefined;
nglr.DataStore.prototype.entity = function(name, defaults){
DataStore.prototype.entity = function(name, defaults){
if (!name) {
return nglr.DataStore.NullEntity;
return DataStore.NullEntity;
}
var self = this;
var entity = function(initialState){
return new nglr.Model(entity, initialState);
return new Model(entity, initialState);
};
// entity.name does not work as name seems to be reserved for functions
entity.title = name;
@ -275,7 +275,7 @@ nglr.DataStore.prototype.entity = function(name, defaults){
return entity;
};
nglr.DataStore.prototype.join = function(join){
DataStore.prototype.join = function(join){
var fn = function(){
throw "Joined entities can not be instantiated into a document.";
};
@ -312,7 +312,7 @@ nglr.DataStore.prototype.join = function(join){
var row = {};
joinedResult.push(row);
row[baseName] = doc;
var id = nglr.Scope.getter(row, nextJoinOn);
var id = Scope.getter(row, nextJoinOn);
joinIds[id] = id;
});
nextJoin.join.loadMany(_.toArray(joinIds), function(result){
@ -321,7 +321,7 @@ nglr.DataStore.prototype.join = function(join){
byId[doc.$id] = doc;
});
_(joinedResult).each(function(row){
var id = nglr.Scope.getter(row, nextJoinOn);
var id = Scope.getter(row, nextJoinOn);
row[nextJoinName] = byId[id];
});
});

View file

@ -60,11 +60,11 @@ angular.filter.date = function(amount) {
angular.filter.json = function(object) {
jQuery(this.element).addClass("ng-monospace");
return nglr.toJson(object, true);
return toJson(object, true);
};
angular.filter.trackPackage = function(trackingNo, noMatch) {
trackingNo = nglr.trim(trackingNo);
trackingNo = trim(trackingNo);
var tNo = trackingNo.replace(/ /g, '');
var MATCHERS = angular.filter.trackPackage.MATCHERS;
for ( var i = 0; i < MATCHERS.length; i++) {
@ -77,7 +77,7 @@ angular.filter.trackPackage = function(trackingNo, noMatch) {
return new angular.filter.Meta({
text:text,
url:url,
html: '<a href="' + nglr.escapeAttr(url) + '">' + text + '</a>',
html: '<a href="' + escapeAttr(url) + '">' + text + '</a>',
trackingNo:trackingNo});
}
}
@ -115,7 +115,7 @@ angular.filter.link = function(obj, title) {
if (angular.validator.email(url) === null) {
url = "mailto:" + url;
}
var html = '<a href="' + nglr.escapeHtml(url) + '">' + text + '</a>';
var html = '<a href="' + escapeHtml(url) + '">' + text + '</a>';
return new angular.filter.Meta({text:text, url:url, html:html});
}
return obj;

View file

@ -1,18 +1,18 @@
nglr.array = [].constructor;
array = [].constructor;
nglr.toJson = function(obj, pretty){
toJson = function(obj, pretty){
var buf = [];
nglr.toJsonArray(buf, obj, pretty ? "\n " : null);
toJsonArray(buf, obj, pretty ? "\n " : null);
return buf.join('');
};
nglr.toPrettyJson = function(obj) {
return nglr.toJson(obj, true);
toPrettyJson = function(obj) {
return toJson(obj, true);
};
nglr.fromJson = function(json) {
fromJson = function(json) {
try {
var parser = new nglr.Parser(json, true);
var parser = new Parser(json, true);
var expression = parser.primary();
parser.assertAllConsumed();
return expression();
@ -23,7 +23,7 @@ nglr.fromJson = function(json) {
};
nglr.toJsonArray = function(buf, obj, pretty){
toJsonArray = function(buf, obj, pretty){
var type = typeof obj;
if (obj === null) {
buf.push("null");
@ -50,7 +50,7 @@ nglr.toJsonArray = function(buf, obj, pretty){
if (typeof item == 'function' || typeof item == 'undefined') {
buf.push("null");
} else {
nglr.toJsonArray(buf, item, pretty);
toJsonArray(buf, item, pretty);
}
sep = true;
}
@ -80,7 +80,7 @@ nglr.toJsonArray = function(buf, obj, pretty){
}
buf.push(angular.String.quote(key));
buf.push(":");
nglr.toJsonArray(buf, value, childPretty);
toJsonArray(buf, value, childPretty);
comma = true;
}
} catch (e) {

View file

@ -22,34 +22,37 @@ if (typeof Node == 'undefined') {
};
}
if (_.isUndefined(window.nglr)) nglr = {};
if (_.isUndefined(window.angular)) angular = {};
if (_.isUndefined(angular.validator)) angular.validator = {};
if (_.isUndefined(angular.filter)) angular.filter = {};
if (_.isUndefined(window.console))
var callbacks = {};
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 (_.isUndefined(nglr.alert)) {
nglr.alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
if (_.isUndefined(alert)) {
alert = function(){console.log(arguments); window.alert.apply(window, arguments); };
}
nglr.consoleLog = function(level, objs) {
var consoleNode;
consoleLog = function(level, objs) {
var log = document.createElement("div");
log.className = level;
var msg = "";
var sep = "";
for ( var i = 0; i < objs.length; i++) {
var obj = objs[i];
msg += sep + (typeof obj == 'string' ? obj : nglr.toJson(obj));
msg += sep + (typeof obj == 'string' ? obj : toJson(obj));
sep = " ";
}
log.appendChild(document.createTextNode(msg));
nglr.consoleNode.appendChild(log);
consoleNode.appendChild(log);
};
nglr.isNode = function(inp) {
isNode = function(inp) {
return inp &&
inp.tagName &&
inp.nodeName &&
@ -57,7 +60,7 @@ nglr.isNode = function(inp) {
inp.removeAttribute;
};
nglr.isLeafNode = function(node) {
isLeafNode = function(node) {
switch (node.nodeName) {
case "OPTION":
case "PRE":
@ -68,11 +71,11 @@ nglr.isLeafNode = function(node) {
}
};
nglr.noop = function() {
noop = function() {
};
nglr.setHtml = function(node, html) {
if (nglr.isLeafNode(node)) {
if (nglr.msie) {
setHtml = function(node, html) {
if (isLeafNode(node)) {
if (msie) {
node.innerText = html;
} else {
node.textContent = html;
@ -82,7 +85,7 @@ nglr.setHtml = function(node, html) {
}
};
nglr.escapeHtml = function(html) {
escapeHtml = function(html) {
if (!html || !html.replace)
return html;
return html.
@ -91,14 +94,14 @@ nglr.escapeHtml = function(html) {
replace(/>/g, '&gt;');
};
nglr.escapeAttr = function(html) {
escapeAttr = function(html) {
if (!html || !html.replace)
return html;
return html.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g,
'&quot;');
};
nglr.bind = function(_this, _function) {
bind = function(_this, _function) {
if (!_this)
throw "Missing this";
if (!_.isFunction(_function))
@ -108,7 +111,7 @@ nglr.bind = function(_this, _function) {
};
};
nglr.shiftBind = function(_this, _function) {
shiftBind = function(_this, _function) {
return function() {
var args = [ this ];
for ( var i = 0; i < arguments.length; i++) {
@ -118,7 +121,7 @@ nglr.shiftBind = function(_this, _function) {
};
};
nglr.outerHTML = function(node) {
outerHTML = function(node) {
var temp = document.createElement('div');
temp.appendChild(node);
var outerHTML = temp.innerHTML;
@ -126,26 +129,26 @@ nglr.outerHTML = function(node) {
return outerHTML;
};
nglr.trim = function(str) {
trim = function(str) {
return str.replace(/^ */, '').replace(/ *$/, '');
};
nglr.toBoolean = function(value) {
toBoolean = function(value) {
var v = ("" + value).toLowerCase();
if (v == 'f' || v == '0' || v == 'false' || v == 'no')
value = false;
return !!value;
};
nglr.merge = function(src, dst) {
merge = function(src, dst) {
for ( var key in src) {
var value = dst[key];
var type = typeof value;
if (type == 'undefined') {
dst[key] = nglr.fromJson(nglr.toJson(src[key]));
} else if (type == 'object' && value.constructor != nglr.array &&
dst[key] = fromJson(toJson(src[key]));
} else if (type == 'object' && value.constructor != array &&
key.substring(0, 1) != "$") {
nglr.merge(src[key], value);
merge(src[key], value);
}
}
};
@ -154,25 +157,25 @@ nglr.merge = function(src, dst) {
// Loader
// ////////////////////////////
nglr.Loader = function(document, head, config) {
Loader = function(document, head, config) {
this.document = jQuery(document);
this.head = jQuery(head);
this.config = config;
this.location = window.location;
};
nglr.Loader.prototype.load = function() {
Loader.prototype.load = function() {
this.configureLogging();
this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css');
this.loadCss('/stylesheets/nglr.css');
this.loadCss('/stylesheets/css');
console.log("Server: " + this.config.server);
nglr.msie = jQuery.browser.msie;
msie = jQuery.browser.msie;
this.configureJQueryPlugins();
this.computeConfiguration();
this.bindHtml();
};
nglr.Loader.prototype.configureJQueryPlugins = function() {
Loader.prototype.configureJQueryPlugins = function() {
console.log('Loader.configureJQueryPlugins()');
jQuery.fn.removeNode = function() {
var node = this.get(0);
@ -189,15 +192,15 @@ nglr.Loader.prototype.configureJQueryPlugins = function() {
return null;
};
jQuery.fn.controller = function() {
return this.data('controller') || nglr.NullController.instance;
return this.data('controller') || NullController.instance;
};
};
nglr.Loader.prototype.uid = function() {
Loader.prototype.uid = function() {
return "" + new Date().getTime();
};
nglr.Loader.prototype.computeConfiguration = function() {
Loader.prototype.computeConfiguration = function() {
var config = this.config;
if (!config.database) {
var match = config.server.match(/https?:\/\/([\w]*)/);
@ -205,27 +208,27 @@ nglr.Loader.prototype.computeConfiguration = function() {
}
};
nglr.Loader.prototype.bindHtml = function() {
Loader.prototype.bindHtml = function() {
console.log('Loader.bindHtml()');
var watcher = new nglr.UrlWatcher(this.location);
var watcher = new UrlWatcher(this.location);
var document = this.document;
var widgetFactory = new nglr.WidgetFactory(this.config.server, this.config.database);
var binder = new nglr.Binder(document[0], widgetFactory, watcher, this.config);
widgetFactory.onChangeListener = nglr.shiftBind(binder, binder.updateModel);
var controlBar = new nglr.ControlBar(document.find('body'), this.config.server);
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 nglr.FrameServer(this.window) :
new nglr.Server(this.config.server, jQuery.getScript);
server = new nglr.VisualServer(server, new nglr.Status(jQuery(document.body)), onUpdate);
var users = new nglr.Users(server, controlBar);
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 nglr.DataStore(post, users, binder.anchor);
var datastore = new DataStore(post, users, binder.anchor);
binder.updateListeners.push(function(){datastore.flush();});
var scope = new nglr.Scope( {
var scope = new Scope( {
$anchor : binder.anchor,
$binder : binder,
$config : this.config,
@ -241,7 +244,7 @@ nglr.Loader.prototype.bindHtml = function() {
jQuery.each(["get", "set", "eval", "addWatchListener", "updateView"],
function(i, method){
angular[method] = nglr.bind(scope, scope[method]);
angular[method] = bind(scope, scope[method]);
});
document.data('scope', scope);
@ -265,7 +268,7 @@ nglr.Loader.prototype.bindHtml = function() {
fetchCurrentUser();
console.log('PopUp.bind()');
new nglr.PopUp(document).bind();
new PopUp(document).bind();
console.log('$binder.parseAnchor()');
binder.parseAnchor();
@ -276,16 +279,16 @@ nglr.Loader.prototype.bindHtml = function() {
console.log('$binder.updateView()');
binder.updateView();
watcher.listener = nglr.bind(binder, binder.onUrlChange, watcher);
watcher.onUpdate = function(){nglr.alert("update");};
watcher.listener = bind(binder, binder.onUrlChange, watcher);
watcher.onUpdate = function(){alert("update");};
watcher.watch();
document.find("body").show();
console.log('ready()');
};
nglr.Loader.prototype.visualPost = function(delegate) {
var status = new nglr.Status(jQuery(document.body));
Loader.prototype.visualPost = function(delegate) {
var status = new Status(jQuery(document.body));
return function(request, delegateCallback) {
status.beginRequest(request);
var callback = function() {
@ -293,14 +296,14 @@ nglr.Loader.prototype.visualPost = function(delegate) {
try {
delegateCallback.apply(this, arguments);
} catch (e) {
nglr.alert(nglr.toJson(e));
alert(toJson(e));
}
};
delegate(request, callback);
};
};
nglr.Loader.prototype.configureLogging = function() {
Loader.prototype.configureLogging = function() {
var url = window.location.href + '#';
url = url.split('#')[1];
var config = {
@ -312,19 +315,19 @@ nglr.Loader.prototype.configureLogging = function() {
config[part[0]] = part[1];
}
if (config.debug == 'console') {
nglr.consoleNode = document.createElement("div");
nglr.consoleNode.id = 'ng-console';
document.getElementsByTagName('body')[0].appendChild(nglr.consoleNode);
consoleNode = document.createElement("div");
consoleNode.id = 'ng-console';
document.getElementsByTagName('body')[0].appendChild(consoleNode);
console.log = function() {
nglr.consoleLog('ng-console-info', arguments);
consoleLog('ng-console-info', arguments);
};
console.error = function() {
nglr.consoleLog('ng-console-error', arguments);
consoleLog('ng-console-error', arguments);
};
}
};
nglr.Loader.prototype.loadCss = function(css) {
Loader.prototype.loadCss = function(css) {
var cssTag = document.createElement('link');
cssTag.rel = "stylesheet";
cssTag.type = "text/css";
@ -334,7 +337,7 @@ nglr.Loader.prototype.loadCss = function(css) {
this.head[0].appendChild(cssTag);
};
nglr.UrlWatcher = function(location) {
UrlWatcher = function(location) {
this.location = location;
this.delay = 25;
this.setTimeout = function(fn, delay) {
@ -346,7 +349,7 @@ nglr.UrlWatcher = function(location) {
this.expectedUrl = location.href;
};
nglr.UrlWatcher.prototype.watch = function() {
UrlWatcher.prototype.watch = function() {
var self = this;
var pull = function() {
if (self.expectedUrl !== self.location.href) {
@ -357,12 +360,12 @@ nglr.UrlWatcher.prototype.watch = function() {
}
self.location.href = self.expectedUrl;
var id = '_iframe_notify_' + notify[1];
var notifyFn = nglr[id];
delete nglr[id];
var notifyFn = callbacks[id];
delete callbacks[id];
try {
(notifyFn||nglr.noop)();
(notifyFn||noop)();
} catch (e) {
nglr.alert(e);
alert(e);
}
} else {
self.listener(self.location.href);
@ -374,16 +377,16 @@ nglr.UrlWatcher.prototype.watch = function() {
pull();
};
nglr.UrlWatcher.prototype.setUrl = function(url) {
UrlWatcher.prototype.setUrl = function(url) {
var existingURL = window.location.href;
if (!existingURL.match(/#/))
existingURL += '#';
if (existingURL != url)
window.location.href = url;
self.existingURL = url;
this.existingURL = url;
};
nglr.UrlWatcher.prototype.getUrl = function() {
UrlWatcher.prototype.getUrl = function() {
return window.location.href;
};
@ -394,7 +397,7 @@ angular['compile'] = function(root, config) {
};
//todo: don't load stylesheet by default
//todo: don't start watcher
var loader = new nglr.Loader(root, jQuery("head"), _(defaults).extend(config));
var loader = new Loader(root, jQuery("head"), _(defaults).extend(config));
loader.load();
return jQuery(root).scope();
};

View file

@ -3,14 +3,14 @@
// Single $ is special and does not get searched
// Double $$ is special an is client only (does not get sent to server)
nglr.Model = function(entity, initial) {
Model = function(entity, initial) {
this.$$entity = entity;
this.$loadFrom(initial||{});
this.$entity = entity.title;
this.$migrate();
};
nglr.Model.copyDirectFields = function(src, dst) {
Model.copyDirectFields = function(src, dst) {
if (src === dst || !src || !dst) return;
var isDataField = function(src, dst, field) {
return (field.substring(0,2) !== '$$') &&
@ -27,39 +27,39 @@ nglr.Model.copyDirectFields = function(src, dst) {
}
};
nglr.Model.prototype.$migrate = function() {
nglr.merge(this.$$entity.defaults, this);
Model.prototype.$migrate = function() {
merge(this.$$entity.defaults, this);
return this;
};
nglr.Model.prototype.$merge = function(other) {
nglr.merge(other, this);
Model.prototype.$merge = function(other) {
merge(other, this);
return this;
};
nglr.Model.prototype.$save = function(callback) {
Model.prototype.$save = function(callback) {
this.$$entity.datastore.save(this, callback === true ? undefined : callback);
if (callback === true) this.$$entity.datastore.flush();
return this;
};
nglr.Model.prototype.$delete = function(callback) {
Model.prototype.$delete = function(callback) {
this.$$entity.datastore.remove(this, callback === true ? undefined : callback);
if (callback === true) this.$$entity.datastore.flush();
return this;
};
nglr.Model.prototype.$loadById = function(id, callback) {
Model.prototype.$loadById = function(id, callback) {
this.$$entity.datastore.load(this, id, callback);
return this;
};
nglr.Model.prototype.$loadFrom = function(other) {
nglr.Model.copyDirectFields(other, this);
Model.prototype.$loadFrom = function(other) {
Model.copyDirectFields(other, this);
return this;
};
nglr.Model.prototype.$saveTo = function(other) {
nglr.Model.copyDirectFields(this, other);
Model.prototype.$saveTo = function(other) {
Model.copyDirectFields(this, other);
return this;
};

View file

@ -1,4 +1,4 @@
nglr.Lexer = function(text, parsStrings){
Lexer = function(text, parsStrings){
this.text = text;
// UTC dates have 20 characters, we send them through parser
this.dateParseLength = parsStrings ? 20 : -1;
@ -6,7 +6,7 @@ nglr.Lexer = function(text, parsStrings){
this.index = 0;
};
nglr.Lexer.OPERATORS = {
Lexer.OPERATORS = {
'null':function(self){return null;},
'true':function(self){return true;},
'false':function(self){return false;},
@ -31,7 +31,7 @@ nglr.Lexer.OPERATORS = {
'!':function(self, a){return !a;}
};
nglr.Lexer.prototype.peek = function() {
Lexer.prototype.peek = function() {
if (this.index + 1 < this.text.length) {
return this.text.charAt(this.index + 1);
} else {
@ -39,9 +39,9 @@ nglr.Lexer.prototype.peek = function() {
}
};
nglr.Lexer.prototype.parse = function() {
Lexer.prototype.parse = function() {
var tokens = this.tokens;
var OPERATORS = nglr.Lexer.OPERATORS;
var OPERATORS = Lexer.OPERATORS;
var canStartRegExp = true;
while (this.index < this.text.length) {
var ch = this.text.charAt(this.index);
@ -102,22 +102,22 @@ nglr.Lexer.prototype.parse = function() {
return tokens;
};
nglr.Lexer.prototype.isNumber = function(ch) {
Lexer.prototype.isNumber = function(ch) {
return '0' <= ch && ch <= '9';
};
nglr.Lexer.prototype.isWhitespace = function(ch) {
Lexer.prototype.isWhitespace = function(ch) {
return ch == ' ' || ch == '\r' || ch == '\t' ||
ch == '\n' || ch == '\v';
};
nglr.Lexer.prototype.isIdent = function(ch) {
Lexer.prototype.isIdent = function(ch) {
return 'a' <= ch && ch <= 'z' ||
'A' <= ch && ch <= 'Z' ||
'_' == ch || ch == '$';
};
nglr.Lexer.prototype.readNumber = function() {
Lexer.prototype.readNumber = function() {
var number = "";
var start = this.index;
while (this.index < this.text.length) {
@ -134,7 +134,7 @@ nglr.Lexer.prototype.readNumber = function() {
fn:function(){return number;}});
};
nglr.Lexer.prototype.readIdent = function() {
Lexer.prototype.readIdent = function() {
var ident = "";
var start = this.index;
while (this.index < this.text.length) {
@ -146,7 +146,7 @@ nglr.Lexer.prototype.readIdent = function() {
}
this.index++;
}
var fn = nglr.Lexer.OPERATORS[ident];
var fn = Lexer.OPERATORS[ident];
if (!fn) {
fn = function(self){
return self.scope.get(ident);
@ -155,8 +155,8 @@ nglr.Lexer.prototype.readIdent = function() {
}
this.tokens.push({index:start, text:ident, fn:fn});
};
nglr.Lexer.ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'};
nglr.Lexer.prototype.readString = function(quote) {
Lexer.ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'};
Lexer.prototype.readString = function(quote) {
var start = this.index;
var dateParseLength = this.dateParseLength;
this.index++;
@ -170,7 +170,7 @@ nglr.Lexer.prototype.readString = function(quote) {
this.index += 4;
string += String.fromCharCode(parseInt(hex, 16));
} else {
var rep = nglr.Lexer.ESCAPE[ch];
var rep = Lexer.ESCAPE[ch];
if (rep) {
string += rep;
} else {
@ -198,7 +198,7 @@ nglr.Lexer.prototype.readString = function(quote) {
(start+1) + "' in expression '" + this.text + "'.";
};
nglr.Lexer.prototype.readRegexp = function(quote) {
Lexer.prototype.readRegexp = function(quote) {
var start = this.index;
this.index++;
var regexp = "";
@ -233,30 +233,30 @@ nglr.Lexer.prototype.readRegexp = function(quote) {
};
nglr.Parser = function(text, parseStrings){
Parser = function(text, parseStrings){
this.text = text;
this.tokens = new nglr.Lexer(text, parseStrings).parse();
this.tokens = new Lexer(text, parseStrings).parse();
this.index = 0;
};
nglr.Parser.ZERO = function(){
Parser.ZERO = function(){
return 0;
};
nglr.Parser.prototype.error = function(msg, token) {
Parser.prototype.error = function(msg, token) {
throw "Token '" + token.text +
"' is " + msg + " at column='" +
(token.index + 1) + "' of expression '" +
this.text + "' starting at '" + this.text.substring(token.index) + "'.";
};
nglr.Parser.prototype.peekToken = function() {
Parser.prototype.peekToken = function() {
if (this.tokens.length === 0)
throw "Unexpected end of expression: " + this.text;
return this.tokens[0];
};
nglr.Parser.prototype.peek = function(e1, e2, e3, e4) {
Parser.prototype.peek = function(e1, e2, e3, e4) {
var tokens = this.tokens;
if (tokens.length > 0) {
var token = tokens[0];
@ -269,7 +269,7 @@ nglr.Parser.prototype.peek = function(e1, e2, e3, e4) {
return false;
};
nglr.Parser.prototype.expect = function(e1, e2, e3, e4){
Parser.prototype.expect = function(e1, e2, e3, e4){
var token = this.peek(e1, e2, e3, e4);
if (token) {
this.tokens.shift();
@ -279,7 +279,7 @@ nglr.Parser.prototype.expect = function(e1, e2, e3, e4){
return false;
};
nglr.Parser.prototype.consume = function(e1){
Parser.prototype.consume = function(e1){
if (!this.expect(e1)) {
var token = this.peek();
throw "Expecting '" + e1 + "' at column '" +
@ -289,32 +289,32 @@ nglr.Parser.prototype.consume = function(e1){
}
};
nglr.Parser.prototype._unary = function(fn, parse) {
Parser.prototype._unary = function(fn, parse) {
var right = parse.apply(this);
return function(self) {
return fn(self, right(self));
};
};
nglr.Parser.prototype._binary = function(left, fn, parse) {
Parser.prototype._binary = function(left, fn, parse) {
var right = parse.apply(this);
return function(self) {
return fn(self, left(self), right(self));
};
};
nglr.Parser.prototype.hasTokens = function () {
Parser.prototype.hasTokens = function () {
return this.tokens.length > 0;
};
nglr.Parser.prototype.assertAllConsumed = function(){
Parser.prototype.assertAllConsumed = function(){
if (this.tokens.length !== 0) {
throw "Did not understand '" + this.text.substring(this.tokens[0].index) +
"' while evaluating '" + this.text + "'.";
}
};
nglr.Parser.prototype.statements = function(){
Parser.prototype.statements = function(){
var statements = [];
while(true) {
if (this.tokens.length > 0 && !this.peek('}', ')', ';', ']'))
@ -333,7 +333,7 @@ nglr.Parser.prototype.statements = function(){
}
};
nglr.Parser.prototype.filterChain = function(){
Parser.prototype.filterChain = function(){
var left = this.expression();
var token;
while(true) {
@ -345,15 +345,15 @@ nglr.Parser.prototype.filterChain = function(){
}
};
nglr.Parser.prototype.filter = function(){
Parser.prototype.filter = function(){
return this._pipeFunction(angular.filter);
};
nglr.Parser.prototype.validator = function(){
Parser.prototype.validator = function(){
return this._pipeFunction(angular.validator);
};
nglr.Parser.prototype._pipeFunction = function(fnScope){
Parser.prototype._pipeFunction = function(fnScope){
var fn = this.functionIdent(fnScope);
var argsFn = [];
var token;
@ -375,11 +375,11 @@ nglr.Parser.prototype._pipeFunction = function(fnScope){
}
};
nglr.Parser.prototype.expression = function(){
Parser.prototype.expression = function(){
return this.throwStmt();
};
nglr.Parser.prototype.throwStmt = function(){
Parser.prototype.throwStmt = function(){
if (this.expect('throw')) {
var throwExp = this.assignment();
return function (self) {
@ -390,7 +390,7 @@ nglr.Parser.prototype.throwStmt = function(){
}
};
nglr.Parser.prototype.assignment = function(){
Parser.prototype.assignment = function(){
var left = this.logicalOR();
var token;
if (token = this.expect('=')) {
@ -406,7 +406,7 @@ nglr.Parser.prototype.assignment = function(){
}
};
nglr.Parser.prototype.logicalOR = function(){
Parser.prototype.logicalOR = function(){
var left = this.logicalAND();
var token;
while(true) {
@ -418,7 +418,7 @@ nglr.Parser.prototype.logicalOR = function(){
}
};
nglr.Parser.prototype.logicalAND = function(){
Parser.prototype.logicalAND = function(){
var left = this.negated();
var token;
while(true) {
@ -430,7 +430,7 @@ nglr.Parser.prototype.logicalAND = function(){
}
};
nglr.Parser.prototype.negated = function(){
Parser.prototype.negated = function(){
var token;
if (token = this.expect('!')) {
return this._unary(token.fn, this.equality);
@ -439,7 +439,7 @@ nglr.Parser.prototype.negated = function(){
}
};
nglr.Parser.prototype.equality = function(){
Parser.prototype.equality = function(){
var left = this.relational();
var token;
while(true) {
@ -451,7 +451,7 @@ nglr.Parser.prototype.equality = function(){
}
};
nglr.Parser.prototype.relational = function(){
Parser.prototype.relational = function(){
var left = this.additive();
var token;
while(true) {
@ -463,7 +463,7 @@ nglr.Parser.prototype.relational = function(){
}
};
nglr.Parser.prototype.additive = function(){
Parser.prototype.additive = function(){
var left = this.multiplicative();
var token;
while(token = this.expect('+','-')) {
@ -472,7 +472,7 @@ nglr.Parser.prototype.additive = function(){
return left;
};
nglr.Parser.prototype.multiplicative = function(){
Parser.prototype.multiplicative = function(){
var left = this.unary();
var token;
while(token = this.expect('*','/','%')) {
@ -481,18 +481,18 @@ nglr.Parser.prototype.multiplicative = function(){
return left;
};
nglr.Parser.prototype.unary = function(){
Parser.prototype.unary = function(){
var token;
if (this.expect('+')) {
return this.primary();
} else if (token = this.expect('-')) {
return this._binary(nglr.Parser.ZERO, token.fn, this.multiplicative);
return this._binary(Parser.ZERO, token.fn, this.multiplicative);
} else {
return this.primary();
}
};
nglr.Parser.prototype.functionIdent = function(fnScope) {
Parser.prototype.functionIdent = function(fnScope) {
var token = this.expect();
var element = token.text.split('.');
var instance = fnScope;
@ -509,7 +509,7 @@ nglr.Parser.prototype.functionIdent = function(fnScope) {
return instance;
};
nglr.Parser.prototype.primary = function() {
Parser.prototype.primary = function() {
var primary;
if (this.expect('(')) {
var expression = this.filterChain();
@ -545,7 +545,7 @@ nglr.Parser.prototype.primary = function() {
return primary;
};
nglr.Parser.prototype.closure = function(hasArgs) {
Parser.prototype.closure = function(hasArgs) {
var args = [];
if (hasArgs) {
if (!this.expect(')')) {
@ -561,7 +561,7 @@ nglr.Parser.prototype.closure = function(hasArgs) {
this.consume("}");
return function(self){
return function($){
var scope = new nglr.Scope(self.scope.state);
var scope = new Scope(self.scope.state);
scope.set('$', $);
for ( var i = 0; i < args.length; i++) {
scope.set(args[i], arguments[i]);
@ -571,16 +571,16 @@ nglr.Parser.prototype.closure = function(hasArgs) {
};
};
nglr.Parser.prototype.fieldAccess = function(object) {
Parser.prototype.fieldAccess = function(object) {
var field = this.expect().text;
var fn = function (self){
return nglr.Scope.getter(object(self), field);
return Scope.getter(object(self), field);
};
fn.isAssignable = field;
return fn;
};
nglr.Parser.prototype.objectIndex = function(obj) {
Parser.prototype.objectIndex = function(obj) {
var indexFn = this.expression();
this.consume(']');
if (this.expect('=')) {
@ -597,7 +597,7 @@ nglr.Parser.prototype.objectIndex = function(obj) {
}
};
nglr.Parser.prototype.functionCall = function(fn) {
Parser.prototype.functionCall = function(fn) {
var argsFn = [];
if (this.peekToken().text != ')') {
do {
@ -620,7 +620,7 @@ nglr.Parser.prototype.functionCall = function(fn) {
};
// This is used with json array declaration
nglr.Parser.prototype.arrayDeclaration = function () {
Parser.prototype.arrayDeclaration = function () {
var elementFns = [];
if (this.peekToken().text != ']') {
do {
@ -637,7 +637,7 @@ nglr.Parser.prototype.arrayDeclaration = function () {
};
};
nglr.Parser.prototype.object = function () {
Parser.prototype.object = function () {
var keyValues = [];
if (this.peekToken().text != '}') {
do {
@ -659,7 +659,7 @@ nglr.Parser.prototype.object = function () {
};
};
nglr.Parser.prototype.entityDeclaration = function () {
Parser.prototype.entityDeclaration = function () {
var decl = [];
while(this.hasTokens()) {
decl.push(this.entityDecl());
@ -676,7 +676,7 @@ nglr.Parser.prototype.entityDeclaration = function () {
};
};
nglr.Parser.prototype.entityDecl = function () {
Parser.prototype.entityDecl = function () {
var entity = this.expect().text;
var instance;
var defaults;
@ -705,7 +705,7 @@ nglr.Parser.prototype.entityDecl = function () {
};
};
nglr.Parser.prototype.watch = function () {
Parser.prototype.watch = function () {
var decl = [];
while(this.hasTokens()) {
decl.push(this.watchDecl());
@ -722,7 +722,7 @@ nglr.Parser.prototype.watch = function () {
};
};
nglr.Parser.prototype.watchDecl = function () {
Parser.prototype.watchDecl = function () {
var anchorName = this.expect().text;
this.consume(":");
var expression;

View file

@ -1,6 +1,6 @@
// Copyright (C) 2009 BRAT Tech LLC
nglr.Scope = function(initialState, name) {
Scope = function(initialState, name) {
this.widgets = [];
this.watchListeners = {};
this.name = name;
@ -14,9 +14,9 @@ nglr.Scope = function(initialState, name) {
}
};
nglr.Scope.expressionCache = {};
Scope.expressionCache = {};
nglr.Scope.prototype.updateView = function() {
Scope.prototype.updateView = function() {
var self = this;
this.fireWatchers();
_.each(this.widgets, function(widget){
@ -26,21 +26,21 @@ nglr.Scope.prototype.updateView = function() {
});
};
nglr.Scope.prototype.addWidget = function(controller) {
Scope.prototype.addWidget = function(controller) {
if (controller) this.widgets.push(controller);
};
nglr.Scope.prototype.isProperty = function(exp) {
Scope.prototype.isProperty = function(exp) {
for ( var i = 0; i < exp.length; i++) {
var ch = exp.charAt(i);
if (ch!='.' && !nglr.Lexer.prototype.isIdent(ch)) {
if (ch!='.' && !Lexer.prototype.isIdent(ch)) {
return false;
}
}
return true;
};
nglr.Scope.getter = function(instance, path) {
Scope.getter = function(instance, path) {
if (!path) return instance;
var element = path.split('.');
var key;
@ -65,16 +65,16 @@ nglr.Scope.getter = function(instance, path) {
}
}
if (typeof instance === 'function' && !instance.$$factory) {
return nglr.bind(lastInstance, instance);
return bind(lastInstance, instance);
}
return instance;
};
nglr.Scope.prototype.get = function(path) {
return nglr.Scope.getter(this.state, path);
Scope.prototype.get = function(path) {
return Scope.getter(this.state, path);
};
nglr.Scope.prototype.set = function(path, value) {
Scope.prototype.set = function(path, value) {
var element = path.split('.');
var instance = this.state;
for ( var i = 0; element.length > 1; i++) {
@ -90,17 +90,17 @@ nglr.Scope.prototype.set = function(path, value) {
return value;
};
nglr.Scope.prototype.setEval = function(expressionText, value) {
this.eval(expressionText + "=" + nglr.toJson(value));
Scope.prototype.setEval = function(expressionText, value) {
this.eval(expressionText + "=" + toJson(value));
};
nglr.Scope.prototype.eval = function(expressionText, context) {
var expression = nglr.Scope.expressionCache[expressionText];
Scope.prototype.eval = function(expressionText, context) {
var expression = Scope.expressionCache[expressionText];
if (!expression) {
var parser = new nglr.Parser(expressionText);
var parser = new Parser(expressionText);
expression = parser.statements();
parser.assertAllConsumed();
nglr.Scope.expressionCache[expressionText] = expression;
Scope.expressionCache[expressionText] = expression;
}
context = context || {};
context.scope = this;
@ -110,7 +110,7 @@ nglr.Scope.prototype.eval = function(expressionText, context) {
//TODO: Refactor. This function needs to be an execution closure for widgets
// move to widgets
// remove expression, just have inner closure.
nglr.Scope.prototype.evalWidget = function(widget, expression, context, onSuccess, onFailure) {
Scope.prototype.evalWidget = function(widget, expression, context, onSuccess, onFailure) {
try {
var value = this.eval(expression, context);
if (widget.hasError) {
@ -125,7 +125,7 @@ nglr.Scope.prototype.evalWidget = function(widget, expression, context, onSucces
return true;
} catch (e){
console.error('Eval Widget Error:', e);
var jsonError = nglr.toJson(e, true);
var jsonError = toJson(e, true);
widget.hasError = true;
jQuery(widget.view).
addClass('ng-exception').
@ -137,42 +137,42 @@ nglr.Scope.prototype.evalWidget = function(widget, expression, context, onSucces
}
};
nglr.Scope.prototype.validate = function(expressionText, value) {
var expression = nglr.Scope.expressionCache[expressionText];
Scope.prototype.validate = function(expressionText, value) {
var expression = Scope.expressionCache[expressionText];
if (!expression) {
expression = new nglr.Parser(expressionText).validator();
nglr.Scope.expressionCache[expressionText] = expression;
expression = new Parser(expressionText).validator();
Scope.expressionCache[expressionText] = expression;
}
var self = {scope:this};
return expression(self)(self, value);
};
nglr.Scope.prototype.entity = function(entityDeclaration) {
var expression = new nglr.Parser(entityDeclaration).entityDeclaration();
Scope.prototype.entity = function(entityDeclaration) {
var expression = new Parser(entityDeclaration).entityDeclaration();
return expression({scope:this});
};
nglr.Scope.prototype.markInvalid = function(widget) {
Scope.prototype.markInvalid = function(widget) {
this.state.$invalidWidgets.push(widget);
};
nglr.Scope.prototype.watch = function(declaration) {
Scope.prototype.watch = function(declaration) {
var self = this;
new nglr.Parser(declaration).watch()({
new Parser(declaration).watch()({
scope:this,
addListener:function(watch, exp){
self.addWatchListener(watch, function(n,o){
try {
return exp({scope:self}, n, o);
} catch(e) {
nglr.alert(e);
alert(e);
}
});
}
});
};
nglr.Scope.prototype.addWatchListener = function(watchExpression, listener) {
Scope.prototype.addWatchListener = function(watchExpression, listener) {
var watcher = this.watchListeners[watchExpression];
if (!watcher) {
watcher = {listeners:[], expression:watchExpression};
@ -181,7 +181,7 @@ nglr.Scope.prototype.addWatchListener = function(watchExpression, listener) {
watcher.listeners.push(listener);
};
nglr.Scope.prototype.fireWatchers = function() {
Scope.prototype.fireWatchers = function() {
var self = this;
var fired = false;
jQuery.each(this.watchListeners, function(name, watcher) {

View file

@ -1,6 +1,6 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
nglr.Server = function(url, getScript) {
Server = function(url, getScript) {
this.url = url;
this.nextId = 0;
this.getScript = getScript;
@ -8,51 +8,51 @@ nglr.Server = function(url, getScript) {
this.maxSize = 1800;
};
nglr.Server.prototype.base64url = function(txt) {
Server.prototype.base64url = function(txt) {
return Base64.encode(txt);
};
nglr.Server.prototype.request = function(method, url, request, callback) {
Server.prototype.request = function(method, url, request, callback) {
var requestId = this.uuid + (this.nextId++);
nglr[requestId] = function(response) {
delete nglr[requestId];
callbacks[requestId] = function(response) {
delete angular[requestId];
callback(200, response);
};
var payload = {u:url, m:method, p:request};
payload = this.base64url(nglr.toJson(payload));
payload = this.base64url(toJson(payload));
var totalPockets = Math.ceil(payload.length / this.maxSize);
var baseUrl = this.url + "/$/" + requestId + "/" + totalPockets + "/";
for ( var pocketNo = 0; pocketNo < totalPockets; pocketNo++) {
var pocket = payload.substr(pocketNo * this.maxSize, this.maxSize);
this.getScript(baseUrl + (pocketNo+1) + "?h=" + pocket, nglr.noop);
this.getScript(baseUrl + (pocketNo+1) + "?h=" + pocket, noop);
}
};
nglr.FrameServer = function(frame) {
FrameServer = function(frame) {
this.frame = frame;
};
nglr.FrameServer.PREFIX = "$DATASET:";
FrameServer.PREFIX = "$DATASET:";
nglr.FrameServer.prototype = {
FrameServer.prototype = {
read:function(){
this.data = nglr.fromJson(this.frame.name.substr(nglr.FrameServer.PREFIX.length));
this.data = fromJson(this.frame.name.substr(FrameServer.PREFIX.length));
},
write:function(){
this.frame.name = nglr.FrameServer.PREFIX + nglr.toJson(this.data);
this.frame.name = FrameServer.PREFIX + toJson(this.data);
},
request: function(method, url, request, callback) {
//alert(method + " " + url + " " + nglr.toJson(request) + " " + nglr.toJson(callback));
//alert(method + " " + url + " " + toJson(request) + " " + toJson(callback));
}
};
nglr.VisualServer = function(delegate, status, update) {
VisualServer = function(delegate, status, update) {
this.delegate = delegate;
this.update = update;
this.status = status;
};
nglr.VisualServer.prototype = {
VisualServer.prototype = {
request:function(method, url, request, callback) {
var self = this;
this.status.beginRequest(request);
@ -61,7 +61,7 @@ nglr.VisualServer.prototype = {
try {
callback.apply(this, arguments);
} catch (e) {
nglr.alert(nglr.toJson(e));
alert(toJson(e));
}
self.update();
});

View file

@ -1,10 +1,10 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
nglr.Users = function(server, controlBar) {
Users = function(server, controlBar) {
this.server = server;
this.controlBar = controlBar;
};
nglr.Users.prototype = {
Users.prototype = {
fetchCurrentUser:function(callback) {
var self = this;
this.server.request("GET", "/account.json", {}, function(code, response){
@ -17,7 +17,7 @@ nglr.Users.prototype = {
var self = this;
this.controlBar.logout(function(){
delete self.current;
(callback||nglr.noop)();
(callback||noop)();
});
},
@ -25,7 +25,7 @@ nglr.Users.prototype = {
var self = this;
this.controlBar.login(function(){
self.fetchCurrentUser(function(){
(callback||nglr.noop)();
(callback||noop)();
});
});
},

View file

@ -72,7 +72,7 @@ angular.validator.url = function(value) {
angular.validator.json = function(value) {
try {
nglr.fromJson(value);
fromJson(value);
return null;
} catch (e) {
return e.toString();

View file

@ -1,7 +1,7 @@
// Copyright (C) 2009 BRAT Tech LLC
nglr.WidgetFactory = function(serverUrl, database) {
WidgetFactory = function(serverUrl, database) {
this.nextUploadId = 0;
this.serverUrl = serverUrl;
this.database = database;
@ -9,7 +9,7 @@ nglr.WidgetFactory = function(serverUrl, database) {
this.onChangeListener = function(){};
};
nglr.WidgetFactory.prototype.createController = function(input, scope) {
WidgetFactory.prototype.createController = function(input, scope) {
var controller;
var type = input.attr('type').toLowerCase();
var exp = input.attr('name');
@ -17,22 +17,22 @@ nglr.WidgetFactory.prototype.createController = function(input, scope) {
var event = "change";
var bubbleEvent = true;
if (type == 'button' || type == 'submit' || type == 'reset' || type == 'image') {
controller = new nglr.ButtonController(input[0], exp);
controller = new ButtonController(input[0], exp);
event = "click";
bubbleEvent = false;
} else if (type == 'text' || type == 'textarea' || type == 'hidden' || type == 'password') {
controller = new nglr.TextController(input[0], exp);
controller = new TextController(input[0], exp);
event = "keyup change";
} else if (type == 'checkbox') {
controller = new nglr.CheckboxController(input[0], exp);
controller = new CheckboxController(input[0], exp);
event = "click";
} else if (type == 'radio') {
controller = new nglr.RadioController(input[0], exp);
controller = new RadioController(input[0], exp);
event="click";
} else if (type == 'select-one') {
controller = new nglr.SelectController(input[0], exp);
controller = new SelectController(input[0], exp);
} else if (type == 'select-multiple') {
controller = new nglr.MultiSelectController(input[0], exp);
controller = new MultiSelectController(input[0], exp);
} else if (type == 'file') {
controller = this.createFileController(input, exp);
} else {
@ -54,9 +54,9 @@ nglr.WidgetFactory.prototype.createController = function(input, scope) {
return controller;
};
nglr.WidgetFactory.prototype.createFileController = function(fileInput) {
WidgetFactory.prototype.createFileController = function(fileInput) {
var uploadId = '__uploadWidget_' + (this.nextUploadId++);
var view = nglr.FileController.template(uploadId);
var view = FileController.template(uploadId);
fileInput.after(view);
var att = {
data:this.serverUrl + "/admin/ServerAPI.swf",
@ -67,13 +67,13 @@ nglr.WidgetFactory.prototype.createFileController = function(fileInput) {
allowScriptAccess:"always"};
var swfNode = this.createSWF(att, par, uploadId);
fileInput.remove();
var cntl = new nglr.FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
var cntl = new FileController(view, fileInput[0].name, swfNode, this.serverUrl + "/data/" + this.database);
jQuery(swfNode).data('controller', cntl);
return cntl;
};
nglr.WidgetFactory.prototype.createTextWidget = function(textInput) {
var controller = new nglr.TextController(textInput);
WidgetFactory.prototype.createTextWidget = function(textInput) {
var controller = new TextController(textInput);
controller.onChange(this.onChangeListener);
return controller;
};
@ -82,7 +82,7 @@ nglr.WidgetFactory.prototype.createTextWidget = function(textInput) {
// FileController
///////////////////////
nglr.FileController = function(view, scopeName, uploader, databaseUrl) {
FileController = function(view, scopeName, uploader, databaseUrl) {
this.view = view;
this.uploader = uploader;
this.scopeName = scopeName;
@ -91,13 +91,13 @@ nglr.FileController = function(view, scopeName, uploader, databaseUrl) {
this.lastValue = undefined;
};
nglr.FileController.dispatchEvent = function(id, event, args) {
FileController.dispatchEvent = function(id, event, args) {
var object = document.getElementById(id);
var controller = jQuery(object).data("controller");
nglr.FileController.prototype['_on_' + event].apply(controller, args);
FileController.prototype['_on_' + event].apply(controller, args);
};
nglr.FileController.template = function(id) {
FileController.template = function(id) {
return jQuery('<span class="ng-upload-widget">' +
'<input type="checkbox" ng-non-bindable="true"/>' +
'<object id="' + id + '" />' +
@ -106,33 +106,33 @@ nglr.FileController.template = function(id) {
'</span>');
};
nglr.FileController.prototype._on_cancel = function() {
FileController.prototype._on_cancel = function() {
};
nglr.FileController.prototype._on_complete = function() {
FileController.prototype._on_complete = function() {
};
nglr.FileController.prototype._on_httpStatus = function(status) {
nglr.alert("httpStatus:" + this.scopeName + " status:" + status);
FileController.prototype._on_httpStatus = function(status) {
alert("httpStatus:" + this.scopeName + " status:" + status);
};
nglr.FileController.prototype._on_ioError = function() {
nglr.alert("ioError:" + this.scopeName);
FileController.prototype._on_ioError = function() {
alert("ioError:" + this.scopeName);
};
nglr.FileController.prototype._on_open = function() {
nglr.alert("open:" + this.scopeName);
FileController.prototype._on_open = function() {
alert("open:" + this.scopeName);
};
nglr.FileController.prototype._on_progress = function(bytesLoaded, bytesTotal) {
FileController.prototype._on_progress = function(bytesLoaded, bytesTotal) {
};
nglr.FileController.prototype._on_securityError = function() {
nglr.alert("securityError:" + this.scopeName);
FileController.prototype._on_securityError = function() {
alert("securityError:" + this.scopeName);
};
nglr.FileController.prototype._on_uploadCompleteData = function(data) {
var value = nglr.fromJson(data);
FileController.prototype._on_uploadCompleteData = function(data) {
var value = fromJson(data);
value.url = this.attachmentsPath + '/' + value.id + '/' + value.text;
this.view.find("input").attr('checked', true);
var scope = this.view.scope();
@ -142,14 +142,14 @@ nglr.FileController.prototype._on_uploadCompleteData = function(data) {
scope.get('$binder').updateView();
};
nglr.FileController.prototype._on_select = function(name, size, type) {
FileController.prototype._on_select = function(name, size, type) {
this.name = name;
this.view.find("a").text(name).attr('href', name);
this.view.find("span").text(angular.filter.bytes(size));
this.upload();
};
nglr.FileController.prototype.updateModel = function(scope) {
FileController.prototype.updateModel = function(scope) {
var isChecked = this.view.find("input").attr('checked');
var value = isChecked ? this.value : null;
if (this.lastValue === value) {
@ -160,7 +160,7 @@ nglr.FileController.prototype.updateModel = function(scope) {
}
};
nglr.FileController.prototype.updateView = function(scope) {
FileController.prototype.updateView = function(scope) {
var modelValue = scope.get(this.scopeName);
if (modelValue && this.value !== modelValue) {
this.value = modelValue;
@ -172,7 +172,7 @@ nglr.FileController.prototype.updateView = function(scope) {
this.view.find("input").attr('checked', !!modelValue);
};
nglr.FileController.prototype.upload = function() {
FileController.prototype.upload = function() {
if (this.name) {
this.uploader.uploadFile(this.attachmentsPath);
}
@ -182,23 +182,23 @@ nglr.FileController.prototype.upload = function() {
///////////////////////
// NullController
///////////////////////
nglr.NullController = function(view) {this.view = view;};
nglr.NullController.prototype.updateModel = function() { return true; };
nglr.NullController.prototype.updateView = function() { };
nglr.NullController.instance = new nglr.NullController();
NullController = function(view) {this.view = view;};
NullController.prototype.updateModel = function() { return true; };
NullController.prototype.updateView = function() { };
NullController.instance = new NullController();
///////////////////////
// ButtonController
///////////////////////
nglr.ButtonController = function(view) {this.view = view;};
nglr.ButtonController.prototype.updateModel = function(scope) { return true; };
nglr.ButtonController.prototype.updateView = function(scope) {};
ButtonController = function(view) {this.view = view;};
ButtonController.prototype.updateModel = function(scope) { return true; };
ButtonController.prototype.updateView = function(scope) {};
///////////////////////
// TextController
///////////////////////
nglr.TextController = function(view, exp) {
TextController = function(view, exp) {
this.view = view;
this.exp = exp;
this.validator = view.getAttribute('ng-validate');
@ -212,7 +212,7 @@ nglr.TextController = function(view, exp) {
}
};
nglr.TextController.prototype.updateModel = function(scope) {
TextController.prototype.updateModel = function(scope) {
var value = this.view.value;
if (this.lastValue === value) {
return false;
@ -223,7 +223,7 @@ nglr.TextController.prototype.updateModel = function(scope) {
}
};
nglr.TextController.prototype.updateView = function(scope) {
TextController.prototype.updateView = function(scope) {
var view = this.view;
var value = scope.get(this.exp);
if (typeof value === "undefined") {
@ -258,14 +258,14 @@ nglr.TextController.prototype.updateView = function(scope) {
///////////////////////
// CheckboxController
///////////////////////
nglr.CheckboxController = function(view, exp) {
CheckboxController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = view.checked ? view.value : "";
};
nglr.CheckboxController.prototype.updateModel = function(scope) {
CheckboxController.prototype.updateModel = function(scope) {
var input = this.view;
var value = input.checked ? input.value : '';
if (this.lastValue === value) {
@ -277,7 +277,7 @@ nglr.CheckboxController.prototype.updateModel = function(scope) {
}
};
nglr.CheckboxController.prototype.updateView = function(scope) {
CheckboxController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.eval(this.exp);
if (typeof value === "undefined") {
@ -290,14 +290,14 @@ nglr.CheckboxController.prototype.updateView = function(scope) {
///////////////////////
// SelectController
///////////////////////
nglr.SelectController = function(view, exp) {
SelectController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = view.value;
};
nglr.SelectController.prototype.updateModel = function(scope) {
SelectController.prototype.updateModel = function(scope) {
var input = this.view;
if (input.selectedIndex < 0) {
scope.setEval(this.exp, null);
@ -313,7 +313,7 @@ nglr.SelectController.prototype.updateModel = function(scope) {
}
};
nglr.SelectController.prototype.updateView = function(scope) {
SelectController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.get(this.exp);
if (typeof value === 'undefined') {
@ -329,14 +329,14 @@ nglr.SelectController.prototype.updateView = function(scope) {
///////////////////////
// MultiSelectController
///////////////////////
nglr.MultiSelectController = function(view, exp) {
MultiSelectController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = this.selected();
};
nglr.MultiSelectController.prototype.selected = function () {
MultiSelectController.prototype.selected = function () {
var value = [];
var options = this.view.options;
for ( var i = 0; i < options.length; i++) {
@ -348,7 +348,7 @@ nglr.MultiSelectController.prototype.selected = function () {
return value;
};
nglr.MultiSelectController.prototype.updateModel = function(scope) {
MultiSelectController.prototype.updateModel = function(scope) {
var value = this.selected();
// TODO: This is wrong! no caching going on here as we are always comparing arrays
if (this.lastValue === value) {
@ -360,7 +360,7 @@ nglr.MultiSelectController.prototype.updateModel = function(scope) {
}
};
nglr.MultiSelectController.prototype.updateView = function(scope) {
MultiSelectController.prototype.updateView = function(scope) {
var input = this.view;
var selected = scope.get(this.exp);
if (typeof selected === "undefined") {
@ -380,7 +380,7 @@ nglr.MultiSelectController.prototype.updateView = function(scope) {
///////////////////////
// RadioController
///////////////////////
nglr.RadioController = function(view, exp) {
RadioController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastChecked = undefined;
@ -389,7 +389,7 @@ nglr.RadioController = function(view, exp) {
this.initialValue = view.checked ? view.value : null;
};
nglr.RadioController.prototype.updateModel = function(scope) {
RadioController.prototype.updateModel = function(scope) {
var input = this.view;
if (this.lastChecked) {
return false;
@ -401,7 +401,7 @@ nglr.RadioController.prototype.updateModel = function(scope) {
}
};
nglr.RadioController.prototype.updateView = function(scope) {
RadioController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.get(this.exp);
if (this.initialValue && typeof value === "undefined") {
@ -417,25 +417,25 @@ nglr.RadioController.prototype.updateView = function(scope) {
///////////////////////
//ElementController
///////////////////////
nglr.BindUpdater = function(view, exp) {
BindUpdater = function(view, exp) {
this.view = view;
this.exp = nglr.Binder.parseBindings(exp);
this.exp = Binder.parseBindings(exp);
this.hasError = false;
this.scopeSelf = {element:view};
};
nglr.BindUpdater.toText = function(obj) {
var e = nglr.escapeHtml;
BindUpdater.toText = function(obj) {
var e = escapeHtml;
switch(typeof obj) {
case "string":
case "boolean":
case "number":
return e(obj);
case "function":
return nglr.BindUpdater.toText(obj());
return BindUpdater.toText(obj());
case "object":
if (nglr.isNode(obj)) {
return nglr.outerHTML(obj);
if (isNode(obj)) {
return outerHTML(obj);
} else if (obj instanceof angular.filter.Meta) {
switch(typeof obj.html) {
case "string":
@ -444,8 +444,8 @@ nglr.BindUpdater.toText = function(obj) {
case "function":
return obj.html();
case "object":
if (nglr.isNode(obj.html))
return nglr.outerHTML(obj.html);
if (isNode(obj.html))
return outerHTML(obj.html);
default:
break;
}
@ -461,43 +461,43 @@ nglr.BindUpdater.toText = function(obj) {
}
if (obj === null)
return "";
return e(nglr.toJson(obj, true));
return e(toJson(obj, true));
default:
return "";
}
};
nglr.BindUpdater.prototype.updateModel = function(scope) {};
nglr.BindUpdater.prototype.updateView = function(scope) {
BindUpdater.prototype.updateModel = function(scope) {};
BindUpdater.prototype.updateView = function(scope) {
var html = [];
var parts = this.exp;
var length = parts.length;
for(var i=0; i<length; i++) {
var part = parts[i];
var binding = nglr.Binder.binding(part);
var binding = Binder.binding(part);
if (binding) {
scope.evalWidget(this, binding, this.scopeSelf, function(value){
html.push(nglr.BindUpdater.toText(value));
html.push(BindUpdater.toText(value));
}, function(e, text){
nglr.setHtml(this.view, text);
setHtml(this.view, text);
});
if (this.hasError) {
return;
}
} else {
html.push(nglr.escapeHtml(part));
html.push(escapeHtml(part));
}
}
nglr.setHtml(this.view, html.join(''));
setHtml(this.view, html.join(''));
};
nglr.BindAttrUpdater = function(view, attrs) {
BindAttrUpdater = function(view, attrs) {
this.view = view;
this.attrs = attrs;
};
nglr.BindAttrUpdater.prototype.updateModel = function(scope) {};
nglr.BindAttrUpdater.prototype.updateView = function(scope) {
BindAttrUpdater.prototype.updateModel = function(scope) {};
BindAttrUpdater.prototype.updateView = function(scope) {
var jNode = jQuery(this.view);
var attributeTemplates = this.attrs;
if (this.hasError) {
@ -508,19 +508,19 @@ nglr.BindAttrUpdater.prototype.updateView = function(scope) {
}
var isImage = jNode.is('img');
for (var attrName in attributeTemplates) {
var attributeTemplate = nglr.Binder.parseBindings(attributeTemplates[attrName]);
var attributeTemplate = Binder.parseBindings(attributeTemplates[attrName]);
var attrValues = [];
for ( var i = 0; i < attributeTemplate.length; i++) {
var binding = nglr.Binder.binding(attributeTemplate[i]);
var binding = Binder.binding(attributeTemplate[i]);
if (binding) {
try {
var value = scope.eval(binding, {element:jNode[0], attrName:attrName});
if (value && (value.constructor !== nglr.array || value.length !== 0))
if (value && (value.constructor !== array || value.length !== 0))
attrValues.push(value);
} catch (e) {
this.hasError = true;
console.error('BindAttrUpdater', e);
var jsonError = nglr.toJson(e, true);
var jsonError = toJson(e, true);
attrValues.push('[' + jsonError + ']');
jNode.
addClass('ng-exception').
@ -537,22 +537,22 @@ nglr.BindAttrUpdater.prototype.updateView = function(scope) {
}
};
nglr.EvalUpdater = function(view, exp) {
EvalUpdater = function(view, exp) {
this.view = view;
this.exp = exp;
this.hasError = false;
};
nglr.EvalUpdater.prototype.updateModel = function(scope) {};
nglr.EvalUpdater.prototype.updateView = function(scope) {
EvalUpdater.prototype.updateModel = function(scope) {};
EvalUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp);
};
nglr.HideUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.HideUpdater.prototype.updateModel = function(scope) {};
nglr.HideUpdater.prototype.updateView = function(scope) {
HideUpdater = function(view, exp) { this.view = view; this.exp = exp; };
HideUpdater.prototype.updateModel = function(scope) {};
HideUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(hideValue){
var view = jQuery(this.view);
if (nglr.toBoolean(hideValue)) {
if (toBoolean(hideValue)) {
view.hide();
} else {
view.show();
@ -560,12 +560,12 @@ nglr.HideUpdater.prototype.updateView = function(scope) {
});
};
nglr.ShowUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ShowUpdater.prototype.updateModel = function(scope) {};
nglr.ShowUpdater.prototype.updateView = function(scope) {
ShowUpdater = function(view, exp) { this.view = view; this.exp = exp; };
ShowUpdater.prototype.updateModel = function(scope) {};
ShowUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(hideValue){
var view = jQuery(this.view);
if (nglr.toBoolean(hideValue)) {
if (toBoolean(hideValue)) {
view.show();
} else {
view.hide();
@ -573,9 +573,9 @@ nglr.ShowUpdater.prototype.updateView = function(scope) {
});
};
nglr.ClassUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ClassUpdater.prototype.updateModel = function(scope) {};
nglr.ClassUpdater.prototype.updateView = function(scope) {
ClassUpdater = function(view, exp) { this.view = view; this.exp = exp; };
ClassUpdater.prototype.updateModel = function(scope) {};
ClassUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
if (classValue !== null && classValue !== undefined) {
this.view.className = classValue;
@ -583,27 +583,27 @@ nglr.ClassUpdater.prototype.updateView = function(scope) {
});
};
nglr.ClassEvenUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ClassEvenUpdater.prototype.updateModel = function(scope) {};
nglr.ClassEvenUpdater.prototype.updateView = function(scope) {
ClassEvenUpdater = function(view, exp) { this.view = view; this.exp = exp; };
ClassEvenUpdater.prototype.updateModel = function(scope) {};
ClassEvenUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
var index = scope.get('$index');
jQuery(this.view).toggleClass(classValue, index % 2 === 1);
});
};
nglr.ClassOddUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ClassOddUpdater.prototype.updateModel = function(scope) {};
nglr.ClassOddUpdater.prototype.updateView = function(scope) {
ClassOddUpdater = function(view, exp) { this.view = view; this.exp = exp; };
ClassOddUpdater.prototype.updateModel = function(scope) {};
ClassOddUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
var index = scope.get('$index');
jQuery(this.view).toggleClass(classValue, index % 2 === 0);
});
};
nglr.StyleUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.StyleUpdater.prototype.updateModel = function(scope) {};
nglr.StyleUpdater.prototype.updateView = function(scope) {
StyleUpdater = function(view, exp) { this.view = view; this.exp = exp; };
StyleUpdater.prototype.updateModel = function(scope) {};
StyleUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(styleValue){
jQuery(this.view).attr('style', "").css(styleValue);
});
@ -612,7 +612,7 @@ nglr.StyleUpdater.prototype.updateView = function(scope) {
///////////////////////
// RepeaterUpdater
///////////////////////
nglr.RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
this.view = view;
this.template = template;
this.prefix = prefix;
@ -633,8 +633,8 @@ nglr.RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
this.keyExp = match[2];
};
nglr.RepeaterUpdater.prototype.updateModel = function(scope) {};
nglr.RepeaterUpdater.prototype.updateView = function(scope) {
RepeaterUpdater.prototype.updateModel = function(scope) {};
RepeaterUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.iteratorExp, {}, function(iterator){
var self = this;
if (!iterator) {
@ -660,7 +660,7 @@ nglr.RepeaterUpdater.prototype.updateView = function(scope) {
// grow children
var name = self.prefix +
valueExp + " in " + self.iteratorExp + "[" + i + "]";
var childScope = new nglr.Scope(scope.state, name);
var childScope = new Scope(scope.state, name);
childScope.set('$index', i);
if (keyExp)
childScope.set(keyExp, key);
@ -696,22 +696,22 @@ nglr.RepeaterUpdater.prototype.updateView = function(scope) {
// PopUp
//////////////////////////////////
nglr.PopUp = function(doc) {
PopUp = function(doc) {
this.doc = doc;
};
nglr.PopUp.OUT_EVENT = "mouseleave mouseout click dblclick keypress keyup";
PopUp.OUT_EVENT = "mouseleave mouseout click dblclick keypress keyup";
nglr.PopUp.prototype.bind = function () {
PopUp.prototype.bind = function () {
var self = this;
this.doc.find('.ng-validation-error,.ng-exception').
live("mouseover", nglr.PopUp.onOver);
live("mouseover", PopUp.onOver);
};
nglr.PopUp.onOver = function(e) {
nglr.PopUp.onOut();
PopUp.onOver = function(e) {
PopUp.onOut();
var jNode = jQuery(this);
jNode.bind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut);
jNode.bind(PopUp.OUT_EVENT, PopUp.onOut);
var position = jNode.position();
var de = document.documentElement;
var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
@ -740,9 +740,9 @@ nglr.PopUp.onOver = function(e) {
return true;
};
nglr.PopUp.onOut = function() {
PopUp.onOut = function() {
jQuery('#ng-callout').
unbind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut).
unbind(PopUp.OUT_EVENT, PopUp.onOut).
remove();
return true;
};
@ -752,21 +752,21 @@ nglr.PopUp.onOut = function() {
//////////////////////////////////
nglr.Status = function(body) {
this.loader = body.append(nglr.Status.DOM).find("#ng-loading");
Status = function(body) {
this.loader = body.append(Status.DOM).find("#ng-loading");
this.requestCount = 0;
};
nglr.Status.DOM ='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';
Status.DOM ='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>';
nglr.Status.prototype.beginRequest = function () {
Status.prototype.beginRequest = function () {
if (this.requestCount === 0) {
this.loader.show();
}
this.requestCount++;
};
nglr.Status.prototype.endRequest = function () {
Status.prototype.endRequest = function () {
this.requestCount--;
if (this.requestCount === 0) {
this.loader.hide("fold");

View file

@ -1,764 +0,0 @@
// Copyright (C) 2009 BRAT Tech LLC
nglr.WidgetFactory = function(serverUrl) {
this.nextUploadId = 0;
this.serverUrl = serverUrl;
this.createSWF = swfobject.createSWF;
this.onChangeListener = function(){};
};
nglr.WidgetFactory.prototype.createController = function(input, scope) {
var controller;
var type = input.attr('type').toLowerCase();
var exp = input.attr('name');
if (exp) exp = exp.split(':').pop();
var event = "change";
var bubbleEvent = true;
if (type == 'button' || type == 'submit' || type == 'reset') {
controller = new nglr.ButtonController(input[0], exp);
event = "click";
bubbleEvent = false;
} else if (type == 'text' || type == 'textarea') {
controller = new nglr.TextController(input[0], exp);
event = "keyup change";
} else if (type == 'checkbox') {
controller = new nglr.CheckboxController(input[0], exp);
event = "click";
} else if (type == 'radio') {
controller = new nglr.RadioController(input[0], exp);
event="click";
} else if (type == 'select-one') {
controller = new nglr.SelectController(input[0], exp);
} else if (type == 'select-multiple') {
controller = new nglr.MultiSelectController(input[0], exp);
} else if (type == 'file') {
controller = this.createFileController(input, exp);
} else {
throw 'Unknown type: ' + type;
}
input.data('controller', controller);
var binder = scope.get('$binder');
var action = function() {
if (controller.updateModel(scope)) {
var action = jQuery(controller.view).attr('ng-action') || "";
if (scope.evalWidget(controller, action)) {
binder.updateView(scope);
}
}
return bubbleEvent;
};
jQuery(controller.view, ":input").
bind(event, action);
return controller;
};
nglr.WidgetFactory.prototype.createFileController = function(fileInput) {
var uploadId = '__uploadWidget_' + (this.nextUploadId++);
var view = nglr.FileController.template(uploadId);
fileInput.after(view);
var att = {
data:this.serverUrl + "/admin/ServerAPI.swf",
width:"95", height:"20", align:"top",
wmode:"transparent"};
var par = {
flashvars:"uploadWidgetId=" + uploadId,
allowScriptAccess:"always"};
var swfNode = this.createSWF(att, par, uploadId);
fileInput.remove();
var cntl = new nglr.FileController(view, fileInput[0].name, swfNode, this.serverUrl);
jQuery(swfNode).data('controller', cntl);
return cntl;
};
nglr.WidgetFactory.prototype.createTextWidget = function(textInput) {
var controller = new nglr.TextController(textInput);
controller.onChange(this.onChangeListener);
return controller;
};
/////////////////////
// FileController
///////////////////////
nglr.FileController = function(view, scopeName, uploader, serverUrl) {
this.view = view;
this.uploader = uploader;
this.scopeName = scopeName;
this.uploadUrl = serverUrl + '/upload';
this.attachmentBase = serverUrl + '/attachments';
this.value = null;
this.lastValue = undefined;
};
nglr.FileController.dispatchEvent = function(id, event, args) {
var object = document.getElementById(id);
var controller = jQuery(object).data("controller");
nglr.FileController.prototype['_on_' + event].apply(controller, args);
};
nglr.FileController.template = function(id) {
return jQuery('<span class="ng-upload-widget">' +
'<input type="checkbox" ng-non-bindable="true"/>' +
'<object id="' + id + '" />' +
'<a></a>' +
'<span/>' +
'</span>');
};
nglr.FileController.prototype._on_cancel = function() {
};
nglr.FileController.prototype._on_complete = function() {
};
nglr.FileController.prototype._on_httpStatus = function(status) {
nglr.alert("httpStatus:" + this.scopeName + " status:" + status);
};
nglr.FileController.prototype._on_ioError = function() {
nglr.alert("ioError:" + this.scopeName);
};
nglr.FileController.prototype._on_open = function() {
nglr.alert("open:" + this.scopeName);
};
nglr.FileController.prototype._on_progress = function(bytesLoaded, bytesTotal) {
};
nglr.FileController.prototype._on_securityError = function() {
nglr.alert("securityError:" + this.scopeName);
};
nglr.FileController.prototype._on_uploadCompleteData = function(data) {
this.value = nglr.fromJson(data);
this.value.url = this.attachmentBase + '/' + this.value.id + '/' + this.value.text;
this.view.find("input").attr('checked', true);
var scope = this.view.scope();
this.updateModel(scope);
scope.get('$binder').updateView();
};
nglr.FileController.prototype._on_select = function(name, size, type) {
this.name = name;
this.view.find("a").text(name).attr('href', name);
this.view.find("span").text(filters.bytes(size));
this.upload();
};
nglr.FileController.prototype.updateModel = function(scope) {
var isChecked = this.view.find("input").attr('checked');
var value = isChecked ? this.value : null;
if (this.lastValue === value) {
return false;
} else {
scope.set(this.scopeName, value);
return true;
}
};
nglr.FileController.prototype.updateView = function(scope) {
var modelValue = scope.get(this.scopeName);
if (modelValue && this.value !== modelValue) {
this.value = modelValue;
this.view.find("a").
attr("href", this.value.url).
text(this.value.name);
this.view.find("span").text(filters.bytes(this.value.size));
}
this.view.find("input").attr('checked', !!modelValue);
};
nglr.FileController.prototype.upload = function() {
if (this.name) {
this.uploader.uploadFile(this.uploadUrl);
}
};
///////////////////////
// NullController
///////////////////////
nglr.NullController = function(view) {this.view = view;};
nglr.NullController.prototype.updateModel = function() { return true; };
nglr.NullController.prototype.updateView = function() { };
nglr.NullController.instance = new nglr.NullController();
///////////////////////
// ButtonController
///////////////////////
nglr.ButtonController = function(view) {this.view = view;};
nglr.ButtonController.prototype.updateModel = function(scope) { return true; };
nglr.ButtonController.prototype.updateView = function(scope) {};
///////////////////////
// TextController
///////////////////////
nglr.TextController = function(view, exp) {
this.view = view;
this.exp = exp;
this.validator = view.getAttribute('ng-validate');
this.required = typeof view.attributes['ng-required'] != "undefined";
this.lastErrorText = null;
this.lastValue = undefined;
this.initialValue = view.value;
var widget = view.getAttribute('ng-widget');
if (widget === 'datepicker') {
jQuery(view).datepicker();
}
};
nglr.TextController.prototype.updateModel = function(scope) {
var value = this.view.value;
if (this.lastValue === value) {
return false;
} else {
scope.set(this.exp, value);
this.lastValue = value;
return true;
}
};
nglr.TextController.prototype.updateView = function(scope) {
var view = this.view;
var value = scope.get(this.exp);
if (typeof value === "undefined") {
value = this.initialValue;
scope.set(this.exp, value);
}
value = value ? value : '';
if (this.lastValue != value) {
view.value = value;
this.lastValue = value;
}
var isValidationError = false;
view.removeAttribute('ng-error');
if (this.required) {
isValidationError = !(value && value.length > 0);
}
var errorText = isValidationError ? "Required Value" : null;
if (!isValidationError && this.validator && value) {
errorText = scope.validate(this.validator, value);
isValidationError = !!errorText;
}
if (this.lastErrorText !== errorText) {
this.lastErrorText = isValidationError;
if (errorText !== null) {
view.setAttribute('ng-error', errorText);
scope.markInvalid(this);
}
jQuery(view).toggleClass('ng-validation-error', isValidationError);
}
};
///////////////////////
// CheckboxController
///////////////////////
nglr.CheckboxController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = view.checked ? view.value : "";
};
nglr.CheckboxController.prototype.updateModel = function(scope) {
var input = this.view;
var value = input.checked ? input.value : '';
if (this.lastValue === value) {
return false;
} else {
scope.setEval(this.exp, value);
this.lastValue = value;
return true;
}
};
nglr.CheckboxController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.eval(this.exp);
if (typeof value === "undefined") {
value = this.initialValue;
scope.setEval(this.exp, value);
}
input.checked = input.value == (''+value);
};
///////////////////////
// SelectController
///////////////////////
nglr.SelectController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = view.value;
};
nglr.SelectController.prototype.updateModel = function(scope) {
var input = this.view;
if (input.selectedIndex < 0) {
scope.set(this.exp, null);
} else {
var value = this.view.value;
if (this.lastValue === value) {
return false;
} else {
scope.set(this.exp, value);
this.lastValue = value;
return true;
}
}
};
nglr.SelectController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.get(this.exp);
if (typeof value === 'undefined') {
value = this.initialValue;
scope.set(this.exp, value);
}
if (value !== this.lastValue) {
input.value = value ? value : "";
this.lastValue = value;
}
};
///////////////////////
// MultiSelectController
///////////////////////
nglr.MultiSelectController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastValue = undefined;
this.initialValue = this.selected();
};
nglr.MultiSelectController.prototype.selected = function () {
var value = [];
var options = this.view.options;
for ( var i = 0; i < options.length; i++) {
var option = options[i];
if (option.selected) {
value.push(option.value);
}
}
return value;
};
nglr.MultiSelectController.prototype.updateModel = function(scope) {
var value = this.selected();
// TODO: This is wrong! no caching going on here as we are always comparing arrays
if (this.lastValue === value) {
return false;
} else {
scope.set(this.exp, value);
this.lastValue = value;
return true;
}
};
nglr.MultiSelectController.prototype.updateView = function(scope) {
var input = this.view;
var selected = scope.get(this.exp);
if (typeof selected === "undefined") {
selected = this.initialValue;
scope.set(this.exp, selected);
}
if (selected !== this.lastValue) {
var options = input.options;
for ( var i = 0; i < options.length; i++) {
var option = options[i];
option.selected = selected.contains(option.value);
}
this.lastValue = selected;
}
};
///////////////////////
// RadioController
///////////////////////
nglr.RadioController = function(view, exp) {
this.view = view;
this.exp = exp;
this.lastChecked = undefined;
this.lastValue = undefined;
this.inputValue = view.value;
this.initialValue = view.checked ? view.value : null;
};
nglr.RadioController.prototype.updateModel = function(scope) {
var input = this.view;
if (this.lastChecked) {
return false;
} else {
input.checked = true;
this.lastValue = scope.set(this.exp, this.inputValue);
this.lastChecked = true;
return true;
}
};
nglr.RadioController.prototype.updateView = function(scope) {
var input = this.view;
var value = scope.get(this.exp);
if (this.initialValue && typeof value === "undefined") {
value = this.initialValue;
scope.set(this.exp, value);
}
if (this.lastValue != value) {
this.lastChecked = input.checked = this.inputValue == (''+value);
this.lastValue = value;
}
};
///////////////////////
//ElementController
///////////////////////
nglr.BindUpdater = function(view, exp) {
this.view = view;
this.exp = exp.parseBindings();
this.hasError = false;
this.scopeSelf = {element:view};
};
nglr.BindUpdater.toText = function(obj) {
var e = nglr.escapeHtml;
switch(typeof obj) {
case "string":
case "boolean":
case "number":
return e(obj);
case "function":
return nglr.BindUpdater.toText(obj());
case "object":
if (nglr.isNode(obj)) {
return nglr.outerHTML(obj);
} else if (obj && obj.TAG === filters.Meta.TAG) {
switch(typeof obj.html) {
case "string":
case "number":
return obj.html;
case "function":
return obj.html();
default:
break;
}
switch(typeof obj.text) {
case "string":
case "number":
return e(obj.text);
case "function":
return e(obj.text());
default:
break;
}
}
if (obj === null)
return "";
return e(nglr.toJson(obj, true));
default:
return "";
}
};
nglr.BindUpdater.prototype.updateModel = function(scope) {};
nglr.BindUpdater.prototype.updateView = function(scope) {
var html = [];
var parts = this.exp;
var length = parts.length;
for(var i=0; i<length; i++) {
var part = parts[i];
var binding = part.binding();
if (binding) {
scope.evalWidget(this, binding, this.scopeSelf, function(value){
html.push(nglr.BindUpdater.toText(value));
}, function(e, text){
nglr.setHtml(this.view, text);
});
if (this.hasError) {
return;
}
} else {
html.push(nglr.escapeHtml(part));
}
}
nglr.setHtml(this.view, html.join(''));
};
nglr.BindAttrUpdater = function(view, attrs) {
this.view = view;
this.attrs = attrs;
};
nglr.BindAttrUpdater.prototype.updateModel = function(scope) {};
nglr.BindAttrUpdater.prototype.updateView = function(scope) {
var jNode = jQuery(this.view);
var attributeTemplates = this.attrs;
if (this.hasError) {
this.hasError = false;
jNode.
removeClass('ng-exception').
removeAttr('ng-error');
}
var isImage = jNode.is('img');
for (var attrName in attributeTemplates) {
var attributeTemplate = attributeTemplates[attrName].parseBindings();
var attrValues = [];
for ( var i = 0; i < attributeTemplate.length; i++) {
var binding = attributeTemplate[i].binding();
if (binding) {
try {
var value = scope.eval(binding, {element:jNode[0], attrName:attrName});
if (value && (value.constructor !== nglr.array || value.length !== 0))
attrValues.push(value);
} catch (e) {
this.hasError = true;
console.error('BindAttrUpdater', e);
var jsonError = nglr.toJson(e, true);
attrValues.push('[' + jsonError + ']');
jNode.
addClass('ng-exception').
attr('ng-error', jsonError);
}
} else {
attrValues.push(attributeTemplate[i]);
}
}
var attrValue = attrValues.length ? attrValues.join('') : null;
if(isImage && attrName == 'src' && !attrValue)
attrValue = scope.get('config.server') + '/images/blank.gif';
jNode.attr(attrName, attrValue);
}
};
nglr.EvalUpdater = function(view, exp) {
this.view = view;
this.exp = exp;
this.hasError = false;
};
nglr.EvalUpdater.prototype.updateModel = function(scope) {};
nglr.EvalUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp);
};
nglr.HideUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.HideUpdater.prototype.updateModel = function(scope) {};
nglr.HideUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(hideValue){
var view = jQuery(this.view);
if (nglr.toBoolean(hideValue)) {
view.hide();
} else {
view.show();
}
});
};
nglr.ShowUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ShowUpdater.prototype.updateModel = function(scope) {};
nglr.ShowUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(hideValue){
var view = jQuery(this.view);
if (nglr.toBoolean(hideValue)) {
view.show();
} else {
view.hide();
}
});
};
nglr.ClassUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ClassUpdater.prototype.updateModel = function(scope) {};
nglr.ClassUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
if (classValue !== null && classValue !== undefined) {
this.view.className = classValue;
}
});
};
nglr.ClassEvenUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ClassEvenUpdater.prototype.updateModel = function(scope) {};
nglr.ClassEvenUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
var index = scope.get('$index');
jQuery(this.view).toggleClass(classValue, index % 2 === 1);
});
};
nglr.ClassOddUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.ClassOddUpdater.prototype.updateModel = function(scope) {};
nglr.ClassOddUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(classValue){
var index = scope.get('$index');
jQuery(this.view).toggleClass(classValue, index % 2 === 0);
});
};
nglr.StyleUpdater = function(view, exp) { this.view = view; this.exp = exp; };
nglr.StyleUpdater.prototype.updateModel = function(scope) {};
nglr.StyleUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.exp, {}, function(styleValue){
jQuery(this.view).attr('style', "").css(styleValue);
});
};
///////////////////////
// RepeaterUpdater
///////////////////////
nglr.RepeaterUpdater = function(view, repeaterExpression, template, prefix) {
this.view = view;
this.template = template;
this.prefix = prefix;
this.children = [];
var match = repeaterExpression.match(/^\s*(.+)\s+in\s+(.*)\s*$/);
if (! match) {
throw "Expected ng-repeat in form of 'item in collection' but got '" + repeaterExpression + "'.";
}
this.itemExp = match[1];
this.iteratorExp = match[2];
};
nglr.RepeaterUpdater.prototype.updateModel = function(scope) {};
nglr.RepeaterUpdater.prototype.updateView = function(scope) {
scope.evalWidget(this, this.iteratorExp, {}, function(iterator){
if (!iterator) {
iterator = [];
if (scope.isProperty(this.iteratorExp)) {
scope.set(this.iteratorExp, iterator);
}
}
var iteratorLength = iterator.length;
var childrenLength = this.children.length;
var cursor = this.view;
var time = 0;
var child = null;
var itemExp = this.itemExp;
for ( var i = 0; i < iteratorLength; i++) {
if (i < iteratorLength) {
if (i < childrenLength) { // reuse children
child = this.children[i];
child.scope.set(itemExp, iterator[i]);
} else { // grow children
var name = this.prefix +
itemExp + " in " + this.iteratorExp + "[" + i + "]";
var childScope = new nglr.Scope(scope.state, name);
childScope.set('$index', i);
childScope.set(itemExp, iterator[i]);
child = { scope:childScope, element:this.template(childScope, this.prefix, i) };
cursor.after(child.element);
this.children.push(child);
}
cursor = child.element;
var s = new Date().getTime();
child.scope.updateView();
time += new Date().getTime() - s;
}
}
// shrink children
for ( var r = childrenLength; r > iteratorLength; --r) {
var unneeded = this.children.pop();
unneeded.element.removeNode();
}
// Special case for option in select
if (child && child.element[0].nodeName === "OPTION") {
var select = jQuery(child.element[0].parentNode);
var cntl = select.data('controller');
if (cntl) {
cntl.lastValue = undefined;
cntl.updateView(scope);
}
}
});
};
//////////////////////////////////
// PopUp
//////////////////////////////////
nglr.PopUp = function(doc) {
this.doc = doc;
};
nglr.PopUp.OUT_EVENT = "mouseleave mouseout click dblclick keypress keyup";
nglr.PopUp.prototype.bind = function () {
var self = this;
this.doc.find('.ng-validation-error,.ng-exception').
live("mouseover", nglr.PopUp.onOver);
};
nglr.PopUp.onOver = function(e) {
nglr.PopUp.onOut();
var jNode = jQuery(this);
jNode.bind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut);
var position = jNode.position();
var de = document.documentElement;
var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
var hasArea = w - position.left;
var width = 300;
var title = jNode.hasClass("ng-exception") ? "EXCEPTION:" : "Validation error...";
var msg = jNode.attr("ng-error");
var x;
var arrowPos = hasArea>(width+75) ? "left" : "right";
var tip = jQuery(
"<div id='ng-callout' style='width:"+width+"px'>" +
"<div class='ng-arrow-"+arrowPos+"'/>" +
"<div class='ng-title'>"+title+"</div>" +
"<div class='ng-content'>"+msg+"</div>" +
"</div>");
jQuery("body").append(tip);
if(arrowPos === 'left'){
x = position.left + this.offsetWidth + 11;
}else{
x = position.left - (width + 15);
tip.find('.ng-arrow-right').css({left:width+1});
}
tip.css({left: x+"px", top: (position.top - 3)+"px"});
return true;
};
nglr.PopUp.onOut = function() {
jQuery('#ng-callout').
unbind(nglr.PopUp.OUT_EVENT, nglr.PopUp.onOut).
remove();
return true;
};
//////////////////////////////////
// Status
//////////////////////////////////
nglr.Status = function (body) {
this.body = body;
this.requestCount = 0;
};
nglr.Status.ANGULAR = "&lt;a class='ng-angular-logo' href='http://www.getangular.com'&gt;&amp;lt;angular/&amp;gt;&lt;/a&gt;&trade;";
nglr.Status.prototype.beginRequest = function () {
if (this.requestCount === 0) {
<<<<<<< HEAD:public/javascripts/nglr/Widgets.js
this.dialogView = jQuery('<div class="ng-dialog" title="'+nglr.ControlBar.ANGULAR+' Server Communication:">Please Wait...<div/><div class="loader"></div></div>');
=======
this.dialogView = jQuery('<div title="'+nglr.Status.ANGULAR+' Server Communication:">Please Wait...<div/></div>');
this.progressWidget = this.dialogView.find("div");
this.progressWidget.progressbar({value:0});
>>>>>>> master:public/javascripts/nglr/Widgets.js
this.dialogView.dialog({bgiframe:true, minHeight:50, modal:true});
this.maxRequestCount = 0;
}
this.requestCount++;
this.maxRequestCount++;
};
nglr.Status.prototype.endRequest = function () {
this.requestCount--;
if (this.requestCount === 0) {
this.dialogView.dialog("destroy");
this.dialogView.remove();
this.dialogView = null;
}
};

View file

@ -1,100 +0,0 @@
// Copyright (C) 2008,2009 BRAT Tech LLC
if (typeof nglr == 'undefined') nglr = {};
if (typeof console == 'undefined') console = {};
if (typeof console.log == 'undefined')
console.log = function() {};
if (typeof console.error == 'undefined')
console.error = function() {};
nglr.XSitePost = function(baseUrl, window, prefix) {
this.baseUrl = baseUrl;
this.post = jQuery.post;
this.window = window;
this.inQueue = {};
this.outQueue = [];
this.maxMsgSize = 100000;
this.delay = 20;
this.prefix = prefix;
this.setTimeout=function(fn, delay){window.setTimeout(fn, delay);};
};
nglr.XSitePost.prototype.init = function() {
this.window.name = '';
this.response('ready', 'null');
};
nglr.XSitePost.prototype.incomingFragment = function(fragment) {
var parts = fragment.split(";");
this.incomingMsg(parts.shift(), 1*parts.shift(), 1*parts.shift(), parts.shift());
};
nglr.XSitePost.prototype.incomingMsg = function(id, partNo, totalParts, msgPart) {
var msg = this.inQueue[id];
if (!msg) {
msg = {id:id, parts:[], count:0};
this.inQueue[id] = msg;
}
msg.parts[partNo] = msgPart;
msg.count++;
if (totalParts === msg.count) {
delete this.inQueue[id];
var request = this.decodePost(msg.parts.join(''));
var self = this;
this.post(this.baseUrl + request.url, request.params, function(response, status){
self.response(id, response, status);
});
}
};
nglr.XSitePost.prototype.response = function(id, response, status) {
var start = 0;
var end;
var msg = Base64.encode(response);
var msgLen = msg.length;
var total = Math.ceil(msgLen / this.maxMsgSize);
var part = 0;
while (start < msgLen) {
end = Math.min(msgLen, start + this.maxMsgSize);
this.outQueue.push(id + ':'+part+':'+total+':' + msg.substring(start, end));
start = end;
part++;
}
};
nglr.XSitePost.prototype.decodePost = function(post) {
var parts = post.split(':');
var url = Base64.decode(parts.shift());
var params = {};
while(parts.length !== 0) {
var key = parts.shift();
var value = Base64.decode(parts.shift());
params[key] = value;
}
return {url:url, params:params};
};
nglr.XSitePost.prototype.listen = function() {
console.log("listen()");
var self = this;
var window = this.window;
var outQueue = this.outQueue;
var setTimeout = this.setTimeout;
var prefix = this.prefix;
var prefixLen = prefix.length;
var prefixRec = prefix + '>';
var prefixRecLen = prefixRec.length;
window.name = prefix;
var pull = function(){
var value = window.name;
if (value == prefix && outQueue.length > 0) {
window.name = prefix + '<' + outQueue.shift();
} else if (value.substr(0, prefixRecLen) == prefixRec) {
self.incomingFragment(value.substr(prefixRecLen));
window.name = prefix;
}
setTimeout(pull, self.delay);
};
pull();
};

View file

@ -80,9 +80,8 @@
doc = window.document.getElementById(id);
}
}
var angular = window.angularFactory(scriptConfig);
if (scriptConfig.autoBind && doc) {
window.angularScope = angular.compile(doc);
window.angularScope = angular.compile(doc, scriptConfig);
}
if (typeof previousOnLoad === 'function') {
try {

2
src/angular.prefix Normal file
View file

@ -0,0 +1,2 @@
(function(window, document){

1
src/angular.suffix Normal file
View file

@ -0,0 +1 @@
})(window, document);

View file

@ -1,11 +1,11 @@
if (!nglr.test) nglr.test = {};
if (typeof test == 'undefined') test = {};
nglr.test.ScenarioRunner = function(scenarios, body) {
test.ScenarioRunner = function(scenarios, body) {
this.scenarios = scenarios;
this.body = body;
};
nglr.test.ScenarioRunner.prototype = {
test.ScenarioRunner.prototype = {
run:function(){
this.setUpUI();
this.runScenarios();
@ -25,22 +25,22 @@ nglr.test.ScenarioRunner.prototype = {
});
},
runScenarios:function(){
var runner = new nglr.test.Runner(this.console, this.testFrame);
var runner = new test.Runner(this.console, this.testFrame);
_.stepper(this.scenarios, function(next, scenario, name){
new nglr.test.Scenario(name, scenario).run(runner, next);
new test.Scenario(name, scenario).run(runner, next);
}, function(){
}
);
}
};
nglr.test.Runner = function(console, frame){
test.Runner = function(console, frame){
this.console = console;
this.current = null;
this.tests = [];
this.frame = frame;
};
nglr.test.Runner.prototype = {
test.Runner.prototype = {
start:function(name){
var current = this.current = {
name:name,
@ -75,7 +75,7 @@ nglr.test.Runner.prototype = {
var buf = [];
for ( var i = 1; i < arguments.length; i++) {
var arg = arguments[i];
buf.push(typeof arg == "string" ?arg:nglr.toJson(arg));
buf.push(typeof arg == "string" ?arg:toJson(arg));
}
var log = jQuery('<div class="' + level + '"></div>');
log.text(buf.join(" "));
@ -86,11 +86,11 @@ nglr.test.Runner.prototype = {
}
};
nglr.test.Scenario = function(name, scenario){
test.Scenario = function(name, scenario){
this.name = name;
this.scenario = scenario;
};
nglr.test.Scenario.prototype = {
test.Scenario.prototype = {
run:function(runner, callback) {
var self = this;
_.stepper(this.scenario, function(next, steps, name){
@ -115,7 +115,7 @@ nglr.test.Scenario.prototype = {
else if (step.When) fn = angular.test.WHEN[step.When];
else if (step.Then) fn = angular.test.THEN[step.Then];
return fn || function (){
throw "ERROR: Need Given/When/Then got: " + nglr.toJson(step);
throw "ERROR: Need Given/When/Then got: " + toJson(step);
};
},
context: function(runner) {
@ -149,14 +149,14 @@ nglr.test.Scenario.prototype = {
callback();
return;
}
runner.log("info", nglr.toJson(step));
runner.log("info", toJson(step));
var fn = this.verb(step);
var context = this.context(runner);
_.extend(context, step);
try {
(fn.call(context)||function(c){c();})(callback);
} catch (e) {
runner.log("error", "ERROR: " + nglr.toJson(e));
runner.log("error", "ERROR: " + toJson(e));
}
}
};

View file

@ -14,7 +14,7 @@ angular.test.GIVEN = {
};
},
dataset:function(){
this.frame.name="$DATASET:" + nglr.toJson({dataset:this.dataset});
this.frame.name="$DATASET:" + toJson({dataset:this.dataset});
}
};
angular.test.WHEN = {

View file

@ -3,10 +3,10 @@ BinderTest = TestCase('BinderTest');
function compile(content, initialScope, config) {
var h = html(content);
config = config || {autoSubmit:true};
var scope = new nglr.Scope(initialScope, "ROOT");
var scope = new Scope(initialScope, "ROOT");
h.data('scope', scope);
var binder = new nglr.Binder(h[0], new nglr.WidgetFactory(), new MockUrlWatcher(), config);
var datastore = new nglr.DataStore();
var binder = new Binder(h[0], new WidgetFactory(), new MockUrlWatcher(), config);
var datastore = new DataStore();
scope.set("$datastore", datastore);
scope.set("$binder", binder);
scope.set("$anchor", binder.anchor);
@ -19,80 +19,79 @@ function compileToHtml(content) {
return compile(content).node.sortedHtml();
}
BinderTest.prototype.testParseTextWithNoBindings = function(){
var parts = nglr.Binder.parseBindings("a");
var parts = Binder.parseBindings("a");
assertEquals(parts.length, 1);
assertEquals(parts[0], "a");
assertTrue(!nglr.Binder.binding(parts[0]));
assertTrue(!Binder.binding(parts[0]));
};
BinderTest.prototype.testParseEmptyText = function(){
var parts = nglr.Binder.parseBindings("");
var parts = Binder.parseBindings("");
assertEquals(parts.length, 1);
assertEquals(parts[0], "");
assertTrue(!nglr.Binder.binding(parts[0]));
assertTrue(!Binder.binding(parts[0]));
};
BinderTest.prototype.testParseInnerBinding = function(){
var parts = nglr.Binder.parseBindings("a{{b}}c");
var parts = Binder.parseBindings("a{{b}}c");
assertEquals(parts.length, 3);
assertEquals(parts[0], "a");
assertTrue(!nglr.Binder.binding(parts[0]));
assertTrue(!Binder.binding(parts[0]));
assertEquals(parts[1], "{{b}}");
assertEquals(nglr.Binder.binding(parts[1]), "b");
assertEquals(Binder.binding(parts[1]), "b");
assertEquals(parts[2], "c");
assertTrue(!nglr.Binder.binding(parts[2]));
assertTrue(!Binder.binding(parts[2]));
};
BinderTest.prototype.testParseEndingBinding = function(){
var parts = nglr.Binder.parseBindings("a{{b}}");
var parts = Binder.parseBindings("a{{b}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "a");
assertTrue(!nglr.Binder.binding(parts[0]));
assertTrue(!Binder.binding(parts[0]));
assertEquals(parts[1], "{{b}}");
assertEquals(nglr.Binder.binding(parts[1]), "b");
assertEquals(Binder.binding(parts[1]), "b");
};
BinderTest.prototype.testParseBeggingBinding = function(){
var parts = nglr.Binder.parseBindings("{{b}}c");
var parts = Binder.parseBindings("{{b}}c");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
assertEquals(nglr.Binder.binding(parts[0]), "b");
assertEquals(Binder.binding(parts[0]), "b");
assertEquals(parts[1], "c");
assertTrue(!nglr.Binder.binding(parts[1]));
assertTrue(!Binder.binding(parts[1]));
};
BinderTest.prototype.testParseLoanBinding = function(){
var parts = nglr.Binder.parseBindings("{{b}}");
var parts = Binder.parseBindings("{{b}}");
assertEquals(parts.length, 1);
assertEquals(parts[0], "{{b}}");
assertEquals(nglr.Binder.binding(parts[0]), "b");
assertEquals(Binder.binding(parts[0]), "b");
};
BinderTest.prototype.testParseTwoBindings = function(){
var parts = nglr.Binder.parseBindings("{{b}}{{c}}");
var parts = Binder.parseBindings("{{b}}{{c}}");
assertEquals(parts.length, 2);
assertEquals(parts[0], "{{b}}");
assertEquals(nglr.Binder.binding(parts[0]), "b");
assertEquals(Binder.binding(parts[0]), "b");
assertEquals(parts[1], "{{c}}");
assertEquals(nglr.Binder.binding(parts[1]), "c");
assertEquals(Binder.binding(parts[1]), "c");
};
BinderTest.prototype.testParseTwoBindingsWithTextInMiddle = function(){
var parts = nglr.Binder.parseBindings("{{b}}x{{c}}");
var parts = Binder.parseBindings("{{b}}x{{c}}");
assertEquals(parts.length, 3);
assertEquals(parts[0], "{{b}}");
assertEquals(nglr.Binder.binding(parts[0]), "b");
assertEquals(Binder.binding(parts[0]), "b");
assertEquals(parts[1], "x");
assertTrue(!nglr.Binder.binding(parts[1]));
assertTrue(!Binder.binding(parts[1]));
assertEquals(parts[2], "{{c}}");
assertEquals(nglr.Binder.binding(parts[2]), "c");
assertEquals(Binder.binding(parts[2]), "c");
};
BinderTest.prototype.testParseMultiline = function(){
var parts = nglr.Binder.parseBindings('"X\nY{{A\nB}}C\nD"');
assertTrue(!!nglr.Binder.binding('{{A\nB}}'));
var parts = Binder.parseBindings('"X\nY{{A\nB}}C\nD"');
assertTrue(!!Binder.binding('{{A\nB}}'));
assertEquals(parts.length, 3);
assertEquals(parts[0], '"X\nY');
assertEquals(parts[1], '{{A\nB}}');
@ -100,9 +99,9 @@ BinderTest.prototype.testParseMultiline = function(){
};
BinderTest.prototype.testHasBinding = function(){
assertTrue(nglr.Binder.hasBinding("{{a}}"));
assertTrue(!nglr.Binder.hasBinding("a"));
assertTrue(nglr.Binder.hasBinding("{{b}}x{{c}}"));
assertTrue(Binder.hasBinding("{{a}}"));
assertTrue(!Binder.hasBinding("a"));
assertTrue(Binder.hasBinding("{{b}}x{{c}}"));
};
@ -119,9 +118,9 @@ BinderTest.prototype.testChangingTextfieldUpdatesModel = function(){
BinderTest.prototype.testChangingTextareaUpdatesModel = function(){
var form = html('<textarea name="model.note">abc</textarea>');
var scope = new nglr.Scope({model:{}});
var scope = new Scope({model:{}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals(scope.get('model').note, 'abc');
@ -130,9 +129,9 @@ BinderTest.prototype.testChangingTextareaUpdatesModel = function(){
BinderTest.prototype.testChangingRadioUpdatesModel = function(){
var form = html('<input type="radio" name="model.price" value="A" checked>' +
'<input type="radio" name="model.price" value="B">');
var scope = new nglr.Scope({model:{}});
var scope = new Scope({model:{}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals(scope.get('model').price, 'A');
@ -140,9 +139,9 @@ BinderTest.prototype.testChangingRadioUpdatesModel = function(){
BinderTest.prototype.testChangingCheckboxUpdatesModel = function(){
var form = html('<input type="checkbox" name="model.price" value="A" checked>');
var scope = new nglr.Scope({model:{}});
var scope = new Scope({model:{}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals('A', scope.get('model').price);
@ -156,9 +155,9 @@ BinderTest.prototype.testBindUpdate = function() {
BinderTest.prototype.testChangingSelectNonSelectedUpdatesModel = function(){
var form = html('<select name="model.price"><option value="A">A</option><option value="B">B</option></select>');
var scope = new nglr.Scope({model:{}});
var scope = new Scope({model:{}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals('A', scope.get('model').price);
@ -170,9 +169,9 @@ BinderTest.prototype.testChangingMultiselectUpdatesModel = function(){
'<option value="B" selected>Extra padding</option>' +
'<option value="C">Expedite</option>' +
'</select>');
var scope = new nglr.Scope({Invoice:{}});
var scope = new Scope({Invoice:{}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
binder.compile();
binder.updateView();
assertJsonEquals(["A", "B"], scope.get('Invoice').options);
@ -180,9 +179,9 @@ BinderTest.prototype.testChangingMultiselectUpdatesModel = function(){
BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){
var form = html('<select name="model.price"><option>A</option><option selected value="b">B</option></select>');
var scope = new nglr.Scope({model:{}});
var scope = new Scope({model:{}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals(scope.get('model').price, 'b');
@ -190,18 +189,18 @@ BinderTest.prototype.testChangingSelectSelectedUpdatesModel = function(){
BinderTest.prototype.testExecuteInitialization = function() {
var form = html('<div ng-init="a=123">');
var scope = new nglr.Scope();
var scope = new Scope();
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0));
var binder = new Binder(form.get(0));
binder.executeInit();
assertEquals(scope.get('a'), 123);
};
BinderTest.prototype.testExecuteInitializationStatements = function() {
var form = html('<div ng-init="a=123;b=345">');
var scope = new nglr.Scope();
var scope = new Scope();
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0));
var binder = new Binder(form.get(0));
binder.executeInit();
assertEquals(scope.get('a'), 123);
assertEquals(scope.get('b'), 345);
@ -209,9 +208,9 @@ BinderTest.prototype.testExecuteInitializationStatements = function() {
BinderTest.prototype.testApplyTextBindings = function(){
var form = html('<div ng-bind="model.a">x</div>');
var scope = new nglr.Scope({model:{a:123}});
var scope = new Scope({model:{a:123}});
form.data('scope', scope);
var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher());
var binder = new Binder(form.get(0), null, new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals('123', form.text());
@ -224,15 +223,15 @@ BinderTest.prototype.testReplaceBindingInTextWithSpan = function() {
BinderTest.prototype.testReplaceBindingCreatesCorrectNumberOfWidgets = function() {
var h = html("space{{a}}<b>{{a}}a{{a}}</b>{{a}}");
h.data('scope', new nglr.Scope());
var binder = new nglr.Binder(h.get(0), new nglr.WidgetFactory());
h.data('scope', new Scope());
var binder = new Binder(h.get(0), new WidgetFactory());
binder.compile();
assertEquals(4, h.scope().widgets.length);
};
BinderTest.prototype.testBindingSpaceConfusesIE = function() {
if (!nglr.msie) return;
if (!msie) return;
var span = document.createElement("span");
span.innerHTML = '&nbsp;';
var nbsp = span.firstChild.nodeValue;
@ -246,30 +245,30 @@ BinderTest.prototype.testBindingSpaceConfusesIE = function() {
BinderTest.prototype.testBindingOfAttributes = function() {
var form = html("<a href='http://s/a{{b}}c' foo='x'></a>");
form.data('scope', new nglr.Scope());
var binder = new nglr.Binder(form.get(0));
form.data('scope', new Scope());
var binder = new Binder(form.get(0));
binder.compile();
var attrbinding = form.find("a").attr("ng-bind-attr");
var bindings = nglr.fromJson(attrbinding);
var bindings = fromJson(attrbinding);
assertEquals("http://s/a{{b}}c", decodeURI(bindings.href));
assertTrue(!bindings.foo);
};
BinderTest.prototype.testMarkMultipleAttributes = function() {
var form = html("<a href='http://s/a{{b}}c' foo='{{d}}'></a>");
form.data('scope', new nglr.Scope());
var binder = new nglr.Binder(form.get(0));
form.data('scope', new Scope());
var binder = new Binder(form.get(0));
binder.compile();
var attrbinding = form.find("a").attr("ng-bind-attr");
var bindings = nglr.fromJson(attrbinding);
var bindings = fromJson(attrbinding);
assertEquals(decodeURI(bindings.href), "http://s/a{{b}}c");
assertEquals(bindings.foo, "{{d}}");
};
BinderTest.prototype.testAttributesNoneBound = function() {
var form = html("<a href='abc' foo='def'></a>");
form.data('scope', new nglr.Scope());
var binder = new nglr.Binder(form.get(0));
form.data('scope', new Scope());
var binder = new Binder(form.get(0));
binder.compile();
var a = form.find("a");
assertEquals(a.get(0).nodeName, "A");
@ -278,8 +277,8 @@ BinderTest.prototype.testAttributesNoneBound = function() {
BinderTest.prototype.testExistingAttrbindingIsAppended = function() {
var form = html("<a href='http://s/{{abc}}' ng-bind-attr='{\"b\":\"{{def}}\"}'></a>");
form.data('scope', new nglr.Scope());
var binder = new nglr.Binder(form.get(0));
form.data('scope', new Scope());
var binder = new Binder(form.get(0));
binder.compile();
var a = form.find("a");
assertEquals('{"b":"{{def}}","href":"http://s/{{abc}}"}', a.attr('ng-bind-attr'));
@ -287,8 +286,8 @@ BinderTest.prototype.testExistingAttrbindingIsAppended = function() {
BinderTest.prototype.testAttributesAreEvaluated = function(){
var form = html('<a ng-bind-attr=\'{"a":"a", "b":"a+b={{a+b}}"}\'></a>');
form.data('scope', new nglr.Scope({a:1, b:2}));
var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher());
form.data('scope', new Scope({a:1, b:2}));
var binder = new Binder(form.get(0), null, new MockUrlWatcher());
binder.compile();
binder.updateView();
var a = form.find("a");
@ -305,8 +304,8 @@ BinderTest.prototype.testInputsAreUpdated = function(){
'<input name="A.checkbox" type="checkbox" value="c" />' +
'<input name="A.checkboxOff" type="checkbox" value="c" />' +
'<select name="A.select"><option>a</option><option value="S">b</option></select>');
var binder = new nglr.Binder(form.get(0), new nglr.WidgetFactory(), new MockUrlWatcher());
form.data('scope', new nglr.Scope({A:{text:"t1", textarea:"t2", radio:"r", checkbox:"c", select:"S"}}));
var binder = new Binder(form.get(0), new WidgetFactory(), new MockUrlWatcher());
form.data('scope', new Scope({A:{text:"t1", textarea:"t2", radio:"r", checkbox:"c", select:"S"}}));
binder.compile();
binder.updateView();
assertEquals(form.find("input[type=text]").attr('value'), 't1');
@ -349,7 +348,7 @@ BinderTest.prototype.testButtonElementActionExecutesInScope = function(){
};
BinderTest.prototype.testParseEmptyAnchor = function(){
var binder = new nglr.Binder(null, null, new MockUrlWatcher());
var binder = new Binder(null, null, new MockUrlWatcher());
var anchor = binder.anchor;
binder.parseAnchor("a#x=1");
assertEquals(1, binder.anchor.x);
@ -360,7 +359,7 @@ BinderTest.prototype.testParseEmptyAnchor = function(){
};
BinderTest.prototype.testParseAnchor = function(){
var binder = new nglr.Binder(null, null, new MockUrlWatcher());
var binder = new Binder(null, null, new MockUrlWatcher());
binder.parseAnchor("a#x=1");
assertEquals(binder.anchor.x, "1");
binder.parseAnchor("a#a=b&c=%20&d");
@ -371,7 +370,7 @@ BinderTest.prototype.testParseAnchor = function(){
};
BinderTest.prototype.testWriteAnchor = function(){
var binder = new nglr.Binder(null, null, new MockUrlWatcher());
var binder = new Binder(null, null, new MockUrlWatcher());
binder.urlWatcher.setUrl('a');
binder.anchor.a = 'b';
binder.anchor.c = ' ';
@ -381,9 +380,9 @@ BinderTest.prototype.testWriteAnchor = function(){
};
BinderTest.prototype.testWriteAnchorAsPartOfTheUpdateView = function(){
var binder = new nglr.Binder(html("<div/>")[0], null, new MockUrlWatcher());
var binder = new Binder(html("<div/>")[0], null, new MockUrlWatcher());
binder.urlWatcher.setUrl('a');
$(binder.doc).data('scope', new nglr.Scope());
$(binder.doc).data('scope', new Scope());
binder.anchor.a = 'b';
binder.updateView();
assertEquals(binder.urlWatcher.getUrl(), "a#a=b");
@ -391,9 +390,9 @@ BinderTest.prototype.testWriteAnchorAsPartOfTheUpdateView = function(){
BinderTest.prototype.testRepeaterUpdateBindings = function(){
var form = html('<ul><LI ng-repeat="item in model.items" ng-bind="item.a"/></ul>');
var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher());
var binder = new Binder(form.get(0), null, new MockUrlWatcher());
var items = [{a:"A"}, {a:"B"}];
form.data('scope', new nglr.Scope({model:{items:items}}));
form.data('scope', new Scope({model:{items:items}}));
binder.compile();
binder.updateView();
@ -423,8 +422,8 @@ BinderTest.prototype.testRepeaterUpdateBindings = function(){
BinderTest.prototype.testRepeaterContentDoesNotBind = function(){
var form = html('<ul><LI ng-repeat="item in model.items"><span ng-bind="item.a"/></li></ul>');
form.data('scope', new nglr.Scope({model:{items:[{a:"A"}]}}));
var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher());
form.data('scope', new Scope({model:{items:[{a:"A"}]}}));
var binder = new Binder(form.get(0), null, new MockUrlWatcher());
binder.compile();
binder.updateView();
assertEquals('<ul>' +
@ -450,9 +449,9 @@ BinderTest.prototype.testRepeaterInputContentDoesNotBind = function(){
var form =
html('<ul><LI repeater="item in model.items">' +
'<input type="text" name="item.a" value="OLD"/></li></ul>');
var binder = new nglr.Binder(form.get(0), null, new MockUrlWatcher());
var binder = new Binder(form.get(0), null, new MockUrlWatcher());
var items = [{a:"A"}];
form.data('scope', new nglr.Scope({model:{items:items}}));
form.data('scope', new Scope({model:{items:items}}));
assertEquals(form.find(":input").attr("value"), "OLD");
};
@ -492,9 +491,9 @@ BinderTest.prototype.testDoNotOverwriteCustomAction = function(){
BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
expectAsserts(1);
var form = jQuery("body").append('<div id="testTag"><input type="file"></div>');
form.data('scope', new nglr.Scope());
form.data('scope', new Scope());
var factory = {};
var binder = new nglr.Binder(form.get(0), factory, new MockUrlWatcher());
var binder = new Binder(form.get(0), factory, new MockUrlWatcher());
factory.createController = function(node){
assertEquals(node.attr('type'), 'file');
return {updateModel:function(){}};
@ -505,8 +504,8 @@ BinderTest.prototype.testReplaceFileUploadWithSwf = function(){
BinderTest.prototype.testRepeaterAdd = function(){
var doc = $('<div><input type="text" name="item.x" ng-repeat="item in items"></div>');
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
doc.data('scope', new nglr.Scope({items:[{x:'a'}, {x:'b'}], $binder:binder}));
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
doc.data('scope', new Scope({items:[{x:'a'}, {x:'b'}], $binder:binder}));
binder.compile();
binder.updateView();
assertEquals('a', doc.find(':input')[0].value);
@ -520,16 +519,16 @@ BinderTest.prototype.testRepeaterAdd = function(){
BinderTest.prototype.testIfTextBindingThrowsErrorDecorateTheSpan = function(){
var doc = $('<div>{{error.throw()}}</div>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('error.throw', function(){throw "ErrorMsg1";});
binder.updateView();
var span = doc.find('span');
assertTrue(span.hasClass('ng-exception'));
assertEquals('ErrorMsg1', nglr.fromJson(span.text()));
assertEquals('ErrorMsg1', fromJson(span.text()));
assertEquals('"ErrorMsg1"', span.attr('ng-error'));
scope.set('error.throw', function(){throw "MyError";});
@ -548,9 +547,9 @@ BinderTest.prototype.testIfTextBindingThrowsErrorDecorateTheSpan = function(){
BinderTest.prototype.testIfAttrBindingThrowsErrorDecorateTheSpan = function(){
var doc = $('<div attr="before {{error.throw()}} after"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('error.throw', function(){throw "ErrorMsg";});
@ -570,9 +569,9 @@ BinderTest.prototype.testNestedRepeater = function() {
var doc = html('<div ng-repeat="m in model" name="{{m.name}}">' +
'<ul name="{{i}}" ng-repeat="i in m.item"></ul>' +
'</div>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('model', [{name:'a', item:['a1', 'a2']}, {name:'b', item:['b1', 'b2']}]);
@ -594,9 +593,9 @@ BinderTest.prototype.testNestedRepeater = function() {
BinderTest.prototype.testRadioButtonGetsPrefixed = function () {
var doc = html('<input ng-repeat="m in model" type="radio" name="m.a" value="on"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('model', ['a1', 'a2']);
@ -611,9 +610,9 @@ BinderTest.prototype.testRadioButtonGetsPrefixed = function () {
BinderTest.prototype.testHideBindingExpression = function() {
var doc = html('<div ng-hide="hidden == 3"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('hidden', 3);
@ -629,9 +628,9 @@ BinderTest.prototype.testHideBindingExpression = function() {
BinderTest.prototype.testHideBinding = function() {
var doc = html('<div ng-hide="hidden"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('hidden', 'true');
@ -652,9 +651,9 @@ BinderTest.prototype.testHideBinding = function() {
BinderTest.prototype.testShowBinding = function() {
var doc = html('<div ng-show="show"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('show', 'true');
@ -684,9 +683,9 @@ BinderTest.prototype.testBindClassUndefined = function() {
BinderTest.prototype.testBindClass = function() {
var doc = html('<div ng-class="class"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.set('class', 'testClass');
@ -713,9 +712,9 @@ BinderTest.prototype.testBindClassEvenOdd = function() {
BinderTest.prototype.testBindStyle = function() {
var doc = html('<div ng-style="style"/>');
var scope = new nglr.Scope();
var scope = new Scope();
doc.data('scope', scope);
var binder = new nglr.Binder(doc[0], new nglr.WidgetFactory(), new MockUrlWatcher());
var binder = new Binder(doc[0], new WidgetFactory(), new MockUrlWatcher());
binder.compile();
scope.eval('style={color:"red"}');
@ -734,7 +733,7 @@ BinderTest.prototype.testActionOnAHrefThrowsError = function(){
var state = compile('<a ng-action="throw {a:\'abc\', b:2};">Add Phone</a>', model);
var input = state.node.find('a');
input.click();
assertEquals('abc', nglr.fromJson(input.attr('ng-error')).a);
assertEquals('abc', fromJson(input.attr('ng-error')).a);
assertNotNull(input.data('qtip'));
assertTrue("should have an error class", input.hasClass('ng-exception'));
@ -890,7 +889,7 @@ BinderTest.prototype.testItShouldCallListenersWhenAnchorChanges = function() {
};
BinderTest.prototype.testParseQueryString = function(){
var binder = new nglr.Binder();
var binder = new Binder();
assertJsonEquals({"a":"1"}, binder.parseQueryString("a=1"));
assertJsonEquals({"a":"1", "b":"two"}, binder.parseQueryString("a=1&b=two"));
assertJsonEquals({}, binder.parseQueryString(""));
@ -905,8 +904,8 @@ BinderTest.prototype.testParseQueryString = function(){
BinderTest.prototype.testSetBinderAnchorTriggersListeners = function(){
expectAsserts(2);
var doc = html("<div/>")[0];
var binder = new nglr.Binder(doc, null, new MockUrlWatcher());
var scope = new nglr.Scope({$binder:binder, $anchor:binder.anchor});
var binder = new Binder(doc, null, new MockUrlWatcher());
var scope = new Scope({$binder:binder, $anchor:binder.anchor});
jQuery(doc).data('scope', scope);
scope.addWatchListener("$anchor.name", function(newVal, oldVal) {

View file

@ -1,13 +1,12 @@
ConsoleTest = TestCase('ConsoleTest');
ConsoleTest.prototype.testConsoleWrite = function(){
var consoleNode = $("<div></div>")[0];
nglr.consoleNode = consoleNode;
nglr.consoleLog("error", ["Hello", "world"]);
consoleNode = $("<div></div>")[0];
consoleLog("error", ["Hello", "world"]);
assertEquals($(consoleNode)[0].nodeName, 'DIV');
assertEquals($(consoleNode).text(), 'Hello world');
assertEquals($('div', consoleNode)[0].className, 'error');
nglr.consoleLog("error",["Bye"]);
consoleLog("error",["Bye"]);
assertEquals($(consoleNode).text(), 'Hello worldBye');
nglr.consoleNode = null;
consoleNode = null;
};

View file

@ -11,14 +11,14 @@ DataStoreTest.prototype.testSavePostsToServer = function(){
assertEquals("123", posted.$id);
assertEquals("1", posted.$version);
assertFalse('function' == typeof posted.save);
response = nglr.fromJson(nglr.toJson(posted));
response = fromJson(toJson(posted));
response.$entity = "abc";
response.$id = "123";
response.$version = "2";
callback(200, [response]);
};
var model;
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
model = datastore.entity('abc', {name: "value"})();
model.$id = "123";
model.$version = "1";
@ -44,7 +44,7 @@ DataStoreTest.prototype.testLoadGetsFromServer = function(){
response = [{$entity:'abc', $id:'1', $version:'2', key:"value"}];
callback(200, response);
};
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
var model = datastore.entity("abc", {merge:true})();
assertEquals(datastore.load(model, '1', function(obj){
@ -72,14 +72,14 @@ DataStoreTest.prototype.testRemove = function(){
assertEquals("123", posted.$id);
assertEquals("1", posted.$version);
assertFalse('function' == typeof posted.save);
response = nglr.fromJson(nglr.toJson(posted));
response = fromJson(toJson(posted));
response.$entity = "abc";
response.$id = "123";
response.$version = "2";
callback(200, [response]);
};
var model;
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
model = datastore.entity('abc', {name: "value"})();
model.$id = "123";
model.$version = "1";
@ -101,7 +101,7 @@ DataStoreTest.prototype.test401ResponseDoesNotCallCallback = function(){
callback(200, {$status_code: 401});
};
var datastore = new nglr.DataStore(post, {login:function(){
var datastore = new DataStore(post, {login:function(){
assertTrue(true);
}});
@ -119,7 +119,7 @@ DataStoreTest.prototype.test403ResponseDoesNotCallCallback = function(){
callback(200, [{$status_code: 403}]);
};
var datastore = new nglr.DataStore(post, {notAuthorized:function(){
var datastore = new DataStore(post, {notAuthorized:function(){
assertTrue(true);
}});
@ -136,14 +136,14 @@ DataStoreTest.prototype.testLoadCalledWithoutIdShouldBeNoop = function(){
var post = function(url, callback){
assertTrue(false);
};
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
var model = datastore.entity("abc")();
assertEquals(datastore.load(model, undefined), model);
assertEquals(model.$entity, "abc");
};
DataStoreTest.prototype.testEntityFactory = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var Recipe = ds.entity("Recipe", {a:1, b:2});
assertEquals(Recipe.title, "Recipe");
assertEquals(Recipe.defaults.a, 1);
@ -161,7 +161,7 @@ DataStoreTest.prototype.testEntityFactory = function(){
};
DataStoreTest.prototype.testEntityFactoryNoDefaults = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var Recipe = ds.entity("Recipe");
assertEquals(Recipe.title, "Recipe");
@ -170,7 +170,7 @@ DataStoreTest.prototype.testEntityFactoryNoDefaults = function(){
};
DataStoreTest.prototype.testEntityFactoryWithInitialValues = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var Recipe = ds.entity("Recipe");
var recipe = Recipe({name: "name"});
@ -178,7 +178,7 @@ DataStoreTest.prototype.testEntityFactoryWithInitialValues = function(){
};
DataStoreTest.prototype.testEntityLoad = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var Recipe = ds.entity("Recipe", {a:1, b:2});
ds.load = function(instance, id, callback){
callback.apply(instance);
@ -192,7 +192,7 @@ DataStoreTest.prototype.testEntityLoad = function(){
};
DataStoreTest.prototype.testSaveScope = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var log = "";
var Person = ds.entity("Person");
var person1 = Person({name:"A", $entity:"Person", $id:"1", $version:"1"}, ds);
@ -215,7 +215,7 @@ DataStoreTest.prototype.testSaveScope = function(){
};
DataStoreTest.prototype.testEntityLoadAllRows = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var Recipe = ds.entity("Recipe");
var list = [];
ds.loadAll = function(entity, callback){
@ -236,7 +236,7 @@ DataStoreTest.prototype.testLoadAll = function(){
assertEquals("A", data[0][1]);
callback(200, [[{$entity:'A', $id:'1'},{$entity:'A', $id:'2'}]]);
};
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
var list = datastore.entity("A").all(function(){
assertTrue(true);
});
@ -256,7 +256,7 @@ DataStoreTest.prototype.testQuery = function(){
callback(200, [[{$entity:"Employee", $id: "456", managerId: "123ABC"}]]);
};
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
var Employee = datastore.entity("Employee");
var list = Employee.query('managerId', "123abc", function(){
assertTrue(true);
@ -269,7 +269,7 @@ DataStoreTest.prototype.testQuery = function(){
DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function() {
expectAsserts(12);
var post;
var datastore = new nglr.DataStore(function(r, c){post(r,c);});
var datastore = new DataStore(function(r, c){post(r,c);});
var Book = datastore.entity('Book');
post = function(req, callback) {
callback(200, [[{$id:1, $entity:"Book", name:"Moby"},
@ -285,7 +285,7 @@ DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function()
assertEquals("Dick", queryBooks[1].name);
post = function(req, callback) {
assertEquals('[["GET","Book/1"]]', nglr.toJson(req));
assertEquals('[["GET","Book/1"]]', toJson(req));
callback(200, [{$id:1, $entity:"Book", name:"Moby Dick"}]);
};
var book = Book.load(1);
@ -307,7 +307,7 @@ DataStoreTest.prototype.testLoadingDocumentRefreshesExistingArrays = function()
DataStoreTest.prototype.testEntityProperties = function() {
expectAsserts(2);
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var callback = {};
datastore._jsonRequest = function(request, callbackFn) {
@ -322,11 +322,11 @@ DataStoreTest.prototype.testEntityProperties = function() {
DataStoreTest.prototype.testLoadInstanceIsNotFromCache = function() {
var post;
var datastore = new nglr.DataStore(function(r, c){post(r,c);});
var datastore = new DataStore(function(r, c){post(r,c);});
var Book = datastore.entity('Book');
post = function(req, callback) {
assertEquals('[["GET","Book/1"]]', nglr.toJson(req));
assertEquals('[["GET","Book/1"]]', toJson(req));
callback(200, [{$id:1, $entity:"Book", name:"Moby Dick"}]);
};
var book = Book.load(1);
@ -336,14 +336,14 @@ DataStoreTest.prototype.testLoadInstanceIsNotFromCache = function() {
};
DataStoreTest.prototype.testLoadStarsIsNewDocument = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Book = datastore.entity('Book');
var book = Book.load('*');
assertEquals('Book', book.$entity);
};
DataStoreTest.prototype.testUndefinedEntityReturnsNullValueObject = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Entity = datastore.entity(undefined);
var all = Entity.all();
assertEquals(0, all.length);
@ -355,7 +355,7 @@ DataStoreTest.prototype.testFetchEntities = function(){
assertJsonEquals(["GET", "$entities"], data[0]);
callback(200, [{A:0, B:0}]);
};
var datastore = new nglr.DataStore(post);
var datastore = new DataStore(post);
var entities = datastore.entities(function(){
assertTrue(true);
});
@ -367,20 +367,20 @@ DataStoreTest.prototype.testFetchEntities = function(){
};
DataStoreTest.prototype.testItShouldMigrateSchema = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Entity = datastore.entity("Entity", {a:[], user:{name:"Misko", email:""}});
var doc = Entity().$loadFrom({b:'abc', user:{email:"misko@hevery.com"}});
assertFalse(
nglr.toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}) ==
nglr.toJson(doc));
toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}) ==
toJson(doc));
doc.$migrate();
assertEquals(
nglr.toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}),
nglr.toJson(doc));
toJson({a:[], b:'abc', user:{name:"Misko", email:"misko@hevery.com"}}),
toJson(doc));
};
DataStoreTest.prototype.testItShouldCollectRequestsForBulk = function() {
var ds = new nglr.DataStore();
var ds = new DataStore();
var Book = ds.entity("Book");
var Library = ds.entity("Library");
Book.all();
@ -391,7 +391,7 @@ DataStoreTest.prototype.testItShouldCollectRequestsForBulk = function() {
};
DataStoreTest.prototype.testEmptyFlushShouldDoNothing = function () {
var ds = new nglr.DataStore(function(){
var ds = new DataStore(function(){
fail("expecting noop");
});
ds.flush();
@ -400,17 +400,17 @@ DataStoreTest.prototype.testEmptyFlushShouldDoNothing = function () {
DataStoreTest.prototype.testFlushShouldCallAllCallbacks = function() {
var log = "";
function post(request, callback){
log += 'BulkRequest:' + nglr.toJson(request) + ';';
log += 'BulkRequest:' + toJson(request) + ';';
callback(200, [[{$id:'ABC'}], {$id:'XYZ'}]);
}
var ds = new nglr.DataStore(post);
var ds = new DataStore(post);
var Book = ds.entity("Book");
var Library = ds.entity("Library");
Book.all(function(instance){
log += nglr.toJson(instance) + ';';
log += toJson(instance) + ';';
});
Library.load("123", function(instance){
log += nglr.toJson(instance) + ';';
log += toJson(instance) + ';';
});
assertEquals("", log);
ds.flush();
@ -421,7 +421,7 @@ DataStoreTest.prototype.testFlushShouldCallAllCallbacks = function() {
DataStoreTest.prototype.testSaveOnNotLoggedInRetriesAfterLoggin = function(){
var log = "";
var book;
var ds = new nglr.DataStore(null, {login:function(c){c();}});
var ds = new DataStore(null, {login:function(c){c();}});
ds.post = function (request, callback){
assertJsonEquals([["POST", "", book]], request);
ds.post = function(request, callback){
@ -439,7 +439,7 @@ DataStoreTest.prototype.testSaveOnNotLoggedInRetriesAfterLoggin = function(){
DataStoreTest.prototype.testItShouldRemoveItemFromCollectionWhenDeleted = function() {
expectAsserts(6);
var ds = new nglr.DataStore();
var ds = new DataStore();
ds.post = function(request, callback){
assertJsonEquals([["GET", "Book"]], request);
callback(200, [[{name:"Moby Dick", $id:123, $entity:'Book'}]]);
@ -462,7 +462,7 @@ DataStoreTest.prototype.testItShouldRemoveItemFromCollectionWhenDeleted = functi
DataStoreTest.prototype.testItShouldAddToAll = function() {
expectAsserts(8);
var ds = new nglr.DataStore();
var ds = new DataStore();
ds.post = function(request, callback){
assertJsonEquals([["GET", "Book"]], request);
callback(200, [[]]);
@ -490,7 +490,7 @@ DataStoreTest.prototype.testItShouldAddToAll = function() {
DataStoreTest.prototype.testItShouldReturnCreatedDocumentCountByUser = function(){
expectAsserts(2);
var datastore = new nglr.DataStore(
var datastore = new DataStore(
function(request, callback){
assertJsonEquals([["GET", "$users"]], request);
callback(200, [{misko:1, adam:1}]);
@ -502,7 +502,7 @@ DataStoreTest.prototype.testItShouldReturnCreatedDocumentCountByUser = function(
DataStoreTest.prototype.testItShouldReturnDocumentIdsForUeserByEntity = function(){
expectAsserts(2);
var datastore = new nglr.DataStore(
var datastore = new DataStore(
function(request, callback){
assertJsonEquals([["GET", "$users/misko@hevery.com"]], request);
callback(200, [{Book:["1"], Library:["2"]}]);
@ -514,7 +514,7 @@ DataStoreTest.prototype.testItShouldReturnDocumentIdsForUeserByEntity = function
DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){
expectAsserts(7);
var log = "";
var datastore = new nglr.DataStore(
var datastore = new DataStore(
function(request, callback){
assertJsonEquals([["GET", "User/misko"]], request);
callback(200, [{$status_code:404}]);
@ -532,13 +532,13 @@ DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){
DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){
var log = "";
var datastore = new nglr.DataStore(
var datastore = new DataStore(
function(request, callback){
assertJsonEquals([["GET", "User/misko"],["GET", "User/adam"]], request);
callback(200, [{$id:'misko'},{$id:'adam'}]);
});
var User = datastore.entity("User");
var users = User.loadMany(['misko', 'adam'], function(i){log+="cb "+nglr.toJson(i)+";";});
var users = User.loadMany(['misko', 'adam'], function(i){log+="cb "+toJson(i)+";";});
datastore.flush();
assertEquals("misko", users[0].$id);
assertEquals("adam", users[1].$id);
@ -546,7 +546,7 @@ DataStoreTest.prototype.testItShouldReturnNewInstanceOn404 = function(){
};
DataStoreTest.prototype.testItShouldCreateJoinAndQuery = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
var InvoiceWithCustomer = datastore.join({
@ -568,7 +568,7 @@ DataStoreTest.prototype.testItShouldCreateJoinAndQuery = function() {
};
DataStoreTest.prototype.testItShouldThrowIfMoreThanOneEntityIsPrimary = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
assertThrows("Exactly one entity needs to be primary.", function(){
@ -580,7 +580,7 @@ DataStoreTest.prototype.testItShouldThrowIfMoreThanOneEntityIsPrimary = function
};
DataStoreTest.prototype.testItShouldThrowIfLoopInReferences = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
assertThrows("Infinite loop in join: invoice -> customer", function(){
@ -592,7 +592,7 @@ DataStoreTest.prototype.testItShouldThrowIfLoopInReferences = function() {
};
DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
assertThrows("Named entity 'x' is undefined.", function(){
@ -604,7 +604,7 @@ DataStoreTest.prototype.testItShouldThrowIfReferenceToNonExistantJoin = function
};
DataStoreTest.prototype.testItShouldThrowIfQueryOnNonPrimary = function() {
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var Invoice = datastore.entity("Invoice");
var Customer = datastore.entity("Customer");
var InvoiceWithCustomer = datastore.join({

View file

@ -2,7 +2,7 @@ EntityDeclarationTest = TestCase('EntityDeclarationTest');
EntityDeclarationTest.prototype.testEntityTypeOnly = function(){
expectAsserts(2);
var scope = new nglr.Scope({$datastore:{entity:function(name){
var scope = new Scope({$datastore:{entity:function(name){
assertEquals("Person", name);
}}});
var init = scope.entity("Person");
@ -11,7 +11,7 @@ EntityDeclarationTest.prototype.testEntityTypeOnly = function(){
EntityDeclarationTest.prototype.testWithDefaults = function(){
expectAsserts(4);
var scope = new nglr.Scope({$datastore:{entity:function(name, init){
var scope = new Scope({$datastore:{entity:function(name, init){
assertEquals("Person", name);
assertEquals("=a:", init.a);
assertEquals(0, init.b.length);
@ -22,7 +22,7 @@ EntityDeclarationTest.prototype.testWithDefaults = function(){
EntityDeclarationTest.prototype.testWithName = function(){
expectAsserts(2);
var scope = new nglr.Scope({$datastore:{entity:function(name, init){
var scope = new Scope({$datastore:{entity:function(name, init){
assertEquals("Person", name);
return function (){ return {}; };
}}});
@ -34,7 +34,7 @@ EntityDeclarationTest.prototype.testMultipleEntities = function(){
expectAsserts(3);
var expect = ['Person', 'Book'];
var i=0;
var scope = new nglr.Scope({$datastore:{entity:function(name, init){
var scope = new Scope({$datastore:{entity:function(name, init){
assertEquals(expect[i], name);
i++;
return function (){ return {}; };

View file

@ -3,7 +3,7 @@ FileControllerTest = TestCase('FileControllerTest');
FileControllerTest.prototype.testOnSelectUpdateView = function(){
var view = jQuery('<span><a/><span/></span>');
var swf = {};
var controller = new nglr.FileController(view, null, swf);
var controller = new FileController(view, null, swf);
swf.uploadFile = function(path){};
controller._on_select('A', 9, '9 bytes');
assertEquals(view.find('a').text(), "A");
@ -11,14 +11,14 @@ FileControllerTest.prototype.testOnSelectUpdateView = function(){
};
FileControllerTest.prototype.testUpdateModelView = function(){
var view = nglr.FileController.template('');
var view = FileController.template('');
var input = $('<input name="value.input">');
var controller;
var scope = new nglr.Scope({value:{}, $binder:{updateView:function(){
var scope = new Scope({value:{}, $binder:{updateView:function(){
controller.updateView(scope);
}}});
view.data('scope', scope);
controller = new nglr.FileController(view, 'value.input', null, "http://server_base");
controller = new FileController(view, 'value.input', null, "http://server_base");
var value = '{"text":"A", "size":123, "id":"890"}';
controller._on_uploadCompleteData(value);
controller.updateView(scope);
@ -34,7 +34,7 @@ FileControllerTest.prototype.testUpdateModelView = function(){
FileControllerTest.prototype.testFileUpload = function(){
expectAsserts(1);
var swf = {};
var controller = new nglr.FileController(null, null, swf, "http://server_base");
var controller = new FileController(null, null, swf, "http://server_base");
swf.uploadFile = function(path){
assertEquals("http://server_base/_attachments", path);
};
@ -47,16 +47,16 @@ FileControllerTest.prototype.testFileUploadNoFileIsNoop = function(){
var swf = {uploadFile:function(path){
fail();
}};
var controller = new nglr.FileController(null, swf);
var controller = new FileController(null, swf);
controller.upload("basePath", null);
};
FileControllerTest.prototype.testRemoveAttachment = function(){
var doc = nglr.FileController.template();
var doc = FileController.template();
var input = $('<input name="file">');
var scope = new nglr.Scope();
var scope = new Scope();
input.data('scope', scope);
var controller = new nglr.FileController(doc, 'file', null, null);
var controller = new FileController(doc, 'file', null, null);
controller.updateView(scope);
assertEquals(false, doc.find('input').attr('checked'));
@ -75,10 +75,10 @@ FileControllerTest.prototype.testRemoveAttachment = function(){
};
FileControllerTest.prototype.testShouldEmptyOutOnUndefined = function () {
var view = nglr.FileController.template('hello');
var controller = new nglr.FileController(view, 'abc', null, null);
var view = FileController.template('hello');
var controller = new FileController(view, 'abc', null, null);
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('abc', {text: 'myname', url: 'myurl', size: 1234});
controller.updateView(scope);

View file

@ -3,7 +3,7 @@ FiltersTest = TestCase('FiltersTest');
FiltersTest.prototype.testCurrency = function(){
var html = $('<span/>');
var context = {element:html[0]};
var currency = nglr.bind(context, angular.filter.currency);
var currency = bind(context, angular.filter.currency);
assertEquals(currency(0), '$0.00');
assertEquals(html.hasClass('ng-format-negative'), false);
@ -15,8 +15,8 @@ FiltersTest.prototype.testCurrency = function(){
FiltersTest.prototype.testFilterThisIsContext = function(){
expectAsserts(2);
var scope = new nglr.Scope();
nglr.Scope.expressionCache = {};
var scope = new Scope();
Scope.expressionCache = {};
var context = {element:123};
angular.filter.testFn = function () {
assertEquals('Context not equal', this, context);
@ -28,7 +28,7 @@ FiltersTest.prototype.testFilterThisIsContext = function(){
FiltersTest.prototype.testNumberFormat = function(){
var context = {jqElement:$('<span/>')};
var number = nglr.bind(context, angular.filter.number);
var number = bind(context, angular.filter.number);
assertEquals('0', number(0, 0));
assertEquals('0.00', number(0));
@ -40,7 +40,7 @@ FiltersTest.prototype.testNumberFormat = function(){
};
FiltersTest.prototype.testJson = function () {
assertEquals(nglr.toJson({a:"b"}, true), angular.filter.json({a:"b"}));
assertEquals(toJson({a:"b"}, true), angular.filter.json({a:"b"}));
};
FiltersTest.prototype.testPackageTracking = function () {
@ -48,9 +48,9 @@ FiltersTest.prototype.testPackageTracking = function () {
var val = angular.filter.trackPackage(trackingNo, title);
assertNotNull("Did Not Match: " + trackingNo, val);
assertEquals(angular.filter.Meta.TAG, val.TAG);
assertEquals(title + ": " + nglr.trim(trackingNo), val.text);
assertEquals(title + ": " + trim(trackingNo), val.text);
assertNotNull(val.url);
assertEquals(nglr.trim(trackingNo), val.trackingNo);
assertEquals(trim(trackingNo), val.trackingNo);
assertEquals('<a href="' + val.url + '">' + val.text + '</a>', val.html);
};
assert('UPS', ' 1Z 999 999 99 9999 999 9 ');
@ -83,7 +83,7 @@ FiltersTest.prototype.testLink = function() {
};
FiltersTest.prototype.testBytes = function(){
var controller = new nglr.FileController();
var controller = new FileController();
assertEquals(angular.filter.bytes(123), '123 bytes');
assertEquals(angular.filter.bytes(1234), '1.2 KB');
assertEquals(angular.filter.bytes(1234567), '1.1 MB');

View file

@ -1,69 +1,69 @@
JsonTest = TestCase("JsonTest");
JsonTest.prototype.testPrimitives = function () {
assertEquals("null", nglr.toJson(0/0));
assertEquals("null", nglr.toJson(null));
assertEquals("true", nglr.toJson(true));
assertEquals("false", nglr.toJson(false));
assertEquals("123.45", nglr.toJson(123.45));
assertEquals('"abc"', nglr.toJson("abc"));
assertEquals('"a \\t \\n \\r b \\\\"', nglr.toJson("a \t \n \r b \\"));
assertEquals("null", toJson(0/0));
assertEquals("null", toJson(null));
assertEquals("true", toJson(true));
assertEquals("false", toJson(false));
assertEquals("123.45", toJson(123.45));
assertEquals('"abc"', toJson("abc"));
assertEquals('"a \\t \\n \\r b \\\\"', toJson("a \t \n \r b \\"));
};
JsonTest.prototype.testEscaping = function () {
assertEquals("\"7\\\\\\\"7\"", nglr.toJson("7\\\"7"));
assertEquals("\"7\\\\\\\"7\"", toJson("7\\\"7"));
};
JsonTest.prototype.testObjects = function () {
assertEquals('{"a":1,"b":2}', nglr.toJson({a:1,b:2}));
assertEquals('{"a":{"b":2}}', nglr.toJson({a:{b:2}}));
assertEquals('{"a":{"b":{"c":0}}}', nglr.toJson({a:{b:{c:0}}}));
assertEquals('{"a":{"b":null}}', nglr.toJson({a:{b:0/0}}));
assertEquals('{"a":1,"b":2}', toJson({a:1,b:2}));
assertEquals('{"a":{"b":2}}', toJson({a:{b:2}}));
assertEquals('{"a":{"b":{"c":0}}}', toJson({a:{b:{c:0}}}));
assertEquals('{"a":{"b":null}}', toJson({a:{b:0/0}}));
};
JsonTest.prototype.testObjectPretty = function () {
assertEquals('{\n "a":1,\n "b":2}', nglr.toJson({a:1,b:2}, true));
assertEquals('{\n "a":{\n "b":2}}', nglr.toJson({a:{b:2}}, true));
assertEquals('{\n "a":1,\n "b":2}', toJson({a:1,b:2}, true));
assertEquals('{\n "a":{\n "b":2}}', toJson({a:{b:2}}, true));
};
JsonTest.prototype.testArray = function () {
assertEquals('[]', nglr.toJson([]));
assertEquals('[1,"b"]', nglr.toJson([1,"b"]));
assertEquals('[]', toJson([]));
assertEquals('[1,"b"]', toJson([1,"b"]));
};
JsonTest.prototype.testIgnoreFunctions = function () {
assertEquals('[null,1]', nglr.toJson([function(){},1]));
assertEquals('{}', nglr.toJson({a:function(){}}));
assertEquals('[null,1]', toJson([function(){},1]));
assertEquals('{}', toJson({a:function(){}}));
};
JsonTest.prototype.testParseNull = function () {
assertNull(nglr.fromJson("null"));
assertNull(fromJson("null"));
};
JsonTest.prototype.testParseBoolean = function () {
assertTrue(nglr.fromJson("true"));
assertFalse(nglr.fromJson("false"));
assertTrue(fromJson("true"));
assertFalse(fromJson("false"));
};
JsonTest.prototype.test$$isIgnored = function () {
assertEquals("{}", nglr.toJson({$$:0}));
assertEquals("{}", toJson({$$:0}));
};
JsonTest.prototype.testArrayWithEmptyItems = function () {
var a = [];
a[1] = "X";
assertEquals('[null,"X"]', nglr.toJson(a));
assertEquals('[null,"X"]', toJson(a));
};
JsonTest.prototype.testItShouldEscapeUnicode = function () {
assertEquals(1, "\u00a0".length);
assertEquals(8, nglr.toJson("\u00a0").length);
assertEquals(1, nglr.fromJson(nglr.toJson("\u00a0")).length);
assertEquals(8, toJson("\u00a0").length);
assertEquals(1, fromJson(toJson("\u00a0")).length);
};
JsonTest.prototype.testItShouldUTCDates = function() {
var date = angular.String.toDate("2009-10-09T01:02:03Z");
assertEquals('"2009-10-09T01:02:03Z"', nglr.toJson(date));
assertEquals('"2009-10-09T01:02:03Z"', toJson(date));
assertEquals(date.getTime(),
nglr.fromJson('"2009-10-09T01:02:03Z"').getTime());
fromJson('"2009-10-09T01:02:03Z"').getTime());
};

View file

@ -3,7 +3,7 @@ LoaderTest = TestCase('LoaderTest');
LoaderTest.prototype.testLoadCss = function(){
if ($.browser.safari) return;
var head = jQuery('<head/>')[0];
var loader = new nglr.Loader(document, head, {});
var loader = new Loader(document, head, {});
var log = '';
loader.config.server = 'http://';
loader.loadCss('x');
@ -11,15 +11,15 @@ LoaderTest.prototype.testLoadCss = function(){
};
LoaderTest.prototype.testDefaultDatabasePathFromSubdomain = function() {
var loader = new nglr.Loader(null, null, {server:"http://account.getangular.com", database:"database"});
var loader = new Loader(null, null, {server:"http://account.getangular.com", database:"database"});
loader.computeConfiguration();
assertEquals("database", loader.config.database);
loader = new nglr.Loader(null, null, {server:"http://account.getangular.com"});
loader = new Loader(null, null, {server:"http://account.getangular.com"});
loader.computeConfiguration();
assertEquals("account", loader.config.database);
loader = new nglr.Loader(null, null, {server:"https://account.getangular.com"});
loader = new Loader(null, null, {server:"https://account.getangular.com"});
loader.computeConfiguration();
assertEquals("account", loader.config.database);
};
@ -31,7 +31,7 @@ UrlWatcherTest = TestCase('UrlWatcherTest');
UrlWatcherTest.prototype.testUrlWatcher = function () {
expectAsserts(2);
var location = {href:"http://server", hash:""};
var watcher = new nglr.UrlWatcher(location);
var watcher = new UrlWatcher(location);
watcher.delay = 1;
watcher.listener = function(url){
assertEquals('http://getangular.test', url);
@ -49,9 +49,9 @@ UrlWatcherTest.prototype.testUrlWatcher = function () {
UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = function(){
expectAsserts(2);
var location = {href:"http://server", hash:"#$iframe_notify=1234"};
var watcher = new nglr.UrlWatcher(location);
nglr._iframe_notify_1234 = function () {
assertEquals("undefined", typeof nglr._iframe_notify_1234);
var watcher = new UrlWatcher(location);
callbacks._iframe_notify_1234 = function () {
assertEquals("undefined", typeof callbacks._iframe_notify_1234);
assertEquals("http://server2#", location.href);
};
watcher.delay = 1;
@ -66,5 +66,5 @@ UrlWatcherTest.prototype.testItShouldFireOnUpdateEventWhenSpecialURLSet = functi
FunctionTest = TestCase("FunctionTest");
FunctionTest.prototype.testEscapeHtml = function () {
assertEquals("&lt;div&gt;&amp;amp;&lt;/div&gt;", nglr.escapeHtml('<div>&amp;</div>'));
assertEquals("&lt;div&gt;&amp;amp;&lt;/div&gt;", escapeHtml('<div>&amp;</div>'));
};

View file

@ -1,7 +1,7 @@
ModelTest = TestCase('ModelTest');
ModelTest.prototype.testLoadSaveOperations = function(){
var m1 = new nglr.DataStore().entity('A')();
var m1 = new DataStore().entity('A')();
m1.a = 1;
var m2 = {b:1};
@ -13,7 +13,7 @@ ModelTest.prototype.testLoadSaveOperations = function(){
};
ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){
var m1 = new nglr.DataStore().entity('A')();
var m1 = new DataStore().entity('A')();
m1.id = function(){return 'OK';};
m1.$loadFrom({id:null});
assertEquals(m1.id(), 'OK');
@ -24,7 +24,7 @@ ModelTest.prototype.testLoadfromDoesNotClobberFunctions = function(){
};
ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){
var ds = new nglr.DataStore();
var ds = new DataStore();
var m = ds.entity('A')();
assertTrue(m.$$entity.datastore === ds);
m.$loadFrom({});
@ -33,7 +33,7 @@ ModelTest.prototype.testDataStoreDoesNotGetClobbered = function(){
ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){
expectAsserts(7);
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var model = datastore.entity("A", {a:1})();
var fn = {};
datastore.save = function(instance, callback) {
@ -56,7 +56,7 @@ ModelTest.prototype.testManagedModelDelegatesMethodsToDataStore = function(){
ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){
expectAsserts(6);
var datastore = new nglr.DataStore();
var datastore = new DataStore();
var model = datastore.entity("A", {a:1})();
datastore.save = function(instance, callback) {
@ -77,7 +77,7 @@ ModelTest.prototype.testManagedModelCanBeForcedToFlush = function(){
ModelTest.prototype.testItShouldMakeDeepCopyOfInitialValues = function (){
var initial = {a:[]};
var entity = new nglr.DataStore().entity("A", initial);
var entity = new DataStore().entity("A", initial);
var model = entity();
model.a.push(1);
assertEquals(0, entity().a.length);

View file

@ -1,7 +1,7 @@
LexerTest = TestCase('LexerTest');
LexerTest.prototype.testTokenizeAString = function(){
var lexer = new nglr.Lexer("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\"");
var lexer = new Lexer("a.bc[22]+1.3|f:'a\\\'c':\"d\\\"e\"");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@ -54,7 +54,7 @@ LexerTest.prototype.testTokenizeAString = function(){
LexerTest.prototype.testTokenizeRegExp = function(){
var lexer = new nglr.Lexer("/r 1/");
var lexer = new Lexer("/r 1/");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@ -64,7 +64,7 @@ LexerTest.prototype.testTokenizeRegExp = function(){
LexerTest.prototype.testQuotedString = function(){
var str = "['\\'', \"\\\"\"]";
var lexer = new nglr.Lexer(str);
var lexer = new Lexer(str);
var tokens = lexer.parse();
assertEquals(1, tokens[1].index);
@ -77,21 +77,21 @@ LexerTest.prototype.testQuotedString = function(){
LexerTest.prototype.testQuotedStringEscape = function(){
var str = '"\\"\\n\\f\\r\\t\\v\\u00A0"';
var lexer = new nglr.Lexer(str);
var lexer = new Lexer(str);
var tokens = lexer.parse();
assertEquals('"\n\f\r\t\v\u00A0', tokens[0].text);
};
LexerTest.prototype.testTokenizeUnicode = function(){
var lexer = new nglr.Lexer('"\\u00A0"');
var lexer = new Lexer('"\\u00A0"');
var tokens = lexer.parse();
assertEquals(1, tokens.length);
assertEquals('\u00a0', tokens[0].text);
};
LexerTest.prototype.testTokenizeRegExpWithOptions = function(){
var lexer = new nglr.Lexer("/r/g");
var lexer = new Lexer("/r/g");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@ -101,7 +101,7 @@ LexerTest.prototype.testTokenizeRegExpWithOptions = function(){
};
LexerTest.prototype.testTokenizeRegExpWithEscape = function(){
var lexer = new nglr.Lexer("/\\/\\d/");
var lexer = new Lexer("/\\/\\d/");
var tokens = lexer.parse();
var i = 0;
assertEquals(tokens[i].index, 0);
@ -110,14 +110,14 @@ LexerTest.prototype.testTokenizeRegExpWithEscape = function(){
};
LexerTest.prototype.testIgnoreWhitespace = function(){
var lexer = new nglr.Lexer("a \t \n \r b");
var lexer = new Lexer("a \t \n \r b");
var tokens = lexer.parse();
assertEquals(tokens[0].text, 'a');
assertEquals(tokens[1].text, 'b');
};
LexerTest.prototype.testRelation = function(){
var lexer = new nglr.Lexer("! == != < > <= >=");
var lexer = new Lexer("! == != < > <= >=");
var tokens = lexer.parse();
assertEquals(tokens[0].text, '!');
assertEquals(tokens[1].text, '==');
@ -129,7 +129,7 @@ LexerTest.prototype.testRelation = function(){
};
LexerTest.prototype.testStatements = function(){
var lexer = new nglr.Lexer("a;b;");
var lexer = new Lexer("a;b;");
var tokens = lexer.parse();
assertEquals(tokens[0].text, 'a');
assertEquals(tokens[1].text, ';');
@ -140,7 +140,7 @@ LexerTest.prototype.testStatements = function(){
ParserTest = TestCase('ParserTest');
ParserTest.prototype.testExpressions = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("-1"), -1);
assertEquals(scope.eval("1 + 2.5"), 3.5);
assertEquals(scope.eval("1 + -2.5"), -1.5);
@ -151,7 +151,7 @@ ParserTest.prototype.testExpressions = function(){
};
ParserTest.prototype.testComparison = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("false"), false);
assertEquals(scope.eval("!true"), false);
assertEquals(scope.eval("1==1"), true);
@ -163,14 +163,14 @@ ParserTest.prototype.testComparison = function(){
};
ParserTest.prototype.testLogical = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("0&&2"), 0&&2);
assertEquals(scope.eval("0||2"), 0||2);
assertEquals(scope.eval("0||1&&2"), 0||1&&2);
};
ParserTest.prototype.testString = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("'a' + 'b c'"), "ab c");
};
@ -182,7 +182,7 @@ ParserTest.prototype.testFilters = function(){
angular.filter.upper = {_case:function(input) {
return input.toUpperCase();
}};
var scope = new nglr.Scope();
var scope = new Scope();
try {
scope.eval("1|nonExistant");
fail();
@ -196,7 +196,7 @@ ParserTest.prototype.testFilters = function(){
};
ParserTest.prototype.testScopeAccess = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('a', 123);
scope.set('b.c', 456);
assertEquals(scope.eval("a", scope), 123);
@ -205,16 +205,16 @@ ParserTest.prototype.testScopeAccess = function(){
};
ParserTest.prototype.testGrouping = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("(1+2)*3"), (1+2)*3);
};
ParserTest.prototype.testAssignments = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("a=12"), 12);
assertEquals(scope.get("a"), 12);
scope = new nglr.Scope();
scope = new Scope();
assertEquals(scope.eval("x.y.z=123;"), 123);
assertEquals(scope.get("x.y.z"), 123);
@ -224,13 +224,13 @@ ParserTest.prototype.testAssignments = function(){
};
ParserTest.prototype.testFunctionCallsNoArgs = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('const', function(a,b){return 123;});
assertEquals(scope.eval("const()"), 123);
};
ParserTest.prototype.testFunctionCalls = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('add', function(a,b){
return a+b;
});
@ -238,7 +238,7 @@ ParserTest.prototype.testFunctionCalls = function(){
};
ParserTest.prototype.testCalculationBug = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('taxRate', 8);
scope.set('subTotal', 100);
assertEquals(scope.eval("taxRate / 100 * subTotal"), 8);
@ -246,7 +246,7 @@ ParserTest.prototype.testCalculationBug = function(){
};
ParserTest.prototype.testArray = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("[]").length, 0);
assertEquals(scope.eval("[1, 2]").length, 2);
assertEquals(scope.eval("[1, 2]")[0], 1);
@ -254,7 +254,7 @@ ParserTest.prototype.testArray = function(){
};
ParserTest.prototype.testArrayAccess = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("[1][0]"), 1);
assertEquals(scope.eval("[[1]][0][0]"), 1);
assertEquals(scope.eval("[].length"), 0);
@ -262,33 +262,33 @@ ParserTest.prototype.testArrayAccess = function(){
};
ParserTest.prototype.testObject = function(){
var scope = new nglr.Scope();
assertEquals(nglr.toJson(scope.eval("{}")), "{}");
assertEquals(nglr.toJson(scope.eval("{a:'b'}")), '{"a":"b"}');
assertEquals(nglr.toJson(scope.eval("{'a':'b'}")), '{"a":"b"}');
assertEquals(nglr.toJson(scope.eval("{\"a\":'b'}")), '{"a":"b"}');
var scope = new Scope();
assertEquals(toJson(scope.eval("{}")), "{}");
assertEquals(toJson(scope.eval("{a:'b'}")), '{"a":"b"}');
assertEquals(toJson(scope.eval("{'a':'b'}")), '{"a":"b"}');
assertEquals(toJson(scope.eval("{\"a\":'b'}")), '{"a":"b"}');
};
ParserTest.prototype.testObjectAccess = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals("WC", scope.eval("{false:'WC', true:'CC'}[false]"));
};
ParserTest.prototype.testJSON = function(){
var scope = new nglr.Scope();
assertEquals(nglr.toJson(scope.eval("[{}]")), "[{}]");
assertEquals(nglr.toJson(scope.eval("[{a:[]}, {b:1}]")), '[{"a":[]},{"b":1}]');
var scope = new Scope();
assertEquals(toJson(scope.eval("[{}]")), "[{}]");
assertEquals(toJson(scope.eval("[{a:[]}, {b:1}]")), '[{"a":[]},{"b":1}]');
};
ParserTest.prototype.testMultippleStatements = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(scope.eval("a=1;b=3;a+b"), 4);
assertEquals(scope.eval(";;1;;"), 1);
};
ParserTest.prototype.testParseThrow = function(){
expectAsserts(1);
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('e', 'abc');
try {
scope.eval("throw e");
@ -298,7 +298,7 @@ ParserTest.prototype.testParseThrow = function(){
};
ParserTest.prototype.testMethodsGetDispatchedWithCorrectThis = function(){
var scope = new nglr.Scope();
var scope = new Scope();
var C = function (){
this.a=123;
};
@ -310,7 +310,7 @@ ParserTest.prototype.testMethodsGetDispatchedWithCorrectThis = function(){
assertEquals(123, scope.eval("obj.getA()"));
};
ParserTest.prototype.testMethodsArgumentsGetCorrectThis = function(){
var scope = new nglr.Scope();
var scope = new Scope();
var C = function (){
this.a=123;
};
@ -326,13 +326,13 @@ ParserTest.prototype.testMethodsArgumentsGetCorrectThis = function(){
};
ParserTest.prototype.testObjectPointsToScopeValue = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('a', "abc");
assertEquals("abc", scope.eval("{a:a}").a);
};
ParserTest.prototype.testFieldAccess = function(){
var scope = new nglr.Scope();
var scope = new Scope();
var fn = function(){
return {name:'misko'};
};
@ -341,14 +341,14 @@ ParserTest.prototype.testFieldAccess = function(){
};
ParserTest.prototype.testArrayIndexBug = function () {
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('items', [{}, {name:'misko'}]);
assertEquals("misko", scope.eval('items[1].name'));
};
ParserTest.prototype.testArrayAssignment = function () {
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('items', []);
assertEquals("abc", scope.eval('items[1] = "abc"'));
@ -359,30 +359,30 @@ ParserTest.prototype.testArrayAssignment = function () {
};
ParserTest.prototype.testFiltersCanBeGrouped = function () {
var scope = new nglr.Scope({name:'MISKO'});
var scope = new Scope({name:'MISKO'});
assertEquals('misko', scope.eval('n = (name|lowercase)'));
assertEquals('misko', scope.eval('n'));
};
ParserTest.prototype.testFiltersCanBeGrouped = function () {
var scope = new nglr.Scope({name:'MISKO'});
var scope = new Scope({name:'MISKO'});
assertEquals('misko', scope.eval('n = (name|lowercase)'));
assertEquals('misko', scope.eval('n'));
};
ParserTest.prototype.testRemainder = function () {
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(1, scope.eval('1%2'));
};
ParserTest.prototype.testSumOfUndefinedIsNotUndefined = function () {
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(1, scope.eval('1+undefined'));
assertEquals(1, scope.eval('undefined+1'));
};
ParserTest.prototype.testMissingThrowsError = function() {
var scope = new nglr.Scope();
var scope = new Scope();
try {
scope.eval('[].count(');
fail();
@ -392,7 +392,7 @@ ParserTest.prototype.testMissingThrowsError = function() {
};
ParserTest.prototype.testItShouldParseOnChangeIntoHashSet = function () {
var scope = new nglr.Scope({count:0});
var scope = new Scope({count:0});
scope.watch("$anchor.a:count=count+1;$anchor.a:count=count+20;b:count=count+300");
scope.watchListeners["$anchor.a"].listeners[0]();
@ -403,7 +403,7 @@ ParserTest.prototype.testItShouldParseOnChangeIntoHashSet = function () {
assertEquals(321, scope.get("count"));
};
ParserTest.prototype.testItShouldParseOnChangeBlockIntoHashSet = function () {
var scope = new nglr.Scope({count:0});
var scope = new Scope({count:0});
var listeners = {a:[], b:[]};
scope.watch("a:{count=count+1;count=count+20;};b:count=count+300",
function(n, fn){listeners[n].push(fn);});
@ -417,12 +417,12 @@ ParserTest.prototype.testItShouldParseOnChangeBlockIntoHashSet = function () {
};
ParserTest.prototype.testItShouldParseEmptyOnChangeAsNoop = function () {
var scope = new nglr.Scope();
var scope = new Scope();
scope.watch("", function(){fail();});
};
ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function () {
var scope = new nglr.Scope();
var scope = new Scope();
var fn = scope.eval("{:value}");
scope.set("value", 1);
assertEquals(1, fn());
@ -433,7 +433,7 @@ ParserTest.prototype.testItShouldCreateClosureFunctionWithNoArguments = function
};
ParserTest.prototype.testItShouldCreateClosureFunctionWithArguments = function () {
var scope = new nglr.Scope();
var scope = new Scope();
var fn = scope.eval("{(a):value+a}");
scope.set("value", 1);
assertEquals(11, fn(10));
@ -444,14 +444,14 @@ ParserTest.prototype.testItShouldCreateClosureFunctionWithArguments = function (
};
ParserTest.prototype.testItShouldHaveDefaultArugument = function(){
var scope = new nglr.Scope();
var scope = new Scope();
var fn = scope.eval("{:$*2}");
assertEquals(4, fn(2));
};
ParserTest.prototype.testReturnFunctionsAreNotBound = function(){
var scope = new nglr.Scope();
scope.set("$datastore", new nglr.DataStore());
var scope = new Scope();
scope.set("$datastore", new DataStore());
scope.entity("Group");
var Group = scope.get("Group");
assertEquals("eval Group", "function", typeof scope.eval("Group"));

View file

@ -23,13 +23,13 @@ ScopeTest.prototype.testNoScopeDoesNotCauseInfiniteRecursion = function(){
};
ScopeTest.prototype.testScopeEval = function(){
var scope = new nglr.Scope({b:345});
var scope = new Scope({b:345});
assertEquals(scope.eval('b = 123'), 123);
assertEquals(scope.get('b'), 123);
};
ScopeTest.prototype.testScopeFromPrototype = function(){
var scope = new nglr.Scope({b:123});
var scope = new Scope({b:123});
scope.eval('a = b');
scope.eval('b = 456');
assertEquals(scope.get('a'), 123);
@ -37,32 +37,32 @@ ScopeTest.prototype.testScopeFromPrototype = function(){
};
ScopeTest.prototype.testSetScopeGet = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('a', 987);
assertEquals(scope.get('a'), 987);
assertEquals(scope.eval('a'), 987);
};
ScopeTest.prototype.testGetChain = function(){
var scope = new nglr.Scope({a:{b:987}});
var scope = new Scope({a:{b:987}});
assertEquals(scope.get('a.b'), 987);
assertEquals(scope.eval('a.b'), 987);
};
ScopeTest.prototype.testGetUndefinedChain = function(){
var scope = new nglr.Scope();
var scope = new Scope();
assertEquals(typeof scope.get('a.b'), 'undefined');
};
ScopeTest.prototype.testSetChain = function(){
var scope = new nglr.Scope({a:{}});
var scope = new Scope({a:{}});
scope.set('a.b', 987);
assertEquals(scope.get('a.b'), 987);
assertEquals(scope.eval('a.b'), 987);
};
ScopeTest.prototype.testSetGetOnChain = function(){
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('a.b', 987);
assertEquals(scope.get('a.b'), 987);
assertEquals(scope.eval('a.b'), 987);
@ -70,7 +70,7 @@ ScopeTest.prototype.testSetGetOnChain = function(){
ScopeTest.prototype.testGlobalFunctionAccess =function(){
window['scopeAddTest'] = function (a, b) {return a+b;};
var scope = new nglr.Scope({window:window});
var scope = new Scope({window:window});
assertEquals(scope.eval('window.scopeAddTest(1,2)'), 3);
scope.set('add', function (a, b) {return a+b;});
@ -82,7 +82,7 @@ ScopeTest.prototype.testGlobalFunctionAccess =function(){
ScopeTest.prototype.testValidationEval = function(){
expectAsserts(4);
var scope = new nglr.Scope();
var scope = new Scope();
angular.validator.testValidator = function(value, expect){
assertEquals(scope, this.scope);
return value == expect ? null : "Error text";
@ -96,7 +96,7 @@ ScopeTest.prototype.testValidationEval = function(){
ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException = function() {
expectAsserts(1);
var scope = new nglr.Scope({obj:{}});
var scope = new Scope({obj:{}});
try {
scope.eval("obj.iDontExist()");
fail();
@ -106,7 +106,7 @@ ScopeTest.prototype.testCallingNonExistantMethodShouldProduceFriendlyException =
};
ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() {
var scope = new nglr.Scope();
var scope = new Scope();
try {
scope.get('a.{{b}}');
fail();
@ -116,25 +116,25 @@ ScopeTest.prototype.testAccessingWithInvalidPathShouldThrowError = function() {
};
ScopeTest.prototype.testItShouldHave$parent = function() {
var parent = new nglr.Scope({}, "ROOT");
var child = new nglr.Scope(parent.state);
var parent = new Scope({}, "ROOT");
var child = new Scope(parent.state);
assertSame("parent", child.state.$parent, parent.state);
assertSame("root", child.state.$root, parent.state);
};
ScopeTest.prototype.testItShouldHave$root = function() {
var scope = new nglr.Scope({}, "ROOT");
var scope = new Scope({}, "ROOT");
assertSame(scope.state.$root, scope.state);
};
ScopeTest.prototype.testItShouldBuildPathOnUndefined = function(){
var scope = new nglr.Scope({}, "ROOT");
var scope = new Scope({}, "ROOT");
scope.setEval("a.$b.c", 1);
assertJsonEquals({$b:{c:1}}, scope.get("a"));
};
ScopeTest.prototype.testItShouldMapUnderscoreFunctions = function(){
var scope = new nglr.Scope({}, "ROOT");
var scope = new Scope({}, "ROOT");
scope.set("a", [1,2,3]);
assertEquals('function', typeof scope.get("a.$size"));
scope.eval("a.$includeIf(4,true)");

View file

@ -1,7 +1,7 @@
ServerTest = TestCase("ServerTest");
ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
var log = "";
var server = new nglr.Server("http://server", function(url){
var server = new Server("http://server", function(url){
log += "|" + url;
});
server.maxSize = 30;
@ -10,7 +10,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
assertEquals(200, code);
assertEquals("response", r);
});
nglr.uuid0("response");
callbacks.uuid0("response");
assertEquals(
"|http://server/$/uuid0/2/1?h=eyJtIjoiUE9TVCIsInAiOnt9LCJ1Ij" +
"|http://server/$/uuid0/2/2?h=oiL2RhdGEvZGF0YWJhc2UifQ==",
@ -18,7 +18,7 @@ ServerTest.prototype.testBreakLargeRequestIntoPackets = function() {
};
ServerTest.prototype.testItShouldEncodeUsingUrlRules = function() {
var server = new nglr.Server("http://server");
var server = new Server("http://server");
assertEquals("fn5-fn5-", server.base64url("~~~~~~"));
assertEquals("fn5_fn5_", server.base64url("~~\u007f~~\u007f"));
};
@ -28,13 +28,13 @@ FrameServerTest = TestCase("FrameServerTest");
FrameServerTest.prototype = {
testRead:function(){
var window = {name:'$DATASET:"MyData"'};
var server = new nglr.FrameServer(window);
var server = new FrameServer(window);
server.read();
assertEquals("MyData", server.data);
},
testWrite:function(){
var window = {};
var server = new nglr.FrameServer(window);
var server = new FrameServer(window);
server.data = "TestData"
server.write();
assertEquals('$DATASET:"TestData"', window.name);

View file

@ -10,10 +10,10 @@ UsersTest.prototype = {
testItShouldFetchCurrentUser:function(){
expectAsserts(5);
var user;
var users = new nglr.Users({request:function(method, url, request, callback){
var users = new Users({request:function(method, url, request, callback){
assertEquals("GET", method);
assertEquals("/account.json", url);
assertEquals("{}", nglr.toJson(request));
assertEquals("{}", toJson(request));
callback(200, {$status_code:200, user:{name:'misko'}});
}});
users.fetchCurrentUser(function(u){

View file

@ -2,8 +2,8 @@ WidgetTest = TestCase('WidgetTest');
WidgetTest.prototype.testRequired = function () {
var view = $('<input name="a" ng-required>');
var scope = new nglr.Scope({$invalidWidgets:[]});
var cntl = new nglr.TextController(view[0], 'a');
var scope = new Scope({$invalidWidgets:[]});
var cntl = new TextController(view[0], 'a');
cntl.updateView(scope);
assertTrue(view.hasClass('ng-validation-error'));
assertEquals("Required Value", view.attr('ng-error'));
@ -15,8 +15,8 @@ WidgetTest.prototype.testRequired = function () {
WidgetTest.prototype.testValidator = function () {
var view = $('<input name="a" ng-validate="testValidator:\'ABC\'">');
var scope = new nglr.Scope({$invalidWidgets:[]});
var cntl = new nglr.TextController(view[0], 'a');
var scope = new Scope({$invalidWidgets:[]});
var cntl = new TextController(view[0], 'a');
angular.validator.testValidator = function(value, expect){
return value == expect ? null : "Error text";
};
@ -43,8 +43,8 @@ WidgetTest.prototype.testValidator = function () {
WidgetTest.prototype.testRequiredValidator = function () {
var view = $('<input name="a" ng-required ng-validate="testValidator:\'ABC\'">');
var scope = new nglr.Scope({$invalidWidgets:[]});
var cntl = new nglr.TextController(view[0], 'a');
var scope = new Scope({$invalidWidgets:[]});
var cntl = new TextController(view[0], 'a');
angular.validator.testValidator = function(value, expect){
return value == expect ? null : "Error text";
};
@ -67,29 +67,29 @@ WidgetTest.prototype.testRequiredValidator = function () {
delete angular.validator['testValidator'];
};
TextController = TestCase("TextController");
TextControllerTest = TestCase("TextControllerTest");
TextController.prototype.testDatePicker = function() {
TextControllerTest.prototype.testDatePicker = function() {
var input = $('<input type="text" ng-widget="datepicker">');
input.data('scope', new nglr.Scope());
input.data('scope', new Scope());
var body = $(document.body);
body.append(input);
var binder = new nglr.Binder(input[0], new nglr.WidgetFactory());
var binder = new Binder(input[0], new WidgetFactory());
assertTrue('before', input.data('datepicker') === undefined);
binder.compile();
assertTrue('after', input.data('datepicker') !== null);
assertTrue(body.html(), input.hasClass('hasDatepicker'));
};
RepeaterUpdater = TestCase("RepeaterUpdater");
RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest");
RepeaterUpdater.prototype.testRemoveThenAdd = function() {
RepeaterUpdaterTest.prototype.testRemoveThenAdd = function() {
var view = $("<div><span/></div>");
var template = function () {
return $("<li/>");
};
var repeater = new nglr.RepeaterUpdater(view.find("span"), "a in b", template, "");
var scope = new nglr.Scope();
var repeater = new RepeaterUpdater(view.find("span"), "a in b", template, "");
var scope = new Scope();
scope.set('b', [1,2]);
repeater.updateView(scope);
@ -102,14 +102,14 @@ RepeaterUpdater.prototype.testRemoveThenAdd = function() {
assertEquals(1, view.find("li").size());
};
RepeaterUpdater.prototype.testShouldBindWidgetOnRepeaterClone = function(){
RepeaterUpdaterTest.prototype.testShouldBindWidgetOnRepeaterClone = function(){
//fail();
};
RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){
RepeaterUpdaterTest.prototype.testShouldThrowInformativeSyntaxError= function(){
expectAsserts(1);
try {
var repeater = new nglr.RepeaterUpdater(null, "a=b");
var repeater = new RepeaterUpdater(null, "a=b");
} catch (e) {
assertEquals("Expected ng-repeat in form of 'item in collection' but got 'a=b'.", e);
}
@ -118,17 +118,17 @@ RepeaterUpdater.prototype.testShouldThrowInformativeSyntaxError= function(){
SelectControllerTest = TestCase("SelectControllerTest");
SelectControllerTest.prototype.testShouldUpdateModelNullOnNothingSelected = function(){
var scope = new nglr.Scope();
var scope = new Scope();
var view = {selectedIndex:-1, options:[]};
var cntl = new nglr.SelectController(view, 'abc');
var cntl = new SelectController(view, 'abc');
cntl.updateModel(scope);
assertNull(scope.get('abc'));
};
SelectControllerTest.prototype.testShouldUpdateModelWhenNothingSelected = function(){
var scope = new nglr.Scope();
var scope = new Scope();
var view = {value:'123'};
var cntl = new nglr.SelectController(view, 'abc');
var cntl = new SelectController(view, 'abc');
cntl.updateView(scope);
assertEquals("123", scope.get('abc'));
};
@ -137,8 +137,8 @@ BindUpdaterTest = TestCase("BindUpdaterTest");
BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () {
var view = $('<span />');
var controller = new nglr.BindUpdater(view[0], "{{a}}");
var scope = new nglr.Scope();
var controller = new BindUpdater(view[0], "{{a}}");
var scope = new Scope();
scope.set('a', undefined);
controller.updateView(scope);
@ -151,20 +151,20 @@ BindUpdaterTest.prototype.testShouldDisplayNothingForUndefined = function () {
BindUpdaterTest.prototype.testShouldDisplayJsonForNonStrings = function () {
var view = $('<span />');
var controller = new nglr.BindUpdater(view[0], "{{obj}}");
var controller = new BindUpdater(view[0], "{{obj}}");
controller.updateView(new nglr.Scope({obj:[]}));
controller.updateView(new Scope({obj:[]}));
assertEquals("[]", view.text());
controller.updateView(new nglr.Scope({obj:{text:'abc'}}));
assertEquals('abc', nglr.fromJson(view.text()).text);
controller.updateView(new Scope({obj:{text:'abc'}}));
assertEquals('abc', fromJson(view.text()).text);
};
BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () {
var view = $('<span />');
var controller = new nglr.BindUpdater(view[0], "<fake>&{{obj}}</fake>");
var scope = new nglr.Scope();
var controller = new BindUpdater(view[0], "<fake>&{{obj}}</fake>");
var scope = new Scope();
scope.set("obj", $('<div>myDiv</div>')[0]);
controller.updateView(scope);
@ -174,8 +174,8 @@ BindUpdaterTest.prototype.testShouldInsertHtmlNode = function () {
BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () {
var view = $('<div />');
var controller = new nglr.BindUpdater(view[0], "{{obj}}");
var scope = new nglr.Scope();
var controller = new BindUpdater(view[0], "{{obj}}");
var scope = new Scope();
scope.set("obj", new angular.filter.Meta({text:function(){return "abc";}}));
controller.updateView(scope);
@ -187,13 +187,13 @@ BindUpdaterTest.prototype.testShouldDisplayTextMethod = function () {
scope.set("obj", {text:"123"});
controller.updateView(scope);
assertEquals("123", nglr.fromJson(view.text()).text);
assertEquals("123", fromJson(view.text()).text);
};
BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () {
var view = $('<div />');
var controller = new nglr.BindUpdater(view[0], "{{obj}}");
var scope = new nglr.Scope();
var controller = new BindUpdater(view[0], "{{obj}}");
var scope = new Scope();
scope.set("obj", new angular.filter.Meta({html:function(){return "a<div>b</div>c";}}));
controller.updateView(scope);
@ -205,13 +205,13 @@ BindUpdaterTest.prototype.testShouldDisplayHtmlMethod = function () {
scope.set("obj", {html:"123"});
controller.updateView(scope);
assertEquals("123", nglr.fromJson(view.text()).html);
assertEquals("123", fromJson(view.text()).html);
};
BindUpdaterTest.prototype.testUdateBoolean = function() {
var view = $('<div />');
var controller = new nglr.BindUpdater(view[0], "{{true}}, {{false}}");
controller.updateView(new nglr.Scope());
var controller = new BindUpdater(view[0], "{{true}}, {{false}}");
controller.updateView(new Scope());
assertEquals('true, false', view.text());
};
@ -219,9 +219,9 @@ BindAttrUpdaterTest = TestCase("BindAttrUpdaterTest");
BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = function () {
var view = $('<img />');
var controller = new nglr.BindAttrUpdater(view[0], {src: '{{imageUrl}}'});
var controller = new BindAttrUpdater(view[0], {src: '{{imageUrl}}'});
var scope = new nglr.Scope();
var scope = new Scope();
scope.set('imageUrl', undefined);
scope.set('config.server', 'http://server');
@ -229,16 +229,15 @@ BindAttrUpdaterTest.prototype.testShouldLoadBlankImageWhenBindingIsUndefined = f
assertEquals("http://server/images/blank.gif", view.attr('src'));
};
RepeaterUpdaterTest = TestCase("RepeaterUpdaterTest");
RepeaterUpdaterTest.prototype.testShouldNotDieWhenRepeatExpressionIsNull = function() {
var rep = new nglr.RepeaterUpdater(null, "$item in items", null, null);
var scope = new nglr.Scope();
var rep = new RepeaterUpdater(null, "$item in items", null, null);
var scope = new Scope();
scope.set('items', undefined);
rep.updateView(scope);
};
RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() {
var rep = new nglr.RepeaterUpdater(null, "($k,_v) in items", null, null);
var rep = new RepeaterUpdater(null, "($k,_v) in items", null, null);
assertEquals("items", rep.iteratorExp);
assertEquals("_v", rep.valueExp);
assertEquals("$k", rep.keyExp);
@ -247,14 +246,14 @@ RepeaterUpdaterTest.prototype.testShouldIterateOverKeys = function() {
EvalUpdaterTest = TestCase("EvalUpdaterTest");
EvalUpdaterTest.prototype.testEvalThrowsException = function(){
var view = $('<div/>');
var eval = new nglr.EvalUpdater(view[0], 'undefined()');
var eval = new EvalUpdater(view[0], 'undefined()');
eval.updateView(new nglr.Scope());
eval.updateView(new Scope());
assertTrue(!!view.attr('ng-error'));
assertTrue(view.hasClass('ng-exception'));
eval.exp = "1";
eval.updateView(new nglr.Scope());
eval.updateView(new Scope());
assertFalse(!!view.attr('ng-error'));
assertFalse(view.hasClass('ng-exception'));
};
@ -262,8 +261,8 @@ EvalUpdaterTest.prototype.testEvalThrowsException = function(){
RadioControllerTest = TestCase("RadioController");
RadioControllerTest.prototype.testItShouldTreatTrueStringAsBoolean = function () {
var view = $('<input type="radio" name="select" value="true"/>');
var radio = new nglr.RadioController(view[0], 'select');
var scope = new nglr.Scope({select:true});
var radio = new RadioController(view[0], 'select');
var scope = new Scope({select:true});
radio.updateView(scope);
assertTrue(view[0].checked);
};

View file

@ -1,47 +0,0 @@
XSitePost = TestCase("XSitePost");
var e = function(text){ return Base64.encode(text); };
XSitePost.prototype.testMessageReceived = function () {
expectAsserts(4);
var xPost = new nglr.XSitePost();
xPost.baseUrl = "http://getangular.test";
xPost.post = function(url, request, callback){
assertEquals('http://getangular.test/url', url);
assertEquals('abc', request.a);
assertEquals('xyz', request.x);
};
xPost.incomingFragment('#id;0;1;'+e('/url')+':a:'+e('abc')+':x:'+e('xyz'));
assertEquals('{}', nglr.toJson(xPost.inQueue));
};
XSitePost.prototype.testMessageReceivedInParts = function () {
expectAsserts(5);
var xPost = new nglr.XSitePost();
xPost.baseUrl = "http://getangular.test";
xPost.post = function(url, request, callback){
assertEquals('http://getangular.test/url', url);
assertEquals('abc', request.a);
assertEquals('xyz', request.x);
};
xPost.incomingFragment('#id;1;2;:x:'+e('xyz'));
assertNotSame('{}', nglr.toJson(xPost.inQueue));
xPost.incomingFragment('#id;0;2;'+e('/url')+':a:'+e('abc'));
assertEquals('{}', nglr.toJson(xPost.inQueue));
};
XSitePost.prototype.testPostResponsIsEnqueued = function () {
var xPost = new nglr.XSitePost();
xPost.maxMsgSize = 11;
xPost.response("id", "response", "status");
assertEquals('["id:0:2:cmVzcG9uc2U","id:1:2:="]',
nglr.toJson(xPost.outQueue));
};
XSitePost.prototype.testPush = function () {
var window = {};
var xPost = new nglr.XSitePost(window);
xPost.response("id", "response", "status");
assertEquals('id:0:1:cmVzcG9uc2U=', xPost.outQueue[0]);
};

View file

@ -2,7 +2,7 @@ nglrTest = TestCase('nglrTest');
nglrTest.prototype.testShiftBind = function(){
expectAsserts(3);
nglr.shiftBind('this', function(target, arg) {
shiftBind('this', function(target, arg) {
assertEquals(this, 'this');
assertEquals(target, 'target');
assertEquals(arg, 'arg');
@ -11,7 +11,7 @@ nglrTest.prototype.testShiftBind = function(){
nglrTest.prototype.testBind = function(){
expectAsserts(2);
nglr.bind('this', function(arg) {
bind('this', function(arg) {
assertEquals(this, 'this');
assertEquals(arg, 'arg');
}).apply('XXX', ['arg']);

View file

@ -6,8 +6,8 @@ HIDDEN = jQuery.browser.msie ?
' style="display: none; "' :
' style="display: none;"';
nglr.msie = jQuery.browser.msie;
nglr.alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);};
msie = jQuery.browser.msie;
alert = function(msg) {jstestdriver.console.log("ALERT: " + msg);};
function noop(){}
@ -50,7 +50,7 @@ jQuery.fn.sortedHtml = function() {
var toString = function(index, node) {
node = node || this;
if (node.nodeName == "#text") {
html += nglr.escapeHtml(node.nodeValue);
html += escapeHtml(node.nodeValue);
} else {
html += '<' + node.nodeName.toLowerCase();
var attributes = node.attributes || [];
@ -89,14 +89,14 @@ jQuery.fn.sortedHtml = function() {
};
function encode64(obj){
return Base64.encode(nglr.toJson(obj));
return Base64.encode(toJson(obj));
}
function decode64(base64){
return nglr.fromJson(Base64.decode(base64));
return fromJson(Base64.decode(base64));
}
nglr.Loader.prototype.configureJQueryPlugins();
Loader.prototype.configureJQueryPlugins();
function assertHidden(node) {
var display = node.css('display');
@ -110,7 +110,7 @@ function assertVisible(node) {
}
function assertJsonEquals(expected, actual) {
assertEquals(nglr.toJson(expected), nglr.toJson(actual));
assertEquals(toJson(expected), toJson(actual));
}
function assertUndefined(value) {
@ -118,7 +118,7 @@ function assertUndefined(value) {
}
function assertDefined(value) {
assertTrue(nglr.toJson(value), !!value);
assertTrue(toJson(value), !!value);
}
function assertThrows(error, fn){