/************************************/ /* jQuery dimensions code */ /************************************/ (function($){ var height = $.fn.height, width = $.fn.width; $.fn.extend({ height: function() { if (!this[0]) error(); if ( this[0] == window ) if ( ($.browser.mozilla || $.browser.opera) && $(document).width() > self.innerWidth) return self.innerHeight - getScrollbarWidth(); else return self.innerHeight || $.boxModel && document.documentElement.clientHeight || document.body.clientHeight; if ( this[0] == document ) return Math.max( document.body.scrollHeight, document.body.offsetHeight ); return height.apply(this, arguments); }, width: function() { if (!this[0]) error(); if ( this[0] == window ) if (($.browser.mozilla || $.browser.opera) && $(document).height() > self.innerHeight) return self.innerWidth - getScrollbarWidth(); else return self.innerWidth || $.boxModel && document.documentElement.clientWidth || document.body.clientWidth; if ( this[0] == document ) if ($.browser.mozilla) { var scrollLeft = self.pageXOffset; self.scrollTo(99999999, self.pageYOffset); var scrollWidth = self.pageXOffset; self.scrollTo(scrollLeft, self.pageYOffset); return document.body.offsetWidth + scrollWidth; } else return Math.max( document.body.scrollWidth, document.body.offsetWidth ); return width.apply(this, arguments); }, innerHeight: function() { if (!this[0]) error(); return this[0] == window || this[0] == document ? this.height() : this.is(':visible') ? this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') : this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom'); }, innerWidth: function() { if (!this[0]) error(); return this[0] == window || this[0] == document ? this.width() : this.is(':visible') ? this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') : this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight'); }, outerHeight: function(options) { if (!this[0]) error(); options = $.extend({ margin: false }, options || {}); return this[0] == window || this[0] == document ? this.height() : this.is(':visible') ? this[0].offsetHeight + (options.margin ? (num(this, 'marginTop') + num(this, 'marginBottom')) : 0) : this.height() + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') + num(this, 'paddingTop') + num(this, 'paddingBottom') + (options.margin ? (num(this, 'marginTop') + num(this, 'marginBottom')) : 0); }, outerWidth: function(options) { if (!this[0]) error(); options = $.extend({ margin: false }, options || {}); return this[0] == window || this[0] == document ? this.width() : this.is(':visible') ? this[0].offsetWidth + (options.margin ? (num(this, 'marginLeft') + num(this, 'marginRight')) : 0) : this.width() + num(this, 'borderLeftWidth') + num(this, 'borderRightWidth') + num(this, 'paddingLeft') + num(this, 'paddingRight') + (options.margin ? (num(this, 'marginLeft') + num(this, 'marginRight')) : 0); }, scrollLeft: function(val) { if (!this[0]) error(); if ( val != undefined ) return this.each(function() { if (this == window || this == document) window.scrollTo( val, $(window).scrollTop() ); else this.scrollLeft = val; }); if ( this[0] == window || this[0] == document ) return self.pageXOffset || $.boxModel && document.documentElement.scrollLeft || document.body.scrollLeft; return this[0].scrollLeft; }, scrollTop: function(val) { if (!this[0]) error(); if ( val != undefined ) return this.each(function() { if (this == window || this == document) window.scrollTo( $(window).scrollLeft(), val ); else this.scrollTop = val; }); if ( this[0] == window || this[0] == document ) return self.pageYOffset || $.boxModel && document.documentElement.scrollTop || document.body.scrollTop; return this[0].scrollTop; }, position: function(returnObject) { return this.offset({ margin: false, scroll: false, relativeTo: this.offsetParent() }, returnObject); } }); var error = function() { throw "Dimensions: jQuery collection is empty"; }; var num = function(el, prop) { return parseInt($.css(el.jquery?el[0]:el,prop))||0; }; var handleOffsetReturn = function(elem, options, x, y, sl, st) { if ( !options.margin ) { x -= num(elem, 'marginLeft'); y -= num(elem, 'marginTop'); } if ( options.border && (($.browser.safari && parseInt($.browser.version) < 520) || $.browser.opera) ) { x += num(elem, 'borderLeftWidth'); y += num(elem, 'borderTopWidth'); } else if ( !options.border && !(($.browser.safari && parseInt($.browser.version) < 520) || $.browser.opera) ) { x -= num(elem, 'borderLeftWidth'); y -= num(elem, 'borderTopWidth'); } if ( options.padding ) { x += num(elem, 'paddingLeft'); y += num(elem, 'paddingTop'); } if ( options.scroll && (!$.browser.opera || elem.offsetLeft != elem.scrollLeft && elem.offsetTop != elem.scrollLeft) ) { sl -= elem.scrollLeft; st -= elem.scrollTop; } return options.scroll ? { top: y - st, left: x - sl, scrollTop: st, scrollLeft: sl } : { top: y, left: x }; }; var scrollbarWidth = 0; var getScrollbarWidth = function() { if (!scrollbarWidth) { var testEl = $('