From: edward Date: Thu, 19 May 2016 04:04:48 +0000 (+0800) Subject: roojs-core.js X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=43566c10f3e12cdf950a5b912e04b4dc6ebb1875 roojs-core.js roojs-core-debug.js --- diff --git a/roojs-core-debug.js b/roojs-core-debug.js index 32f8f0a703..2b586a8b59 100644 --- a/roojs-core-debug.js +++ b/roojs-core-debug.js @@ -314,7 +314,7 @@ Roo.factory(conf, Roo.data); return c; } if (ns[c.xtype]) { - if (Roo.debug) Roo.log("Roo.Factory(" + c.xtype + ")"); + if (Roo.debug) { Roo.log("Roo.Factory(" + c.xtype + ")"); } var ret = new ns[c.xtype](c); ret.xns = false; return ret; @@ -941,7 +941,7 @@ Roo.applyIf(Array.prototype, { */ indexOf : function(o){ for (var i = 0, len = this.length; i < len; i++){ - if(this[i] == o) return i; + if(this[i] == o) { return i; } } return -1; }, @@ -963,15 +963,16 @@ Roo.applyIf(Array.prototype, { map : function(fun ) { var len = this.length >>> 0; - if (typeof fun != "function") + if (typeof fun != "function") { throw new TypeError(); - + } var res = new Array(len); var thisp = arguments[1]; for (var i = 0; i < len; i++) { - if (i in this) + if (i in this) { res[i] = fun.call(thisp, this[i], i, this); + } } return res; @@ -980,7 +981,8 @@ Roo.applyIf(Array.prototype, { }); - /* + +/* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC. @@ -1757,7 +1759,7 @@ document.write(dt3); //returns 'Fri Oct 06 2006 07:30:00' */ Date.prototype.add = function(interval, value){ var d = this.clone(); - if (!interval || value === 0) return d; + if (!interval || value === 0) { return d; } switch(interval.toLowerCase()){ case Date.MILLI: d.setMilliseconds(this.getMilliseconds() + value); @@ -4151,7 +4153,7 @@ Roo.DomHelper = function(){ } b += "<" + o.tag; for(var attr in o){ - if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue; + if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") { continue; } if(attr == "style"){ var s = o["style"]; if(typeof s == "function"){ @@ -4234,7 +4236,7 @@ Roo.DomHelper = function(){ for(var attr in o){ if(attr == "tag" || attr == "ns" ||attr == "xmlns" ||attr == "children" || attr == "cn" || attr == "html" || - attr == "style" || typeof o[attr] == "function") continue; + attr == "style" || typeof o[attr] == "function") { continue; } if(attr=="cls" && Roo.isIE){ el.className = o["cls"]; @@ -7066,7 +7068,7 @@ if(opt.anim.isAnimated()){ */ enableDisplayMode : function(display){ this.setVisibilityMode(El.DISPLAY); - if(typeof display != "undefined") this.originalDisplay = display; + if(typeof display != "undefined") { this.originalDisplay = display; } return this; }, @@ -7287,7 +7289,7 @@ if(opt.anim.isAnimated()){ this.setHeight(oldHeight); // restore original height this.setHeight(height, animate, duration, function(){ this.unclip(); - if(typeof onComplete == "function") onComplete(); + if(typeof onComplete == "function") { onComplete(); } }.createDelegate(this), easing); } }.createDelegate(this), 0); @@ -9385,12 +9387,15 @@ if(opt.anim.isAnimated()){ var el = this.dom; useSet = typeof useSet == 'undefined' ? (el.setAttribute ? true : false) : useSet; for(var attr in o){ - if(attr == "style" || typeof o[attr] == "function") continue; + if(attr == "style" || typeof o[attr] == "function") { continue; } if(attr=="cls"){ el.className = o["cls"]; }else{ - if(useSet) el.setAttribute(attr, o[attr]); - else el[attr] = o[attr]; + if(useSet) { + el.setAttribute(attr, o[attr]); + } else { + el[attr] = o[attr]; + } } } if(o.style){ @@ -10998,7 +11003,9 @@ Roo.CompositeElement = function(els){ Roo.CompositeElement.prototype = { isComposite: true, addElements : function(els){ - if(!els) return this; + if(!els) { + return this; + } if(typeof els == "string"){ els = Roo.Element.selectorFunction(els); } @@ -13089,7 +13096,9 @@ mc.add(otherEl); indexOf : function(o){ if(!this.items.indexOf){ for(var i = 0, len = this.items.length; i < len; i++){ - if(this.items[i] == o) return i; + if(this.items[i] == o) { + return i; + } } return -1; }else{ @@ -13105,7 +13114,9 @@ mc.add(otherEl); indexOfKey : function(key){ if(!this.keys.indexOf){ for(var i = 0, len = this.keys.length; i < len; i++){ - if(this.keys[i] == key) return i; + if(this.keys[i] == key) { + return i; + } } return -1; }else{ @@ -14804,7 +14815,9 @@ Roo.extend(Roo.state.Provider, Roo.util.Observable, { decodeValue : function(cookie){ var re = /^(a|n|d|b|s|o)\:(.*)$/; var matches = re.exec(unescape(cookie)); - if(!matches || !matches[1]) return; // non state cookie + if(!matches || !matches[1]) { + return; // non state cookie + } var type = matches[1]; var v = matches[2]; switch(type){ @@ -14851,7 +14864,9 @@ Roo.extend(Roo.state.Provider, Roo.util.Observable, { var flat = ""; for(var i = 0, len = v.length; i < len; i++){ flat += this.encodeValue(v[i]); - if(i != len-1) flat += "^"; + if(i != len-1) { + flat += "^"; + } } enc = "a:" + flat; }else if(typeof v == "object"){ diff --git a/roojs-core.js b/roojs-core.js index e21dd45ea0..eedc56b040 100644 --- a/roojs-core.js +++ b/roojs-core.js @@ -5,8 +5,8 @@ return true;}catch(e){return false;}})();if(F&&!G){try{document.execCommand("Bac if(!Q[s]){Q[s]=Roo.select(s);}Q[s].on(R[1],o[b]);}}Q=null;},id:function(el,Q){Q=Q||"roo-gen";el=Roo.getDom(el);var id=Q+(++A);return el?(el.id?el.id:(el.id=id)):id;},extend:function(){var io=function(o){for(var m in o){this[m]=o[m];}};return function(sb,sp,Q){if(typeof sp=='object'){Q=sp; sp=sb;sb=function(){sp.apply(this,arguments);};}var F=function(){},R,S=sp.prototype;F.prototype=S;R=sb.prototype=new F();R.constructor=sb;sb.superclass=S;if(S.constructor==Object.prototype.constructor){S.constructor=sp;}sb.override=function(o){Roo.override(sb,o); };R.override=io;Roo.override(sb,Q);return sb;};}(),override:function(Q,R){if(R){var p=Q.prototype;for(var S in R){p[S]=R[S];}}},namespace:function(){var a=arguments,o=null,i,j,d,rt;for(i=0;i0x10000){bs[0]=0xF0|((c&0x1C0000)>>>18);bs[1]=0x80|((c&0x3F000)>>>12);bs[2]=0x80|((c&0xFC0)>>>6);bs[3]=0x80|(c&0x3F);}else if(c>0x800){bs[0]=0xE0|((c&0xF000)>>>12);bs[1]=0x80|((c&0xFC0)>>>6);bs[2]=0x80|(c&0x3F); @@ -31,8 +31,8 @@ return A.replace(/\{(\d+)\}/g,function(m,i){return Roo.util.Format.htmlEncode(B[ // Number.js Roo.applyIf(Number.prototype,{constrain:function(A,B){return Math.min(Math.max(this,A),B);}}); // Array.js -Roo.applyIf(Array.prototype,{indexOf:function(o){for(var i=0,A=this.length;i>>0;if(typeof A!="function")throw new TypeError(); -var C=new Array(B);var D=arguments[1];for(var i=0;i>>0;if(typeof A!="function"){throw new TypeError(); +}var C=new Array(B);var D=arguments[1];for(var i=0;i28){C=Math.min(C,this.getFirstDateOfMonth().add('mo',B).getLastDateOfMonth().getDate());}d.setDate(C);d.setMonth(this.getMonth()+B); break;case Date.YEAR:d.setFullYear(this.getFullYear()+B);break;}return d;}; // Roo/lib/Dom.js @@ -191,11 +191,11 @@ var id=el.id||el.tagName;return ("Scroll "+id);};B.doMethod=function(C,D,E){var // Roo/DomHelper.js if(typeof Range!="undefined"&&typeof Range.prototype.createContextualFragment=="undefined"){Range.prototype.createContextualFragment=function(A){var B=window.document;var C=B.createElement("div");C.innerHTML=A;var D=B.createDocumentFragment(),n;while((n=C.firstChild)){D.appendChild(n); }return D;};}Roo.DomHelper=function(){var A=null;var B=/^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;var C=/^table|tbody|tr|td$/i;var D={};var E=function(o){if(typeof o=='string'){return o;}var b="";if(!o.tag){o.tag="div";}b+="<"+o.tag; -for(var M in o){if(M=="tag"||M=="children"||M=="cn"||M=="html"||typeof o[M]=="function")continue;if(M=="style"){var s=o["style"];if(typeof s=="function"){s=s.call();}if(typeof s=="string"){b+=' style="'+s+'"';}else if(typeof s=="object"){b+=' style="';for(var N in s){if(typeof s[N]!="function"){b+=N+":"+s[N]+";"; +for(var M in o){if(M=="tag"||M=="children"||M=="cn"||M=="html"||typeof o[M]=="function"){continue;}if(M=="style"){var s=o["style"];if(typeof s=="function"){s=s.call();}if(typeof s=="string"){b+=' style="'+s+'"';}else if(typeof s=="object"){b+=' style="';for(var N in s){if(typeof s[N]!="function"){b+=N+":"+s[N]+";"; }}b+='"';}}else{if(M=="cls"){b+=' class="'+o["cls"]+'"';}else if(M=="htmlFor"){b+=' for="'+o["htmlFor"]+'"';}else{b+=" "+M+'="'+o[M]+'"';}}}if(B.test(o.tag)){b+="/>";}else{b+=">";var cn=o.children||o.cn;if(cn){if((cn instanceof Array)||(Roo.isSafari&&typeof(cn.join)=="function")){for(var i=0,O=cn.length; i";}return b;};var F=function(o,M){var ns=false;if(o.ns&&o.ns!='html'){if(o.xmlns&&typeof(D[o.ns])=='undefined'){D[o.ns]=o.xmlns;ns=o.xmlns;}if(typeof(D[o.ns])=='undefined'){console.log("Trying to create namespace element "+o.ns+", however no xmlns was sent to builder previously"); }ns=D[o.ns];}if(typeof(o)=='string'){return M.appendChild(document.createTextNode(o));}o.tag=o.tag||div;if(o.ns&&Roo.isIE){ns=false;o.tag=o.ns+':'+o.tag;}var el=ns?document.createElementNS(ns,o.tag||'div'):document.createElement(o.tag||'div');var N=el.setAttribute?true:false; -for(var O in o){if(O=="tag"||O=="ns"||O=="xmlns"||O=="children"||O=="cn"||O=="html"||O=="style"||typeof o[O]=="function")continue;if(O=="cls"&&Roo.isIE){el.className=o["cls"];}else{if(N){el.setAttribute(O=="cls"?'class':O,o[O]);}else{el[O]=o[O];}}}Roo.DomHelper.applyStyles(el,o.style); +for(var O in o){if(O=="tag"||O=="ns"||O=="xmlns"||O=="children"||O=="cn"||O=="html"||O=="style"||typeof o[O]=="function"){continue;}if(O=="cls"&&Roo.isIE){el.className=o["cls"];}else{if(N){el.setAttribute(O=="cls"?'class':O,o[O]);}else{el[O]=o[O];}}}Roo.DomHelper.applyStyles(el,o.style); var cn=o.children||o.cn;if(cn){if((cn instanceof Array)||(Roo.isSafari&&typeof(cn.join)=="function")){for(var i=0,P=cn.length;i',I=''+te,J=H+'',K=''+I;var L=function(M,N,el,O){if(!A){A=document.createElement('div');}var P;var Q=null;if(M=='td'){if(N=='afterbegin'||N=='beforeend'){return; }if(N=='beforebegin'){Q=el;el=el.parentNode;}else{Q=el.nextSibling;el=el.parentNode;}P=G(4,J,O,K);}else if(M=='tr'){if(N=='beforebegin'){Q=el;el=el.parentNode;P=G(3,H,O,I);}else if(N=='afterend'){Q=el.nextSibling;el=el.parentNode;P=G(3,H,O,I);}else{if(N=='afterbegin'){Q=el.firstChild; @@ -302,7 +302,7 @@ return Roo.isSafari?(A[k]||k):k;},getPageX:function(){return this.xy[0];},getPag // Roo/Element.js (function(){var D=Roo.lib.Dom;var E=Roo.lib.Event;var A=Roo.lib.Anim;var B={};var C=/(-[a-z])/gi;var F=function(m,a){return a.charAt(1).toUpperCase();};var G=document.defaultView;Roo.Element=function(J,K){var L=typeof J=="string"?document.getElementById(J):J; if(!L){return null;}var id=L.id;if(K!==true&&id&&Roo.Element.cache[id]){return Roo.Element.cache[id];}this.dom=L;this.id=id||Roo.id(L);};var El=Roo.Element;El.prototype={originalDisplay:"",visibilityMode:1,defaultUnit:"px",setVisibilityMode:function(J){this.visibilityMode=J; -return this;},enableDisplayMode:function(J){this.setVisibilityMode(El.DISPLAY);if(typeof J!="undefined")this.originalDisplay=J;return this;},findParent:function(J,K,L){var p=this.dom,b=document.body,M=0,dq=Roo.DomQuery,N;K=K||50;if(typeof K!="number"){N=Roo.getDom(K); +return this;},enableDisplayMode:function(J){this.setVisibilityMode(El.DISPLAY);if(typeof J!="undefined"){this.originalDisplay=J;}return this;},findParent:function(J,K,L){var p=this.dom,b=document.body,M=0,dq=Roo.DomQuery,N;K=K||50;if(typeof K!="number"){N=Roo.getDom(K); K=10;}while(p&&p.nodeType==1&&Mcb){c.scrollTop=b-ch; }if(K!==false){if(lcr){c.scrollLeft=r-c.clientWidth;}}return this;},scrollChildIntoView:function(J,K){Roo.fly(J,'_scrollChildIntoView').scrollIntoView(this,K);},autoHeight:function(J,K,L,M){var N=this.getHeight();this.clip(); -this.setHeight(1);setTimeout(function(){var O=parseInt(this.dom.scrollHeight,10);if(!J){this.setHeight(O);this.unclip();if(typeof L=="function"){L();}}else{this.setHeight(N);this.setHeight(O,J,K,function(){this.unclip();if(typeof L=="function")L();}.createDelegate(this),M); +this.setHeight(1);setTimeout(function(){var O=parseInt(this.dom.scrollHeight,10);if(!J){this.setHeight(O);this.unclip();if(typeof L=="function"){L();}}else{this.setHeight(N);this.setHeight(O,J,K,function(){this.unclip();if(typeof L=="function"){L();}}.createDelegate(this),M); }}.createDelegate(this),0);return this;},contains:function(el){if(!el){return false;}return D.isAncestor(this.dom,el.dom?el.dom:el);},isVisible:function(J){var K=!(this.getStyle("visibility")=="hidden"||this.getStyle("display")=="none");if(J!==true||!K){return K; }var p=this.dom.parentNode;while(p&&p.tagName.toLowerCase()!="body"){if(!Roo.fly(p,'_isVisible').isVisible()){return false;}p=p.parentNode;}return true;},select:function(J,K){return El.select(J,K,this.dom);},query:function(J,K){return Roo.DomQuery.select(J,this.dom); },child:function(J,K){var n=Roo.DomQuery.selectNode(J,this.dom);return K?n:Roo.get(n);},down:function(J,K){var n=Roo.DomQuery.selectNode(" > "+J,this.dom);return K?n:Roo.get(n);},initDD:function(J,K,L){var dd=new Roo.dd.DD(Roo.id(this.dom),J,K);return Roo.apply(dd,L); @@ -393,8 +393,8 @@ if(J===true){this.fitToParentDelegate=this.fitToParent.createDelegate(this,[true this.dom.insertBefore(el,this.dom.firstChild);return !J?Roo.get(el):el;}},insertSibling:function(el,J,K){J=J?J.toLowerCase():'before';el=el||{};var rt,L=J=='before'?this.dom:this.dom.nextSibling;if(typeof el=='object'&&!el.nodeType){if(J=='after'&&!this.dom.nextSibling){rt=Roo.DomHelper.append(this.dom.parentNode,el,!K); }else{rt=Roo.DomHelper[J=='after'?'insertAfter':'insertBefore'](this.dom,el,!K);}}else{rt=this.dom.parentNode.insertBefore(Roo.getDom(el),J=='before'?this.dom:this.dom.nextSibling);if(!K){rt=Roo.get(rt);}}return rt;},wrap:function(J,K){if(!J){J={tag:"div"} ;}var L=Roo.DomHelper.insertBefore(this.dom,J,!K);L.dom?L.dom.appendChild(this.dom):L.appendChild(this.dom);return L;},replace:function(el){el=Roo.get(el);this.insertBefore(el);el.remove();return this;},insertHtml:function(J,K,L){var el=Roo.DomHelper.insertHtml(J,this.dom,K); -return L?Roo.get(el):el;},set:function(o,J){var el=this.dom;J=typeof J=='undefined'?(el.setAttribute?true:false):J;for(var K in o){if(K=="style"||typeof o[K]=="function")continue;if(K=="cls"){el.className=o["cls"];}else{if(J)el.setAttribute(K,o[K]);elseel[K]=o[K]; -}}if(o.style){Roo.DomHelper.applyStyles(el,o.style);}return this;},addKeyListener:function(J,fn,K){var L;if(typeof J!="object"||J instanceof Array){L={key:J,fn:fn,scope:K};}else{L={key:J.key,shift:J.shift,ctrl:J.ctrl,alt:J.alt,fn:fn,scope:K};}return new Roo.KeyMap(this,L); +return L?Roo.get(el):el;},set:function(o,J){var el=this.dom;J=typeof J=='undefined'?(el.setAttribute?true:false):J;for(var K in o){if(K=="style"||typeof o[K]=="function"){continue;}if(K=="cls"){el.className=o["cls"];}else{if(J){el.setAttribute(K,o[K]);}else{el[K]=o[K]; +}}}if(o.style){Roo.DomHelper.applyStyles(el,o.style);}return this;},addKeyListener:function(J,fn,K){var L;if(typeof J!="object"||J instanceof Array){L={key:J,fn:fn,scope:K};}else{L={key:J.key,shift:J.shift,ctrl:J.ctrl,alt:J.alt,fn:fn,scope:K};}return new Roo.KeyMap(this,L); },addKeyMap:function(J){return new Roo.KeyMap(this,J);},isScrollable:function(){var J=this.dom;return J.scrollHeight>J.clientHeight||J.scrollWidth>J.clientWidth;},scrollTo:function(J,K,L){var M=J.toLowerCase()=="left"?"scrollLeft":"scrollTop";if(!L||!A){this.dom[M]=K; }else{var to=M=="scrollLeft"?[K,this.dom.scrollTop]:[this.dom.scrollLeft,K];this.anim({scroll:{"to":to}},this.preanim(arguments,2),'scroll');}return this;},scroll:function(J,K,L){if(!this.isScrollable()){return;}var el=this.dom;var l=el.scrollLeft,t=el.scrollTop; var w=el.scrollWidth,h=el.scrollHeight;var cw=el.clientWidth,ch=el.clientHeight;J=J.toLowerCase();var M=false;var a=this.preanim(arguments,2);switch(J){case "l":case "left":if(w-l>cw){var v=Math.min(l+K,w-cw);this.scrollTo("left",v,a);M=true;}break;case "r":case "right":if(l>0){var v=Math.max(l-K,0); @@ -452,7 +452,7 @@ return {pos:this.getPositioning(),width:st.width,height:st.height};},afterFx:fun if(!o.concurrent){this.fxQueue.shift();this.nextFx();}},getFxEl:function(){return Roo.get(this.dom);},fxanim:function(A,B,C,D,E,cb){C=C||'run';B=B||{};var F=Roo.lib.Anim[C](this.dom,A,(B.duration||D)||.35,(B.easing||E)||'easeOut',function(){Roo.callback(cb,this); },this);B.anim=F;return F;}};Roo.Fx.resize=Roo.Fx.scale;Roo.apply(Roo.Element.prototype,Roo.Fx); // Roo/CompositeElement.js -Roo.CompositeElement=function(A){this.elements=[];this.addElements(A);};Roo.CompositeElement.prototype={isComposite:true,addElements:function(A){if(!A)return this;if(typeof A=="string"){A=Roo.Element.selectorFunction(A);}var B=this.elements;var C=B.length-1; +Roo.CompositeElement=function(A){this.elements=[];this.addElements(A);};Roo.CompositeElement.prototype={isComposite:true,addElements:function(A){if(!A){return this;}if(typeof A=="string"){A=Roo.Element.selectorFunction(A);}var B=this.elements;var C=B.length-1; for(var i=0,D=A.length;i=this.length){return this.add(B,o);}this.length++;this.items.splice(A,0,o);if(typeof B!="undefined"&&B!=null){this.map[B]=o;}this.keys.splice(A,0,B);this.fireEvent("add",A,o,B); return o;},remove:function(o){return this.removeAt(this.indexOf(o));},removeAt:function(A){if(A=0){this.length--;var o=this.items[A];this.items.splice(A,1);var B=this.keys[A];if(typeof B!="undefined"){delete this.map[B];}this.keys.splice(A,1); -this.fireEvent("remove",o,B);}},removeKey:function(A){return this.removeAt(this.indexOfKey(A));},getCount:function(){return this.length;},indexOf:function(o){if(!this.items.indexOf){for(var i=0,A=this.items.length;i