/*
 * jquery.scrollIntoView
 * Courtesy of http://bililite.com/blog/2009/02/04/new-plugin-scrollintoview/
 * Packed with http://dean.edwards.name/packer/
 */
(function ($) { var f; function propPx(a, b, c) { return Math.round((!b.padding && -parseFloat(a.css('padding' + c) || 0)) + (!b.border && -parseFloat(a.css('border' + c + 'Width') || 0)) + (b.margin && parseFloat(a.css('margin' + c) || 0))) } function constrainPx(a, b, c) { return document.documentElement['client' + c] - a['outer' + c]() - (c == 'Height' ? propPx(a, b, 'Top') + propPx(a, b, 'Bottom') : propPx(a, b, 'Left') + propPx(a, b, 'Right')) } $.fn.scrollIntoView = function (a, b, c) { f = f || ($('body')[0].scrollHeight >= $('html')[0].scrollHeight ? $('body')[0] : $('html')[0]); if (typeof a != 'object') a = { duration: a, easing: b, complete: c }; a = $.extend({}, $.fn.scrollIntoView.defaults, $.metadata && this.metadata()['scrollIntoView'], a); if (a.complete) { var d = a.complete, self = this[0]; a.complete = function () { d.apply(self, arguments) } } if (a.margin) a.border = true; if (a.border) a.padding = true; var e = this.offset(); e.top -= propPx(this, a, 'Top'); e.left -= propPx(this, a, 'Left'); var h = Math.max(0, constrainPx(this, a, 'Height')), w = Math.max(0, constrainPx(this, a, 'Width')); $(f).animate({ scrollTop: Math.min(e.top, Math.max(f.scrollTop, e.top - h)), scrollLeft: Math.min(e.left, Math.max(f.scrollLeft, e.left - w)) }, a); return this }; $.fn.scrollIntoView.defaults = { padding: true, border: true, margin: false} })(jQuery);
