From: Alan Knowles Date: Thu, 17 Jun 2021 04:49:50 +0000 (+0800) Subject: Fix #6833 - print layer map X-Git-Url: http://git.roojs.org/?p=roojs1;a=commitdiff_plain;h=242e8cb7d4eb31741bfb8d282303ac36f54dd00e Fix #6833 - print layer map --- diff --git a/Roo/Element.js b/Roo/Element.js index 5d3361fe66..36d6dce660 100644 --- a/Roo/Element.js +++ b/Roo/Element.js @@ -614,7 +614,11 @@ if(opt.anim.isAnimated()){ } }else{ if(className && !this.hasClass(className)){ - this.dom.className = this.dom.className + " " + className; + if (this.dom instanceof SVGElement) { + this.dom.className.baseVal =this.dom.className.baseVal + " " + className; + } else { + this.dom.className = this.dom.className + " " + className; + } } } return this; @@ -643,7 +647,9 @@ if(opt.anim.isAnimated()){ * @return {Roo.Element} this */ removeClass : function(className){ - if(!className || !this.dom.className){ + + var cn = this.dom instanceof SVGElement ? this.dom.className.baseVal : this.dom.className; + if(!className || !cn){ return this; } if(className instanceof Array){ @@ -657,8 +663,11 @@ if(opt.anim.isAnimated()){ re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g"); this.classReCache[className] = re; } - this.dom.className = - this.dom.className.replace(re, " "); + if (this.dom instanceof SVGElement) { + this.dom.className.baseVal = cn.replace(re, " "); + } else { + this.dom.className = cn.replace(re, " "); + } } } return this; @@ -687,6 +696,9 @@ if(opt.anim.isAnimated()){ * @return {Boolean} True if the class exists, else false */ hasClass : function(className){ + if (this.dom instanceof SVGElement) { + return className && (' '+this.dom.className.baseVal +' ').indexOf(' '+className+' ') != -1; + } return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1; }, diff --git a/Roo/bootstrap/ComboBox.js b/Roo/bootstrap/ComboBox.js index c482ac50d3..21c9aef32e 100644 --- a/Roo/bootstrap/ComboBox.js +++ b/Roo/bootstrap/ComboBox.js @@ -1129,7 +1129,7 @@ Roo.extend(Roo.bootstrap.ComboBox, Roo.bootstrap.TriggerField, { this.inputEl().on('mousedown', this.onTriggerClick, this); this.inputEl().addClass('x-combo-noedit'); }else{ - this.inputEl().dom.setAttribute('readOnly', false); + this.inputEl().dom.removeAttribute('readOnly'); this.inputEl().un('mousedown', this.onTriggerClick, this); this.inputEl().removeClass('x-combo-noedit'); } diff --git a/Roo/bootstrap/Menu.js b/Roo/bootstrap/Menu.js index b0f64f4ae9..e5fa5cf2d7 100644 --- a/Roo/bootstrap/Menu.js +++ b/Roo/bootstrap/Menu.js @@ -154,19 +154,22 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { // Roo.log("ADD event"); // Roo.log(this.triggerEl.dom); + if (this.triggerEl) { + + this.triggerEl.on('click', this.onTriggerClick, this); + + this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); + + if (!this.hideTrigger) { + if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { + // dropdown toggle on the 'a' in BS4? + this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); + } else { + this.triggerEl.addClass('dropdown-toggle'); + } + } + } - this.triggerEl.on('click', this.onTriggerClick, this); - - this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); - - if (!this.hideTrigger) { - if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { - // dropdown toggle on the 'a' in BS4? - this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); - } else { - this.triggerEl.addClass('dropdown-toggle'); - } - } if (Roo.isTouch) { this.el.on('touchstart' , this.onTouch, this); } @@ -328,7 +331,10 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { //this.el.show(); this.hideMenuItems(); this.hidden = false; - this.triggerEl.addClass('open'); + if (this.triggerEl) { + this.triggerEl.addClass('open'); + } + this.el.addClass('show'); @@ -367,9 +373,9 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { hide : function(deep) { if (false === this.fireEvent("beforehide", this)) { - Roo.log("hide canceled"); - return; - } + Roo.log("hide canceled"); + return; + } this.hideMenuItems(); if(this.el && this.isVisible()){ @@ -377,8 +383,11 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { this.activeItem.deactivate(); this.activeItem = null; } - this.triggerEl.removeClass('open');; - this.el.removeClass('show'); + if (this.triggerEl) { + this.triggerEl.removeClass('open'); + } + + this.el.removeClass('show'); this.hidden = true; this.fireEvent("hide", this); } @@ -423,7 +432,7 @@ Roo.extend(Roo.bootstrap.Menu, Roo.bootstrap.Component, { this.hide(); } else { Roo.log('show'); - + this.show(this.triggerEl, this.align, false); } diff --git a/docs/src/Roo_Element.js.html b/docs/src/Roo_Element.js.html index 787257e1ac..af724c2ed7 100644 --- a/docs/src/Roo_Element.js.html +++ b/docs/src/Roo_Element.js.html @@ -614,7 +614,11 @@ if(opt.anim.isAnimated()){ } }else{ if(className && !this.hasClass(className)){ - this.dom.className = this.dom.className + " " + className; + if (this.dom instanceof SVGElement) { + this.dom.className.baseVal =this.dom.className.baseVal + " " + className; + } else { + this.dom.className = this.dom.className + " " + className; + } } } return this; @@ -643,7 +647,9 @@ if(opt.anim.isAnimated()){ * @return {Roo.Element} this */ removeClass : function(className){ - if(!className || !this.dom.className){ + + var cn = this.dom instanceof SVGElement ? this.dom.className.baseVal : this.dom.className; + if(!className || !cn){ return this; } if(className instanceof Array){ @@ -657,8 +663,11 @@ if(opt.anim.isAnimated()){ re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g"); this.classReCache[className] = re; } - this.dom.className = - this.dom.className.replace(re, " "); + if (this.dom instanceof SVGElement) { + this.dom.className.baseVal = cn.replace(re, " "); + } else { + this.dom.className = cn.replace(re, " "); + } } } return this; @@ -687,6 +696,9 @@ if(opt.anim.isAnimated()){ * @return {Boolean} True if the class exists, else false */ hasClass : function(className){ + if (this.dom instanceof SVGElement) { + return className && (' '+this.dom.className.baseVal +' ').indexOf(' '+className+' ') != -1; + } return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1; }, diff --git a/docs/src/Roo_bootstrap_ComboBox.js.html b/docs/src/Roo_bootstrap_ComboBox.js.html index 223da32d9e..99553928f4 100644 --- a/docs/src/Roo_bootstrap_ComboBox.js.html +++ b/docs/src/Roo_bootstrap_ComboBox.js.html @@ -1129,7 +1129,7 @@ this.inputEl().on('mousedown', this.onTriggerClick, this); this.inputEl().addClass('x-combo-noedit'); }else{ - this.inputEl().dom.setAttribute('readOnly', false); + this.inputEl().dom.removeAttribute('readOnly'); this.inputEl().un('mousedown', this.onTriggerClick, this); this.inputEl().removeClass('x-combo-noedit'); } diff --git a/docs/src/Roo_bootstrap_Menu.js.html b/docs/src/Roo_bootstrap_Menu.js.html index 225884dca1..bbcbc95d9e 100644 --- a/docs/src/Roo_bootstrap_Menu.js.html +++ b/docs/src/Roo_bootstrap_Menu.js.html @@ -154,19 +154,22 @@ // Roo.log("ADD event"); // Roo.log(this.triggerEl.dom); + if (this.triggerEl) { - this.triggerEl.on('click', this.onTriggerClick, this); + this.triggerEl.on('click', this.onTriggerClick, this); - this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); + this.triggerEl.on(Roo.isTouch ? 'touchstart' : 'mouseup', this.onTriggerPress, this); + + if (!this.hideTrigger) { + if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { + // dropdown toggle on the 'a' in BS4? + this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); + } else { + this.triggerEl.addClass('dropdown-toggle'); + } + } + } - if (!this.hideTrigger) { - if (this.triggerEl.hasClass('nav-item') && this.triggerEl.select('.nav-link',true).length) { - // dropdown toggle on the 'a' in BS4? - this.triggerEl.select('.nav-link',true).first().addClass('dropdown-toggle'); - } else { - this.triggerEl.addClass('dropdown-toggle'); - } - } if (Roo.isTouch) { this.el.on('touchstart' , this.onTouch, this); } @@ -328,7 +331,10 @@ //this.el.show(); this.hideMenuItems(); this.hidden = false; - this.triggerEl.addClass('open'); + if (this.triggerEl) { + this.triggerEl.addClass('open'); + } + this.el.addClass('show'); @@ -367,9 +373,9 @@ hide : function(deep) { if (false === this.fireEvent("beforehide", this)) { - Roo.log("hide canceled"); - return; - } + Roo.log("hide canceled"); + return; + } this.hideMenuItems(); if(this.el && this.isVisible()){ @@ -377,8 +383,11 @@ this.activeItem.deactivate(); this.activeItem = null; } - this.triggerEl.removeClass('open');; - this.el.removeClass('show'); + if (this.triggerEl) { + this.triggerEl.removeClass('open'); + } + + this.el.removeClass('show'); this.hidden = true; this.fireEvent("hide", this); } diff --git a/roojs-all.js b/roojs-all.js index 2f622db7e3..c47b57b2b4 100644 --- a/roojs-all.js +++ b/roojs-all.js @@ -325,65 +325,66 @@ this.setHeight(1);setTimeout(function(){var O=parseInt(this.dom.scrollHeight,10) }else{this.fixDisplay();this.dom.style.visibility=J?"visible":"hidden";}}else{var L=this.dom;var M=this.visibilityMode;if(J){this.setOpacity(.01);this.setVisible(true);}this.anim({opacity:{to:(J?1:0)}},this.preanim(arguments,1),null,.35,'easeIn',function(){if(!J){if(M==El.DISPLAY){L.style.display="none"; }else{L.style.visibility="hidden";}Roo.get(L).setOpacity(1);}});}return this;},isDisplayed:function(){return this.getStyle("display")!="none";},toggle:function(J){this.setVisible(!this.isVisible(),this.preanim(arguments,0));return this;},setDisplayed:function(J){if(typeof J=="boolean"){J=J?this.originalDisplay:"none"; }this.setStyle("display",J);return this;},focus:function(){try{this.dom.focus();}catch(e){}return this;},blur:function(){try{this.dom.blur();}catch(e){}return this;},addClass:function(J){if(J instanceof Array){for(var i=0,K=J.length;idw+Q){x=O?r.left-w:dw+Q-w;}if(xdh+R){y=N?r.top-h:dh+R-h;}if(yvr){x=vr-w;N=true;}if((y+h)>vb){y=vb-h;N=true;}if(x';E.onAvailable(id,function(){var hd=document.getElementsByTagName("head")[0];var re=/(?:]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;var N=/\ssrc=([\'\"])(.*?)\1/i;var O=/\stype=([\'\"])(.*?)\1/i; -var P;while(P=re.exec(J)){var Q=P[1];var R=Q?Q.match(N):false;if(R&&R[2]){var s=document.createElement("script");s.src=R[2];var S=Q.match(O);if(S&&S[2]){s.type=S[2];}hd.appendChild(s);}else if(P[2]&&P[2].length>0){if(window.execScript){window.execScript(P[2]); -}else{window.eval(P[2]);}}}var el=document.getElementById(id);if(el){el.parentNode.removeChild(el);}if(typeof L=="function"){L();}});M.innerHTML=J.replace(/(?:)((\n|\r|.)*?)(?:<\/script>)/ig,"");return this;},load:function(){var um=this.getUpdateManager(); -um.update.apply(um,arguments);return this;},getUpdateManager:function(){if(!this.updateManager){this.updateManager=new Roo.UpdateManager(this);}return this.updateManager;},unselectable:function(){this.dom.unselectable="on";this.swallowEvent("selectstart",true); -this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");this.addClass("x-unselectable");return this;},getCenterXY:function(){return this.getAlignToXY(document,'c-c');},center:function(J){this.alignTo(J||document,'c-c');return this;},isBorderBox:function(){return I[this.dom.tagName.toLowerCase()]||Roo.isBorderBox; -},getBox:function(J,K){var xy;if(!K){xy=this.getXY();}else{var L=parseInt(this.getStyle("left"),10)||0;var M=parseInt(this.getStyle("top"),10)||0;xy=[L,M];}var el=this.dom,w=el.offsetWidth,h=el.offsetHeight,bx;if(!J){bx={x:xy[0],y:xy[1],0:xy[0],1:xy[1],width:w,height:h} -;}else{var l=this.getBorderWidth("l")+this.getPadding("l");var r=this.getBorderWidth("r")+this.getPadding("r");var t=this.getBorderWidth("t")+this.getPadding("t");var b=this.getBorderWidth("b")+this.getPadding("b");bx={x:xy[0]+l,y:xy[1]+t,0:xy[0]+l,1:xy[1]+t,width:w-(l+r),height:h-(t+b)} -;}bx.right=bx.x+bx.width;bx.bottom=bx.y+bx.height;return bx;},getFrameWidth:function(J,K){return K&&Roo.isBorderBox?0:(this.getPadding(J)+this.getBorderWidth(J));},setBox:function(J,K,L){var w=J.width,h=J.height;if((K&&!this.autoBoxAdjust)&&!this.isBorderBox()){w-=(this.getBorderWidth("lr")+this.getPadding("lr")); -h-=(this.getBorderWidth("tb")+this.getPadding("tb"));}this.setBounds(J.x,J.y,w,h,this.preanim(arguments,2));return this;},repaint:function(){var J=this.dom;this.addClass("x-repaint");setTimeout(function(){Roo.get(J).removeClass("x-repaint");},1);return this; -},getMargins:function(J){if(!J){return {top:parseInt(this.getStyle("margin-top"),10)||0,left:parseInt(this.getStyle("margin-left"),10)||0,bottom:parseInt(this.getStyle("margin-bottom"),10)||0,right:parseInt(this.getStyle("margin-right"),10)||0};}else{return this.addStyles(J,El.margins); -}},addStyles:function(J,K){var L=0,v,w;for(var i=0,M=J.length;idw+Q){x=O?r.left-w:dw+Q-w;}if(xdh+R){y=N?r.top-h:dh+R-h;}if(yvr){x=vr-w;N=true;}if((y+h)>vb){y=vb-h; +N=true;}if(x';E.onAvailable(id,function(){var hd=document.getElementsByTagName("head")[0]; +var re=/(?:]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;var N=/\ssrc=([\'\"])(.*?)\1/i;var O=/\stype=([\'\"])(.*?)\1/i;var P;while(P=re.exec(J)){var Q=P[1];var R=Q?Q.match(N):false;if(R&&R[2]){var s=document.createElement("script");s.src=R[2];var S=Q.match(O); +if(S&&S[2]){s.type=S[2];}hd.appendChild(s);}else if(P[2]&&P[2].length>0){if(window.execScript){window.execScript(P[2]);}else{window.eval(P[2]);}}}var el=document.getElementById(id);if(el){el.parentNode.removeChild(el);}if(typeof L=="function"){L();}});M.innerHTML=J.replace(/(?:)((\n|\r|.)*?)(?:<\/script>)/ig,""); +return this;},load:function(){var um=this.getUpdateManager();um.update.apply(um,arguments);return this;},getUpdateManager:function(){if(!this.updateManager){this.updateManager=new Roo.UpdateManager(this);}return this.updateManager;},unselectable:function(){this.dom.unselectable="on"; +this.swallowEvent("selectstart",true);this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");this.addClass("x-unselectable");return this;},getCenterXY:function(){return this.getAlignToXY(document,'c-c');},center:function(J){this.alignTo(J||document,'c-c'); +return this;},isBorderBox:function(){return I[this.dom.tagName.toLowerCase()]||Roo.isBorderBox;},getBox:function(J,K){var xy;if(!K){xy=this.getXY();}else{var L=parseInt(this.getStyle("left"),10)||0;var M=parseInt(this.getStyle("top"),10)||0;xy=[L,M];}var el=this.dom,w=el.offsetWidth,h=el.offsetHeight,bx; +if(!J){bx={x:xy[0],y:xy[1],0:xy[0],1:xy[1],width:w,height:h};}else{var l=this.getBorderWidth("l")+this.getPadding("l");var r=this.getBorderWidth("r")+this.getPadding("r");var t=this.getBorderWidth("t")+this.getPadding("t");var b=this.getBorderWidth("b")+this.getPadding("b"); +bx={x:xy[0]+l,y:xy[1]+t,0:xy[0]+l,1:xy[1]+t,width:w-(l+r),height:h-(t+b)};}bx.right=bx.x+bx.width;bx.bottom=bx.y+bx.height;return bx;},getFrameWidth:function(J,K){return K&&Roo.isBorderBox?0:(this.getPadding(J)+this.getBorderWidth(J));},setBox:function(J,K,L){var w=J.width,h=J.height; +if((K&&!this.autoBoxAdjust)&&!this.isBorderBox()){w-=(this.getBorderWidth("lr")+this.getPadding("lr"));h-=(this.getBorderWidth("tb")+this.getPadding("tb"));}this.setBounds(J.x,J.y,w,h,this.preanim(arguments,2));return this;},repaint:function(){var J=this.dom; +this.addClass("x-repaint");setTimeout(function(){Roo.get(J).removeClass("x-repaint");},1);return this;},getMargins:function(J){if(!J){return {top:parseInt(this.getStyle("margin-top"),10)||0,left:parseInt(this.getStyle("margin-left"),10)||0,bottom:parseInt(this.getStyle("margin-bottom"),10)||0,right:parseInt(this.getStyle("margin-right"),10)||0} +;}else{return this.addStyles(J,El.margins);}},addStyles:function(J,K){var L=0,v,w;for(var i=0,M=J.length;i=Roo.lib.Dom.getViewWidth()){xy=this.el.getAlignToXY(el,this.align.replace('/l/g','r'))}if(xy[0]<0){xy=this.el.getAlignToXY(el,this.align.replace('/r/g','l'))}if(this.el.getHeight()+xy[1]>=Roo.lib.Dom.getViewHeight()||xy[1]<0){var a=this.align.replace('?','').split('-'); -xy=this.el.getAlignToXY(el,a[1]+'-'+a[0]+'?')}this.showAt(xy,B,false);},showAt:function(xy,A,_e){this.parentMenu=A;if(!this.el){this.render();}if(_e!==false){this.fireEvent("beforeshow",this);}this.hideMenuItems();this.hidden=false;this.triggerEl.addClass('open'); -this.el.addClass('show');if(this.el.getStyle('top')!='auto'&&this.el.getStyle('top').slice(-1)!="%"){this.el.setXY(xy);}this.focus();this.fireEvent("show",this);},focus:function(){return;if(!this.hidden){this.doFocus.defer(50,this);}},doFocus:function(){if(!this.hidden){this.focusEl.focus(); -}},hide:function(A){if(false===this.fireEvent("beforehide",this)){Roo.log("hide canceled");return;}this.hideMenuItems();if(this.el&&this.isVisible()){if(this.activeItem){this.activeItem.deactivate();this.activeItem=null;}this.triggerEl.removeClass('open'); -;this.el.removeClass('show');this.hidden=true;this.fireEvent("hide",this);}if(A===true&&this.parentMenu){this.parentMenu.hide(true);}},onTriggerClick:function(e){Roo.log('trigger click');var A=e.getTarget();Roo.log(A.nodeName.toLowerCase());if(A.nodeName.toLowerCase()==='i'){e.preventDefault(); +xy=this.el.getAlignToXY(el,a[1]+'-'+a[0]+'?')}this.showAt(xy,B,false);},showAt:function(xy,A,_e){this.parentMenu=A;if(!this.el){this.render();}if(_e!==false){this.fireEvent("beforeshow",this);}this.hideMenuItems();this.hidden=false;if(this.triggerEl){this.triggerEl.addClass('open'); +}this.el.addClass('show');if(this.el.getStyle('top')!='auto'&&this.el.getStyle('top').slice(-1)!="%"){this.el.setXY(xy);}this.focus();this.fireEvent("show",this);},focus:function(){return;if(!this.hidden){this.doFocus.defer(50,this);}},doFocus:function(){if(!this.hidden){this.focusEl.focus(); +}},hide:function(A){if(false===this.fireEvent("beforehide",this)){Roo.log("hide canceled");return;}this.hideMenuItems();if(this.el&&this.isVisible()){if(this.activeItem){this.activeItem.deactivate();this.activeItem=null;}if(this.triggerEl){this.triggerEl.removeClass('open'); +}this.el.removeClass('show');this.hidden=true;this.fireEvent("hide",this);}if(A===true&&this.parentMenu){this.parentMenu.hide(true);}},onTriggerClick:function(e){Roo.log('trigger click');var A=e.getTarget();Roo.log(A.nodeName.toLowerCase());if(A.nodeName.toLowerCase()==='i'){e.preventDefault(); }},onTriggerPress:function(e){Roo.log('trigger press');var A=Roo.get(e.getTarget());if(A.findParent('.dropdown-menu')||A.findParent('.treeview-menu')){Roo.log('is treeview or dropdown?');return;}if(e.getTarget().nodeName.toLowerCase()!=='i'&&this.isLink){return; }if(this.isVisible()){Roo.log('hide');this.hide();}else{Roo.log('show');this.show(this.triggerEl,this.align,false);}if(this.stopEvent||e.getTarget().nodeName.toLowerCase()==='i'){e.stopEvent();}},hideMenuItems:function(){Roo.log("hide Menu Items");if(!this.el){return; }this.el.select('.open',true).each(function(aa){aa.removeClass('open');});},addxtypeChild:function(A,B){var C=Roo.bootstrap.Menu.superclass.addxtypeChild.call(this,A,B);this.menuitems.add(C);return C;},getEl:function(){Roo.log(this.el);return this.el;},clear:function(){this.getEl().dom.innerHTML=''; @@ -663,9 +663,9 @@ this.store.on('loadexception',this.onLoadException,this);if(this.editable){this. }this.indicator=this.indicatorEl();if(this.indicator){this.indicator.setVisibilityMode(Roo.Element.DISPLAY);this.indicator.hide();}},onDestroy:function(){if(this.view){this.view.setStore(null);this.view.el.removeAllListeners();this.view.el.remove();this.view.purgeListeners(); }if(this.list){this.list.dom.innerHTML='';}if(this.store){this.store.un('beforeload',this.onBeforeLoad,this);this.store.un('load',this.onLoad,this);this.store.un('loadexception',this.onLoadException,this);}Roo.bootstrap.ComboBox.superclass.onDestroy.call(this); },fireKey:function(e){if(e.isNavKeyPress()&&!this.list.isVisible()){this.fireEvent("specialkey",this,e);}},onResize:function(w,h){},setEditable:function(A){if(A==this.editable){return;}this.editable=A;if(!A){this.inputEl().dom.setAttribute('readOnly',true); -this.inputEl().on('mousedown',this.onTriggerClick,this);this.inputEl().addClass('x-combo-noedit');}else{this.inputEl().dom.setAttribute('readOnly',false);this.inputEl().un('mousedown',this.onTriggerClick,this);this.inputEl().removeClass('x-combo-noedit'); -}},onBeforeLoad:function(A,B){if(!this.hasFocus){return;}if(!B.add){this.list.dom.innerHTML='
  • '+(this.loadingText||'loading')+'
  • ';}this.restrictHeight();this.selectedIndex=-1;},onLoad:function(){this.hasQuery=false;if(!this.hasFocus){return; -}if(typeof(this.loading)!=='undefined'&&this.loading!==null){this.loading.hide();}if(this.store.getCount()>0){this.expand();this.restrictHeight();if(this.lastQuery==this.allQuery){if(this.editable&&!this.tickable){this.inputEl().dom.select();}if(!this.selectByValue(this.value,true)&&this.autoFocus&&(!this.store.lastOptions||typeof(this.store.lastOptions.add)=='undefined'||this.store.lastOptions.add!=true)){this.select(0,true); +this.inputEl().on('mousedown',this.onTriggerClick,this);this.inputEl().addClass('x-combo-noedit');}else{this.inputEl().dom.removeAttribute('readOnly');this.inputEl().un('mousedown',this.onTriggerClick,this);this.inputEl().removeClass('x-combo-noedit');}},onBeforeLoad:function(A,B){if(!this.hasFocus){return; +}if(!B.add){this.list.dom.innerHTML='
  • '+(this.loadingText||'loading')+'
  • ';}this.restrictHeight();this.selectedIndex=-1;},onLoad:function(){this.hasQuery=false;if(!this.hasFocus){return;}if(typeof(this.loading)!=='undefined'&&this.loading!==null){this.loading.hide(); +}if(this.store.getCount()>0){this.expand();this.restrictHeight();if(this.lastQuery==this.allQuery){if(this.editable&&!this.tickable){this.inputEl().dom.select();}if(!this.selectByValue(this.value,true)&&this.autoFocus&&(!this.store.lastOptions||typeof(this.store.lastOptions.add)=='undefined'||this.store.lastOptions.add!=true)){this.select(0,true); }}else{if(this.autoFocus){this.selectNext();}if(this.typeAhead&&this.lastKey!=Roo.EventObject.BACKSPACE&&this.lastKey!=Roo.EventObject.DELETE){this.taTask.delay(this.typeAheadDelay);}}}else{this.onEmptyResults();}},onLoadException:function(){this.hasQuery=false; if(typeof(this.loading)!=='undefined'&&this.loading!==null){this.loading.hide();}if(this.tickable&&this.editable){return;}this.collapse();},onTypeAhead:function(){if(this.store.getCount()>0){var r=this.store.getAt(0);var A=r.data[this.displayField];var B=A.length; var C=this.getRawValue().length;if(C!=B){this.setRawValue(A);this.selectText(C,A.length);}}},onSelect:function(A,B){if(this.fireEvent('beforeselect',this,A,B)!==false){this.setFromData(B>-1?A.data:false);this.collapse();this.fireEvent('select',this,A,B);} diff --git a/roojs-core-debug.js b/roojs-core-debug.js index cb3923e536..54d7ab7777 100644 --- a/roojs-core-debug.js +++ b/roojs-core-debug.js @@ -7675,7 +7675,11 @@ if(opt.anim.isAnimated()){ } }else{ if(className && !this.hasClass(className)){ - this.dom.className = this.dom.className + " " + className; + if (this.dom instanceof SVGElement) { + this.dom.className.baseVal =this.dom.className.baseVal + " " + className; + } else { + this.dom.className = this.dom.className + " " + className; + } } } return this; @@ -7704,7 +7708,9 @@ if(opt.anim.isAnimated()){ * @return {Roo.Element} this */ removeClass : function(className){ - if(!className || !this.dom.className){ + + var cn = this.dom instanceof SVGElement ? this.dom.className.baseVal : this.dom.className; + if(!className || !cn){ return this; } if(className instanceof Array){ @@ -7718,8 +7724,11 @@ if(opt.anim.isAnimated()){ re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g"); this.classReCache[className] = re; } - this.dom.className = - this.dom.className.replace(re, " "); + if (this.dom instanceof SVGElement) { + this.dom.className.baseVal = cn.replace(re, " "); + } else { + this.dom.className = cn.replace(re, " "); + } } } return this; @@ -7748,6 +7757,9 @@ if(opt.anim.isAnimated()){ * @return {Boolean} True if the class exists, else false */ hasClass : function(className){ + if (this.dom instanceof SVGElement) { + return className && (' '+this.dom.className.baseVal +' ').indexOf(' '+className+' ') != -1; + } return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1; }, diff --git a/roojs-core.js b/roojs-core.js index 32bf87b900..1f18081009 100644 --- a/roojs-core.js +++ b/roojs-core.js @@ -325,65 +325,66 @@ this.setHeight(1);setTimeout(function(){var O=parseInt(this.dom.scrollHeight,10) }else{this.fixDisplay();this.dom.style.visibility=J?"visible":"hidden";}}else{var L=this.dom;var M=this.visibilityMode;if(J){this.setOpacity(.01);this.setVisible(true);}this.anim({opacity:{to:(J?1:0)}},this.preanim(arguments,1),null,.35,'easeIn',function(){if(!J){if(M==El.DISPLAY){L.style.display="none"; }else{L.style.visibility="hidden";}Roo.get(L).setOpacity(1);}});}return this;},isDisplayed:function(){return this.getStyle("display")!="none";},toggle:function(J){this.setVisible(!this.isVisible(),this.preanim(arguments,0));return this;},setDisplayed:function(J){if(typeof J=="boolean"){J=J?this.originalDisplay:"none"; }this.setStyle("display",J);return this;},focus:function(){try{this.dom.focus();}catch(e){}return this;},blur:function(){try{this.dom.blur();}catch(e){}return this;},addClass:function(J){if(J instanceof Array){for(var i=0,K=J.length;idw+Q){x=O?r.left-w:dw+Q-w;}if(xdh+R){y=N?r.top-h:dh+R-h;}if(yvr){x=vr-w;N=true;}if((y+h)>vb){y=vb-h;N=true;}if(x';E.onAvailable(id,function(){var hd=document.getElementsByTagName("head")[0];var re=/(?:]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;var N=/\ssrc=([\'\"])(.*?)\1/i;var O=/\stype=([\'\"])(.*?)\1/i; -var P;while(P=re.exec(J)){var Q=P[1];var R=Q?Q.match(N):false;if(R&&R[2]){var s=document.createElement("script");s.src=R[2];var S=Q.match(O);if(S&&S[2]){s.type=S[2];}hd.appendChild(s);}else if(P[2]&&P[2].length>0){if(window.execScript){window.execScript(P[2]); -}else{window.eval(P[2]);}}}var el=document.getElementById(id);if(el){el.parentNode.removeChild(el);}if(typeof L=="function"){L();}});M.innerHTML=J.replace(/(?:)((\n|\r|.)*?)(?:<\/script>)/ig,"");return this;},load:function(){var um=this.getUpdateManager(); -um.update.apply(um,arguments);return this;},getUpdateManager:function(){if(!this.updateManager){this.updateManager=new Roo.UpdateManager(this);}return this.updateManager;},unselectable:function(){this.dom.unselectable="on";this.swallowEvent("selectstart",true); -this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");this.addClass("x-unselectable");return this;},getCenterXY:function(){return this.getAlignToXY(document,'c-c');},center:function(J){this.alignTo(J||document,'c-c');return this;},isBorderBox:function(){return I[this.dom.tagName.toLowerCase()]||Roo.isBorderBox; -},getBox:function(J,K){var xy;if(!K){xy=this.getXY();}else{var L=parseInt(this.getStyle("left"),10)||0;var M=parseInt(this.getStyle("top"),10)||0;xy=[L,M];}var el=this.dom,w=el.offsetWidth,h=el.offsetHeight,bx;if(!J){bx={x:xy[0],y:xy[1],0:xy[0],1:xy[1],width:w,height:h} -;}else{var l=this.getBorderWidth("l")+this.getPadding("l");var r=this.getBorderWidth("r")+this.getPadding("r");var t=this.getBorderWidth("t")+this.getPadding("t");var b=this.getBorderWidth("b")+this.getPadding("b");bx={x:xy[0]+l,y:xy[1]+t,0:xy[0]+l,1:xy[1]+t,width:w-(l+r),height:h-(t+b)} -;}bx.right=bx.x+bx.width;bx.bottom=bx.y+bx.height;return bx;},getFrameWidth:function(J,K){return K&&Roo.isBorderBox?0:(this.getPadding(J)+this.getBorderWidth(J));},setBox:function(J,K,L){var w=J.width,h=J.height;if((K&&!this.autoBoxAdjust)&&!this.isBorderBox()){w-=(this.getBorderWidth("lr")+this.getPadding("lr")); -h-=(this.getBorderWidth("tb")+this.getPadding("tb"));}this.setBounds(J.x,J.y,w,h,this.preanim(arguments,2));return this;},repaint:function(){var J=this.dom;this.addClass("x-repaint");setTimeout(function(){Roo.get(J).removeClass("x-repaint");},1);return this; -},getMargins:function(J){if(!J){return {top:parseInt(this.getStyle("margin-top"),10)||0,left:parseInt(this.getStyle("margin-left"),10)||0,bottom:parseInt(this.getStyle("margin-bottom"),10)||0,right:parseInt(this.getStyle("margin-right"),10)||0};}else{return this.addStyles(J,El.margins); -}},addStyles:function(J,K){var L=0,v,w;for(var i=0,M=J.length;idw+Q){x=O?r.left-w:dw+Q-w;}if(xdh+R){y=N?r.top-h:dh+R-h;}if(yvr){x=vr-w;N=true;}if((y+h)>vb){y=vb-h; +N=true;}if(x';E.onAvailable(id,function(){var hd=document.getElementsByTagName("head")[0]; +var re=/(?:]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;var N=/\ssrc=([\'\"])(.*?)\1/i;var O=/\stype=([\'\"])(.*?)\1/i;var P;while(P=re.exec(J)){var Q=P[1];var R=Q?Q.match(N):false;if(R&&R[2]){var s=document.createElement("script");s.src=R[2];var S=Q.match(O); +if(S&&S[2]){s.type=S[2];}hd.appendChild(s);}else if(P[2]&&P[2].length>0){if(window.execScript){window.execScript(P[2]);}else{window.eval(P[2]);}}}var el=document.getElementById(id);if(el){el.parentNode.removeChild(el);}if(typeof L=="function"){L();}});M.innerHTML=J.replace(/(?:)((\n|\r|.)*?)(?:<\/script>)/ig,""); +return this;},load:function(){var um=this.getUpdateManager();um.update.apply(um,arguments);return this;},getUpdateManager:function(){if(!this.updateManager){this.updateManager=new Roo.UpdateManager(this);}return this.updateManager;},unselectable:function(){this.dom.unselectable="on"; +this.swallowEvent("selectstart",true);this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");this.addClass("x-unselectable");return this;},getCenterXY:function(){return this.getAlignToXY(document,'c-c');},center:function(J){this.alignTo(J||document,'c-c'); +return this;},isBorderBox:function(){return I[this.dom.tagName.toLowerCase()]||Roo.isBorderBox;},getBox:function(J,K){var xy;if(!K){xy=this.getXY();}else{var L=parseInt(this.getStyle("left"),10)||0;var M=parseInt(this.getStyle("top"),10)||0;xy=[L,M];}var el=this.dom,w=el.offsetWidth,h=el.offsetHeight,bx; +if(!J){bx={x:xy[0],y:xy[1],0:xy[0],1:xy[1],width:w,height:h};}else{var l=this.getBorderWidth("l")+this.getPadding("l");var r=this.getBorderWidth("r")+this.getPadding("r");var t=this.getBorderWidth("t")+this.getPadding("t");var b=this.getBorderWidth("b")+this.getPadding("b"); +bx={x:xy[0]+l,y:xy[1]+t,0:xy[0]+l,1:xy[1]+t,width:w-(l+r),height:h-(t+b)};}bx.right=bx.x+bx.width;bx.bottom=bx.y+bx.height;return bx;},getFrameWidth:function(J,K){return K&&Roo.isBorderBox?0:(this.getPadding(J)+this.getBorderWidth(J));},setBox:function(J,K,L){var w=J.width,h=J.height; +if((K&&!this.autoBoxAdjust)&&!this.isBorderBox()){w-=(this.getBorderWidth("lr")+this.getPadding("lr"));h-=(this.getBorderWidth("tb")+this.getPadding("tb"));}this.setBounds(J.x,J.y,w,h,this.preanim(arguments,2));return this;},repaint:function(){var J=this.dom; +this.addClass("x-repaint");setTimeout(function(){Roo.get(J).removeClass("x-repaint");},1);return this;},getMargins:function(J){if(!J){return {top:parseInt(this.getStyle("margin-top"),10)||0,left:parseInt(this.getStyle("margin-left"),10)||0,bottom:parseInt(this.getStyle("margin-bottom"),10)||0,right:parseInt(this.getStyle("margin-right"),10)||0} +;}else{return this.addStyles(J,El.margins);}},addStyles:function(J,K){var L=0,v,w;for(var i=0,M=J.length;i