diff options
| -rw-r--r-- | Rakefile | 2 | ||||
| -rw-r--r-- | TODO.text | 6 | ||||
| -rw-r--r-- | angular.js | 164 | ||||
| -rw-r--r-- | example/calculator-manual_init.html | 2 | ||||
| -rw-r--r-- | src/Loader.js | 1 |
5 files changed, 173 insertions, 2 deletions
@@ -28,8 +28,8 @@ end desc 'Compile JavaScript with Google Closure Compiler' task :compileclosure do +# --compilation_level ADVANCED_OPTIMIZATIONS \ %x(java -jar lib/compiler-closure/compiler.jar \ - --compilation_level ADVANCED_OPTIMIZATIONS \ --js lib/webtoolkit/webtoolkit.base64.js \ --js lib/underscore/underscore.js \ --js src/Loader.js \ diff --git a/TODO.text b/TODO.text new file mode 100644 index 00000000..fab19695 --- /dev/null +++ b/TODO.text @@ -0,0 +1,6 @@ +* move angular-bootstrap.js out of anugular.js. +* 'angular' is the official namespace for public API + - angular.defaults = {} + - var scope = angular.compile(element, options); +* angular.js is not self boot straping by default. +* diff --git a/angular.js b/angular.js new file mode 100644 index 00000000..2ac33572 --- /dev/null +++ b/angular.js @@ -0,0 +1,164 @@ +var a,Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",encode:function(b){var c="",d,f,e,h,j,l,n=0;for(b=Base64._utf8_encode(b);n<b.length;){d=b.charCodeAt(n++);f=b.charCodeAt(n++);e=b.charCodeAt(n++);h=d>>2;d=(d&3)<<4|f>>4;j=(f&15)<<2|e>>6;l=e&63;if(isNaN(f))j=l=64;else if(isNaN(e))l=64;c=c+this._keyStr.charAt(h)+this._keyStr.charAt(d)+this._keyStr.charAt(j)+this._keyStr.charAt(l)}return c},decode:function(b){var c="",d,f,e,h,j,l=0;for(b=b.replace(/[^A-Za-z0-9\+\/\=]/g, +"");l<b.length;){d=this._keyStr.indexOf(b.charAt(l++));f=this._keyStr.indexOf(b.charAt(l++));h=this._keyStr.indexOf(b.charAt(l++));j=this._keyStr.indexOf(b.charAt(l++));d=d<<2|f>>4;f=(f&15)<<4|h>>2;e=(h&3)<<6|j;c+=String.fromCharCode(d);if(h!=64)c+=String.fromCharCode(f);if(j!=64)c+=String.fromCharCode(e)}return c=Base64._utf8_decode(c)},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");for(var c="",d=0;d<b.length;d++){var f=b.charCodeAt(d);if(f<128)c+=String.fromCharCode(f);else{if(f>127&&f<2048)c+= +String.fromCharCode(f>>6|192);else{c+=String.fromCharCode(f>>12|224);c+=String.fromCharCode(f>>6&63|128)}c+=String.fromCharCode(f&63|128)}}return c},_utf8_decode:function(b){for(var c="",d=0,f=c1=c2=0;d<b.length;){f=b.charCodeAt(d);if(f<128){c+=String.fromCharCode(f);d++}else if(f>191&&f<224){c2=b.charCodeAt(d+1);c+=String.fromCharCode((f&31)<<6|c2&63);d+=2}else{c2=b.charCodeAt(d+1);c3=b.charCodeAt(d+2);c+=String.fromCharCode((f&15)<<12|(c2&63)<<6|c3&63);d+=3}}return c}};(function(){var b=this,c=b._,d=function(g){this._wrapped=g},f=typeof StopIteration!=="undefined"?StopIteration:"__break__",e=b._=function(g){return new d(g)};if(typeof exports!=="undefined")exports._=e;var h=Array.prototype.slice,j=Array.prototype.unshift,l=Object.prototype.toString,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable;e.VERSION="0.5.1";e.each=function(g,i,k){try{if(g.forEach)g.forEach(i,k);else if(e.isArray(g)||e.isArguments(g))for(var m=0,q=g.length;m<q;m++)i.call(k, +g[m],m,g);else{var r=e.keys(g);q=r.length;for(m=0;m<q;m++)i.call(k,g[r[m]],r[m],g)}}catch(t){if(t!=f)throw t;}return g};e.map=function(g,i,k){if(g&&e.isFunction(g.map))return g.map(i,k);var m=[];e.each(g,function(q,r,t){m.push(i.call(k,q,r,t))});return m};e.reduce=function(g,i,k,m){if(g&&e.isFunction(g.reduce))return g.reduce(e.bind(k,m),i);e.each(g,function(q,r,t){i=k.call(m,i,q,r,t)});return i};e.reduceRight=function(g,i,k,m){if(g&&e.isFunction(g.reduceRight))return g.reduceRight(e.bind(k,m),i); +var q=e.clone(e.toArray(g)).reverse();e.each(q,function(r,t){i=k.call(m,i,r,t,g)});return i};e.detect=function(g,i,k){var m;e.each(g,function(q,r,t){if(i.call(k,q,r,t)){m=q;e.breakLoop()}});return m};e.select=function(g,i,k){if(g&&e.isFunction(g.filter))return g.filter(i,k);var m=[];e.each(g,function(q,r,t){i.call(k,q,r,t)&&m.push(q)});return m};e.reject=function(g,i,k){var m=[];e.each(g,function(q,r,t){!i.call(k,q,r,t)&&m.push(q)});return m};e.all=function(g,i,k){i=i||e.identity;if(g&&e.isFunction(g.every))return g.every(i, +k);var m=true;e.each(g,function(q,r,t){(m=m&&i.call(k,q,r,t))||e.breakLoop()});return m};e.any=function(g,i,k){i=i||e.identity;if(g&&e.isFunction(g.some))return g.some(i,k);var m=false;e.each(g,function(q,r,t){if(m=i.call(k,q,r,t))e.breakLoop()});return m};e.include=function(g,i){if(e.isArray(g))return e.indexOf(g,i)!=-1;var k=false;e.each(g,function(m){if(k=m===i)e.breakLoop()});return k};e.invoke=function(g,i){var k=e.rest(arguments,2);return e.map(g,function(m){return(i?m[i]:m).apply(m,k)})};e.pluck= +function(g,i){return e.map(g,function(k){return k[i]})};e.max=function(g,i,k){if(!i&&e.isArray(g))return Math.max.apply(Math,g);var m={computed:-Infinity};e.each(g,function(q,r,t){r=i?i.call(k,q,r,t):q;r>=m.computed&&(m={value:q,computed:r})});return m.value};e.min=function(g,i,k){if(!i&&e.isArray(g))return Math.min.apply(Math,g);var m={computed:Infinity};e.each(g,function(q,r,t){r=i?i.call(k,q,r,t):q;r<m.computed&&(m={value:q,computed:r})});return m.value};e.sortBy=function(g,i,k){return e.pluck(e.map(g, +function(m,q,r){return{value:m,criteria:i.call(k,m,q,r)}}).sort(function(m,q){m=m.criteria;q=q.criteria;return m<q?-1:m>q?1:0}),"value")};e.sortedIndex=function(g,i,k){k=k||e.identity;for(var m=0,q=g.length;m<q;){var r=m+q>>1;k(g[r])<k(i)?(m=r+1):(q=r)}return m};e.toArray=function(g){if(!g)return[];if(g.toArray)return g.toArray();if(e.isArray(g))return g;if(e.isArguments(g))return h.call(g);return e.map(g,function(i){return i})};e.size=function(g){return e.toArray(g).length};e.first=function(g,i, +k){return i&&!k?h.call(g,0,i):g[0]};e.rest=function(g,i,k){return h.call(g,e.isUndefined(i)||k?1:i)};e.last=function(g){return g[g.length-1]};e.compact=function(g){return e.select(g,function(i){return!!i})};e.flatten=function(g){return e.reduce(g,[],function(i,k){if(e.isArray(k))return i.concat(e.flatten(k));i.push(k);return i})};e.without=function(g){var i=e.rest(arguments);return e.select(g,function(k){return!e.include(i,k)})};e.uniq=function(g,i){return e.reduce(g,[],function(k,m,q){if(0==q||(i=== +true?e.last(k)!=m:!e.include(k,m)))k.push(m);return k})};e.intersect=function(g){var i=e.rest(arguments);return e.select(e.uniq(g),function(k){return e.all(i,function(m){return e.indexOf(m,k)>=0})})};e.zip=function(){for(var g=e.toArray(arguments),i=e.max(e.pluck(g,"length")),k=new Array(i),m=0;m<i;m++)k[m]=e.pluck(g,String(m));return k};e.indexOf=function(g,i){if(g.indexOf)return g.indexOf(i);for(var k=0,m=g.length;k<m;k++)if(g[k]===i)return k;return-1};e.lastIndexOf=function(g,i){if(g.lastIndexOf)return g.lastIndexOf(i); +for(var k=g.length;k--;)if(g[k]===i)return k;return-1};e.range=function(g,i,k){var m=e.toArray(arguments),q=m.length<=1;g=q?0:m[0];i=q?m[0]:m[1];k=m[2]||1;m=Math.ceil((i-g)/k);if(m<=0)return[];m=new Array(m);q=g;for(var r=0;;q+=k){if((k>0?q-i:i-q)>=0)return m;m[r++]=q}};e.bind=function(g,i){var k=e.rest(arguments,2);return function(){return g.apply(i||b,k.concat(e.toArray(arguments)))}};e.bindAll=function(g){var i=e.rest(arguments);if(i.length==0)i=e.functions(g);e.each(i,function(k){g[k]=e.bind(g[k], +g)});return g};e.delay=function(g,i){var k=e.rest(arguments,2);return setTimeout(function(){return g.apply(g,k)},i)};e.defer=function(g){return e.delay.apply(e,[g,1].concat(e.rest(arguments)))};e.wrap=function(g,i){return function(){var k=[g].concat(e.toArray(arguments));return i.apply(i,k)}};e.compose=function(){var g=e.toArray(arguments);return function(){for(var i=e.toArray(arguments),k=g.length-1;k>=0;k--)i=[g[k].apply(this,i)];return i[0]}};e.keys=function(g){if(e.isArray(g))return e.range(0, +g.length);var i=[];for(var k in g)n.call(g,k)&&i.push(k);return i};e.values=function(g){return e.map(g,e.identity)};e.functions=function(g){return e.select(e.keys(g),function(i){return e.isFunction(g[i])}).sort()};e.extend=function(g,i){for(var k in i)g[k]=i[k];return g};e.clone=function(g){if(e.isArray(g))return g.slice(0);return e.extend({},g)};e.isEqual=function(g,i){if(g===i)return true;var k=typeof g;if(k!=typeof i)return false;if(g==i)return true;if(!g&&i||g&&!i)return false;if(g.isEqual)return g.isEqual(i); +if(e.isDate(g)&&e.isDate(i))return g.getTime()===i.getTime();if(e.isNaN(g)&&e.isNaN(i))return true;if(e.isRegExp(g)&&e.isRegExp(i))return g.source===i.source&&g.global===i.global&&g.ignoreCase===i.ignoreCase&&g.multiline===i.multiline;if(k!=="object")return false;if(g.length&&g.length!==i.length)return false;k=e.keys(g);var m=e.keys(i);if(k.length!=m.length)return false;for(var q in g)if(!e.isEqual(g[q],i[q]))return false;return true};e.isEmpty=function(g){return e.keys(g).length==0};e.isElement= +function(g){return!!(g&&g.nodeType==1)};e.isArguments=function(g){return g&&e.isNumber(g.length)&&!e.isArray(g)&&!o.call(g,"length")};e.isNaN=function(g){return e.isNumber(g)&&isNaN(g)};e.isNull=function(g){return g===null};e.isUndefined=function(g){return typeof g=="undefined"};for(var p=["Array","Date","Function","Number","RegExp","String"],s=0,v=p.length;s<v;s++)(function(){var g="[object "+p[s]+"]";e["is"+p[s]]=function(i){return l.call(i)==g}})();e.noConflict=function(){b._=c;return this};e.identity= +function(g){return g};e.breakLoop=function(){throw f;};var u=0;e.uniqueId=function(g){var i=u++;return g?g+i:i};e.template=function(g,i){g=new Function("obj","var p=[],print=function(){p.push.apply(p,arguments);};with(obj){p.push('"+g.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 i?g(i):g};e.forEach=e.each;e.foldl=e.inject= +e.reduce;e.foldr=e.reduceRight;e.filter=e.select;e.every=e.all;e.some=e.any;e.head=e.first;e.tail=e.rest;e.methods=e.functions;var w=function(g,i){return i?e(g).chain():g};e.each(e.functions(e),function(g){var i=e[g];d.prototype[g]=function(){j.call(arguments,this._wrapped);return w(i.apply(e,arguments),this._chain)}});e.each(["pop","push","reverse","shift","sort","splice","unshift"],function(g){var i=Array.prototype[g];d.prototype[g]=function(){i.apply(this._wrapped,arguments);return w(this._wrapped, +this._chain)}});e.each(["concat","join","slice"],function(g){var i=Array.prototype[g];d.prototype[g]=function(){return w(i.apply(this._wrapped,arguments),this._chain)}});d.prototype.chain=function(){this._chain=true;return this};d.prototype.value=function(){return this._wrapped}})();if(typeof document.getAttribute=="undefined")document.getAttribute=function(){};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(_.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))window.console={log:function(){},error:function(){}};if(_.isUndefined(nglr.alert))nglr.alert=function(){console.log(arguments);window.alert.apply(window,arguments)};nglr.consoleLog=function(b,c){var d=document.createElement("div");d.className=b;for(var f=b="",e=0;e<c.length;e++){var h=c[e];b+=f+(typeof h=="string"?h:nglr.toJson(h));f=" "}d.appendChild(document.createTextNode(b));nglr.consoleNode.appendChild(d)}; +nglr.isNode=function(b){return b&&b.tagName&&b.nodeName&&b.ownerDocument&&b.removeAttribute};nglr.isLeafNode=function(b){switch(b.nodeName){case "OPTION":case "PRE":case "TITLE":return true;default:return false}};nglr.noop=function(){};nglr.setHtml=function(b,c){if(nglr.isLeafNode(b))if(nglr.msie)b.innerText=c;else b.textContent=c;else b.innerHTML=c};nglr.escapeHtml=function(b){if(!b||!b.replace)return b;return b.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}; +nglr.escapeAttr=function(b){if(!b||!b.replace)return b;return b.replace(/</g,"<").replace(/>/g,">").replace(/\"/g,""")};nglr.bind=function(b,c){if(!b)throw"Missing this";if(!_.isFunction(c))throw"Missing function";return function(){return c.apply(b,arguments)}};nglr.shiftBind=function(b,c){return function(){for(var d=[this],f=0;f<arguments.length;f++)d.push(arguments[f]);return c.apply(b,d)}}; +nglr.outerHTML=function(b){var c=document.createElement("div");c.appendChild(b);var d=c.innerHTML;c.removeChild(b);return d};nglr.trim=function(b){return b.replace(/^ */,"").replace(/ *$/,"")};nglr.toBoolean=function(b){var c=(""+b).toLowerCase();if(c=="f"||c=="0"||c=="false"||c=="no")b=false;return!!b}; +nglr.merge=function(b,c){for(var d in b){var f=c[d],e=typeof f;if(e=="undefined")c[d]=nglr.fromJson(nglr.toJson(b[d]));else e=="object"&&f.constructor!=nglr.array&&d.substring(0,1)!="$"&&nglr.merge(b[d],f)}};nglr.Loader=function(b,c,d){this.document=jQuery(b);this.head=jQuery(c);this.config=d;this.location=window.location};a=nglr.Loader.prototype; +a.load=function(){this.configureLogging();this.loadCss("/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css");this.loadCss("/stylesheets/nglr.css");console.log("Server: "+this.config.server);nglr.msie=jQuery.browser.msie;this.configureJQueryPlugins();this.computeConfiguration();this.bindHtml()}; +a.configureJQueryPlugins=function(){console.log("Loader.configureJQueryPlugins()");jQuery.fn.removeNode=function(){var b=this.get(0);b.parentNode.removeChild(b)};jQuery.fn.scope=function(){for(var b=this;b&&b.get(0);){var c=b.data("scope");if(c)return c;b=b.parent()}return null};jQuery.fn.controller=function(){return this.data("controller")||nglr.NullController.instance}};a.uid=function(){return""+(new Date).getTime()}; +a.computeConfiguration=function(){var b=this.config;if(!b.database){var c=b.server.match(/https?:\/\/([\w]*)/);b.database=c?c[1]:"$MEMORY"}}; +a.bindHtml=function(){function b(){j.fetchCurrentUser(function(p){!p&&d.find("[ng-auth=eager]").length&&j.login()})}console.log("Loader.bindHtml()");var c=new nglr.UrlWatcher(this.location),d=this.document,f=new nglr.WidgetFactory(this.config.server,this.config.database),e=new nglr.Binder(d[0],f,c,this.config);f.onChangeListener=nglr.shiftBind(e,e.updateModel);f=new nglr.ControlBar(d.find("body"),this.config.server);var h=this.config.database=="$MEMORY"?new nglr.FrameServer(this.window):new nglr.Server(this.config.server, +jQuery.getScript);h=new nglr.VisualServer(h,new nglr.Status(jQuery(d.body)),function(){e.updateView()});var j=new nglr.Users(h,f),l="/data/"+this.config.database,n=new nglr.DataStore(function(p,s){h.request("POST",l,p,s)},j,e.anchor);e.updateListeners.push(function(){n.flush()});var o=new nglr.Scope({$anchor:e.anchor,$binder:e,$config:this.config,$console:window.console,$datastore:n,$save:function(p){n.saveScope(o.state,p,e.anchor)},$window:window,$uid:this.uid,$users:j},"ROOT");jQuery.each(["get", +"set","eval","addWatchListener","updateView"],function(p,s){angular[s]=nglr.bind(o,o[s])});d.data("scope",o);console.log("$binder.entity()");e.entity(o);console.log("$binder.compile()");e.compile();console.log("ControlBar.bind()");f.bind();console.log("$users.fetchCurrentUser()");b();console.log("PopUp.bind()");(new nglr.PopUp(d)).bind();console.log("$binder.parseAnchor()");e.parseAnchor();console.log("$binder.executeInit()");e.executeInit();console.log("$binder.updateView()");e.updateView();c.listener= +nglr.bind(e,e.onUrlChange,c);c.onUpdate=function(){nglr.alert("update")};c.watch();d.find("body").show();console.log("ready()")};a.visualPost=function(b){var c=new nglr.Status(jQuery(document.body));return function(d,f){c.beginRequest(d);b(d,function(){c.endRequest();try{f.apply(this,arguments)}catch(e){nglr.alert(nglr.toJson(e))}})}}; +a.configureLogging=function(){var b=window.location.href+"#";b=b.split("#")[1];var c={debug:null};b=b.split("&");for(var d=0;d<b.length;d++){var f=(b[d]+"=").split("=");c[f[0]]=f[1]}if(c.debug=="console"){nglr.consoleNode=document.createElement("div");nglr.consoleNode.id="ng-console";document.getElementsByTagName("body")[0].appendChild(nglr.consoleNode);console.log=function(){nglr.consoleLog("ng-console-info",arguments)};console.error=function(){nglr.consoleLog("ng-console-error",arguments)}}}; +a.loadCss=function(b){var c=document.createElement("link");c.rel="stylesheet";c.type="text/css";b.match(/^http:/)||(b=this.config.server+b);c.href=b;this.head[0].appendChild(c)};nglr.UrlWatcher=function(b){this.location=b;this.delay=25;this.setTimeout=function(c,d){window.setTimeout(c,d)};this.listener=function(c){return c};this.expectedUrl=b.href}; +nglr.UrlWatcher.prototype.watch=function(){var b=this,c=function(){if(b.expectedUrl!==b.location.href){var d=b.location.hash.match(/^#\$iframe_notify=(.*)$/);if(d){b.expectedUrl.match(/#/)||(b.expectedUrl+="#");b.location.href=b.expectedUrl;d="_iframe_notify_"+d[1];var f=nglr[d];delete nglr[d];try{(f||nglr.noop)()}catch(e){nglr.alert(e)}}else{b.listener(b.location.href);b.expectedUrl=b.location.href}}b.setTimeout(c,b.delay)};c()}; +nglr.UrlWatcher.prototype.setUrl=function(b){var c=window.location.href;c.match(/#/)||(c+="#");if(c!=b)window.location.href=b;self.existingURL=b};nglr.UrlWatcher.prototype.getUrl=function(){return window.location.href};window.angularFactory=function(b){function c(f){(new nglr.Loader(f,jQuery("head"),_(d).extend(b))).load();return jQuery(f).scope()}var d={server:""};return{compile:c}};angular.Global={typeOf:function(b){var c=typeof b;switch(c){case "object":if(b===null)return"null";if(b instanceof Array)return"array";if(b instanceof Date)return"date";if(b.nodeType==1)return"element"}return c}};angular.Collection={};angular.Object={}; +angular.Array={includeIf:function(b,c,d){var f=_.indexOf(b,c);if(d)f==-1&&b.push(c);else b.splice(f,1);return b},sum:function(b,c){c=angular.Function.compile(c);for(var d=0,f=0;f<b.length;f++){var e=1*c(b[f]);isNaN(e)||(d+=e)}return d},remove:function(b,c){var d=_.indexOf(b,c);d>=0&&b.splice(d,1);return c},find:function(b,c,d){if(c){var f=angular.Function.compile(c);_.detect(b,function(e){if(f(e)){d=e;return true}});return d}},findById:function(b,c){return angular.Array.find(b,function(d){return d.$id== +c},null)},filter:function(b,c){var d=[];d.check=function(o){for(var p=0;p<d.length;p++)if(!d[p](o))return false;return true};var f=nglr.Scope.getter,e=function(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 s in o)if(s.charAt(0)!=="$"&&e(o[s],p))return true;return false;case "array":for(s=0;s<o.length;s++)if(e(o[s],p))return true;return false;default:return false}};switch(typeof c){case "boolean":case "number":case "string":c= +{$:c};case "object":for(var h in c)h=="$"?function(){var o=(""+c[h]).toLowerCase();o&&d.push(function(p){return e(p,o)})}():function(){var o=h,p=(""+c[h]).toLowerCase();p&&d.push(function(s){return e(f(s,o),p)})}();break;case "function":d.push(c);break;default:return b}for(var j=[],l=0;l<b.length;l++){var n=b[l];d.check(n)&&j.push(n)}return j},add:function(b,c){b.push(_.isUndefined(c)?{}:c);return b},count:function(b,c){if(!c)return b.length;var d=angular.Function.compile(c);return _.reduce(b,0,function(f, +e){return f+(d(e)?1:0)})},orderBy:function(b,c,d){function f(h,j){return nglr.toBoolean(j)?function(l,n){return h(n,l)}:h}function e(h,j){var l=typeof h,n=typeof j;if(l==n){if(l=="string")h=h.toLowerCase();if(l=="string")j=j.toLowerCase();if(h===j)return 0;return h<j?-1:1}else return l<n?-1:1}c=_.isArray(c)?c:[c];c=_.map(c,function(h){var j=false;if(typeof h=="string"&&(h.charAt(0)=="+"||h.charAt(0)=="-")){j=h.charAt(0)=="-";h=h.substring(1)}var l=h?angular.Function.compile(h):_.identity;return f(function(n, +o){return e(l(n),l(o))},j)});return _.clone(b).sort(f(function(h,j){for(var l=0;l<c.length;l++){var n=c[l](h,j);if(n!=0)return n}return 0},d))},orderByToggle:function(b,c){var d=false,f=-1;_.detect(b,function(e,h){if(e==c){d=true;f=h;return true}if((e.charAt(0)=="+"||e.charAt(0)=="-")&&e.substring(1)==c){d=e.charAt(0)=="+";f=h;return true}});f>=0&&b.splice(f,1);b.unshift((d?"-":"+")+c);return b},orderByDirection:function(b,c,d,f){d=d||"ng-ascend";f=f||"ng-descend";b=b[0]||"";var e=true;if(b.charAt(0)== +"-"){b=b.substring(1);e=false}else if(b.charAt(0)=="+")b=b.substring(1);return b==c?e?d:f:""},merge:function(b,c,d){var f=b[c];if(!f){f={};b[c]=f}nglr.merge(d,f);return b}}; +angular.String={quote:function(b){return'"'+b.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v")+'"'},quoteUnicode:function(b){b=angular.String.quote(b);for(var c=[],d=0;d<b.length;d++){var f=b.charCodeAt(d);if(f<128)c.push(b.charAt(d));else{f="000"+f.toString(16);c.push("\\u"+f.substring(f.length-4))}}return c.join("")},toDate:function(b){var c;if(typeof b=="string"&&(c=b.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/))){b= +new Date(0);b.setUTCFullYear(c[1],c[2]-1,c[3]);b.setUTCHours(c[4],c[5],c[6],0);return b}return b}};angular.Date={toString:function(b){function c(d){return d<10?"0"+d:d}return b.getUTCFullYear()+"-"+c(b.getUTCMonth()+1)+"-"+c(b.getUTCDate())+"T"+c(b.getUTCHours())+":"+c(b.getUTCMinutes())+":"+c(b.getUTCSeconds())+"Z"}};angular.Function={compile:function(b){if(_.isFunction(b))return b;else if(b){var c=new nglr.Scope;return function(d){c.state=d;return c.eval(b)}}else return function(d){return d}}}; +(function(){function b(c,d,f){_.extend(c,d);_.each(f||[],function(e){c[e]=_[e]})}b(angular.Global,{},["extend","clone","isEqual","isElement","isArray","isFunction","isUndefined"]);b(angular.Collection,angular.Global,["each","map","reduce","reduceRight","detect","select","reject","all","any","include","invoke","pluck","max","min","sortBy","sortedIndex","toArray","size"]);b(angular.Array,angular.Collection,["first","last","compact","flatten","without","uniq","intersect","zip","indexOf","lastIndexOf"]); +b(angular.Object,angular.Collection,["keys","values"]);b(angular.String,angular.Global);b(angular.Function,angular.Global,["bind","bindAll","delay","defer","wrap","compose"])})();nglr.Binder=function(b,c,d,f){this.doc=b;this.urlWatcher=d;this.anchor={};this.widgetFactory=c;this.config=f||{};this.updateListeners=[]};nglr.Binder.parseBindings=function(b){for(var c=[],d=0,f;(f=b.indexOf("{{",d))>-1;){d<f&&c.push(b.substr(d,f-d));d=f;f=b.indexOf("}}",f);f=f<0?b.length:f+2;c.push(b.substr(d,f-d));d=f}d!=b.length&&c.push(b.substr(d,b.length-d));return c.length===0?[b]:c}; +nglr.Binder.hasBinding=function(b){b=nglr.Binder.parseBindings(b);return b.length>1||nglr.Binder.binding(b[0])!==null};nglr.Binder.binding=function(b){return(b=b.replace(/\n/gm," ").match(/^\{\{(.*)\}\}$/))?b[1]:null};a=nglr.Binder.prototype;a.parseQueryString=function(b){var c={};b.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(d,f,e){if(f)c[decodeURIComponent(f)]=decodeURIComponent(e)});return c}; +a.parseAnchor=function(b){var c=this;b=b||this.urlWatcher.getUrl();var d=b.indexOf("#");if(!(d<0)){b=this.parseQueryString(b.substring(d+1));jQuery.each(c.anchor,function(f){delete c.anchor[f]});jQuery.each(b,function(f,e){c.anchor[f]=e})}};a.onUrlChange=function(b){console.log("URL change detected",b);this.parseAnchor(b);this.updateView()}; +a.updateAnchor=function(){var b=this.urlWatcher.getUrl(),c=b.indexOf("#");if(c>-1)b=b.substring(0,c);b+="#";c="";for(var d in this.anchor){var f=this.anchor[d];if(typeof f==="undefined"||f===null)delete this.anchor[d];else{b+=c+encodeURIComponent(d);if(f!==true)b+="="+encodeURIComponent(f);c="&"}}this.urlWatcher.setUrl(b);return b}; +a.updateView=function(){(new Date).getTime();var b=jQuery(this.doc).scope();b.set("$invalidWidgets",[]);b.updateView();(new Date).getTime();this.updateAnchor();_.each(this.updateListeners,function(c){c()})};a.docFindWithSelf=function(b){var c=jQuery(this.doc),d=c.find(b);if(c.is(b))d=d.andSelf();return d}; +a.executeInit=function(){this.docFindWithSelf("[ng-init]").each(function(){var b=jQuery(this),c=b.scope();try{c.eval(b.attr("ng-init"))}catch(d){nglr.alert("EVAL ERROR:\n"+b.attr("ng-init")+"\n"+nglr.toJson(d,true))}})};a.entity=function(b){this.docFindWithSelf("[ng-entity]").attr("ng-watch",function(){try{var c=jQuery(this);return b.entity(c.attr("ng-entity"))+(c.attr("ng-watch")||"")}catch(d){nglr.alert(d)}})}; +a.compile=function(){var b=jQuery(this.doc),c=this;if(this.config.autoSubmit){var d=this.docFindWithSelf(":submit").not("[ng-action]");d.attr("ng-action","$save()");d.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.precompile(this.doc)(this.doc,b.scope(),"");this.docFindWithSelf("a[ng-action]").live("click",function(){var f=jQuery(this);try{f.scope().eval(f.attr("ng-action"));f.removeAttr("ng-error");f.removeClass("ng-exception")}catch(e){f.addClass("ng-exception"); +f.attr("ng-error",nglr.toJson(e,true))}c.updateView();return false})}; +a.translateBinding=function(b,c,d){c=c.concat();var f=c.pop(),e=nglr.Binder.parseBindings(b.nodeValue);if(e.length>1||nglr.Binder.binding(e[0])){var h=b.parentNode;if(nglr.isLeafNode(h)){h.setAttribute("ng-bind-template",b.nodeValue);d.push({path:c,fn:function(p){return new nglr.BindUpdater(p,p.getAttribute("ng-bind-template"))}})}else for(var j=0;j<e.length;j++){var l=e[j],n=nglr.Binder.binding(l),o;if(n){o=document.createElement("span");jQuery(o).attr("ng-bind",n);j===0&&d.push({path:c.concat(f+ +j),fn:nglr.Binder.prototype.ng_bind})}else if(nglr.msie&&l.charAt(0)==" "){o=document.createElement("span");o.innerHTML=" "+l.substring(1)}else o=document.createTextNode(l);h.insertBefore(o,b)}h.removeChild(b)}};a.precompile=function(b){var c=[];this.precompileNode(b,[],c);return function(d,f,e){for(var h=c.length,j=0;j<h;j++){for(var l=c[j],n=d,o=l.path,p=0;p<o.length;p++)n=n.childNodes[o[p]];try{f.addWidget(l.fn(n,f,e))}catch(s){nglr.alert(s)}}}}; +a.precompileNode=function(b,c,d){var f=b.nodeType;if(f==Node.TEXT_NODE)this.translateBinding(b,c,d);else if(!(f!=Node.ELEMENT_NODE&&f!=Node.DOCUMENT_NODE))if(b.getAttribute){f=b.getAttribute("ng-non-bindable");if(!(f||f==="")){if(f=b.attributes){var e=b.getAttribute("ng-bind-attr");b.removeAttribute("ng-bind-attr");e=e?nglr.fromJson(e):{};for(var h=f.length,j=0;j<h;j++){var l=f[j],n=l.name;l=nglr.msie&&n=="href"?decodeURI(b.getAttribute(n,2)):l.value;if(nglr.Binder.hasBinding(l))e[n]=l}f=nglr.toJson(e); +f.length>2&&b.setAttribute("ng-bind-attr",f)}b.getAttribute||console.log(b);var o=b.getAttribute("ng-repeat");if(o){b.removeAttribute("ng-repeat");var p=this.precompile(b);f=document.createComment("ng-repeat: "+o);e=b.parentNode;e.insertBefore(f,b);e.removeChild(b);var s=function(u,w,g){var i=jQuery(b).clone();i.css("display","");i.attr("ng-repeat-index",""+g);i.data("scope",u);p(i[0],u,w+g+":");return i};d.push({path:c,fn:function(u,w,g){return new nglr.RepeaterUpdater(jQuery(u),o,s,g)}})}else{b.getAttribute("ng-eval")&& +d.push({path:c,fn:this.ng_eval});b.getAttribute("ng-bind")&&d.push({path:c,fn:this.ng_bind});b.getAttribute("ng-bind-attr")&&d.push({path:c,fn:this.ng_bind_attr});b.getAttribute("ng-hide")&&d.push({path:c,fn:this.ng_hide});b.getAttribute("ng-show")&&d.push({path:c,fn:this.ng_show});b.getAttribute("ng-class")&&d.push({path:c,fn:this.ng_class});b.getAttribute("ng-class-odd")&&d.push({path:c,fn:this.ng_class_odd});b.getAttribute("ng-class-even")&&d.push({path:c,fn:this.ng_class_even});b.getAttribute("ng-style")&& +d.push({path:c,fn:this.ng_style});b.getAttribute("ng-watch")&&d.push({path:c,fn:this.ng_watch});f=b.nodeName;if(f=="INPUT"||f=="TEXTAREA"||f=="SELECT"||f=="BUTTON"){var v=this;d.push({path:c,fn:function(u,w,g){u.name=g+u.name.split(":").pop();return v.widgetFactory.createController(jQuery(u),w)}})}if(f=="OPTION")if(!jQuery("<select/>").append(jQuery(b).clone()).html().match(/<option(\s.*\s|\s)value\s*=\s*.*>.*<\/\s*option\s*>/gi))b.value=b.text;f=b.childNodes;for(e=0;e<f.length;e++)this.precompileNode(f[e], +c.concat(e),d)}}}};a.ng_eval=function(b){return new nglr.EvalUpdater(b,b.getAttribute("ng-eval"))};a.ng_bind=function(b){return new nglr.BindUpdater(b,"{{"+b.getAttribute("ng-bind")+"}}")};a.ng_bind_attr=function(b){return new nglr.BindAttrUpdater(b,nglr.fromJson(b.getAttribute("ng-bind-attr")))};a.ng_hide=function(b){return new nglr.HideUpdater(b,b.getAttribute("ng-hide"))};a.ng_show=function(b){return new nglr.ShowUpdater(b,b.getAttribute("ng-show"))}; +a.ng_class=function(b){return new nglr.ClassUpdater(b,b.getAttribute("ng-class"))};a.ng_class_even=function(b){return new nglr.ClassEvenUpdater(b,b.getAttribute("ng-class-even"))};a.ng_class_odd=function(b){return new nglr.ClassOddUpdater(b,b.getAttribute("ng-class-odd"))};a.ng_style=function(b){return new nglr.StyleUpdater(b,b.getAttribute("ng-style"))};a.ng_watch=function(b,c){c.watch(b.getAttribute("ng-watch"))};nglr.ControlBar=function(b,c){this.document=b;this.serverUrl=c;this.window=window;this.callbacks=[]};nglr.ControlBar.prototype.bind=function(){};nglr.ControlBar.HTML='<div><div class="ui-widget-overlay"></div><div id="ng-login" ng-non-bindable="true"><div class="ng-login-container"></div></div></div>';nglr.ControlBar.prototype.login=function(b){this.callbacks.push(b);this.callbacks.length==1&&this.doTemplate("/user_session/new.mini?return_url="+encodeURIComponent(this.urlWithoutAnchor()))}; +nglr.ControlBar.prototype.logout=function(b){this.callbacks.push(b);this.callbacks.length==1&&this.doTemplate("/user_session/do_destroy.mini")};nglr.ControlBar.prototype.urlWithoutAnchor=function(){return this.window.location.href.split("#")[0]}; +nglr.ControlBar.prototype.doTemplate=function(b){var c=this,d=(new Date).getTime(),f=this.urlWithoutAnchor();f+="#$iframe_notify="+d;var e=jQuery('<div style="overflow:hidden; padding:2px 0 0 0;"><iframe name="'+f+'" src="'+this.serverUrl+b+'" width="500" height="330"/></div>');this.document.append(e);e.dialog({height:363,width:500,resizable:false,modal:true,title:'Authentication: <a href="http://www.getangular.com"><tt><angular/></tt></a>'});nglr["_iframe_notify_"+d]=function(){e.dialog("destroy"); +e.remove();jQuery.each(c.callbacks,function(h,j){j()});c.callbacks=[]}};nglr.ControlBar.FORBIDEN='<div ng-non-bindable="true" title="Permission Error:">Sorry, you do not have permission for this!</div>';nglr.ControlBar.prototype.notAuthorized=function(){if(!this.forbidenView){this.forbidenView=jQuery(nglr.ControlBar.FORBIDEN);this.forbidenView.dialog({bgiframe:true,height:70,modal:true})}};nglr.DataStore=function(b,c,d){this.post=b;this.users=c;this._cache={$collections:[]};this.anchor=d;this.bulkRequest=[]};a=nglr.DataStore.prototype;a.cache=function(b){if(b.constructor!=nglr.Model)throw"Parameter must be an instance of Entity! "+nglr.toJson(b);var c=b.$entity+"/"+b.$id,d=this._cache[c];if(d)nglr.Model.copyDirectFields(b,d);else d=this._cache[c]=b;return d}; +a.load=function(b,c,d,f){if(c&&c!=="*"){var e=this;this._jsonRequest(["GET",b.$entity+"/"+c],function(h){b.$loadFrom(h);b.$migrate();h=b.$$entity(b);e.cache(h);(d||nglr.noop)(b)},f)}return b};a.loadMany=function(b,c,d){var f=this,e=[],h=0;jQuery.each(c,function(j,l){e.push(f.load(b(),l,function(){h++;if(h==c.length)(d||nglr.noop)(e)}))});return e};a.loadOrCreate=function(b,c,d){return this.load(b,c,d,function(f){if(f.$status_code==404){b.$id=c;(d||nglr.noop)(b)}else throw f;})}; +a.loadAll=function(b,c){var d=this,f=[];f.$$accept=function(e){return e.$entity==b.title};this._cache.$collections.push(f);this._jsonRequest(["GET",b.title],function(e){for(var h=0;h<e.length;h++){var j=b();j.$loadFrom(e[h]);f.push(d.cache(j))}(c||nglr.noop)(f)});return f}; +a.save=function(b,c){var d=this,f={};b.$saveTo(f);this._jsonRequest(["POST","",f],function(e){b.$loadFrom(e);var h=d.cache(b);_.each(d._cache.$collections,function(j){j.$$accept(b)&&angular.Array.includeIf(j,h,true)});if(b.$$anchor)d.anchor[b.$$anchor]=b.$id;c&&c(b)})}; +a.remove=function(b,c){var d=this,f={};b.$saveTo(f);this._jsonRequest(["DELETE","",f],function(e){delete d._cache[b.$entity+"/"+b.$id];_.each(d._cache.$collections,function(h){for(var j=0;j<h.length;j++)h[j].$id==b.$id&&h.splice(j,1)});(c||nglr.noop)(e)})};a._jsonRequest=function(b,c,d){b.$$callback=c;b.$$failure=d||function(f){throw f;};this.bulkRequest.push(b)}; +a.flush=function(){function b(f,e){console.log("RESPONSE["+f+"]: ",e);if(e.$status_code==401)c.users.login(function(){c.post(d,b)});else if(e.$status_code)nglr.alert(nglr.toJson(e));else for(var h=0;h<e.length;h++){var j=e[h],l=d[h];if(f=j.$status_code)f==403?c.users.notAuthorized():l.$$failure(j);else l.$$callback(j)}}if(this.bulkRequest.length!==0){var c=this,d=this.bulkRequest;this.bulkRequest=[];console.log("REQUEST:",d);this.post(d,b)}}; +a.saveScope=function(b,c){function d(){f--;f===0&&c&&c()}var f=1;for(var e in b){var h=b[e];if(h&&h.$save==nglr.Model.prototype.$save){f++;h.$save(d)}}d()};a.query=function(b,c,d,f){var e=this,h=[];h.$$accept=function(){return false};this._cache.$collections.push(h);this._jsonRequest(["GET",b.title+"/"+c+"="+d],function(j){for(var l=0;l<j.length;l++){var n=(new b).$loadFrom(j[l]);h.push(e.cache(n))}f&&f(h)});return h}; +a.entities=function(b){var c=[],d=this;this._jsonRequest(["GET","$entities"],function(f){for(var e in f)c.push(d.entity(e));c.sort(function(h,j){return h.title>j.title?1:-1});b&&b(c)});return c};a.documentCountsByUser=function(){var b={};this.post([["GET","$users"]],function(c,d){jQuery.each(d[0],function(f,e){b[f]=e})});return b};a.userDocumentIdsByEntity=function(b){var c={};this.post([["GET","$users/"+b]],function(d,f){jQuery.each(f[0],function(e,h){c[e]=h})});return c}; +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; +nglr.DataStore.prototype.entity=function(b,c){if(!b)return nglr.DataStore.NullEntity;var d=this,f=function(e){return new nglr.Model(f,e)};f.title=b;f.$$factory=true;f.datastore=this;f.defaults=c||{};f.load=function(e,h){return d.load(f(),e,h)};f.loadMany=function(e,h){return d.loadMany(f,e,h)};f.loadOrCreate=function(e,h){return d.loadOrCreate(f(),e,h)};f.all=function(e){return d.loadAll(f,e)};f.query=function(e,h,j){return d.query(f,e,h,j)};f.properties=function(e){d._jsonRequest(["GET",b+"/$properties"], +e)};return f}; +nglr.DataStore.prototype.join=function(b){function c(h){return h?h.substring(0,h.indexOf(".")):undefined}function d(h){return h.substring(h.indexOf(".")+1)}var f=function(){throw"Joined entities can not be instantiated into a document.";},e=_(b).chain().map(function(h,j){return j}).sortBy(function(h){var j=[];do{if(_(j).include(h))throw"Infinite loop in join: "+j.join(" -> ");j.push(h);if(!b[h])throw _("Named entity '<%=name%>' is undefined.").template({name:h});h=c(b[h].on)}while(h);return j.length}).value(); +if(_(e).select(function(h){return b[h].on}).length!=e.length-1)throw"Exactly one entity needs to be primary.";f.query=function(h,j){var l=[],n=c(h);if(n!=e[0])throw _("Named entity '<%=name%>' is not a primary entity.").template({name:n});var o=1;b[n].join.query(d(h),j,function(p){var s=e[o++],v=b[s],u=v.on,w={};_(p).each(function(g){var i={};l.push(i);i[n]=g;g=nglr.Scope.getter(i,u);w[g]=g});v.join.loadMany(_.toArray(w),function(g){var i={};_(g).each(function(k){i[k.$id]=k});_(l).each(function(k){var m= +nglr.Scope.getter(k,u);k[s]=i[m]})})});return l};return f};angular.filter.Meta=function(b){if(b)for(var c in b)this[c]=b[c]};angular.filter.Meta.get=function(b,c){c=c||"text";switch(typeof b){case "string":return c=="text"?b:undefined;case "object":if(b&&typeof b[c]!=="undefined")return b[c];return;default:return b}};angular.filter.currency=function(b){jQuery(this.element).toggleClass("ng-format-negative",b<0);return"$"+angular.filter.number.apply(this,[b,2])}; +angular.filter.number=function(b,c){if(isNaN(b)||!isFinite(b))return"";c=typeof c=="undefined"?2:c;var d=b<0;b=Math.abs(b);var f=Math.pow(10,c);b=""+Math.round(b*f);var e=b.substring(0,b.length-c);e=e||"0";f=b.substring(b.length-c);b=d?"-":"";for(d=0;d<e.length;d++){if((e.length-d)%3===0&&d!==0)b+=",";b+=e.charAt(d)}if(c>0){for(d=f.length;d<c;d++)f+="0";b+="."+f.substring(0,c)}return b};angular.filter.date=function(){}; +angular.filter.json=function(b){jQuery(this.element).addClass("ng-monospace");return nglr.toJson(b,true)}; +angular.filter.trackPackage=function(b,c){b=nglr.trim(b);for(var d=b.replace(/ /g,""),f=angular.filter.trackPackage.MATCHERS,e=0;e<f.length;e++)for(var h=f[e],j=0;j<h.regexp.length;j++)if(h.regexp[j].test(d)){c=h.name+": "+b;h=h.url+b;return new angular.filter.Meta({text:c,url:h,html:'<a href="'+nglr.escapeAttr(h)+'">'+c+"</a>",trackingNo:b})}return b?c||new angular.filter.Meta({text:b+" is not recognized"}):null}; +angular.filter.trackPackage.MATCHERS=[{name:"UPS",url:"http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&track.x=0&track.y=0&InquiryNumber1=",regexp:[/^1Z[0-9A-Z]{16}$/i]},{name:"FedEx",url:"http://www.fedex.com/Tracking?tracknumbers=",regexp:[/^96\d{10}?$/i,/^96\d{17}?$/i,/^96\d{20}?$/i,/^\d{15}$/i,/^\d{12}$/i]},{name:"USPS",url:"http://trkcnfrm1.smi.usps.com/PTSInternetWeb/InterLabelInquiry.do?origTrackNum=",regexp:[/^(91\d{20})$/i, +/^(91\d{18})$/i]}];angular.filter.link=function(b,c){c=c||angular.filter.Meta.get(b);var d=angular.filter.Meta.get(b,"url")||angular.filter.Meta.get(b);if(d){if(angular.validator.email(d)===null)d="mailto:"+d;b='<a href="'+nglr.escapeHtml(d)+'">'+c+"</a>";return new angular.filter.Meta({text:c,url:d,html:b})}return b};angular.filter.bytes=function(b){if(b===null)return"";for(var c=0;b>1E3;){b/=1024;c++}b=""+b;var d=b.indexOf(".");if(d>-1&&d+2<b.length)b=b.substring(0,d+2);return b+" "+angular.filter.bytes.SUFFIX[c]}; +angular.filter.bytes.SUFFIX=["bytes","KB","MB","GB","TB","PB"];angular.filter.image=function(b,c,d){if(b&&b.url){var f="";if(c)f=' style="max-width: '+c+"px; max-height: "+(d||c)+'px;"';return new angular.filter.Meta({url:b.url,text:b.url,html:'<img src="'+b.url+'"'+f+"/>"})}return null};angular.filter.lowercase=function(b){return(b=angular.filter.Meta.get(b))?(""+b).toLowerCase():b};angular.filter.uppercase=function(b){return(b=angular.filter.Meta.get(b))?(""+b).toUpperCase():b}; +angular.filter.linecount=function(b){b=angular.filter.Meta.get(b);if(b===""||!b)return 1;return b.split(/\n|\f/).length};angular.filter["if"]=function(b,c){return c?b:undefined};angular.filter.unless=function(b,c){return c?undefined:b}; +angular.filter.googleChartApi=function(b,c,d,f){c=c||{};var e=angular.filter.googleChartApi;b={cht:b,chco:e.collect(c,"color"),chtt:e.title(c),chdl:e.collect(c,"label"),chd:e.values(c),chf:"bg,s,FFFFFF00"};if(_.isArray(c.xLabels)){b.chxt="x";b.chxl="0:|"+c.xLabels.join("|")}return angular.filter.googleChartApi.encode(b,d,f)}; +angular.filter.googleChartApi.values=function(b){var c=[];_.each(b.series||[],function(d){var f=[];_.each(d.values||[],function(e){f.push(e)});c.push(f.join(","))});b=c.join("|");return b===""?null:"t:"+b};angular.filter.googleChartApi.title=function(b){var c=[];b=b.title||[];_.each(_.isArray(b)?b:[b],function(d){c.push(encodeURIComponent(d))});return c.join("|")}; +angular.filter.googleChartApi.collect=function(b,c){var d=[],f=0;_.each(b.series||[],function(e){var h=[];e=e[c]||[];_.each(_.isArray(e)?e:[e],function(j){h.push(encodeURIComponent(j));f++});d.push(h.join("|"))});return f?d.join(","):null}; +angular.filter.googleChartApi.encode=function(b,c,d){c=c||200;d=d||c;var f="http://chart.apis.google.com/chart?",e=[];b.chs=c+"x"+d;for(var h in b){var j=b[h];j&&e.push(h+"="+j)}e.sort();f+=e.join("&");return new angular.filter.Meta({url:f,text:j,html:'<img width="'+c+'" height="'+d+'" src="'+f+'"/>'})};angular.filter.qrcode=function(b,c,d){return angular.filter.googleChartApi.encode({cht:"qr",chl:encodeURIComponent(b)},c,d)}; +angular.filter.chart={pie:function(b,c,d){return angular.filter.googleChartApi("p",b,c,d)},pie3d:function(b,c,d){return angular.filter.googleChartApi("p3",b,c,d)},pieConcentric:function(b,c,d){return angular.filter.googleChartApi("pc",b,c,d)},barHorizontalStacked:function(b,c,d){return angular.filter.googleChartApi("bhs",b,c,d)},barHorizontalGrouped:function(b,c,d){return angular.filter.googleChartApi("bhg",b,c,d)},barVerticalStacked:function(b,c,d){return angular.filter.googleChartApi("bvs",b,c, +d)},barVerticalGrouped:function(b,c,d){return angular.filter.googleChartApi("bvg",b,c,d)},line:function(b,c,d){return angular.filter.googleChartApi("lc",b,c,d)},sparkline:function(b,c,d){return angular.filter.googleChartApi("ls",b,c,d)},scatter:function(b,c,d){return angular.filter.googleChartApi("s",b,c,d)}};angular.filter.html=function(b){return new angular.filter.Meta({html:b})};nglr.array=[].constructor;nglr.toJson=function(b,c){var d=[];nglr.toJsonArray(d,b,c?"\n ":null);return d.join("")};nglr.toPrettyJson=function(b){return nglr.toJson(b,true)};nglr.fromJson=function(b){try{var c=new nglr.Parser(b,true),d=c.primary();c.assertAllConsumed();return d()}catch(f){console.error("fromJson error: ",b,f);throw f;}}; +nglr.toJsonArray=function(b,c,d){var f=typeof c;if(c===null)b.push("null");else if(f!=="function")if(f==="boolean")b.push(""+c);else if(f==="number")isNaN(c)?b.push("null"):b.push(""+c);else if(f==="string")return b.push(angular.String.quoteUnicode(c));else if(f==="object")if(c instanceof Array){b.push("[");var e=c.length;f=false;for(var h=0;h<e;h++){var j=c[h];f&&b.push(",");typeof j=="function"||typeof j=="undefined"?b.push("null"):nglr.toJsonArray(b,j,d);f=true}b.push("]")}else if(c instanceof +Date)b.push(angular.String.quoteUnicode(angular.Date.toString(c)));else{b.push("{");d&&b.push(d);f=false;h=d?d+" ":false;j=[];for(var l in c)l.indexOf("$$")!==0&&j.push(l);j.sort();for(l=0;l<j.length;l++){var n=j[l];try{e=c[n];if(typeof e!="function"){if(f){b.push(",");d&&b.push(d)}b.push(angular.String.quote(n));b.push(":");nglr.toJsonArray(b,e,h);f=true}}catch(o){}}b.push("}")}};nglr.Model=function(b,c){this.$$entity=b;this.$loadFrom(c||{});this.$entity=b.title;this.$migrate()};nglr.Model.copyDirectFields=function(b,c){if(!(b===c||!b||!c)){var d=function(e,h,j){return j.substring(0,2)!=="$$"&&typeof e[j]!=="function"&&typeof h[j]!=="function"};for(var f in c)d(b,c,f)&&delete c[f];for(f in b)if(d(b,c,f))c[f]=b[f]}};a=nglr.Model.prototype;a.$migrate=function(){nglr.merge(this.$$entity.defaults,this);return this};a.$merge=function(b){nglr.merge(b,this);return this}; +a.$save=function(b){this.$$entity.datastore.save(this,b===true?undefined:b);b===true&&this.$$entity.datastore.flush();return this};a.$delete=function(b){this.$$entity.datastore.remove(this,b===true?undefined:b);b===true&&this.$$entity.datastore.flush();return this};a.$loadById=function(b,c){this.$$entity.datastore.load(this,b,c);return this};a.$loadFrom=function(b){nglr.Model.copyDirectFields(b,this);return this};a.$saveTo=function(b){nglr.Model.copyDirectFields(this,b);return this};nglr.Lexer=function(b,c){this.text=b;this.dateParseLength=c?20:-1;this.tokens=[];this.index=0}; +nglr.Lexer.OPERATORS={"null":function(){return null},"true":function(){return true},"false":function(){return false},"+":function(b,c,d){return(c||0)+(d||0)},"-":function(b,c,d){return(c||0)-(d||0)},"*":function(b,c,d){return c*d},"/":function(b,c,d){return c/d},"%":function(b,c,d){return c%d},"^":function(b,c,d){return c^d},"=":function(b,c,d){return b.scope.set(c,d)},"==":function(b,c,d){return c==d},"!=":function(b,c,d){return c!=d},"<":function(b,c,d){return c<d},">":function(b,c,d){return c> +d},"<=":function(b,c,d){return c<=d},">=":function(b,c,d){return c>=d},"&&":function(b,c,d){return c&&d},"||":function(b,c,d){return c||d},"&":function(b,c,d){return c&d},"|":function(b,c,d){return d(b,c)},"!":function(b,c){return!c}};a=nglr.Lexer.prototype;a.peek=function(){return this.index+1<this.text.length?this.text.charAt(this.index+1):false}; +a.parse=function(){for(var b=this.tokens,c=nglr.Lexer.OPERATORS,d=true;this.index<this.text.length;){var f=this.text.charAt(this.index);if(f=='"'||f=="'"){this.readString(f);d=true}else if(f=="("||f=="["){b.push({index:this.index,text:f});this.index++}else if(f=="{"){d=this.peek();if(d==":"||d=="("){b.push({index:this.index,text:f+d});this.index++}else b.push({index:this.index,text:f});this.index++;d=true}else if(f==")"||f=="]"||f=="}"){b.push({index:this.index,text:f});this.index++;d=false}else if(f== +":"||f=="."||f==","||f==";"){b.push({index:this.index,text:f});this.index++;d=true}else if(d&&f=="/"){this.readRegexp();d=false}else if(this.isNumber(f)){this.readNumber();d=false}else if(this.isIdent(f)){this.readIdent();d=false}else if(this.isWhitespace(f))this.index++;else{d=f+this.peek();var e=c[f],h=c[d];if(h){b.push({index:this.index,text:d,fn:h});this.index+=2}else if(e){b.push({index:this.index,text:f,fn: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)+"'.";d=true}}return b};a.isNumber=function(b){return"0"<=b&&b<="9"};a.isWhitespace=function(b){return b==" "||b=="\r"||b=="\t"||b=="\n"||b=="\u000b"};a.isIdent=function(b){return"a"<=b&&b<="z"||"A"<=b&&b<="Z"||"_"==b||b=="$"};a.readNumber=function(){for(var b="",c=this.index;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=="."||this.isNumber(d))b+=d;else break;this.index++}b=1*b;this.tokens.push({index:c,text:b,fn:function(){return b}})}; +a.readIdent=function(){for(var b="",c=this.index;this.index<this.text.length;){var d=this.text.charAt(this.index);if(d=="."||this.isIdent(d)||this.isNumber(d))b+=d;else break;this.index++}d=nglr.Lexer.OPERATORS[b];if(!d){d=function(f){return f.scope.get(b)};d.isAssignable=b}this.tokens.push({index:c,text:b,fn:d})};nglr.Lexer.ESCAPE={n:"\n",f:"\u000c",r:"\r",t:"\t",v:"\u000b","'":"'",'"':'"'}; +nglr.Lexer.prototype.readString=function(b){var c=this.index,d=this.dateParseLength;this.index++;for(var f="",e=false;this.index<this.text.length;){var h=this.text.charAt(this.index);if(e){if(h=="u"){h=this.text.substring(this.index+1,this.index+5);this.index+=4;f+=String.fromCharCode(parseInt(h,16))}else{e=nglr.Lexer.ESCAPE[h];f+=e?e:h}e=false}else if(h=="\\")e=true;else if(h==b){this.index++;this.tokens.push({index:c,text:f,fn:function(){return f.length==d?angular.String.toDate(f):f}});return}else f+= +h;this.index++}throw"Lexer Error: Unterminated quote ["+this.text.substring(c)+"] starting at column '"+(c+1)+"' in expression '"+this.text+"'.";}; +nglr.Lexer.prototype.readRegexp=function(){var b=this.index;this.index++;for(var c="",d=false;this.index<this.text.length;){var f=this.text.charAt(this.index);if(d){c+=f;d=false}else if(f==="\\"){c+=f;d=true}else if(f==="/"){this.index++;d="";if(this.isIdent(this.text.charAt(this.index))){this.readIdent();d=this.tokens.pop().text}var e=new RegExp(c,d);this.tokens.push({index:b,text:c,flags:d,fn:function(){return e}});return}else c+=f;this.index++}throw"Lexer Error: Unterminated RegExp ["+this.text.substring(b)+ +"] starting at column '"+(b+1)+"' in expression '"+this.text+"'.";};nglr.Parser=function(b,c){this.text=b;this.tokens=(new nglr.Lexer(b,c)).parse();this.index=0};nglr.Parser.ZERO=function(){return 0};a=nglr.Parser.prototype;a.error=function(b,c){throw"Token '"+c.text+"' is "+b+" at column='"+(c.index+1)+"' of expression '"+this.text+"' starting at '"+this.text.substring(c.index)+"'.";};a.peekToken=function(){if(this.tokens.length===0)throw"Unexpected end of expression: "+this.text;return this.tokens[0]}; +a.peek=function(b,c,d,f){var e=this.tokens;if(e.length>0){e=e[0];var h=e.text;if(h==b||h==c||h==d||h==f||!b&&!c&&!d&&!f)return e}return false};a.expect=function(b,c,d,f){if(b=this.peek(b,c,d,f)){this.tokens.shift();return this.currentToken=b}return false};a.consume=function(b){if(!this.expect(b)){var c=this.peek();throw"Expecting '"+b+"' at column '"+(c.index+1)+"' in '"+this.text+"' got '"+this.text.substring(c.index)+"'.";}}; +a._unary=function(b,c){var d=c.apply(this);return function(f){return b(f,d(f))}};a._binary=function(b,c,d){var f=d.apply(this);return function(e){return c(e,b(e),f(e))}};a.hasTokens=function(){return this.tokens.length>0};a.assertAllConsumed=function(){if(this.tokens.length!==0)throw"Did not understand '"+this.text.substring(this.tokens[0].index)+"' while evaluating '"+this.text+"'.";}; +a.statements=function(){for(var b=[];;){this.tokens.length>0&&!this.peek("}",")",";","]")&&b.push(this.filterChain());if(!this.expect(";"))return function(c){for(var d,f=0;f<b.length;f++){var e=b[f];if(e)d=e(c)}return d}}};a.filterChain=function(){for(var b=this.expression(),c;;)if(c=this.expect("|"))b=this._binary(b,c.fn,this.filter);else return b};a.filter=function(){return this._pipeFunction(angular.filter)};a.validator=function(){return this._pipeFunction(angular.validator)}; +a._pipeFunction=function(b){for(var c=this.functionIdent(b),d=[];;)if(this.expect(":"))d.push(this.expression());else{var f=function(e,h){h=[h];for(var j=0;j<d.length;j++)h.push(d[j](e));return c.apply(e,h)};return function(){return f}}};a.expression=function(){return this.throwStmt()};a.throwStmt=function(){if(this.expect("throw")){var b=this.assignment();return function(c){throw b(c);}}else return this.assignment()}; +a.assignment=function(){var b=this.logicalOR(),c;if(c=this.expect("=")){if(!b.isAssignable)throw"Left hand side '"+this.text.substring(0,c.index)+"' of assignment '"+this.text.substring(c.index)+"' is not assignable.";return this._binary(function(){return b.isAssignable},c.fn,this.logicalOR)}else return b};a.logicalOR=function(){for(var b=this.logicalAND(),c;;)if(c=this.expect("||"))b=this._binary(b,c.fn,this.logicalAND);else return b}; +a.logicalAND=function(){for(var b=this.negated(),c;;)if(c=this.expect("&&"))b=this._binary(b,c.fn,this.negated);else return b};a.negated=function(){var b;return(b=this.expect("!"))?this._unary(b.fn,this.equality):this.equality()};a.equality=function(){for(var b=this.relational(),c;;)if(c=this.expect("==","!="))b=this._binary(b,c.fn,this.relational);else return b};a.relational=function(){for(var b=this.additive(),c;;)if(c=this.expect("<",">","<=",">="))b=this._binary(b,c.fn,this.additive);else return b}; +a.additive=function(){for(var b=this.multiplicative(),c;c=this.expect("+","-");)b=this._binary(b,c.fn,this.multiplicative);return b};a.multiplicative=function(){for(var b=this.unary(),c;c=this.expect("*","/","%");)b=this._binary(b,c.fn,this.unary);return b};a.unary=function(){var b;return this.expect("+")?this.primary():(b=this.expect("-"))?this._binary(nglr.Parser.ZERO,b.fn,this.multiplicative):this.primary()}; +a.functionIdent=function(b){var c=this.expect(),d=c.text.split(".");b=b;for(var f,e=0;e<d.length;e++){f=d[e];if(b)b=b[f]}if(typeof b!="function")throw"Function '"+c.text+"' at column '"+(c.index+1)+"' in '"+this.text+"' is not defined.";return b}; +a.primary=function(){var b;if(this.expect("(")){b=this.filterChain();this.consume(")");b=b}else if(this.expect("["))b=this.arrayDeclaration();else if(this.expect("{"))b=this.object();else if(this.expect("{:"))b=this.closure(false);else if(this.expect("{("))b=this.closure(true);else{var c=this.expect();(b=c.fn)||this.error("not a primary expression",c)}for(;c=this.expect("(","[",".");)if(c.text==="(")b=this.functionCall(b);else if(c.text==="[")b=this.objectIndex(b);else if(c.text===".")b=this.fieldAccess(b); +else throw"IMPOSSIBLE";return b};a.closure=function(b){var c=[];if(b){if(!this.expect(")")){for(c.push(this.expect().text);this.expect(",");)c.push(this.expect().text);this.consume(")")}this.consume(":")}var d=this.statements();this.consume("}");return function(f){return function(e){var h=new nglr.Scope(f.scope.state);h.set("$",e);for(var j=0;j<c.length;j++)h.set(c[j],arguments[j]);return d({scope:h})}}}; +a.fieldAccess=function(b){var c=this.expect().text,d=function(f){return nglr.Scope.getter(b(f),c)};d.isAssignable=c;return d};a.objectIndex=function(b){var c=this.expression();this.consume("]");if(this.expect("=")){var d=this.expression();return function(f){return b(f)[c(f)]=d(f)}}else return function(f){var e=b(f);f=c(f);return e?e[f]:undefined}}; +a.functionCall=function(b){var c=[];if(this.peekToken().text!=")"){do c.push(this.expression());while(this.expect(","))}this.consume(")");return function(d){for(var f=[],e=0;e<c.length;e++)f.push(c[e](d));e=b(d);if(typeof e==="function")return e.apply(d,f);else throw"Expression '"+b.isAssignable+"' is not a function.";}}; +a.arrayDeclaration=function(){var b=[];if(this.peekToken().text!="]"){do b.push(this.expression());while(this.expect(","))}this.consume("]");return function(c){for(var d=[],f=0;f<b.length;f++)d.push(b[f](c));return d}};a.object=function(){var b=[];if(this.peekToken().text!="}"){do{var c=this.expect().text;this.consume(":");var d=this.expression();b.push({key:c,value:d})}while(this.expect(","))}this.consume("}");return function(f){for(var e={},h=0;h<b.length;h++){var j=b[h],l=j.value(f);e[j.key]=l}return e}}; +a.entityDeclaration=function(){for(var b=[];this.hasTokens();){b.push(this.entityDecl());this.expect(";")||this.assertAllConsumed()}return function(c){for(var d="",f=0;f<b.length;f++)d+=b[f](c);return d}}; +a.entityDecl=function(){var b=this.expect().text,c,d;if(this.expect("=")){c=b;b=this.expect().text}if(this.expect(":"))d=this.primary()(null);return function(f){var e=f.scope.get("$datastore").entity(b,d);f.scope.set(b,e);if(c){e=e();e.$$anchor=c;f.scope.set(c,e);return"$anchor."+c+":{"+c+"="+b+".load($anchor."+c+");"+c+".$$anchor="+angular.String.quote(c)+";};"}else return""}}; +a.watch=function(){for(var b=[];this.hasTokens();){b.push(this.watchDecl());this.expect(";")||this.assertAllConsumed()}this.assertAllConsumed();return function(c){for(var d=0;d<b.length;d++){var f=b[d](c);c.addListener(f.name,f.fn)}}};a.watchDecl=function(){var b=this.expect().text;this.consume(":");var c;if(this.peekToken().text=="{"){this.consume("{");c=this.statements();this.consume("}")}else c=this.expression();return function(){return{name:b,fn:c}}};nglr.Scope=function(b,c){this.widgets=[];this.watchListeners={};this.name=c;b=b||{};var d=function(){};d.prototype=b;this.state=new d;this.state.$parent=b;if(c=="ROOT")this.state.$root=this.state};nglr.Scope.expressionCache={};nglr.Scope.prototype.updateView=function(){var b=this;this.fireWatchers();_.each(this.widgets,function(c){b.evalWidget(c,"",{},function(){this.updateView(b)})})};nglr.Scope.prototype.addWidget=function(b){b&&this.widgets.push(b)}; +nglr.Scope.prototype.isProperty=function(b){for(var c=0;c<b.length;c++){var d=b.charAt(c);if(d!="."&&!nglr.Lexer.prototype.isIdent(d))return false}return true}; +nglr.Scope.getter=function(b,c){if(!c)return b;for(var d=c.split("."),f,e=b,h=d.length,j=0;j<h;j++){f=d[j];if(!f.match(/^[\$\w][\$\w\d]*$/))throw"Expression '"+c+"' is not a valid expression for accesing variables.";if(b){e=b;b=b[f]}if(_.isUndefined(b)&&f.charAt(0)=="$"){var l=angular.Global.typeOf(e);if(f=(l=angular[l.charAt(0).toUpperCase()+l.substring(1)])?l[[f.substring(1)]]:undefined)return b=_.bind(f,e,e)}}if(typeof b==="function"&&!b.$$factory)return nglr.bind(e,b);return b};a=nglr.Scope.prototype; +a.get=function(b){return nglr.Scope.getter(this.state,b)};a.set=function(b,c){b=b.split(".");for(var d=this.state,f=0;b.length>1;f++){var e=b.shift(),h=d[e];if(!h){h={};d[e]=h}d=h}return d[b.shift()]=c};a.setEval=function(b,c){this.eval(b+"="+nglr.toJson(c))};a.eval=function(b,c){var d=nglr.Scope.expressionCache[b];if(!d){var f=new nglr.Parser(b);d=f.statements();f.assertAllConsumed();nglr.Scope.expressionCache[b]=d}c=c||{};c.scope=this;return d(c)}; +a.evalWidget=function(b,c,d,f,e){try{var h=this.eval(c,d);if(b.hasError){b.hasError=false;jQuery(b.view).removeClass("ng-exception").removeAttr("ng-error")}f&&f.apply(b,[h]);return true}catch(j){console.error("Eval Widget Error:",j);c=nglr.toJson(j,true);b.hasError=true;jQuery(b.view).addClass("ng-exception").attr("ng-error",c);e&&e.apply(b,[j,c]);return false}}; +a.validate=function(b,c){var d=nglr.Scope.expressionCache[b];if(!d){d=(new nglr.Parser(b)).validator();nglr.Scope.expressionCache[b]=d}b={scope:this};return d(b)(b,c)};a.entity=function(b){return(new nglr.Parser(b)).entityDeclaration()({scope:this})};a.markInvalid=function(b){this.state.$invalidWidgets.push(b)};a.watch=function(b){var c=this;(new nglr.Parser(b)).watch()({scope:this,addListener:function(d,f){c.addWatchListener(d,function(e,h){try{return f({scope:c},e,h)}catch(j){nglr.alert(j)}})}})}; +a.addWatchListener=function(b,c){var d=this.watchListeners[b];if(!d){d={listeners:[],expression:b};this.watchListeners[b]=d}d.listeners.push(c)};a.fireWatchers=function(){var b=this,c=false;jQuery.each(this.watchListeners,function(d,f){var e=b.eval(f.expression);if(e!==f.lastValue){jQuery.each(f.listeners,function(h,j){j(e,f.lastValue);c=true});f.lastValue=e}});return c};nglr.Server=function(b,c){this.url=b;this.nextId=0;this.getScript=c;this.uuid="_"+(""+Math.random()).substr(2)+"_";this.maxSize=1800};nglr.Server.prototype.base64url=function(b){return Base64.encode(b)}; +nglr.Server.prototype.request=function(b,c,d,f){var e=this.uuid+this.nextId++;nglr[e]=function(l){delete nglr[e];f(200,l)};b={u:c,m:b,p:d};b=this.base64url(nglr.toJson(b));c=Math.ceil(b.length/this.maxSize);d=this.url+"/$/"+e+"/"+c+"/";for(var h=0;h<c;h++){var j=b.substr(h*this.maxSize,this.maxSize);this.getScript(d+(h+1)+"?h="+j,nglr.noop)}};nglr.FrameServer=function(b){this.frame=b};nglr.FrameServer.PREFIX="$DATASET:"; +nglr.FrameServer.prototype={read:function(){this.data=nglr.fromJson(this.frame.name.substr(nglr.FrameServer.PREFIX.length))},write:function(){this.frame.name=nglr.FrameServer.PREFIX+nglr.toJson(this.data)},request:function(){}};nglr.VisualServer=function(b,c,d){this.delegate=b;this.update=d;this.status=c};nglr.VisualServer.prototype={request:function(b,c,d,f){var e=this;this.status.beginRequest(d);this.delegate.request(b,c,d,function(){e.status.endRequest();try{f.apply(this,arguments)}catch(h){nglr.alert(nglr.toJson(h))}e.update()})}};nglr.Users=function(b,c){this.server=b;this.controlBar=c};nglr.Users.prototype={fetchCurrentUser:function(b){var c=this;this.server.request("GET","/account.json",{},function(d,f){c.current=f.user;b(f.user)})},logout:function(b){var c=this;this.controlBar.logout(function(){delete c.current;(b||nglr.noop)()})},login:function(b){var c=this;this.controlBar.login(function(){c.fetchCurrentUser(function(){(b||nglr.noop)()})})},notAuthorized:function(){this.controlBar.notAuthorized()}};angular.validator.regexp=function(b,c,d){return b.match(c)?null:d||"Value does not match expected format "+c+"."};angular.validator.number=function(b,c,d){var f=1*b;if(f==b){if(typeof c!="undefined"&&f<c)return"Value can not be less than "+c+".";if(typeof c!="undefined"&&f>d)return"Value can not be greater than "+d+".";return null}else return"Value is not a number."}; +angular.validator.integer=function(b,c,d){c=angular.validator.number(b,c,d);if(c===null&&b!=Math.round(b))return"Value is not a whole number.";return c};angular.validator.date=function(b){if(b.match(/^\d\d?\/\d\d?\/\d\d\d\d$/))return null;return"Value is not a date. (Expecting format: 12/31/2009)."};angular.validator.ssn=function(b){if(b.match(/^\d\d\d-\d\d-\d\d\d\d$/))return null;return"SSN needs to be in 999-99-9999 format."}; +angular.validator.email=function(b){if(b.match(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/))return null;return"Email needs to be in username@host.com format."};angular.validator.phone=function(b){if(b.match(/^1\(\d\d\d\)\d\d\d-\d\d\d\d$/))return null;if(b.match(/^\+\d{2,3} (\(\d{1,5}\))?[\d ]+\d$/))return null;return"Phone number needs to be in 1(987)654-3210 format in North America or +999 (123) 45678 906 internationaly."}; +angular.validator.url=function(b){if(b.match(/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/))return null;return"URL needs to be in http://server[:port]/path format."};angular.validator.json=function(b){try{nglr.fromJson(b);return null}catch(c){return c.toString()}};nglr.WidgetFactory=function(b,c){this.nextUploadId=0;this.serverUrl=b;this.database=c;this.createSWF=swfobject.createSWF;this.onChangeListener=function(){}}; +nglr.WidgetFactory.prototype.createController=function(b,c){var d,f=b.attr("type").toLowerCase(),e=b.attr("name");if(e)e=e.split(":").pop();var h="change",j=true;if(f=="button"||f=="submit"||f=="reset"||f=="image"){d=new nglr.ButtonController(b[0],e);h="click";j=false}else if(f=="text"||f=="textarea"||f=="hidden"||f=="password"){d=new nglr.TextController(b[0],e);h="keyup change"}else if(f=="checkbox"){d=new nglr.CheckboxController(b[0],e);h="click"}else if(f=="radio"){d=new nglr.RadioController(b[0], +e);h="click"}else if(f=="select-one")d=new nglr.SelectController(b[0],e);else if(f=="select-multiple")d=new nglr.MultiSelectController(b[0],e);else if(f=="file")d=this.createFileController(b,e);else throw"Unknown type: "+f;b.data("controller",d);var l=c.get("$binder");jQuery(d.view,":input").bind(h,function(){if(d.updateModel(c)){var n=jQuery(d.view).attr("ng-action")||"";c.evalWidget(d,n)&&l.updateView(c)}return j});return d}; +nglr.WidgetFactory.prototype.createFileController=function(b){var c="__uploadWidget_"+this.nextUploadId++,d=nglr.FileController.template(c);b.after(d);c=this.createSWF({data:this.serverUrl+"/admin/ServerAPI.swf",width:"95",height:"20",align:"top",wmode:"transparent"},{flashvars:"uploadWidgetId="+c,allowScriptAccess:"always"},c);b.remove();b=new nglr.FileController(d,b[0].name,c,this.serverUrl+"/data/"+this.database);jQuery(c).data("controller",b);return b}; +nglr.WidgetFactory.prototype.createTextWidget=function(b){b=new nglr.TextController(b);b.onChange(this.onChangeListener);return b};nglr.FileController=function(b,c,d,f){this.view=b;this.uploader=d;this.scopeName=c;this.attachmentsPath=f+"/_attachments";this.value=null;this.lastValue=undefined};nglr.FileController.dispatchEvent=function(b,c,d){b=document.getElementById(b);b=jQuery(b).data("controller");nglr.FileController.prototype["_on_"+c].apply(b,d)}; +nglr.FileController.template=function(b){return jQuery('<span class="ng-upload-widget"><input type="checkbox" ng-non-bindable="true"/><object id="'+b+'" /><a></a><span/></span>')};a=nglr.FileController.prototype;a._on_cancel=function(){};a._on_complete=function(){};a._on_httpStatus=function(b){nglr.alert("httpStatus:"+this.scopeName+" status:"+b)};a._on_ioError=function(){nglr.alert("ioError:"+this.scopeName)};a._on_open=function(){nglr.alert("open:"+this.scopeName)};a._on_progress=function(){}; +a._on_securityError=function(){nglr.alert("securityError:"+this.scopeName)};a._on_uploadCompleteData=function(b){b=nglr.fromJson(b);b.url=this.attachmentsPath+"/"+b.id+"/"+b.text;this.view.find("input").attr("checked",true);var c=this.view.scope();this.value=b;this.updateModel(c);this.value=null;c.get("$binder").updateView()};a._on_select=function(b,c){this.name=b;this.view.find("a").text(b).attr("href",b);this.view.find("span").text(angular.filter.bytes(c));this.upload()}; +a.updateModel=function(b){var c=this.view.find("input").attr("checked")?this.value:null;if(this.lastValue===c)return false;else{b.set(this.scopeName,c);return true}};a.updateView=function(b){if((b=b.get(this.scopeName))&&this.value!==b){this.value=b;this.view.find("a").attr("href",this.value.url).text(this.value.text);this.view.find("span").text(angular.filter.bytes(this.value.size))}this.view.find("input").attr("checked",!!b)};a.upload=function(){this.name&&this.uploader.uploadFile(this.attachmentsPath)}; +nglr.NullController=function(b){this.view=b};nglr.NullController.prototype.updateModel=function(){return true};nglr.NullController.prototype.updateView=function(){};nglr.NullController.instance=new nglr.NullController;nglr.ButtonController=function(b){this.view=b};nglr.ButtonController.prototype.updateModel=function(){return true};nglr.ButtonController.prototype.updateView=function(){}; +nglr.TextController=function(b,c){this.view=b;this.exp=c;this.validator=b.getAttribute("ng-validate");this.required=typeof b.attributes["ng-required"]!="undefined";this.lastErrorText=null;this.lastValue=undefined;this.initialValue=b.value;b.getAttribute("ng-widget")==="datepicker"&&jQuery(b).datepicker()};nglr.TextController.prototype.updateModel=function(b){var c=this.view.value;if(this.lastValue===c)return false;else{b.setEval(this.exp,c);this.lastValue=c;return true}}; +nglr.TextController.prototype.updateView=function(b){var c=this.view,d=b.get(this.exp);if(typeof d==="undefined"){d=this.initialValue;b.setEval(this.exp,d)}d=d?d:"";if(this.lastValue!=d)this.lastValue=c.value=d;var f=false;c.removeAttribute("ng-error");if(this.required)f=!(d&&d.length>0);var e=f?"Required Value":null;if(!f&&this.validator&&d){e=b.validate(this.validator,d);f=!!e}if(this.lastErrorText!==e){this.lastErrorText=f;if(e!==null){c.setAttribute("ng-error",e);b.markInvalid(this)}jQuery(c).toggleClass("ng-validation-error", +f)}};nglr.CheckboxController=function(b,c){this.view=b;this.exp=c;this.lastValue=undefined;this.initialValue=b.checked?b.value:""};nglr.CheckboxController.prototype.updateModel=function(b){var c=this.view;c=c.checked?c.value:"";if(this.lastValue===c)return false;else{b.setEval(this.exp,c);this.lastValue=c;return true}}; +nglr.CheckboxController.prototype.updateView=function(b){var c=this.view,d=b.eval(this.exp);if(typeof d==="undefined"){d=this.initialValue;b.setEval(this.exp,d)}c.checked=c.value==""+d};nglr.SelectController=function(b,c){this.view=b;this.exp=c;this.lastValue=undefined;this.initialValue=b.value}; +nglr.SelectController.prototype.updateModel=function(b){if(this.view.selectedIndex<0)b.setEval(this.exp,null);else{var c=this.view.value;if(this.lastValue===c)return false;else{b.setEval(this.exp,c);this.lastValue=c;return true}}};nglr.SelectController.prototype.updateView=function(b){var c=this.view,d=b.get(this.exp);if(typeof d==="undefined"){d=this.initialValue;b.setEval(this.exp,d)}if(d!==this.lastValue){c.value=d?d:"";this.lastValue=d}}; +nglr.MultiSelectController=function(b,c){this.view=b;this.exp=c;this.lastValue=undefined;this.initialValue=this.selected()};nglr.MultiSelectController.prototype.selected=function(){for(var b=[],c=this.view.options,d=0;d<c.length;d++){var f=c[d];f.selected&&b.push(f.value)}return b};nglr.MultiSelectController.prototype.updateModel=function(b){var c=this.selected();if(this.lastValue===c)return false;else{b.setEval(this.exp,c);this.lastValue=c;return true}}; +nglr.MultiSelectController.prototype.updateView=function(b){var c=this.view,d=b.get(this.exp);if(typeof d==="undefined"){d=this.initialValue;b.setEval(this.exp,d)}if(d!==this.lastValue){b=c.options;for(c=0;c<b.length;c++){var f=b[c];f.selected=_.include(d,f.value)}this.lastValue=d}};nglr.RadioController=function(b,c){this.view=b;this.exp=c;this.lastValue=this.lastChecked=undefined;this.inputValue=b.value;this.initialValue=b.checked?b.value:null}; +nglr.RadioController.prototype.updateModel=function(b){var c=this.view;if(this.lastChecked)return false;else{c.checked=true;this.lastValue=b.setEval(this.exp,this.inputValue);return this.lastChecked=true}};nglr.RadioController.prototype.updateView=function(b){var c=this.view,d=b.get(this.exp);if(this.initialValue&&typeof d==="undefined"){d=this.initialValue;b.setEval(this.exp,d)}if(this.lastValue!=d){this.lastChecked=c.checked=this.inputValue==""+d;this.lastValue=d}}; +nglr.BindUpdater=function(b,c){this.view=b;this.exp=nglr.Binder.parseBindings(c);this.hasError=false;this.scopeSelf={element:b}}; +nglr.BindUpdater.toText=function(b){var c=nglr.escapeHtml;switch(typeof b){case "string":case "boolean":case "number":return c(b);case "function":return nglr.BindUpdater.toText(b());case "object":if(nglr.isNode(b))return nglr.outerHTML(b);else if(b instanceof angular.filter.Meta){switch(typeof b.html){case "string":case "number":return b.html;case "function":return b.html();case "object":if(nglr.isNode(b.html))return nglr.outerHTML(b.html);default:break}switch(typeof b.text){case "string":case "number":return c(b.text); +case "function":return c(b.text());default:break}}if(b===null)return"";return c(nglr.toJson(b,true));default:return""}};nglr.BindUpdater.prototype.updateModel=function(){}; +nglr.BindUpdater.prototype.updateView=function(b){for(var c=[],d=this.exp,f=d.length,e=0;e<f;e++){var h=d[e],j=nglr.Binder.binding(h);if(j){b.evalWidget(this,j,this.scopeSelf,function(l){c.push(nglr.BindUpdater.toText(l))},function(l,n){nglr.setHtml(this.view,n)});if(this.hasError)return}else c.push(nglr.escapeHtml(h))}nglr.setHtml(this.view,c.join(""))};nglr.BindAttrUpdater=function(b,c){this.view=b;this.attrs=c};nglr.BindAttrUpdater.prototype.updateModel=function(){}; +nglr.BindAttrUpdater.prototype.updateView=function(b){var c=jQuery(this.view),d=this.attrs;if(this.hasError){this.hasError=false;c.removeClass("ng-exception").removeAttr("ng-error")}var f=c.is("img");for(var e in d){for(var h=nglr.Binder.parseBindings(d[e]),j=[],l=0;l<h.length;l++){var n=nglr.Binder.binding(h[l]);if(n)try{var o=b.eval(n,{element:c[0],attrName:e});if(o&&(o.constructor!==nglr.array||o.length!==0))j.push(o)}catch(p){this.hasError=true;console.error("BindAttrUpdater",p);n=nglr.toJson(p, +true);j.push("["+n+"]");c.addClass("ng-exception").attr("ng-error",n)}else j.push(h[l])}h=j.length?j.join(""):null;if(f&&e=="src"&&!h)h=b.get("config.server")+"/images/blank.gif";c.attr(e,h)}};nglr.EvalUpdater=function(b,c){this.view=b;this.exp=c;this.hasError=false};nglr.EvalUpdater.prototype.updateModel=function(){};nglr.EvalUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp)};nglr.HideUpdater=function(b,c){this.view=b;this.exp=c};nglr.HideUpdater.prototype.updateModel=function(){}; +nglr.HideUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp,{},function(c){var d=jQuery(this.view);nglr.toBoolean(c)?d.hide():d.show()})};nglr.ShowUpdater=function(b,c){this.view=b;this.exp=c};nglr.ShowUpdater.prototype.updateModel=function(){};nglr.ShowUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp,{},function(c){var d=jQuery(this.view);nglr.toBoolean(c)?d.show():d.hide()})};nglr.ClassUpdater=function(b,c){this.view=b;this.exp=c}; +nglr.ClassUpdater.prototype.updateModel=function(){};nglr.ClassUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp,{},function(c){if(c!==null&&c!==undefined)this.view.className=c})};nglr.ClassEvenUpdater=function(b,c){this.view=b;this.exp=c};nglr.ClassEvenUpdater.prototype.updateModel=function(){};nglr.ClassEvenUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp,{},function(c){var d=b.get("$index");jQuery(this.view).toggleClass(c,d%2===1)})}; +nglr.ClassOddUpdater=function(b,c){this.view=b;this.exp=c};nglr.ClassOddUpdater.prototype.updateModel=function(){};nglr.ClassOddUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp,{},function(c){var d=b.get("$index");jQuery(this.view).toggleClass(c,d%2===0)})};nglr.StyleUpdater=function(b,c){this.view=b;this.exp=c};nglr.StyleUpdater.prototype.updateModel=function(){}; +nglr.StyleUpdater.prototype.updateView=function(b){b.evalWidget(this,this.exp,{},function(c){jQuery(this.view).attr("style","").css(c)})}; +nglr.RepeaterUpdater=function(b,c,d,f){this.view=b;this.template=d;this.prefix=f;this.children=[];b=c.match(/^\s*(.+)\s+in\s+(.*)\s*$/);if(!b)throw"Expected ng-repeat in form of 'item in collection' but got '"+c+"'.";c=b[1];this.iteratorExp=b[2];b=c.match(/^([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\)$/);if(!b)throw"'item' in 'item in collection' should be identifier or (key, value) but get '"+c+"'.";this.valueExp=b[3]||b[1];this.keyExp=b[2]};nglr.RepeaterUpdater.prototype.updateModel=function(){}; +nglr.RepeaterUpdater.prototype.updateView=function(b){b.evalWidget(this,this.iteratorExp,{},function(c){var d=this;if(!c){c=[];b.isProperty(this.iteratorExp)&&b.set(this.iteratorExp,c)}var f=c.length,e=this.children.length,h=this.view,j=0,l=null,n=this.keyExp,o=this.valueExp,p=0;jQuery.each(c,function(s,v){if(p<e){l=d.children[p];l.scope.set(o,v)}else{var u=new nglr.Scope(b.state,d.prefix+o+" in "+d.iteratorExp+"["+p+"]");u.set("$index",p);n&&u.set(n,s);u.set(o,v);l={scope:u,element:d.template(u, +d.prefix,p)};h.after(l.element);d.children.push(l)}h=l.element;s=(new Date).getTime();l.scope.updateView();j+=(new Date).getTime()-s;p++});for(c=e;c>f;--c)this.children.pop().element.removeNode();if(l&&l.element[0].nodeName==="OPTION")if(f=jQuery(l.element[0].parentNode).data("controller")){f.lastValue=undefined;f.updateView(b)}})};nglr.PopUp=function(b){this.doc=b};nglr.PopUp.OUT_EVENT="mouseleave mouseout click dblclick keypress keyup"; +nglr.PopUp.prototype.bind=function(){this.doc.find(".ng-validation-error,.ng-exception").live("mouseover",nglr.PopUp.onOver)}; +nglr.PopUp.onOver=function(){nglr.PopUp.onOut();var b=jQuery(this);b.bind(nglr.PopUp.OUT_EVENT,nglr.PopUp.onOut);var c=b.position(),d=document.documentElement,f=(self.innerWidth||d&&d.clientWidth||document.body.clientWidth)-c.left;d=b.hasClass("ng-exception")?"EXCEPTION:":"Validation error...";b=b.attr("ng-error");f=f>375?"left":"right";d=jQuery("<div id='ng-callout' style='width:300px'><div class='ng-arrow-"+f+"'/><div class='ng-title'>"+d+"</div><div class='ng-content'>"+b+"</div></div>");jQuery("body").append(d); +if(f==="left")b=c.left+this.offsetWidth+11;else{b=c.left-315;d.find(".ng-arrow-right").css({left:301})}d.css({left:b+"px",top:c.top-3+"px"});return true};nglr.PopUp.onOut=function(){jQuery("#ng-callout").unbind(nglr.PopUp.OUT_EVENT,nglr.PopUp.onOut).remove();return true};nglr.Status=function(b){this.loader=b.append(nglr.Status.DOM).find("#ng-loading");this.requestCount=0};nglr.Status.DOM='<div id="ng-spacer"></div><div id="ng-loading">loading....</div>'; +nglr.Status.prototype.beginRequest=function(){this.requestCount===0&&this.loader.show();this.requestCount++};nglr.Status.prototype.endRequest=function(){this.requestCount--;this.requestCount===0&&this.loader.hide("fold")};(function(b){for(var c=/(.*)\/angular-(.*).js(#(.*))?/,d=document.getElementsByTagName("script"),f={autoSubmit:true,autoBind:true,autoLoadDependencies:false},e=0;e<d.length;e++){var h=d[e].src;if(h&&h.match(c)){h=h.match(c);if(h[2]=="bootstrap")f.autoLoadDependencies=true;f.server=h[1]||"";if(!f.server)f.server=window.location.toString().split(window.location.pathname)[0];if(h[4]){h=h[4].split("&");for(var j=0;j<h.length;j++){var l=h[j].split("="),n=l[0];l=l.length==1?true:l[1];if(l=="false")l=false; +if(l=="true")l=true;f[n]=l}}}}c=function(o,p){p=p||f.server;document.write('<script type="text/javascript" src="'+p+o+'"><\/script>')};if(f.autoLoadDependencies){c("/../lib/webtoolkit/webtoolkit.base64.js");c("/../lib/swfobject/swfobject.js");c("/../lib/jquery/jquery-1.3.2.js");c("/../lib/jquery/jquery-ui-1.7.1.custom.min.js");c("/../lib/underscore/underscore.js");c("/Loader.js");c("/API.js");c("/Binder.js");c("/ControlBar.js");c("/DataStore.js");c("/Filters.js");c("/JSON.js");c("/Model.js");c("/Parser.js"); +c("/Scope.js");c("/Server.js");c("/Users.js");c("/Validators.js");c("/Widgets.js")}else{c("/ajax/libs/swfobject/2.2/swfobject.js","http://ajax.googleapis.com");c("/ajax/libs/jquery/1.3.2/jquery.min.js","http://ajax.googleapis.com");c("/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js","http://ajax.googleapis.com")}window.onload=function(){var o=window.document;if(f.bindRootId){o=null;for(var p=f.bindRootId.split("|"),s=0;s<p.length&&!o;s++){var v=p[s].split("?"),u=v[0];if(v.length>1)if(!window.document.getElementById(v[1]))continue; +o=window.document.getElementById(u)}}p=window.angularFactory(f);if(f.autoBind&&o)window.angularScope=p.compile(o);if(typeof b==="function")try{b.apply(this,arguments)}catch(w){}}})(window.onload); diff --git a/example/calculator-manual_init.html b/example/calculator-manual_init.html index 0d5c1bb6..6013345e 100644 --- a/example/calculator-manual_init.html +++ b/example/calculator-manual_init.html @@ -1,7 +1,7 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> - <script type="text/javascript" src="../src/angular-bootstrap.js#autoBind=false"></script> + <script type="text/javascript" src="../angular.js#autoBind=false"></script> <script type="text/javascript"> $(document).ready(function(){ var angular = angularFactory({}); diff --git a/src/Loader.js b/src/Loader.js index f7482d24..5240944c 100644 --- a/src/Loader.js +++ b/src/Loader.js @@ -402,3 +402,4 @@ window['angularFactory'] = function(config) { compile:compile }; }; + |
