2 * Interface Elements for jQuery
5 * http://interface.eyecon.ro
7 * Copyright (c) 2006 Stefan Petre
8 * Dual licensed under the MIT (MIT-LICENSE.txt)
9 * and GPL (GPL-LICENSE.txt) licenses.
15 getPosition : function(e)
20 var restoreStyles = false;
21 if (jQuery(e).css('display') == 'none') {
22 var oldVisibility = es.visibility;
23 var oldPosition = es.position;
25 es.visibility = 'hidden';
27 es.position = 'absolute';
31 x += el.offsetLeft + (el.currentStyle && !jQuery.browser.opera ?parseInt(el.currentStyle.borderLeftWidth)||0:0);
32 y += el.offsetTop + (el.currentStyle && !jQuery.browser.opera ?parseInt(el.currentStyle.borderTopWidth)||0:0);
36 while (el && el.tagName && el.tagName.toLowerCase() != 'body')
38 x -= el.scrollLeft||0;
42 if (restoreStyles == true) {
44 es.position = oldPosition;
45 es.visibility = oldVisibility;
49 getPositionLite : function(el)
53 x += el.offsetLeft || 0;
54 y += el.offsetTop || 0;
61 var w = jQuery.css(e,'width');
62 var h = jQuery.css(e,'height');
66 if (jQuery(e).css('display') != 'none') {
70 var oldVisibility = es.visibility;
71 var oldPosition = es.position;
72 es.visibility = 'hidden';
74 es.position = 'absolute';
78 es.position = oldPosition;
79 es.visibility = oldVisibility;
81 return {w:w, h:h, wb:wb, hb:hb};
83 getSizeLite : function(el)
90 getClient : function(e)
97 de = document.documentElement;
98 w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
99 h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
103 getScroll : function (e)
105 var t=0, l=0, w=0, h=0, iw=0, ih=0;
106 if (e && e.nodeName.toLowerCase() != 'body') {
114 if (document.documentElement) {
115 t = document.documentElement.scrollTop;
116 l = document.documentElement.scrollLeft;
117 w = document.documentElement.scrollWidth;
118 h = document.documentElement.scrollHeight;
119 } else if (document.body) {
120 t = document.body.scrollTop;
121 l = document.body.scrollLeft;
122 w = document.body.scrollWidth;
123 h = document.body.scrollHeight;
125 iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0;
126 ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0;
128 return { t: t, l: l, w: w, h: h, iw: iw, ih: ih };
130 getMargins : function(e, toInteger)
133 var t = el.css('marginTop') || '';
134 var r = el.css('marginRight') || '';
135 var b = el.css('marginBottom') || '';
136 var l = el.css('marginLeft') || '';
145 return {t: t, r: r, b: b, l: l};
147 getPadding : function(e, toInteger)
150 var t = el.css('paddingTop') || '';
151 var r = el.css('paddingRight') || '';
152 var b = el.css('paddingBottom') || '';
153 var l = el.css('paddingLeft') || '';
162 return {t: t, r: r, b: b, l: l};
164 getBorder : function(e, toInteger)
167 var t = el.css('borderTopWidth') || '';
168 var r = el.css('borderRightWidth') || '';
169 var b = el.css('borderBottomWidth') || '';
170 var l = el.css('borderLeftWidth') || '';
179 return {t: t, r: r, b: b, l: l};
181 getPointer : function(event)
183 var x = event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) || 0;
184 var y = event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) || 0;
187 traverseDOM : function(nodeEl, func)
190 nodeEl = nodeEl.firstChild;
192 jQuery.iUtil.traverseDOM(nodeEl, func);
193 nodeEl = nodeEl.nextSibling;
196 purgeEvents : function(nodeEl)
198 jQuery.iUtil.traverseDOM(
203 if(typeof el[attr] === 'function') {
210 centerEl : function(el, axis)
212 var clientScroll = jQuery.iUtil.getScroll();
213 var windowSize = jQuery.iUtil.getSize(el);
214 if (!axis || axis == 'vertically')
217 top: clientScroll.t + ((Math.max(clientScroll.h,clientScroll.ih) - clientScroll.t - windowSize.hb)/2) + 'px'
220 if (!axis || axis == 'horizontally')
223 left: clientScroll.l + ((Math.max(clientScroll.w,clientScroll.iw) - clientScroll.l - windowSize.wb)/2) + 'px'
227 fixPNG : function (el, emptyGIF) {
228 var images = jQuery('img[@src*="png"]', el||document), png;
229 images.each( function() {
232 this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + png + "')";
237 // Helper function to support older browsers!
238 [].indexOf || (Array.prototype.indexOf = function(v, n){
239 n = (n == null) ? 0 : n;
241 for (var i=n; i<m; i++)