From df31e9ac57a22a27de01ccc16dd7125cff23c34d Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Thu, 17 Jun 2021 12:20:03 +0800 Subject: [PATCH] support svg addclass hasclass and removeclass --- docs/src/Roo_Element.js.html | 20 +++++++++--- docs/src/Roo_bootstrap_ComboBox.js.html | 2 +- docs/src/Roo_bootstrap_Menu.js.html | 41 +++++++++++++++---------- 3 files changed, 42 insertions(+), 21 deletions(-) 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); } -- 2.39.2