From 1aba6b53b88c70b61a0cc991b1371739305d117b Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sun, 10 Jan 2010 08:58:57 -0800 Subject: basic calculator works with minified.js, lots of references still broken --- .gitignore | 2 + Rakefile | 33 +- angular-minified.js | 231 +++++----- angular.js | 789 ++++------------------------------ example/calculator-manual_init.html | 3 +- example/calculator-minified_init.html | 21 + src/API.js | 72 ++-- src/DataStore.js | 2 +- src/Filters.js | 2 +- src/JSON.js | 6 +- src/Loader.js | 47 +- src/Parser.js | 8 +- src/Scope.js | 2 +- src/Widgets.js | 16 +- src/test/Runner.js | 2 +- src/test/_namespace.js | 10 +- 16 files changed, 343 insertions(+), 903 deletions(-) create mode 100644 .gitignore create mode 100644 example/calculator-minified_init.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..90a1eea4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +angular-minified.map +externs.js diff --git a/Rakefile b/Rakefile index a4823809..8f7bc7ec 100644 --- a/Rakefile +++ b/Rakefile @@ -1,12 +1,39 @@ include FileUtils +desc 'Generate Externs' +task :compileexterns do + out = File.new("externs.js", "w") + + out.write("function _(){};\n") + file = File.new("lib/underscore/underscore.js", "r") + while (line = file.gets) + if line =~ /^\s*_\.(\w+)\s*=.*$/ + out.write("_.#{$1}=function(){};\n") + end + end + file.close + + out.write("function jQuery(){};\n") + file = File.new("lib/jquery/jquery-1.3.2.js", "r") + while (line = file.gets) + if line =~ /^\s*(\w+)\s*:\s*function.*$/ + out.write("jQuery.#{$1}=function(){};\n") + end + end + file.close + out.write("jQuery.scope=function(){};\n") + out.write("jQuery.controller=function(){};\n") + + out.close +end + desc 'Compile JavaScript' task :compile do + Rake::Task['compileexterns'].execute + 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 \ @@ -30,6 +57,8 @@ task :compile do %x(java -jar lib/compiler-closure/compiler.jar \ --compilation_level ADVANCED_OPTIMIZATIONS \ --js angular.js \ + --externs externs.js \ + --create_source_map ./angular-minified.map \ --js_output_file angular-minified.js) end diff --git a/angular-minified.js b/angular-minified.js index a9faa563..ce5155f2 100644 --- a/angular-minified.js +++ b/angular-minified.js @@ -1,122 +1,109 @@ -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=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;qm?1:0}),"value")};b.Sf=function(f,h,j){j=j||b.ga;for(var k=0,m=f.length;k>1;j(f[q])=0})})};b.gg=function(){for(var f=b.A(arguments),h=b.max(b.bb(f,"length")),j=new Array(h),k=0;k0?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)[^\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>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>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;c127&&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;c191&&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/g,">")};escapeAttr=function(a){if(!a||!a.replace)return a;return a.replace(//g,">").replace(/\"/g,""")};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=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-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=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-1;){c1||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=" "+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 -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("')};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;cd;--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("
"+c+"
"+a+"
");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='
loading....
';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); +function m(){return function(){}}function u(n){return function(q){this[n]=q}}function w(n){return function(){return n}} +(function(n,q){var z={z:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",$:function(a){var b="",c,d,e,f,g,h,i=0;for(a=z.Gb(a);i>2;c=(c&3)<<4|d>>4;g=(d&15)<<2|e>>6;h=e&63;if(isNaN(d))g=h=64;else if(isNaN(e))h=64;b=b+this.z.charAt(f)+this.z.charAt(c)+this.z.charAt(g)+this.z.charAt(h)}return b},Gd:function(a){var b="",c,d,e,f,g,h=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");h>4;d=(d&15)<<4|f>>2;e=(f&3)<<6|g;b+=String.fromCharCode(c);if(f!=64)b+=String.fromCharCode(d);if(g!=64)b+=String.fromCharCode(e)}return b=z.Fb(b)},Gb:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",c=0;c127&&d<2048)b+=String.fromCharCode(d>>6|192);else{b+=String.fromCharCode(d>>12|224);b+=String.fromCharCode(d>> +6&63|128)}b+=String.fromCharCode(d&63|128)}}return b},Fb:function(a){for(var b="",c=0,d=c1=c2=0;c191&&d<224){c2=a.charCodeAt(c+1);b+=String.fromCharCode((d&31)<<6|c2&63);c+=2}else{c2=a.charCodeAt(c+1);c3=a.charCodeAt(c+2);b+=String.fromCharCode((d&15)<<12|(c2&63)<<6|c3&63);c+=3}}return b}};if(typeof q.getAttribute=="undefined")q.getAttribute=m();if(typeof Node=="undefined")Node={ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3, +CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12};var x={},j=n.jQuery,A=j.browser.msie;if(!n.ld){angular={};n.angular=angular}if(!angular.h)angular.h={};if(!angular.filter)angular.filter={};if(!n.console)n.console={log:m(),error:m()};if(!angular.alert)angular.alert=function(){console.log(arguments);n.alert.apply(n,arguments)};var y;consoleLog=function(a,b){var c= +q.createElement("div");c.className=a;for(var d=a="",e=0;e/g,">")};escapeAttr=function(a){if(!a||!a.replace)return a;return a.replace(//g,">").replace(/\"/g,""")};bind=function(a,b){if(!a)throw"Missing this";if(!_.isFunction(b))throw"Missing function";return function(){return b.apply(a,arguments)}};shiftBind=function(a,b){return function(){for(var c=[this],d=0;d=0&&a.splice(c,1);return b},find:function(a,b,c){if(b){var d= +angular.Function.compile(b);_.detect(a,function(e){if(d(e)){c=e;return true}});return c}},findById:function(a,b){return angular.gd.find(a,function(c){return c.C==b},null)},filter:function(a,b){var c=[];c.Pb=function(k){for(var l=0;l-1;case "object":for(var o in k)if(o.charAt(0)!== +"$"&&e(k[o],l))return true;return false;case "array":for(o=0;o=0&&a.splice(d,1);a.unshift((c?"-":"+")+b);return a},orderByDirection:function(a,b,c,d){c=c||"ng-ascend";d=d||"ng-descend";a=a[0]||"";var e=true;if(a.charAt(0)=="-"){a=a.substring(1);e=false}else if(a.charAt(0)=="+")a=a.substring(1);return a==b?e?c:d:""},merge:function(a,b,c){var d=a[b];if(!d){d={};a[b]=d}merge(c,d);return a}};angular.String={quote:function(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g, +"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v")+'"'},quoteUnicode:function(a){a=angular.String.quote(a);for(var b=[],c=0;c-1;){c1||Binder.N(a[0])!==null};Binder.N=function(a){return(a=a.replace(/\n/gm, +" ").match(/^\{\{(.*)\}\}$/))?a[1]:null};Binder.prototype.Jc=function(a){var b={};a.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(c,d,e){if(d)b[decodeURIComponent(d)]=decodeURIComponent(e)});return b};Binder.prototype.ib=function(a){var b=this;a=a||this.ya.Va();var c=a.indexOf("#");if(!(c<0)){a=this.Jc(a.substring(c+1));j.each(b.anchor,function(d){delete b.anchor[d]});j.each(a,function(d,e){b.anchor[d]=e})}};Binder.prototype.Ic=function(a){console.log("URL change detected",a);this.ib(a);this.c()}; +Binder.prototype.Vc=function(){var a=this.ya.Va(),b=a.indexOf("#");if(b>-1)a=a.substring(0,b);a+="#";b="";for(var c in this.anchor){var d=this.anchor[c];if(typeof d==="undefined"||d===null)delete this.anchor[c];else{a+=b+encodeURIComponent(c);if(d!==true)a+="="+encodeURIComponent(d);b="&"}}this.ya.Rc(a);return a};Binder.prototype.c=function(){(new Date).getTime();var a=j(this.F).scope();a.l("$invalidWidgets",[]);a.c();(new Date).getTime();this.Vc();_.each(this.rb,function(b){b()})};Binder.prototype.Z= +function(a){var b=j(this.F),c=b.find(a);if(b.is(a))c=c.andSelf();return c};Binder.prototype.fc=function(){this.Z("[ng-init]").each(function(){var a=j(this),b=a.scope();try{b.eval(a.attr("ng-init"))}catch(c){alert("EVAL ERROR:\n"+a.attr("ng-init")+"\n"+toJson(c,true))}})};Binder.prototype.O=function(a){this.Z("[ng-entity]").attr("ng-watch",function(){try{var b=j(this);return a.O(b.attr("ng-entity"))+(b.attr("ng-watch")||"")}catch(c){alert(c)}})};Binder.prototype.compile=function(){var a=j(this.F), +b=this;if(this.k.nd){var c=this.Z(":submit").not("[ng-action]");c.attr("ng-action","$save()");c.not(":disabled").not("ng-bind-attr").attr("ng-bind-attr",'{disabled:"{{$invalidWidgets}}"}')}this.jb(this.F)(this.F,a.scope(),"");this.Z("a[ng-action]").live("click",function(){var d=j(this);try{d.scope().eval(d.attr("ng-action"));d.removeAttr("ng-error");d.removeClass("ng-exception")}catch(e){d.addClass("ng-exception");d.attr("ng-error",toJson(e,true))}b.c();return false})};Binder.prototype.Tc=function(a, +b,c){b=b.concat();var d=b.pop(),e=Binder.ga(a.nodeValue);if(e.length>1||Binder.N(e[0])){var f=a.parentNode;if(isLeafNode(f)){f.setAttribute("ng-bind-template",a.nodeValue);c.push({path:b,b:function(l){return new BindUpdater(l,l.getAttribute("ng-bind-template"))}})}else for(var g=0;g2&&a.setAttribute("ng-bind-attr",d)}a.getAttribute||console.log(a);var k=a.getAttribute("ng-repeat");if(k){a.removeAttribute("ng-repeat");var l=this.jb(a);d=q.createComment("ng-repeat: "+k);e=a.parentNode;e.insertBefore(d,a); +e.removeChild(a);var o=function(p,r,s){var v=j(a).clone();v.css("display","");v.attr("ng-repeat-index",""+s);v.data("scope",p);l(v[0],p,r+s+":");return v};c.push({path:b,b:function(p,r,s){return new RepeaterUpdater(j(p),k,o,s)}})}else{a.getAttribute("ng-eval")&&c.push({path:b,b:this.Ac});a.getAttribute("ng-bind")&&c.push({path:b,b:this.hb});a.getAttribute("ng-bind-attr")&&c.push({path:b,b:this.wc});a.getAttribute("ng-hide")&&c.push({path:b,b:this.Bc});a.getAttribute("ng-show")&&c.push({path:b,b:this.Cc}); +a.getAttribute("ng-class")&&c.push({path:b,b:this.xc});a.getAttribute("ng-class-odd")&&c.push({path:b,b:this.zc});a.getAttribute("ng-class-even")&&c.push({path:b,b:this.yc});a.getAttribute("ng-style")&&c.push({path:b,b:this.Dc});a.getAttribute("ng-watch")&&c.push({path:b,b:this.Ec});d=a.nodeName;if(d=="INPUT"||d=="TEXTAREA"||d=="SELECT"||d=="BUTTON"){var t=this;c.push({path:b,b:function(p,r,s){p.name=s+p.name.split(":").pop();return t.ad.Ub(j(p),r)}})}if(d=="OPTION")if(!j("')};FileController.prototype.e=function(a){var b=this.view.find("input").attr("checked")?this.value:null;if(this.d===b)return false;else{a.l(this.nb,b);return true}};FileController.prototype.c=function(a){if((a=a.get(this.nb))&&this.value!==a){this.value=a;this.view.find("a").attr("href",this.value.url).text(this.value.text); +this.view.find("span").text(angular.filter.bytes(this.value.size))}this.view.find("input").attr("checked",!!a)};NullController=u("view");NullController.prototype.e=w(true);NullController.prototype.c=m();NullController.lc=new NullController;ButtonController=u("view");ButtonController.prototype.e=w(true);ButtonController.prototype.c=m();TextController=function(a,b){this.view=a;this.exp=b;this.h=a.getAttribute("ng-validate");this.Nc=typeof a.attributes["ng-required"]!="undefined";this.Ya=null;this.d= +undefined;this.s=a.value;a.getAttribute("ng-widget")==="datepicker"&&j(a).Fd()};TextController.prototype.e=function(a){var b=this.view.value;if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}};TextController.prototype.c=function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.s;a.p(this.exp,c)}c=c?c:"";if(this.d!=c)this.d=b.value=c;var d=false;b.removeAttribute("ng-error");if(this.Nc)d=!(c&&c.length>0);var e=d?"Required Value":null;if(!d&&this.h&&c){e=a.Yc(this.h, +c);d=!!e}if(this.Ya!==e){this.Ya=d;if(e!==null){b.setAttribute("ng-error",e);a.sc(this)}j(b).toggleClass("ng-validation-error",d)}};CheckboxController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.s=a.checked?a.value:""};CheckboxController.prototype.e=function(a){var b=this.view;b=b.checked?b.value:"";if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}};CheckboxController.prototype.c=function(a){var b=this.view,c=a.eval(this.exp);if(typeof c==="undefined"){c=this.s; +a.p(this.exp,c)}b.checked=b.value==""+c};SelectController=function(a,b){this.view=a;this.exp=b;this.d=undefined;this.s=a.value};SelectController.prototype.e=function(a){if(this.view.selectedIndex<0)a.p(this.exp,null);else{var b=this.view.value;if(this.d===b)return false;else{a.p(this.exp,b);this.d=b;return true}}};SelectController.prototype.c=function(a){var b=this.view,c=a.get(this.exp);if(typeof c==="undefined"){c=this.s;a.p(this.exp,c)}if(c!==this.d){b.value=c?c:"";this.d=c}};MultiSelectController= +function(a,b){this.view=a;this.exp=b;this.d=undefined;this.s=this.selected()};MultiSelectController.prototype.selected=function(){for(var a=[],b=this.view.options,c=0;cd;--b){var o= +this.children.pop().element[0];o.parentNode.removeChild(o)}if(h&&h.element[0].nodeName==="OPTION")if(d=j(h.element[0].parentNode).data("controller")){d.d=undefined;d.c(a)}})};PopUp=u("F");PopUp.Fa="mouseleave mouseout click dblclick keypress keyup";PopUp.prototype.bind=function(){this.F.find(".ng-validation-error,.ng-exception").live("mouseover",PopUp.Hc)};PopUp.Hc=function(){PopUp.wa();var a=j(this);a.bind(PopUp.Fa,PopUp.wa);var b=a.position(),c=q.documentElement,d=(self.innerWidth||c&&c.clientWidth|| +q.body.clientWidth)-b.left;c=a.hasClass("ng-exception")?"EXCEPTION:":"Validation error...";a=a.attr("ng-error");d=d>375?"left":"right";c=j("
"+c+"
"+a+"
");j("body").append(c);if(d==="left")a=b.left+this.offsetWidth+11;else{a=b.left-315;c.find(".ng-arrow-right").css({left:301})}c.css({left:a+"px",top:b.top-3+"px"});return true};PopUp.wa=function(){j("#ng-callout").unbind(PopUp.Fa, +PopUp.wa).remove();return true};Status=function(a){this.cb=a.append(Status.yb).find("#ng-loading");this.ja=0};Status.yb='
loading....
';Status.prototype.Nb=function(){this.ja===0&&this.cb.show();this.ja++};Status.prototype.cc=function(){this.ja--;this.ja===0&&this.cb.hide("fold")}})(window,document); diff --git a/angular.js b/angular.js index 0e1527f2..c113d56b 100644 --- a/angular.js +++ b/angular.js @@ -1,612 +1,3 @@ -// Underscore.js -// (c) 2009 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the terms of the MIT license. -// Portions of Underscore are inspired by or borrowed from Prototype.js, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore/ - -(function() { - - /*------------------------- Baseline setup ---------------------------------*/ - - // Establish the root object, "window" in the browser, or "global" on the server. - var root = this; - - // Save the previous value of the "_" variable. - var previousUnderscore = root._; - - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - var wrapper = function(obj) { this._wrapped = obj; }; - - // Establish the object that gets thrown to break out of a loop iteration. - var breaker = typeof StopIteration !== 'undefined' ? StopIteration : '__break__'; - - // Create a safe reference to the Underscore object for reference below. - var _ = root._ = function(obj) { return new wrapper(obj); }; - - // Export the Underscore object for CommonJS. - if (typeof exports !== 'undefined') exports._ = _; - - // Create quick reference variables for speed access to core prototypes. - var slice = Array.prototype.slice, - unshift = Array.prototype.unshift, - toString = Object.prototype.toString, - hasOwnProperty = Object.prototype.hasOwnProperty, - propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - - // Current version. - _.VERSION = '0.5.1'; - - /*------------------------ Collection Functions: ---------------------------*/ - - // The cornerstone, an each implementation. - // Handles objects implementing forEach, arrays, and raw objects. - _.each = function(obj, iterator, context) { - var index = 0; - try { - if (obj.forEach) { - obj.forEach(iterator, context); - } else if (_.isArray(obj) || _.isArguments(obj)) { - for (var i=0, l=obj.length; i= result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj); - var result = {computed : Infinity}; - _.each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed < result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Sort the object's values by a criteria produced by an iterator. - _.sortBy = function(obj, iterator, context) { - return _.pluck(_.map(obj, function(value, index, list) { - return { - value : value, - criteria : iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }), 'value'); - }; - - // Use a comparator function to figure out at what index an object should - // be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator) { - iterator = iterator || _.identity; - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >> 1; - iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid; - } - return low; - }; - - // Convert anything iterable into a real, live array. - _.toArray = function(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - if (_.isArray(iterable)) return iterable; - if (_.isArguments(iterable)) return slice.call(iterable); - return _.map(iterable, function(val){ return val; }); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - return _.toArray(obj).length; - }; - - /*-------------------------- Array Functions: ------------------------------*/ - - // Get the first element of an array. Passing "n" will return the first N - // values in the array. Aliased as "head". The "guard" check allows it to work - // with _.map. - _.first = function(array, n, guard) { - return n && !guard ? slice.call(array, 0, n) : array[0]; - }; - - // Returns everything but the first entry of the array. Aliased as "tail". - // Especially useful on the arguments object. Passing an "index" will return - // the rest of the values in the array from that index onward. The "guard" - //check allows it to work with _.map. - _.rest = function(array, index, guard) { - return slice.call(array, _.isUndefined(index) || guard ? 1 : index); - }; - - // Get the last element of an array. - _.last = function(array) { - return array[array.length - 1]; - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.select(array, function(value){ return !!value; }); - }; - - // Return a completely flattened version of an array. - _.flatten = function(array) { - return _.reduce(array, [], function(memo, value) { - if (_.isArray(value)) return memo.concat(_.flatten(value)); - memo.push(value); - return memo; - }); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - var values = _.rest(arguments); - return _.select(array, function(value){ return !_.include(values, value); }); - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - _.uniq = function(array, isSorted) { - return _.reduce(array, [], function(memo, el, i) { - if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) memo.push(el); - return memo; - }); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. - _.intersect = function(array) { - var rest = _.rest(arguments); - return _.select(_.uniq(array), function(item) { - return _.all(rest, function(other) { - return _.indexOf(other, item) >= 0; - }); - }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var args = _.toArray(arguments); - var length = _.max(_.pluck(args, 'length')); - var results = new Array(length); - for (var i=0; i 0 ? i - stop : stop - i) >= 0) return range; - range[idx++] = i; - } - }; - - /* ----------------------- Function Functions: -----------------------------*/ - - // Create a function bound to a given object (assigning 'this', and arguments, - // optionally). Binding with arguments is also known as 'curry'. - _.bind = function(func, obj) { - var args = _.rest(arguments, 2); - return function() { - return func.apply(obj || root, args.concat(_.toArray(arguments))); - }; - }; - - // Bind all of an object's methods to that object. Useful for ensuring that - // all callbacks defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = _.rest(arguments); - if (funcs.length == 0) funcs = _.functions(obj); - _.each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = _.rest(arguments, 2); - return setTimeout(function(){ return func.apply(func, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(_.rest(arguments))); - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return function() { - var args = [func].concat(_.toArray(arguments)); - return wrapper.apply(wrapper, args); - }; - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = _.toArray(arguments); - return function() { - var args = _.toArray(arguments); - for (var i=funcs.length-1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - /* ------------------------- Object Functions: ---------------------------- */ - - // Retrieve the names of an object's properties. - _.keys = function(obj) { - if(_.isArray(obj)) return _.range(0, obj.length); - var keys = []; - for (var key in obj) if (hasOwnProperty.call(obj, key)) keys.push(key); - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - return _.map(obj, _.identity); - }; - - // Return a sorted list of the function names available in Underscore. - _.functions = function(obj) { - return _.select(_.keys(obj), function(key){ return _.isFunction(obj[key]); }).sort(); - }; - - // Extend a given object with all of the properties in a source object. - _.extend = function(destination, source) { - for (var property in source) destination[property] = source[property]; - return destination; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (_.isArray(obj)) return obj.slice(0); - return _.extend({}, obj); - }; - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - // Check object identity. - if (a === b) return true; - // Different types? - var atype = typeof(a), btype = typeof(b); - if (atype != btype) return false; - // Basic equality test (watch out for coercions). - if (a == b) return true; - // One is falsy and the other truthy. - if ((!a && b) || (a && !b)) return false; - // One of them implements an isEqual()? - if (a.isEqual) return a.isEqual(b); - // Check dates' integer values. - if (_.isDate(a) && _.isDate(b)) return a.getTime() === b.getTime(); - // Both are NaN? - if (_.isNaN(a) && _.isNaN(b)) return true; - // Compare regular expressions. - if (_.isRegExp(a) && _.isRegExp(b)) - return a.source === b.source && - a.global === b.global && - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline; - // If a is not an object by this point, we can't handle it. - if (atype !== 'object') return false; - // Check for different array lengths before comparing contents. - if (a.length && (a.length !== b.length)) return false; - // Nothing else worked, deep compare the contents. - var aKeys = _.keys(a), bKeys = _.keys(b); - // Different object sizes? - if (aKeys.length != bKeys.length) return false; - // Recursive comparison of contents. - for (var key in a) if (!_.isEqual(a[key], b[key])) return false; - return true; - }; - - // Is a given array or object empty? - _.isEmpty = function(obj) { - return _.keys(obj).length == 0; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType == 1); - }; - - // Is a given variable an arguments object? - _.isArguments = function(obj) { - return obj && _.isNumber(obj.length) && !_.isArray(obj) && !propertyIsEnumerable.call(obj, 'length'); - }; - - // Is the given value NaN -- this one is interesting. NaN != NaN, and - // isNaN(undefined) == true, so we make sure it's a number first. - _.isNaN = function(obj) { - return _.isNumber(obj) && isNaN(obj); - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return typeof obj == 'undefined'; - }; - - // Define the isArray, isDate, isFunction, isNumber, isRegExp, and isString - // functions based on their toString identifiers. - var types = ['Array', 'Date', 'Function', 'Number', 'RegExp', 'String']; - for (var i=0, l=types.length; i)[^\t]*)'/g, "$1\r") - .replace(/\t=(.*?)%>/g, "',$1,'") - .split("\t").join("');") - .split("%>").join("p.push('") - .split("\r").join("\\'") - + "');}return p.join('');"); - return data ? fn(data) : fn; - }; - - /*------------------------------- Aliases ----------------------------------*/ - - _.forEach = _.each; - _.foldl = _.inject = _.reduce; - _.foldr = _.reduceRight; - _.filter = _.select; - _.every = _.all; - _.some = _.any; - _.head = _.first; - _.tail = _.rest; - _.methods = _.functions; - - /*------------------------ Setup the OOP Wrapper: --------------------------*/ - - // Helper function to continue chaining intermediate results. - var result = function(obj, chain) { - return chain ? _(obj).chain() : obj; - }; - - // Add all of the Underscore functions to the wrapper object. - _.each(_.functions(_), function(name) { - var method = _[name]; - wrapper.prototype[name] = function() { - unshift.call(arguments, this._wrapped); - return result(method.apply(_, arguments), this._chain); - }; - }); - - // Add all mutator Array functions to the wrapper. - _.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = Array.prototype[name]; - wrapper.prototype[name] = function() { - method.apply(this._wrapped, arguments); - return result(this._wrapped, this._chain); - }; - }); - - // Add all accessor Array functions to the wrapper. - _.each(['concat', 'join', 'slice'], function(name) { - var method = Array.prototype[name]; - wrapper.prototype[name] = function() { - return result(method.apply(this._wrapped, arguments), this._chain); - }; - }); - - // Start chaining a wrapped Underscore object. - wrapper.prototype.chain = function() { - this._chain = true; - return this; - }; - - // Extracts the result from a wrapped and chained object. - wrapper.prototype.value = function() { - return this._wrapped; - }; - -})(); (function(window, document){/** * @@ -773,19 +164,24 @@ 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 = {}; +var jQuery = window['jQuery']; +var msie = jQuery['browser']['msie']; + +if (!window.angular){ angular = {}; window['angular'] = angular; } +if (!angular.validator) angular.validator = {}; +if (!angular.filter) angular.filter = {}; +if (!window.console) window.console = { log:function() {}, error:function() {} }; -if (_.isUndefined(alert)) { - alert = function(){console.log(arguments); window.alert.apply(window, arguments); }; +if (!angular.alert) { + angular.alert = function(){console.log(arguments); window.alert.apply(window, arguments); }; } +var consoleNode; + consoleLog = function(level, objs) { var log = document.createElement("div"); log.className = level; @@ -917,7 +313,6 @@ Loader.prototype.load = function() { this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css'); this.loadCss('/stylesheets/css'); console.log("Server: " + this.config.server); - msie = jQuery.browser.msie; this.configureJQueryPlugins(); this.computeConfiguration(); this.bindHtml(); @@ -925,11 +320,7 @@ Loader.prototype.load = function() { Loader.prototype.configureJQueryPlugins = function() { console.log('Loader.configureJQueryPlugins()'); - jQuery.fn.removeNode = function() { - var node = this.get(0); - node.parentNode.removeChild(node); - }; - jQuery.fn.scope = function() { + jQuery['fn']['scope'] = function() { var element = this; while (element && element.get(0)) { var scope = element.data("scope"); @@ -939,7 +330,7 @@ Loader.prototype.configureJQueryPlugins = function() { } return null; }; - jQuery.fn.controller = function() { + jQuery['fn']['controller'] = function() { return this.data('controller') || NullController.instance; }; }; @@ -977,24 +368,19 @@ Loader.prototype.bindHtml = function() { var datastore = new DataStore(post, users, binder.anchor); binder.updateListeners.push(function(){datastore.flush();}); var scope = new Scope( { - $anchor : binder.anchor, - $binder : binder, - $config : this.config, - $console : window.console, - $datastore : datastore, - $save : function(callback) { + '$anchor' : binder.anchor, + '$binder' : binder, + '$config' : this.config, + '$console' : window.console, + '$datastore' : datastore, + '$save' : function(callback) { datastore.saveScope(scope.state, callback, binder.anchor); }, - $window : window, - $uid : this.uid, - $users : users + '$window' : window, + '$uid' : this.uid, + '$users' : users }, "ROOT"); - jQuery.each(["get", "set", "eval", "addWatchListener", "updateView"], - function(i, method){ - angular[method] = bind(scope, scope[method]); - }); - document.data('scope', scope); console.log('$binder.entity()'); binder.entity(scope); @@ -1032,7 +418,6 @@ Loader.prototype.bindHtml = function() { watcher.watch(); document.find("body").show(); console.log('ready()'); - }; Loader.prototype.visualPost = function(delegate) { @@ -1108,8 +493,8 @@ 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||noop)(); } catch (e) { @@ -1131,7 +516,7 @@ UrlWatcher.prototype.setUrl = function(url) { existingURL += '#'; if (existingURL != url) window.location.href = url; - self.existingURL = url; + this.existingURL = url; }; UrlWatcher.prototype.getUrl = function() { @@ -1147,11 +532,17 @@ angular['compile'] = function(root, config) { //todo: don't start watcher var loader = new Loader(root, jQuery("head"), _(defaults).extend(config)); loader.load(); - return jQuery(root).scope(); + var scope = jQuery(root).scope(); + //TODO: cleanup + return { + 'updateView':function(){return scope.updateView.apply(scope, arguments);}, + 'set':function(){return scope.set.apply(scope, arguments);}, + 'get':function(){return scope.get.apply(scope, arguments);} + }; }; -angular.Global = { - typeOf:function(obj){ +angular['Global'] = { + 'typeOf':function(obj){ var type = typeof obj; switch(type) { case "object": @@ -1164,10 +555,10 @@ angular.Global = { } }; -angular.Collection = {}; -angular.Object = {}; -angular.Array = { - includeIf:function(array, value, condition) { +angular['Collection'] = {}; +angular['Object'] = {}; +angular['Array'] = { + 'includeIf':function(array, value, condition) { var index = _.indexOf(array, value); if (condition) { if (index == -1) @@ -1177,8 +568,8 @@ angular.Array = { } return array; }, - sum:function(array, expression) { - var fn = angular.Function.compile(expression); + 'sum':function(array, expression) { + var fn = angular['Function']['compile'](expression); var sum = 0; for (var i = 0; i < array.length; i++) { var value = 1 * fn(array[i]); @@ -1188,15 +579,15 @@ angular.Array = { } return sum; }, - remove:function(array, value) { + 'remove':function(array, value) { var index = _.indexOf(array, value); if (index >=0) array.splice(index, 1); return value; }, - find:function(array, condition, defaultValue) { + 'find':function(array, condition, defaultValue) { if (!condition) return undefined; - var fn = angular.Function.compile(condition); + var fn = angular['Function']['compile'](condition); _.detect(array, function($){ if (fn($)){ defaultValue = $; @@ -1205,10 +596,10 @@ angular.Array = { }); return defaultValue; }, - findById:function(array, id) { + 'findById':function(array, id) { return angular.Array.find(array, function($){return $.$id == id;}, null); }, - filter:function(array, expression) { + 'filter':function(array, expression) { var predicates = []; predicates.check = function(value) { for (var j = 0; j < predicates.length; j++) { @@ -1288,16 +679,16 @@ angular.Array = { } return filtered; }, - add:function(array, value) { + 'add':function(array, value) { array.push(_.isUndefined(value)? {} : value); return array; }, - count:function(array, condition) { + 'count':function(array, condition) { if (!condition) return array.length; - var fn = angular.Function.compile(condition); + var fn = angular['Function']['compile'](condition); return _.reduce(array, 0, function(count, $){return count + (fn($)?1:0);}); }, - orderBy:function(array, expression, descend) { + 'orderBy':function(array, expression, descend) { function reverse(comp, descending) { return toBoolean(descending) ? function(a,b){return comp(b,a);} : comp; @@ -1321,7 +712,7 @@ angular.Array = { descending = $.charAt(0) == '-'; $ = $.substring(1); } - var get = $ ? angular.Function.compile($) : _.identity; + var get = $ ? angular['Function']['compile']($) : _.identity; return reverse(function(a,b){ return compare(get(a),get(b)); }, descending); @@ -1335,7 +726,7 @@ angular.Array = { }; return _.clone(array).sort(reverse(comparator, descend)); }, - orderByToggle:function(predicate, attribute) { + 'orderByToggle':function(predicate, attribute) { var STRIP = /^([+|-])?(.*)/; var ascending = false; var index = -1; @@ -1357,7 +748,7 @@ angular.Array = { predicate.unshift((ascending ? "-" : "+") + attribute); return predicate; }, - orderByDirection:function(predicate, attribute, ascend, descend) { + 'orderByDirection':function(predicate, attribute, ascend, descend) { ascend = ascend || 'ng-ascend'; descend = descend || 'ng-descend'; var att = predicate[0] || ''; @@ -1370,7 +761,7 @@ angular.Array = { } return att == attribute ? (direction ? ascend : descend) : ""; }, - merge:function(array, index, mergeValue) { + 'merge':function(array, index, mergeValue) { var value = array[index]; if (!value) { value = {}; @@ -1380,8 +771,8 @@ angular.Array = { return array; } }; -angular.String = { - quote:function(string) { +angular['String'] = { + 'quote':function(string) { return '"' + string.replace(/\\/g, '\\\\'). replace(/"/g, '\\"'). replace(/\n/g, '\\n'). @@ -1391,8 +782,8 @@ angular.String = { replace(/\v/g, '\\v') + '"'; }, - quoteUnicode:function(string) { - var str = angular.String.quote(string); + 'quoteUnicode':function(string) { + var str = angular['String']['quote'](string); var chars = []; for ( var i = 0; i < str.length; i++) { var ch = str.charCodeAt(i); @@ -1405,7 +796,7 @@ angular.String = { } return chars.join(''); }, - toDate:function(string){ + 'toDate':function(string){ var match; if (typeof string == 'string' && (match = string.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/))){ @@ -1417,8 +808,8 @@ angular.String = { return string; } }; -angular.Date = { - toString:function(date){ +angular['Date'] = { + 'toString':function(date){ function pad(n) { return n < 10 ? "0" + n : n; } return (date.getUTCFullYear()) + '-' + pad(date.getUTCMonth() + 1) + '-' + @@ -1428,8 +819,8 @@ angular.Date = { pad(date.getUTCSeconds()) + 'Z'; } }; -angular.Function = { - compile:function(expression) { +angular['Function'] = { + 'compile':function(expression) { if (_.isFunction(expression)){ return expression; } else if (expression){ @@ -1451,21 +842,21 @@ angular.Function = { dst[name] = _[name]; }); }; - extend(angular.Global, {}, + extend(angular['Global'], {}, ['extend', 'clone','isEqual', 'isElement', 'isArray', 'isFunction', 'isUndefined']); - extend(angular.Collection, angular.Global, + extend(angular['Collection'], angular['Global'], ['each', 'map', 'reduce', 'reduceRight', 'detect', 'select', 'reject', 'all', 'any', 'include', 'invoke', 'pluck', 'max', 'min', 'sortBy', 'sortedIndex', 'toArray', 'size']); - extend(angular.Array, angular.Collection, + extend(angular['Array'], angular['Collection'], ['first', 'last', 'compact', 'flatten', 'without', 'uniq', 'intersect', 'zip', 'indexOf', 'lastIndexOf']); - extend(angular.Object, angular.Collection, + extend(angular['Object'], angular['Collection'], ['keys', 'values']); - extend(angular.String, angular.Global); - extend(angular.Function, angular.Global, + extend(angular['String'], angular['Global']); + extend(angular['Function'], angular['Global'], ['bind', 'bindAll', 'delay', 'defer', 'wrap', 'compose']); })();// Copyright (C) 2009 BRAT Tech LLC Binder = function(doc, widgetFactory, urlWatcher, config) { @@ -1868,7 +1259,7 @@ ControlBar.prototype.doTemplate = function (path) { resizable: false, modal:true, title: 'Authentication: <angular/>' }); - nglr["_iframe_notify_" + id] = function() { + callbacks["_iframe_notify_" + id] = function() { loginView.dialog("destroy"); loginView.remove(); jQuery.each(self.callbacks, function(i, callback){ @@ -1982,7 +1373,7 @@ DataStore.prototype.save = function(document, callback) { var cachedDoc = self.cache(document); _.each(self._cache.$collections, function(collection){ if (collection.$$accept(document)) { - angular.Array.includeIf(collection, cachedDoc, true); + angular['Array']['includeIf'](collection, cachedDoc, true); } }); if (document.$$anchor) { @@ -2244,7 +1635,7 @@ angular.filter.Meta.get = function(obj, attr){ } }; -angular.filter.currency = function(amount){ +angular.filter['currency'] = function(amount){ jQuery(this.element).toggleClass('ng-format-negative', amount < 0); return '$' + angular.filter.number.apply(this, [amount, 2]); }; @@ -2550,7 +1941,7 @@ toJsonArray = function(buf, obj, pretty){ buf.push('' + obj); } } else if (type === 'string') { - return buf.push(angular.String.quoteUnicode(obj)); + return buf.push(angular['String']['quoteUnicode'](obj)); } else if (type === 'object') { if (obj instanceof Array) { buf.push("["); @@ -2568,7 +1959,7 @@ toJsonArray = function(buf, obj, pretty){ } buf.push("]"); } else if (obj instanceof Date) { - buf.push(angular.String.quoteUnicode(angular.Date.toString(obj))); + buf.push(angular['String']['quoteUnicode'](angular['Date']['toString'](obj))); } else { buf.push("{"); if (pretty) buf.push(pretty); @@ -2590,7 +1981,7 @@ toJsonArray = function(buf, obj, pretty){ buf.push(","); if (pretty) buf.push(pretty); } - buf.push(angular.String.quote(key)); + buf.push(angular['String']['quote'](key)); buf.push(":"); toJsonArray(buf, value, childPretty); comma = true; @@ -2854,7 +2245,7 @@ Lexer.prototype.readString = function(quote) { this.tokens.push({index:start, text:string, fn:function(){ return (string.length == dateParseLength) ? - angular.String.toDate(string) : string; + angular['String']['toDate'](string) : string; }}); return; } else { @@ -3015,11 +2406,11 @@ Parser.prototype.filterChain = function(){ }; Parser.prototype.filter = function(){ - return this._pipeFunction(angular.filter); + return this._pipeFunction(angular['filter']); }; Parser.prototype.validator = function(){ - return this._pipeFunction(angular.validator); + return this._pipeFunction(angular['validator']); }; Parser.prototype._pipeFunction = function(fnScope){ @@ -3366,7 +2757,7 @@ Parser.prototype.entityDecl = function () { self.scope.set(instance, document); return "$anchor." + instance + ":{" + instance + "=" + entity + ".load($anchor." + instance + ");" + - instance + ".$$anchor=" + angular.String.quote(instance) + ";" + + instance + ".$$anchor=" + angular['String']['quote'](instance) + ";" + "};"; } else { return ""; @@ -3465,7 +2856,7 @@ Scope.getter = function(instance, path) { instance = instance[key]; } if (_.isUndefined(instance) && key.charAt(0) == '$') { - var type = angular.Global.typeOf(lastInstance); + var type = angular['Global']['typeOf'](lastInstance); type = angular[type.charAt(0).toUpperCase()+type.substring(1)]; var fn = type ? type[[key.substring(1)]] : undefined; if (fn) { @@ -3622,8 +3013,8 @@ Server.prototype.base64url = function(txt) { 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}; @@ -3798,7 +3189,13 @@ WidgetFactory = function(serverUrl, database) { this.nextUploadId = 0; this.serverUrl = serverUrl; this.database = database; - this.createSWF = swfobject.createSWF; + if (window.swfobject) { + this.createSWF = swfobject.createSWF; + } else { + this.createSWF = function(){ + alert("ERROR: swfobject not loaded!"); + }; + } this.onChangeListener = function(){}; }; @@ -3938,7 +3335,7 @@ FileController.prototype._on_uploadCompleteData = function(data) { 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.view.find("span").text(angular['filter']['bytes'](size)); this.upload(); }; @@ -3960,7 +3357,7 @@ FileController.prototype.updateView = function(scope) { 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("span").text(angular['filter']['bytes'](this.value.size)); } this.view.find("input").attr('checked', !!modelValue); }; @@ -4470,8 +3867,8 @@ RepeaterUpdater.prototype.updateView = function(scope) { }); // shrink children for ( var r = childrenLength; r > iteratorLength; --r) { - var unneeded = this.children.pop(); - unneeded.element.removeNode(); + var unneeded = this.children.pop().element[0]; + unneeded.parentNode.removeChild(unneeded); } // Special case for option in select if (child && child.element[0].nodeName === "OPTION") { diff --git a/example/calculator-manual_init.html b/example/calculator-manual_init.html index 175d07b9..1a6571c2 100644 --- a/example/calculator-manual_init.html +++ b/example/calculator-manual_init.html @@ -1,7 +1,8 @@ - + + + + + + + + Quantity: + * + Cost: + = {{a * b | currency}} + + diff --git a/src/API.js b/src/API.js index 6fb6e8fc..49089da0 100644 --- a/src/API.js +++ b/src/API.js @@ -1,5 +1,5 @@ -angular.Global = { - typeOf:function(obj){ +angular['Global'] = { + 'typeOf':function(obj){ var type = typeof obj; switch(type) { case "object": @@ -12,10 +12,10 @@ angular.Global = { } }; -angular.Collection = {}; -angular.Object = {}; -angular.Array = { - includeIf:function(array, value, condition) { +angular['Collection'] = {}; +angular['Object'] = {}; +angular['Array'] = { + 'includeIf':function(array, value, condition) { var index = _.indexOf(array, value); if (condition) { if (index == -1) @@ -25,8 +25,8 @@ angular.Array = { } return array; }, - sum:function(array, expression) { - var fn = angular.Function.compile(expression); + 'sum':function(array, expression) { + var fn = angular['Function']['compile'](expression); var sum = 0; for (var i = 0; i < array.length; i++) { var value = 1 * fn(array[i]); @@ -36,15 +36,15 @@ angular.Array = { } return sum; }, - remove:function(array, value) { + 'remove':function(array, value) { var index = _.indexOf(array, value); if (index >=0) array.splice(index, 1); return value; }, - find:function(array, condition, defaultValue) { + 'find':function(array, condition, defaultValue) { if (!condition) return undefined; - var fn = angular.Function.compile(condition); + var fn = angular['Function']['compile'](condition); _.detect(array, function($){ if (fn($)){ defaultValue = $; @@ -53,10 +53,10 @@ angular.Array = { }); return defaultValue; }, - findById:function(array, id) { + 'findById':function(array, id) { return angular.Array.find(array, function($){return $.$id == id;}, null); }, - filter:function(array, expression) { + 'filter':function(array, expression) { var predicates = []; predicates.check = function(value) { for (var j = 0; j < predicates.length; j++) { @@ -136,16 +136,16 @@ angular.Array = { } return filtered; }, - add:function(array, value) { + 'add':function(array, value) { array.push(_.isUndefined(value)? {} : value); return array; }, - count:function(array, condition) { + 'count':function(array, condition) { if (!condition) return array.length; - var fn = angular.Function.compile(condition); + var fn = angular['Function']['compile'](condition); return _.reduce(array, 0, function(count, $){return count + (fn($)?1:0);}); }, - orderBy:function(array, expression, descend) { + 'orderBy':function(array, expression, descend) { function reverse(comp, descending) { return toBoolean(descending) ? function(a,b){return comp(b,a);} : comp; @@ -169,7 +169,7 @@ angular.Array = { descending = $.charAt(0) == '-'; $ = $.substring(1); } - var get = $ ? angular.Function.compile($) : _.identity; + var get = $ ? angular['Function']['compile']($) : _.identity; return reverse(function(a,b){ return compare(get(a),get(b)); }, descending); @@ -183,7 +183,7 @@ angular.Array = { }; return _.clone(array).sort(reverse(comparator, descend)); }, - orderByToggle:function(predicate, attribute) { + 'orderByToggle':function(predicate, attribute) { var STRIP = /^([+|-])?(.*)/; var ascending = false; var index = -1; @@ -205,7 +205,7 @@ angular.Array = { predicate.unshift((ascending ? "-" : "+") + attribute); return predicate; }, - orderByDirection:function(predicate, attribute, ascend, descend) { + 'orderByDirection':function(predicate, attribute, ascend, descend) { ascend = ascend || 'ng-ascend'; descend = descend || 'ng-descend'; var att = predicate[0] || ''; @@ -218,7 +218,7 @@ angular.Array = { } return att == attribute ? (direction ? ascend : descend) : ""; }, - merge:function(array, index, mergeValue) { + 'merge':function(array, index, mergeValue) { var value = array[index]; if (!value) { value = {}; @@ -228,8 +228,8 @@ angular.Array = { return array; } }; -angular.String = { - quote:function(string) { +angular['String'] = { + 'quote':function(string) { return '"' + string.replace(/\\/g, '\\\\'). replace(/"/g, '\\"'). replace(/\n/g, '\\n'). @@ -239,8 +239,8 @@ angular.String = { replace(/\v/g, '\\v') + '"'; }, - quoteUnicode:function(string) { - var str = angular.String.quote(string); + 'quoteUnicode':function(string) { + var str = angular['String']['quote'](string); var chars = []; for ( var i = 0; i < str.length; i++) { var ch = str.charCodeAt(i); @@ -253,7 +253,7 @@ angular.String = { } return chars.join(''); }, - toDate:function(string){ + 'toDate':function(string){ var match; if (typeof string == 'string' && (match = string.match(/^(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)Z$/))){ @@ -265,8 +265,8 @@ angular.String = { return string; } }; -angular.Date = { - toString:function(date){ +angular['Date'] = { + 'toString':function(date){ function pad(n) { return n < 10 ? "0" + n : n; } return (date.getUTCFullYear()) + '-' + pad(date.getUTCMonth() + 1) + '-' + @@ -276,8 +276,8 @@ angular.Date = { pad(date.getUTCSeconds()) + 'Z'; } }; -angular.Function = { - compile:function(expression) { +angular['Function'] = { + 'compile':function(expression) { if (_.isFunction(expression)){ return expression; } else if (expression){ @@ -299,20 +299,20 @@ angular.Function = { dst[name] = _[name]; }); }; - extend(angular.Global, {}, + extend(angular['Global'], {}, ['extend', 'clone','isEqual', 'isElement', 'isArray', 'isFunction', 'isUndefined']); - extend(angular.Collection, angular.Global, + extend(angular['Collection'], angular['Global'], ['each', 'map', 'reduce', 'reduceRight', 'detect', 'select', 'reject', 'all', 'any', 'include', 'invoke', 'pluck', 'max', 'min', 'sortBy', 'sortedIndex', 'toArray', 'size']); - extend(angular.Array, angular.Collection, + extend(angular['Array'], angular['Collection'], ['first', 'last', 'compact', 'flatten', 'without', 'uniq', 'intersect', 'zip', 'indexOf', 'lastIndexOf']); - extend(angular.Object, angular.Collection, + extend(angular['Object'], angular['Collection'], ['keys', 'values']); - extend(angular.String, angular.Global); - extend(angular.Function, angular.Global, + extend(angular['String'], angular['Global']); + extend(angular['Function'], angular['Global'], ['bind', 'bindAll', 'delay', 'defer', 'wrap', 'compose']); })(); \ No newline at end of file diff --git a/src/DataStore.js b/src/DataStore.js index bdf882a0..6eeabb21 100644 --- a/src/DataStore.js +++ b/src/DataStore.js @@ -92,7 +92,7 @@ DataStore.prototype.save = function(document, callback) { var cachedDoc = self.cache(document); _.each(self._cache.$collections, function(collection){ if (collection.$$accept(document)) { - angular.Array.includeIf(collection, cachedDoc, true); + angular['Array']['includeIf'](collection, cachedDoc, true); } }); if (document.$$anchor) { diff --git a/src/Filters.js b/src/Filters.js index dd4217be..b3f56e75 100644 --- a/src/Filters.js +++ b/src/Filters.js @@ -22,7 +22,7 @@ angular.filter.Meta.get = function(obj, attr){ } }; -angular.filter.currency = function(amount){ +angular.filter['currency'] = function(amount){ jQuery(this.element).toggleClass('ng-format-negative', amount < 0); return '$' + angular.filter.number.apply(this, [amount, 2]); }; diff --git a/src/JSON.js b/src/JSON.js index 84c9a857..238ed489 100644 --- a/src/JSON.js +++ b/src/JSON.js @@ -38,7 +38,7 @@ toJsonArray = function(buf, obj, pretty){ buf.push('' + obj); } } else if (type === 'string') { - return buf.push(angular.String.quoteUnicode(obj)); + return buf.push(angular['String']['quoteUnicode'](obj)); } else if (type === 'object') { if (obj instanceof Array) { buf.push("["); @@ -56,7 +56,7 @@ toJsonArray = function(buf, obj, pretty){ } buf.push("]"); } else if (obj instanceof Date) { - buf.push(angular.String.quoteUnicode(angular.Date.toString(obj))); + buf.push(angular['String']['quoteUnicode'](angular['Date']['toString'](obj))); } else { buf.push("{"); if (pretty) buf.push(pretty); @@ -78,7 +78,7 @@ toJsonArray = function(buf, obj, pretty){ buf.push(","); if (pretty) buf.push(pretty); } - buf.push(angular.String.quote(key)); + buf.push(angular['String']['quote'](key)); buf.push(":"); toJsonArray(buf, value, childPretty); comma = true; diff --git a/src/Loader.js b/src/Loader.js index dfaa355a..19840567 100644 --- a/src/Loader.js +++ b/src/Loader.js @@ -23,6 +23,8 @@ if (typeof Node == 'undefined') { } var callbacks = {}; +var jQuery = window['jQuery']; +var msie = jQuery['browser']['msie']; if (!window.angular){ angular = {}; window['angular'] = angular; } if (!angular.validator) angular.validator = {}; @@ -32,8 +34,8 @@ if (!window.console) log:function() {}, error:function() {} }; -if (_.isUndefined(alert)) { - alert = function(){console.log(arguments); window.alert.apply(window, arguments); }; +if (!angular.alert) { + angular.alert = function(){console.log(arguments); window.alert.apply(window, arguments); }; } var consoleNode; @@ -169,7 +171,6 @@ Loader.prototype.load = function() { this.loadCss('/stylesheets/jquery-ui/smoothness/jquery-ui-1.7.1.css'); this.loadCss('/stylesheets/css'); console.log("Server: " + this.config.server); - msie = jQuery.browser.msie; this.configureJQueryPlugins(); this.computeConfiguration(); this.bindHtml(); @@ -177,11 +178,7 @@ Loader.prototype.load = function() { Loader.prototype.configureJQueryPlugins = function() { console.log('Loader.configureJQueryPlugins()'); - jQuery.fn.removeNode = function() { - var node = this.get(0); - node.parentNode.removeChild(node); - }; - jQuery.fn.scope = function() { + jQuery['fn']['scope'] = function() { var element = this; while (element && element.get(0)) { var scope = element.data("scope"); @@ -191,7 +188,7 @@ Loader.prototype.configureJQueryPlugins = function() { } return null; }; - jQuery.fn.controller = function() { + jQuery['fn']['controller'] = function() { return this.data('controller') || NullController.instance; }; }; @@ -229,24 +226,19 @@ Loader.prototype.bindHtml = function() { var datastore = new DataStore(post, users, binder.anchor); binder.updateListeners.push(function(){datastore.flush();}); var scope = new Scope( { - $anchor : binder.anchor, - $binder : binder, - $config : this.config, - $console : window.console, - $datastore : datastore, - $save : function(callback) { + '$anchor' : binder.anchor, + '$binder' : binder, + '$config' : this.config, + '$console' : window.console, + '$datastore' : datastore, + '$save' : function(callback) { datastore.saveScope(scope.state, callback, binder.anchor); }, - $window : window, - $uid : this.uid, - $users : users + '$window' : window, + '$uid' : this.uid, + '$users' : users }, "ROOT"); - jQuery.each(["get", "set", "eval", "addWatchListener", "updateView"], - function(i, method){ - angular[method] = bind(scope, scope[method]); - }); - document.data('scope', scope); console.log('$binder.entity()'); binder.entity(scope); @@ -284,7 +276,6 @@ Loader.prototype.bindHtml = function() { watcher.watch(); document.find("body").show(); console.log('ready()'); - }; Loader.prototype.visualPost = function(delegate) { @@ -399,6 +390,12 @@ angular['compile'] = function(root, config) { //todo: don't start watcher var loader = new Loader(root, jQuery("head"), _(defaults).extend(config)); loader.load(); - return jQuery(root).scope(); + var scope = jQuery(root).scope(); + //TODO: cleanup + return { + 'updateView':function(){return scope.updateView.apply(scope, arguments);}, + 'set':function(){return scope.set.apply(scope, arguments);}, + 'get':function(){return scope.get.apply(scope, arguments);} + }; }; diff --git a/src/Parser.js b/src/Parser.js index b23215be..cdece11e 100644 --- a/src/Parser.js +++ b/src/Parser.js @@ -185,7 +185,7 @@ Lexer.prototype.readString = function(quote) { this.tokens.push({index:start, text:string, fn:function(){ return (string.length == dateParseLength) ? - angular.String.toDate(string) : string; + angular['String']['toDate'](string) : string; }}); return; } else { @@ -346,11 +346,11 @@ Parser.prototype.filterChain = function(){ }; Parser.prototype.filter = function(){ - return this._pipeFunction(angular.filter); + return this._pipeFunction(angular['filter']); }; Parser.prototype.validator = function(){ - return this._pipeFunction(angular.validator); + return this._pipeFunction(angular['validator']); }; Parser.prototype._pipeFunction = function(fnScope){ @@ -697,7 +697,7 @@ Parser.prototype.entityDecl = function () { self.scope.set(instance, document); return "$anchor." + instance + ":{" + instance + "=" + entity + ".load($anchor." + instance + ");" + - instance + ".$$anchor=" + angular.String.quote(instance) + ";" + + instance + ".$$anchor=" + angular['String']['quote'](instance) + ";" + "};"; } else { return ""; diff --git a/src/Scope.js b/src/Scope.js index e3634cee..dff3bfbd 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -55,7 +55,7 @@ Scope.getter = function(instance, path) { instance = instance[key]; } if (_.isUndefined(instance) && key.charAt(0) == '$') { - var type = angular.Global.typeOf(lastInstance); + var type = angular['Global']['typeOf'](lastInstance); type = angular[type.charAt(0).toUpperCase()+type.substring(1)]; var fn = type ? type[[key.substring(1)]] : undefined; if (fn) { diff --git a/src/Widgets.js b/src/Widgets.js index 3a0f2845..4e4facf8 100644 --- a/src/Widgets.js +++ b/src/Widgets.js @@ -5,7 +5,13 @@ WidgetFactory = function(serverUrl, database) { this.nextUploadId = 0; this.serverUrl = serverUrl; this.database = database; - this.createSWF = swfobject.createSWF; + if (window.swfobject) { + this.createSWF = swfobject.createSWF; + } else { + this.createSWF = function(){ + alert("ERROR: swfobject not loaded!"); + }; + } this.onChangeListener = function(){}; }; @@ -145,7 +151,7 @@ FileController.prototype._on_uploadCompleteData = function(data) { 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.view.find("span").text(angular['filter']['bytes'](size)); this.upload(); }; @@ -167,7 +173,7 @@ FileController.prototype.updateView = function(scope) { 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("span").text(angular['filter']['bytes'](this.value.size)); } this.view.find("input").attr('checked', !!modelValue); }; @@ -677,8 +683,8 @@ RepeaterUpdater.prototype.updateView = function(scope) { }); // shrink children for ( var r = childrenLength; r > iteratorLength; --r) { - var unneeded = this.children.pop(); - unneeded.element.removeNode(); + var unneeded = this.children.pop().element[0]; + unneeded.parentNode.removeChild(unneeded); } // Special case for option in select if (child && child.element[0].nodeName === "OPTION") { diff --git a/src/test/Runner.js b/src/test/Runner.js index 5840282e..c6684951 100644 --- a/src/test/Runner.js +++ b/src/test/Runner.js @@ -110,7 +110,7 @@ test.Scenario.prototype = { }, verb:function(step){ var fn = null; - if (!step) fn = function (){ throw "Step is null!"; } + if (!step) fn = function (){ throw "Step is null!"; }; else if (step.Given) fn = angular.test.GIVEN[step.Given]; else if (step.When) fn = angular.test.WHEN[step.When]; else if (step.Then) fn = angular.test.THEN[step.Then]; diff --git a/src/test/_namespace.js b/src/test/_namespace.js index 78f430f1..e29ae72a 100644 --- a/src/test/_namespace.js +++ b/src/test/_namespace.js @@ -1,5 +1,5 @@ -if (!angular) angular = {}; -if (!angular.test) angular.test = {}; -if (!angular.test.GIVEN) angular.test.GIVEN = {}; -if (!angular.test.WHEN) angular.test.WHEN = {}; -if (!angular.test.THEN) angular.test.THEN = {}; +if (!angular) var angular = window['angular'] = {}; +if (!angular['test']) var angularTest = angular['test'] = {}; +if (!angular['test']['GIVEN']) angularTest['GIVEN'] = {}; +if (!angular['test']['WHEN']) angularTest['WHEN'] = {}; +if (!angular['test']['THEN']) angularTest['THEN'] = {}; -- cgit v1.2.3