summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/MochiKit/Style.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/MochiKit/Style.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/MochiKit/Style.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/frontend/gamma/js/MochiKit/Style.js b/frontend/gamma/js/MochiKit/Style.js
index 7f10117..740fd2f 100644
--- a/frontend/gamma/js/MochiKit/Style.js
+++ b/frontend/gamma/js/MochiKit/Style.js
@@ -1,23 +1,26 @@
/***
MochiKit.Style 1.5
See <http://mochikit.com/> for documentation, downloads, license, etc.
(c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved.
+The MochiKit.Style.getElementPosition function is adapted from
+YAHOO.util.Dom.getXY v0.9.0. which is copyrighted by Yahoo! Inc.
+
***/
-MochiKit.Base._module('Style', '1.5', ['Base', 'DOM']);
+MochiKit.Base.module(MochiKit, 'Style', '1.5', ['Base', 'DOM']);
/** @id MochiKit.Style.Dimensions */
MochiKit.Style.Dimensions = function (w, h) {
if (!(this instanceof MochiKit.Style.Dimensions)) {
return new MochiKit.Style.Dimensions(w, h);
}
this.w = w;
this.h = h;
};
MochiKit.Style.Dimensions.prototype.__repr__ = function () {
@@ -170,43 +173,43 @@ MochiKit.Base.update(MochiKit.Style, {
*/
/** @id MochiKit.Style.getElementPosition */
getElementPosition: function (elem, /* optional */relativeTo) {
var self = MochiKit.Style;
var dom = MochiKit.DOM;
var isCoordinates = function (o) {
return o != null &&
o.nodeType == null &&
typeof(o.x) == "number" &&
typeof(o.y) == "number";
- }
+ };
if (typeof(elem) == "string") {
elem = dom.getElement(elem);
}
if (elem == null ||
(!isCoordinates(elem) && self.getStyle(elem, 'display') == 'none')) {
return undefined;
}
var c = new self.Coordinates(0, 0);
var box = null;
var parent = null;
var d = MochiKit.DOM._document;
var de = d.documentElement;
var b = d.body;
- if (!elem.parentNode && elem.x && elem.y) {
+ if (isCoordinates(elem)) {
/* it's just a MochiKit.Style.Coordinates object */
c.x += elem.x || 0;
c.y += elem.y || 0;
} else if (elem.getBoundingClientRect) { // IE shortcut
/*
The IE shortcut can be off by two. We fix it. See:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp
This is similar to the method used in
MochiKit.Signal.Event.mouse().
@@ -219,26 +222,26 @@ MochiKit.Base.update(MochiKit.Style, {
c.y += box.top +
(de.scrollTop || b.scrollTop) -
(de.clientTop || 0);
} else if (elem.offsetParent) {
c.x += elem.offsetLeft;
c.y += elem.offsetTop;
parent = elem.offsetParent;
if (parent != elem) {
while (parent) {
- c.x += parseInt(parent.style.borderLeftWidth) || 0;
- c.y += parseInt(parent.style.borderTopWidth) || 0;
+ c.x += parseInt(parent.style.borderLeftWidth, 10) || 0;
+ c.y += parseInt(parent.style.borderTopWidth, 10) || 0;
c.x += parent.offsetLeft;
c.y += parent.offsetTop;
parent = parent.offsetParent;
}
}
/*
Opera < 9 and old Safari (absolute) incorrectly account for
body offsetTop and offsetLeft.
*/
@@ -381,25 +384,25 @@ MochiKit.Base.update(MochiKit.Style, {
var originalWidth = elem.offsetWidth;
var originalHeight = elem.offsetHeight;
s.display = originalDisplay;
s.position = originalPosition;
s.visibility = originalVisibility;
} else {
originalWidth = elem.offsetWidth || 0;
originalHeight = elem.offsetHeight || 0;
}
if (contentSize) {
var tableCell = 'colSpan' in elem && 'rowSpan' in elem;
var collapse = (tableCell && elem.parentNode && self.getStyle(
- elem.parentNode, 'borderCollapse') == 'collapse')
+ elem.parentNode, 'borderCollapse') == 'collapse');
if (collapse) {
if (/MSIE/.test(navigator.userAgent)) {
var borderLeftQuota = elem.previousSibling? 0.5 : 1;
var borderRightQuota = elem.nextSibling? 0.5 : 1;
}
else {
var borderLeftQuota = 0.5;
var borderRightQuota = 0.5;
}
} else {
var borderLeftQuota = 1;
var borderRightQuota = 1;
@@ -534,25 +537,25 @@ MochiKit.Base.update(MochiKit.Style, {
for (var k in this._defaultDisplay) {
var v = this._defaultDisplay[k];
if (v.indexOf('table') == 0) {
this._defaultDisplay[k] = 'block';
}
}
}
for (var i = 0; i < inlines.length; i++) {
this._defaultDisplay[inlines[i]] = 'inline';
}
// Backwards compatibility aliases
- m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3');
- m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3');
+ m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3', true);
+ m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3', true);
this.hideElement = m.partial(this.setDisplayForElement, 'none');
// TODO: showElement could be improved by using getDefaultDisplay.
this.showElement = m.partial(this.setDisplayForElement, 'block');
m.nameFunctions(this);
}
});
MochiKit.Style.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Style);