El.prototype = {
/**
- * The element's default display mode (defaults to "")
+ * The element's default display mode (defaults to "")
* @type String
*/
originalDisplay : "",
- visibilityMode : 1,
+
+ // note this is overridden in BS version..
+ visibilityMode : 1,
/**
* The default unit to append to CSS values where a unit isn't provided (defaults to px).
* @type String
*/
defaultUnit : "px",
+
/**
* Sets the element's visibility mode. When setVisible() is called it
* will use this to determine whether to set the visibility or the display property.
*/
enableDisplayMode : function(display){
this.setVisibilityMode(El.DISPLAY);
- if(typeof display != "undefined") this.originalDisplay = display;
+ if(typeof display != "undefined") { this.originalDisplay = display; }
return this;
},
var p = Roo.fly(this.dom.parentNode, '_internal');
return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
},
+
+ /**
+ * Looks at the scrollable parent element
+ */
+ findScrollableParent : function()
+ {
+ var overflowRegex = /(auto|scroll)/;
+
+ if(this.getStyle('position') === 'fixed'){
+ return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body);
+ }
+
+ var excludeStaticParent = this.getStyle('position') === "absolute";
+
+ for (var parent = this; (parent = Roo.get(parent.dom.parentNode));){
+
+ if (excludeStaticParent && parent.getStyle('position') === "static") {
+ continue;
+ }
+
+ if (overflowRegex.test(parent.getStyle('overflow') + parent.getStyle('overflow-x') + parent.getStyle('overflow-y'))){
+ return parent;
+ }
+
+ if(parent.dom.nodeName.toLowerCase() == 'body'){
+ return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body);
+ }
+ }
+
+ return Roo.isAndroid ? Roo.get(document.documentElement) : Roo.get(document.body);
+ },
/**
* Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).
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);
}
}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;
* @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){
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;
* @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;
},
if (this.dom) {
Roo.EventManager.on(this.dom, eventName, fn, scope || this, options);
}
+ if (eventName == 'dblclick') {
+ this.addListener('touchstart', this.onTapHandler, this);
+ }
},
+ tapedTwice : false,
+ onTapHandler : function(event)
+ {
+ if(!this.tapedTwice) {
+ this.tapedTwice = true;
+ var s = this;
+ setTimeout( function() {
+ s.tapedTwice = false;
+ }, 300 );
+ return;
+ }
+ event.preventDefault();
+ var revent = new MouseEvent('dblclick', {
+ view: window,
+ bubbles: true,
+ cancelable: true
+ });
+
+ this.dom.dispatchEvent(revent);
+ //action on double tap goes below
+
+ },
/**
* Removes an event handler from this element
* @param {Array} offsets (optional) Offset the positioning by [x, y]
* @return {Array} [x, y]
*/
- getAlignToXY : function(el, p, o){
+ getAlignToXY : function(el, p, o)
+ {
el = Roo.get(el);
var d = this.dom;
if(!el.dom){
//otherwise swap the aligned el to the opposite border of the target.
var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1);
var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1);
- var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
+ var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t") );
var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
var doc = document;
*/
mask : function(msg, msgCls)
{
-// if(this.getStyle("position") == "static"){
-// this.setStyle("position", "relative");
-// }
+ if(this.getStyle("position") == "static" && this.dom.tagName !== 'BODY'){
+ this.setStyle("position", "relative");
+ }
if(!this._mask){
this._mask = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask"}, true);
}
+
this.addClass("x-masked");
this._mask.setDisplayed(true);
// we wander
var z = 0;
- var dom = this.dom
+ var dom = this.dom;
while (dom && dom.style) {
if (!isNaN(parseInt(dom.style.zIndex))) {
z = Math.max(z, parseInt(dom.style.zIndex));
if(typeof msg == 'string'){
if(!this._maskMsg){
- this._maskMsg = Roo.DomHelper.append(this.dom, {cls:"roo-el-mask-msg", cn:{tag:'div'}}, true);
+ this._maskMsg = Roo.DomHelper.append(this.dom, {
+ cls: "roo-el-mask-msg",
+ cn: [
+ {
+ tag: 'i',
+ cls: 'fa fa-spinner fa-spin'
+ },
+ {
+ tag: 'div'
+ }
+ ]
+ }, true);
}
var mm = this._maskMsg;
mm.dom.className = msgCls ? "roo-el-mask-msg " + msgCls : "roo-el-mask-msg";
- mm.dom.firstChild.innerHTML = msg;
+ if (mm.dom.lastChild) { // weird IE issue?
+ mm.dom.lastChild.innerHTML = msg;
+ }
mm.setDisplayed(true);
mm.center(this);
mm.setStyle('z-index', z + 102);
/**
* @private
*/
- fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate
+ fitToParentDelegate : Roo.emptyFn, // keep a reference to the fitToParent delegate
/**
* Sizes this element to its parent element's dimensions performing
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){