/*! * jQuery.scrollTo * Copyright (c) 2007-2015 Ariel Flesler - afleslergmailcom | http://flesler.blogspot.com * Licensed under MIT * http://flesler.blogspot.com/2007/10/jqueryscrollto.html * @projectDescription Easy element scrolling using jQuery. * @author Ariel Flesler * @version 2.1.0 */ ;(function(a){a(["jquery"],function(e){var b=e.sabaiScrollTo=function(h,g,f){return e(window).sabaiScrollTo(h,g,f)};b.defaults={axis:"xy",duration:0,limit:true};function c(f){return !f.nodeName||e.inArray(f.nodeName.toLowerCase(),["iframe","#document","html","body"])!==-1}e.fn.sabaiScrollTo=function(i,h,g){if(typeof h==="object"){g=h;h=0}if(typeof g==="function"){g={onAfter:g}}if(i==="max"){i=9000000000}g=e.extend({},b.defaults,g);h=h||g.duration;var f=g.queue&&g.axis.length>1;if(f){h/=2}g.offset=d(g.offset);g.over=d(g.over);return this.each(function(){if(i===null){return}var p=c(this),o=p?this.contentWindow||window:this,m=e(o),n=i,j={},l;switch(typeof n){case"number":case"string":if(/^([+-]=?)?\d+(\.\d+)?(px|%)?$/.test(n)){n=d(n);break}n=p?e(n):e(n,o);if(!n.length){return}case"object":if(n.is||n.style){l=(n=e(n)).offset()}}var q=e.isFunction(g.offset)&&g.offset(o,n)||g.offset;e.each(g.axis.split(""),function(t,u){var w=u==="x"?"Left":"Top",y=w.toLowerCase(),s="scroll"+w,v=m[s](),r=b.max(o,u);if(l){j[s]=l[y]+(p?0:v-m.offset()[y]);if(g.margin){j[s]-=parseInt(n.css("margin"+w),10)||0;j[s]-=parseInt(n.css("border"+w+"Width"),10)||0}j[s]+=q[y]||0;if(g.over[y]){j[s]+=n[u==="x"?"width":"height"]()*g.over[y]}}else{var x=n[y];j[s]=x.slice&&x.slice(-1)==="%"?parseFloat(x)/100*r:x}if(g.limit&&/^\d+$/.test(j[s])){j[s]=j[s]<=0?0:Math.min(j[s],r)}if(!t&&g.axis.length>1){if(v===j[s]){j={}}else{if(f){k(g.onAfterFirst);j={}}}}});k(g.onAfter);function k(s){var r=e.extend({},g,{queue:true,duration:h,complete:s&&function(){s.call(o,n,g)}});m.animate(j,r)}})};b.max=function(l,k){var j=k==="x"?"Width":"Height",g="scroll"+j;if(!c(l)){return l[g]-e(l)[j.toLowerCase()]()}var i="client"+j,m=l.ownerDocument||l.document,h=m.documentElement,f=m.body;return Math.max(h[g],f[g])-Math.min(h[i],f[i])};function d(f){return e.isFunction(f)||e.isPlainObject(f)?f:{top:f,left:f}}e.Tween.propHooks.scrollLeft=e.Tween.propHooks.scrollTop={get:function(f){return e(f.elem)[f.prop]()},set:function(f){var h=this.get(f);if(f.options.interrupt&&f._last&&f._last!==h){return e(f.elem).stop()}var g=Math.round(f.now);if(h!==g){e(f.elem)[f.prop](g);f._last=this.get(f)}}};return b})}(typeof define==="function"&&define.amd?define:function(b,a){if(typeof module!=="undefined"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}));