/*! jQuery.fracs 0.11 - //larsjung.de/fracs - MIT License */ (function(a,b,c){"use strict";var d=c(a),e=c(b),f=c.extend,g=c.isFunction,h=[].slice,i=Math.max,j=Math.min,k=Math.round,l=function(a,b){return typeof a===b},m=function(a,b){return a instanceof b},n=function(a){return a&&a.nodeType},o=function(a){return n(a)?a:m(a,c)?a[0]:undefined},p=function(a,b,d){return c.each(a,function(a,c){d=b.call(c,d,a,c)}),d},q=function(){var a={},b=1;return function(c){return c?(a[c]||(a[c]=b,b+=1),a[c]):0}}(),r=function(a,b,c){var d,e,f;if(a===b)return!0;if(!a||!b||a.constructor!==b.constructor)return!1;for(d=0,e=c.length;d=0&&g>=0?new s(b,d,f,g):null},envelope:function(a){if(!m(a,s))return this;var b=j(this.left,a.left),c=i(this.right,a.right),d=j(this.top,a.top),e=i(this.bottom,a.bottom),f=c-b,g=e-d;return new s(b,d,f,g)}}),f(s,{ofContent:function(c,d){return!c||c===b||c===a?new s(0,0,e.width(),e.height()):d?new s(0,0,c.scrollWidth,c.scrollHeight):new s(c.offsetLeft-c.scrollLeft,c.offsetTop-c.scrollTop,c.scrollWidth,c.scrollHeight)},ofViewport:function(c,e){return!c||c===b||c===a?new s(d.scrollLeft(),d.scrollTop(),d.width(),d.height()):e?new s(c.scrollLeft,c.scrollTop,c.clientWidth,c.clientHeight):new s(c.offsetLeft,c.offsetTop,c.clientWidth,c.clientHeight)},ofElement:function(a){var b=c(a);if(!b.is(":visible"))return null;var d=b.offset();return new s(d.left,d.top,b.outerWidth(),b.outerHeight())}});var t=function(a,b,c,d){this.visible=a||0,this.viewport=b||0,this.possible=c||0,this.rects=d&&f({},d)||null};f(t.prototype,{equals:function(a){return this.fracsEqual(a)&&this.rectsEqual(a)},fracsEqual:function(a){return r(this,a,["visible","viewport","possible"])},rectsEqual:function(a){return r(this.rects,a.rects,["document","element","viewport"])}}),f(t,{of:function(a,b){var c,d,e;return a=n(a)&&s.ofElement(a)||a,b=n(b)&&s.ofViewport(b)||b||s.ofViewport(),c=a.intersection(b),c?(d=c.area(),e=j(a.width,b.width)*j(a.height,b.height),new t(d/a.area(),d/b.area(),d/e,{document:c,element:c.relativeTo(a),viewport:c.relativeTo(b)})):new t}});var u=function(a,b){this.els=a,this.viewport=b},v=["width","height","left","right","top","bottom"],w=["possible","visible","viewport"],x=function(a,b,d){var e;return c.inArray(d,v)>=0?e=s.ofElement(a):c.inArray(d,w)>=0&&(e=t.of(a,b)),e?e[d]:0},y=function(a,b){return a.val-b.val},z=function(a,b){return b.val-a.val};f(u.prototype,{sorted:function(a,b){var d=this.viewport;return c.map(this.els,function(b){return{el:b,val:x(b,d,a)}}).sort(b?z:y)},best:function(a,b){return this.els.length?this.sorted(a,b)[0]:null}});var A=function(a){var b=s.ofContent(a,!0),c=s.ofViewport(a,!0),d=b.width-c.width,e=b.height-c.height;this.content=b,this.viewport=c,this.width=d<=0?null:c.left/d,this.height=e<=0?null:c.top/e,this.left=c.left,this.top=c.top,this.right=b.right-c.right,this.bottom=b.bottom-c.bottom};f(A.prototype,{equals:function(a){return r(this,a,["width","height","left","top","right","bottom","content","viewport"])}});var B=function(b){this.el=b||a};f(B.prototype,{equals:function(a){return r(this,a,["el"])},scrollState:function(){return new A(this.el)},scrollTo:function(b,d,e){var f=this.el===a?c("html,body"):c(this.el);b=b||0,d=d||0,e=isNaN(e)?1e3:e,f.stop(!0).animate({scrollLeft:b,scrollTop:d},e)},scroll:function(b,e,f){var g=this.el===a?d:c(this.el);b=b||0,e=e||0,this.scrollTo(g.scrollLeft()+b,g.scrollTop()+e,f)},scrollToRect:function(a,b,c,d){b=b||0,c=c||0,this.scrollTo(a.left-b,a.top-c,d)},scrollToElement:function(a,b,c,d){var e=s.ofElement(a).relativeTo(s.ofContent(this.el));this.scrollToRect(e,b,c,d)}});var C={init:function(){this.callbacks=c.Callbacks("memory unique"),this.currVal=null,this.prevVal=null,this.checkProxy=c.proxy(this.check,this),this.autoCheck()},bind:function(a){this.callbacks.add(a)},unbind:function(a){a?this.callbacks.remove(a):this.callbacks.empty()},trigger:function(){this.callbacks.fireWith(this.context,[this.currVal,this.prevVal])},check:function(a){var b=this.updatedValue(a);return b===undefined?!1:(this.prevVal=this.currVal,this.currVal=b,this.trigger(),!0)},$autoTarget:d,autoEvents:"load resize scroll",autoCheck:function(a){this.$autoTarget[a===!1?"off":"on"](this.autoEvents,this.checkProxy)}},D=function(a,b){this.context=a,this.viewport=b,this.init()};f(D.prototype,C,{updatedValue:function(){var a=t.of(this.context,this.viewport);if(!this.currVal||!this.currVal.equals(a))return a}});var E=function(a,b,c,d){this.context=new u(a,b),this.property=c,this.descending=d,this.init()};f(E.prototype,C,{updatedValue:function(){var a=this.context.best(this.property,this.descending);if(a){a=a.val>0?a.el:null;if(this.currVal!==a)return a}}});var F=function(d){!d||d===a||d===b?this.context=a:(this.context=d,this.$autoTarget=c(d)),this.init()};f(F.prototype,C,{updatedValue:function(){var a=new A(this.context);if(!this.currVal||!this.currVal.equals(a))return a}});var G=function(a,b){var d=f({},b),e=function(b,d,e,f){e=g(e)?e.apply(b,d):e;if(g(f[e]))return f[e].apply(b,d);c.error('Method "'+e+'" does not exist on jQuery.'+a)},i=function(){return e(this,h.call(arguments),d.defaultStatic,i)},j=function(a){return g(j[a])?j[a].apply(this,h.call(arguments,1)):e(this,h.call(arguments),d.defaultMethod,j)},k=function(a){a&&(f(i,a.statics),f(j,a.methods)),i.modplug=k};k.prev={statics:c[a],methods:c.fn[a]},k(b),c[a]=i,c.fn[a]=j},H="fracs";G(H,{statics:{version:"0.11",Rect:s,Fractions:t,Group:u,ScrollState:A,Viewport:B,FracsCallbacks:D,GroupCallbacks:E,ScrollStateCallbacks:F,fracs:function(a,b){return t.of(a,b)}},methods:{content:function(a){return this.length?s.ofContent(this[0],a):null},envelope:function(){return p(this,function(a){var b=s.ofElement(this);return a?a.envelope(b):b})},fracs:function(a,b,d){l(a,"string")||(d=b,b=a,a=null),g(b)||(d=b,b=null),d=o(d);var e=H+".fracs."+q(d);return a==="unbind"?this.each(function(){var a=c(this).data(e);a&&a.unbind(b)}):a==="check"?this.each(function(){var a=c(this).data(e);a&&a.check()}):g(b)?this.each(function(){var a=c(this),f=a.data(e);f||(f=new D(this,d),a.data(e,f)),f.bind(b)}):this.length?t.of(this[0],d):null},intersection:function(){return p(this,function(a){var b=s.ofElement(this);return a?a.intersection(b):b})},max:function(a,b,c){return g(b)||(c=b,b=null),c=o(c),b?((new E(this,c,a,!0)).bind(b),this):this.pushStack((new u(this,c)).best(a,!0).el)},min:function(a,b,c){return g(b)||(c=b,b=null),c=o(c),b?((new E(this,c,a)).bind(b),this):this.pushStack((new u(this,c)).best(a).el)},rect:function(){return this.length?s.ofElement(this[0]):null},scrollState:function(a,b){var d=H+".scrollState";return l(a,"string")||(b=a,a=null),a==="unbind"?this.each(function(){var a=c(this).data(d);a&&a.unbind(b)}):a==="check"?this.each(function(){var a=c(this).data(d);a&&a.check()}):g(b)?this.each(function(){var a=c(this),e=a.data(d);e||(e=new F(this),a.data(d,e)),e.bind(b)}):this.length?new A(this[0]):null},scroll:function(a,b,c){return this.each(function(){(new B(this)).scroll(a,b,c)})},scrollTo:function(a,b,d,e){return c.isNumeric(a)&&(e=d,d=b,b=a,a=null),a=o(a),this.each(function(){a?(new B(this)).scrollToElement(a,b,d,e):(new B(this)).scrollTo(b,d,e)})},scrollToThis:function(a,b,c,d){return d=new B(o(d)),d.scrollToElement(this[0],a,b,c),this},softLink:function(a,b,d,e){return e=new B(o(e)),this.filter("a[href^=#]").each(function(){var f=c(this);f.on("click",function(){e.scrollToElement(c(f.attr("href"))[0],a,b,d)})})},sort:function(a,b,d){return l(b,"boolean")||(d=b,b=null),d=o(d),this.pushStack(c.map((new u(this,d)).sorted(a,!b),function(a){return a.el}))},viewport:function(a){return this.length?s.ofViewport(this[0],a):null}},defaultStatic:"fracs",defaultMethod:"fracs"})})(window,document,jQuery)