author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-03-17 21:08:23 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2012-03-17 21:08:23 (UTC) |
commit | 928f3f3ed3981f7f81b69ed94f2a315205db39fa (patch) (side-by-side diff) | |
tree | 8a47229b56e4c906de8512baf0c5ca100bc03dfb /frontend/gamma/js/MochiKit/Style.js | |
parent | bf7d8191a3a6dbd092a88911098a3e7f6cf30cf7 (diff) | |
download | clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.zip clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.gz clipperz-928f3f3ed3981f7f81b69ed94f2a315205db39fa.tar.bz2 |
Fixed frontend properties and updated MochiKit version
Diffstat (limited to 'frontend/gamma/js/MochiKit/Style.js') (more/less context) (show whitespace changes)
-rw-r--r-- | frontend/gamma/js/MochiKit/Style.js | 19 |
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,35 +1,38 @@ /*** 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 () { var repr = MochiKit.Base.repr; return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}'; }; MochiKit.Style.Dimensions.prototype.toString = function () { return this.__repr__(); }; /** @id MochiKit.Style.Coordinates */ MochiKit.Style.Coordinates = function (x, y) { if (!(this instanceof MochiKit.Style.Coordinates)) { @@ -158,99 +161,99 @@ MochiKit.Base.update(MochiKit.Style, { if (/MSIE/.test(navigator.userAgent)) { elem.style['filter'] = self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '') + 'alpha(opacity=' + o * 100 + ')'; } } }, /* getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0. Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved. License: BSD, http://developer.yahoo.net/yui/license.txt */ /** @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(). */ box = elem.getBoundingClientRect(); c.x += box.left + (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0); 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. */ var ua = navigator.userAgent.toLowerCase(); if ((typeof(opera) != 'undefined' && parseFloat(opera.version()) < 9) || (ua.indexOf('AppleWebKit') != -1 && self.getStyle(elem, 'position') == 'absolute')) { c.x -= b.offsetLeft; c.y -= b.offsetTop; } // Adjust position for strange Opera scroll bug @@ -369,49 +372,49 @@ MochiKit.Base.update(MochiKit.Style, { return undefined; } var disp = self.getStyle(elem, 'display'); // display can be empty/undefined on WebKit/KHTML if (disp == 'none' || disp == '' || typeof(disp) == 'undefined') { var s = elem.style; var originalVisibility = s.visibility; var originalPosition = s.position; var originalDisplay = s.display; s.visibility = 'hidden'; s.position = 'absolute'; s.display = self._getDefaultDisplay(elem); 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; } originalWidth -= Math.round( (parseFloat(self.getStyle(elem, 'paddingLeft')) || 0) + (parseFloat(self.getStyle(elem, 'paddingRight')) || 0) + borderLeftQuota * (parseFloat(self.getStyle(elem, 'borderLeftWidth')) || 0) + borderRightQuota * (parseFloat(self.getStyle(elem, 'borderRightWidth')) || 0) ); if (tableCell) { if (/Gecko|Opera/.test(navigator.userAgent) && !/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent)) { @@ -522,37 +525,37 @@ MochiKit.Base.update(MochiKit.Style, { 'TFOOT': 'table-footer-group', 'COLGROUP': 'table-column-group', 'COL': 'table-column', 'TR': 'table-row', 'TD': 'table-cell', 'TH': 'table-cell', 'CAPTION': 'table-caption', 'LI': 'list-item', 'INPUT': 'inline-block', 'SELECT': 'inline-block' }; // CSS 'display' support in IE6/7 is just broken... if (/MSIE/.test(navigator.userAgent)) { 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); |