Diffstat (limited to 'frontend/gamma/js/MochiKit/Style.js') (more/less context) (ignore 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,27 +1,30 @@ | |||
1 | /*** | 1 | /*** |
2 | 2 | ||
3 | MochiKit.Style 1.5 | 3 | MochiKit.Style 1.5 |
4 | 4 | ||
5 | See <http://mochikit.com/> for documentation, downloads, license, etc. | 5 | See <http://mochikit.com/> for documentation, downloads, license, etc. |
6 | 6 | ||
7 | (c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved. | 7 | (c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved. |
8 | 8 | ||
9 | The MochiKit.Style.getElementPosition function is adapted from | ||
10 | YAHOO.util.Dom.getXY v0.9.0. which is copyrighted by Yahoo! Inc. | ||
11 | |||
9 | ***/ | 12 | ***/ |
10 | 13 | ||
11 | MochiKit.Base._module('Style', '1.5', ['Base', 'DOM']); | 14 | MochiKit.Base.module(MochiKit, 'Style', '1.5', ['Base', 'DOM']); |
12 | 15 | ||
13 | 16 | ||
14 | /** @id MochiKit.Style.Dimensions */ | 17 | /** @id MochiKit.Style.Dimensions */ |
15 | MochiKit.Style.Dimensions = function (w, h) { | 18 | MochiKit.Style.Dimensions = function (w, h) { |
16 | if (!(this instanceof MochiKit.Style.Dimensions)) { | 19 | if (!(this instanceof MochiKit.Style.Dimensions)) { |
17 | return new MochiKit.Style.Dimensions(w, h); | 20 | return new MochiKit.Style.Dimensions(w, h); |
18 | } | 21 | } |
19 | this.w = w; | 22 | this.w = w; |
20 | this.h = h; | 23 | this.h = h; |
21 | }; | 24 | }; |
22 | 25 | ||
23 | MochiKit.Style.Dimensions.prototype.__repr__ = function () { | 26 | MochiKit.Style.Dimensions.prototype.__repr__ = function () { |
24 | var repr = MochiKit.Base.repr; | 27 | var repr = MochiKit.Base.repr; |
25 | return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}'; | 28 | return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}'; |
26 | }; | 29 | }; |
27 | 30 | ||
@@ -166,83 +169,83 @@ MochiKit.Base.update(MochiKit.Style, { | |||
166 | 169 | ||
167 | getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0. | 170 | getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0. |
168 | Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved. | 171 | Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved. |
169 | License: BSD, http://developer.yahoo.net/yui/license.txt | 172 | License: BSD, http://developer.yahoo.net/yui/license.txt |
170 | 173 | ||
171 | */ | 174 | */ |
172 | 175 | ||
173 | /** @id MochiKit.Style.getElementPosition */ | 176 | /** @id MochiKit.Style.getElementPosition */ |
174 | getElementPosition: function (elem, /* optional */relativeTo) { | 177 | getElementPosition: function (elem, /* optional */relativeTo) { |
175 | var self = MochiKit.Style; | 178 | var self = MochiKit.Style; |
176 | var dom = MochiKit.DOM; | 179 | var dom = MochiKit.DOM; |
177 | var isCoordinates = function (o) { | 180 | var isCoordinates = function (o) { |
178 | return o != null && | 181 | return o != null && |
179 | o.nodeType == null && | 182 | o.nodeType == null && |
180 | typeof(o.x) == "number" && | 183 | typeof(o.x) == "number" && |
181 | typeof(o.y) == "number"; | 184 | typeof(o.y) == "number"; |
182 | } | 185 | }; |
183 | 186 | ||
184 | if (typeof(elem) == "string") { | 187 | if (typeof(elem) == "string") { |
185 | elem = dom.getElement(elem); | 188 | elem = dom.getElement(elem); |
186 | } | 189 | } |
187 | if (elem == null || | 190 | if (elem == null || |
188 | (!isCoordinates(elem) && self.getStyle(elem, 'display') == 'none')) { | 191 | (!isCoordinates(elem) && self.getStyle(elem, 'display') == 'none')) { |
189 | return undefined; | 192 | return undefined; |
190 | } | 193 | } |
191 | 194 | ||
192 | var c = new self.Coordinates(0, 0); | 195 | var c = new self.Coordinates(0, 0); |
193 | var box = null; | 196 | var box = null; |
194 | var parent = null; | 197 | var parent = null; |
195 | 198 | ||
196 | var d = MochiKit.DOM._document; | 199 | var d = MochiKit.DOM._document; |
197 | var de = d.documentElement; | 200 | var de = d.documentElement; |
198 | var b = d.body; | 201 | var b = d.body; |
199 | 202 | ||
200 | if (!elem.parentNode && elem.x && elem.y) { | 203 | if (isCoordinates(elem)) { |
201 | /* it's just a MochiKit.Style.Coordinates object */ | 204 | /* it's just a MochiKit.Style.Coordinates object */ |
202 | c.x += elem.x || 0; | 205 | c.x += elem.x || 0; |
203 | c.y += elem.y || 0; | 206 | c.y += elem.y || 0; |
204 | } else if (elem.getBoundingClientRect) { // IE shortcut | 207 | } else if (elem.getBoundingClientRect) { // IE shortcut |
205 | /* | 208 | /* |
206 | 209 | ||
207 | The IE shortcut can be off by two. We fix it. See: | 210 | The IE shortcut can be off by two. We fix it. See: |
208 | http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp | 211 | http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp |
209 | 212 | ||
210 | This is similar to the method used in | 213 | This is similar to the method used in |
211 | MochiKit.Signal.Event.mouse(). | 214 | MochiKit.Signal.Event.mouse(). |
212 | 215 | ||
213 | */ | 216 | */ |
214 | box = elem.getBoundingClientRect(); | 217 | box = elem.getBoundingClientRect(); |
215 | 218 | ||
216 | c.x += box.left + | 219 | c.x += box.left + |
217 | (de.scrollLeft || b.scrollLeft) - | 220 | (de.scrollLeft || b.scrollLeft) - |
218 | (de.clientLeft || 0); | 221 | (de.clientLeft || 0); |
219 | 222 | ||
220 | c.y += box.top + | 223 | c.y += box.top + |
221 | (de.scrollTop || b.scrollTop) - | 224 | (de.scrollTop || b.scrollTop) - |
222 | (de.clientTop || 0); | 225 | (de.clientTop || 0); |
223 | 226 | ||
224 | } else if (elem.offsetParent) { | 227 | } else if (elem.offsetParent) { |
225 | c.x += elem.offsetLeft; | 228 | c.x += elem.offsetLeft; |
226 | c.y += elem.offsetTop; | 229 | c.y += elem.offsetTop; |
227 | parent = elem.offsetParent; | 230 | parent = elem.offsetParent; |
228 | 231 | ||
229 | if (parent != elem) { | 232 | if (parent != elem) { |
230 | while (parent) { | 233 | while (parent) { |
231 | c.x += parseInt(parent.style.borderLeftWidth) || 0; | 234 | c.x += parseInt(parent.style.borderLeftWidth, 10) || 0; |
232 | c.y += parseInt(parent.style.borderTopWidth) || 0; | 235 | c.y += parseInt(parent.style.borderTopWidth, 10) || 0; |
233 | c.x += parent.offsetLeft; | 236 | c.x += parent.offsetLeft; |
234 | c.y += parent.offsetTop; | 237 | c.y += parent.offsetTop; |
235 | parent = parent.offsetParent; | 238 | parent = parent.offsetParent; |
236 | } | 239 | } |
237 | } | 240 | } |
238 | 241 | ||
239 | /* | 242 | /* |
240 | 243 | ||
241 | Opera < 9 and old Safari (absolute) incorrectly account for | 244 | Opera < 9 and old Safari (absolute) incorrectly account for |
242 | body offsetTop and offsetLeft. | 245 | body offsetTop and offsetLeft. |
243 | 246 | ||
244 | */ | 247 | */ |
245 | var ua = navigator.userAgent.toLowerCase(); | 248 | var ua = navigator.userAgent.toLowerCase(); |
246 | if ((typeof(opera) != 'undefined' && | 249 | if ((typeof(opera) != 'undefined' && |
247 | parseFloat(opera.version()) < 9) || | 250 | parseFloat(opera.version()) < 9) || |
248 | (ua.indexOf('AppleWebKit') != -1 && | 251 | (ua.indexOf('AppleWebKit') != -1 && |
@@ -377,33 +380,33 @@ MochiKit.Base.update(MochiKit.Style, { | |||
377 | var originalDisplay = s.display; | 380 | var originalDisplay = s.display; |
378 | s.visibility = 'hidden'; | 381 | s.visibility = 'hidden'; |
379 | s.position = 'absolute'; | 382 | s.position = 'absolute'; |
380 | s.display = self._getDefaultDisplay(elem); | 383 | s.display = self._getDefaultDisplay(elem); |
381 | var originalWidth = elem.offsetWidth; | 384 | var originalWidth = elem.offsetWidth; |
382 | var originalHeight = elem.offsetHeight; | 385 | var originalHeight = elem.offsetHeight; |
383 | s.display = originalDisplay; | 386 | s.display = originalDisplay; |
384 | s.position = originalPosition; | 387 | s.position = originalPosition; |
385 | s.visibility = originalVisibility; | 388 | s.visibility = originalVisibility; |
386 | } else { | 389 | } else { |
387 | originalWidth = elem.offsetWidth || 0; | 390 | originalWidth = elem.offsetWidth || 0; |
388 | originalHeight = elem.offsetHeight || 0; | 391 | originalHeight = elem.offsetHeight || 0; |
389 | } | 392 | } |
390 | if (contentSize) { | 393 | if (contentSize) { |
391 | var tableCell = 'colSpan' in elem && 'rowSpan' in elem; | 394 | var tableCell = 'colSpan' in elem && 'rowSpan' in elem; |
392 | var collapse = (tableCell && elem.parentNode && self.getStyle( | 395 | var collapse = (tableCell && elem.parentNode && self.getStyle( |
393 | elem.parentNode, 'borderCollapse') == 'collapse') | 396 | elem.parentNode, 'borderCollapse') == 'collapse'); |
394 | if (collapse) { | 397 | if (collapse) { |
395 | if (/MSIE/.test(navigator.userAgent)) { | 398 | if (/MSIE/.test(navigator.userAgent)) { |
396 | var borderLeftQuota = elem.previousSibling? 0.5 : 1; | 399 | var borderLeftQuota = elem.previousSibling? 0.5 : 1; |
397 | var borderRightQuota = elem.nextSibling? 0.5 : 1; | 400 | var borderRightQuota = elem.nextSibling? 0.5 : 1; |
398 | } | 401 | } |
399 | else { | 402 | else { |
400 | var borderLeftQuota = 0.5; | 403 | var borderLeftQuota = 0.5; |
401 | var borderRightQuota = 0.5; | 404 | var borderRightQuota = 0.5; |
402 | } | 405 | } |
403 | } else { | 406 | } else { |
404 | var borderLeftQuota = 1; | 407 | var borderLeftQuota = 1; |
405 | var borderRightQuota = 1; | 408 | var borderRightQuota = 1; |
406 | } | 409 | } |
407 | originalWidth -= Math.round( | 410 | originalWidth -= Math.round( |
408 | (parseFloat(self.getStyle(elem, 'paddingLeft')) || 0) | 411 | (parseFloat(self.getStyle(elem, 'paddingLeft')) || 0) |
409 | + (parseFloat(self.getStyle(elem, 'paddingRight')) || 0) | 412 | + (parseFloat(self.getStyle(elem, 'paddingRight')) || 0) |
@@ -530,29 +533,29 @@ MochiKit.Base.update(MochiKit.Style, { | |||
530 | 'INPUT': 'inline-block', | 533 | 'INPUT': 'inline-block', |
531 | 'SELECT': 'inline-block' }; | 534 | 'SELECT': 'inline-block' }; |
532 | // CSS 'display' support in IE6/7 is just broken... | 535 | // CSS 'display' support in IE6/7 is just broken... |
533 | if (/MSIE/.test(navigator.userAgent)) { | 536 | if (/MSIE/.test(navigator.userAgent)) { |
534 | for (var k in this._defaultDisplay) { | 537 | for (var k in this._defaultDisplay) { |
535 | var v = this._defaultDisplay[k]; | 538 | var v = this._defaultDisplay[k]; |
536 | if (v.indexOf('table') == 0) { | 539 | if (v.indexOf('table') == 0) { |
537 | this._defaultDisplay[k] = 'block'; | 540 | this._defaultDisplay[k] = 'block'; |
538 | } | 541 | } |
539 | } | 542 | } |
540 | } | 543 | } |
541 | for (var i = 0; i < inlines.length; i++) { | 544 | for (var i = 0; i < inlines.length; i++) { |
542 | this._defaultDisplay[inlines[i]] = 'inline'; | 545 | this._defaultDisplay[inlines[i]] = 'inline'; |
543 | } | 546 | } |
544 | 547 | ||
545 | // Backwards compatibility aliases | 548 | // Backwards compatibility aliases |
546 | m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3'); | 549 | m._deprecated(this, 'elementPosition', 'MochiKit.Style.getElementPosition', '1.3', true); |
547 | m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3'); | 550 | m._deprecated(this, 'elementDimensions', 'MochiKit.Style.getElementDimensions', '1.3', true); |
548 | 551 | ||
549 | this.hideElement = m.partial(this.setDisplayForElement, 'none'); | 552 | this.hideElement = m.partial(this.setDisplayForElement, 'none'); |
550 | // TODO: showElement could be improved by using getDefaultDisplay. | 553 | // TODO: showElement could be improved by using getDefaultDisplay. |
551 | this.showElement = m.partial(this.setDisplayForElement, 'block'); | 554 | this.showElement = m.partial(this.setDisplayForElement, 'block'); |
552 | 555 | ||
553 | m.nameFunctions(this); | 556 | m.nameFunctions(this); |
554 | } | 557 | } |
555 | }); | 558 | }); |
556 | 559 | ||
557 | MochiKit.Style.__new__(); | 560 | MochiKit.Style.__new__(); |
558 | MochiKit.Base._exportSymbols(this, MochiKit.Style); | 561 | MochiKit.Base._exportSymbols(this, MochiKit.Style); |