Access other static DomElement methods through 'this'.

This commit is contained in:
Jürg Lehni 2011-06-26 10:15:30 +02:00
parent f18b5df99d
commit f610acedf2

View file

@ -47,7 +47,7 @@ var DomElement = new function() {
getViewportSize: function(el) { getViewportSize: function(el) {
var doc = el.ownerDocument, var doc = el.ownerDocument,
view = DomElement.getViewport(doc), view = this.getViewport(doc),
body = doc.getElementsByTagName( body = doc.getElementsByTagName(
doc.compatMode === 'CSS1Compat' ? 'html' : 'body')[0]; doc.compatMode === 'CSS1Compat' ? 'html' : 'body')[0];
return Size.create( return Size.create(
@ -59,7 +59,7 @@ var DomElement = new function() {
getComputedStyle: function(el, name) { getComputedStyle: function(el, name) {
if (el.currentStyle) if (el.currentStyle)
return el.currentStyle[Base.camelize(name)]; return el.currentStyle[Base.camelize(name)];
var style = DomElement.getViewport(el.ownerDocument) var style = this.getViewport(el.ownerDocument)
.getComputedStyle(el, null); .getComputedStyle(el, null);
return style ? style.getPropertyValue(Base.hyphenate(name)) : null; return style ? style.getPropertyValue(Base.hyphenate(name)) : null;
}, },
@ -84,15 +84,15 @@ var DomElement = new function() {
}, },
getBounds: function(el, positioned, viewport) { getBounds: function(el, positioned, viewport) {
return new Rectangle(DomElement.getOffset(el, positioned, viewport), return new Rectangle(this.getOffset(el, positioned, viewport),
DomElement.getSize(el)); this.getSize(el));
}, },
/** /**
* Checks if element is invisibile (display: none, ...) * Checks if element is invisibile (display: none, ...)
*/ */
isInvisible: function(el) { isInvisible: function(el) {
return DomElement.getSize(el).equals([0, 0]); return this.getSize(el).equals([0, 0]);
}, },
/** /**
@ -101,9 +101,9 @@ var DomElement = new function() {
isVisible: function(el) { isVisible: function(el) {
// See if the viewport bounds intersect with the windows rectangle // See if the viewport bounds intersect with the windows rectangle
// which always starts at 0, 0 // which always starts at 0, 0
return !DomElement.isInvisible(el) return !this.isInvisible(el)
&& new Rectangle([0, 0], DomElement.getViewportSize(el)) && new Rectangle([0, 0], this.getViewportSize(el))
.intersects(DomElement.getBounds(el, false, true)); .intersects(this.getBounds(el, false, true));
} }
}; };
}; };