/*! * Visual Navigation (visualNav) v2.5.2 * https://github.com/Mottie/visualNav/wiki * by Rob Garrison (Mottie) * MIT licensed. */ ;(function(c){c.visualNav=function(h,k){var b,a=this;a.$el=c(h);a.$el.data("visualNav",a);a.init=function(){var d;a.initialized=!1;a.options=b=c.extend({},c.visualNav.defaultOptions,k);a.winLoc=window.location;a.history="replaceState"in window.history?window.history:null;a.$win=c(window);a.$doc=c(document);a.$body=c("html, body");a.curHash="";a.$lastItem=[null];a.namespace=".visualNav";c.each(b.easing,function(a,d){c.isFunction(c.easing[d])||(b.easing[a]="swing")});b.stopOnInteraction&&a.$body.bind("scroll mousedown DOMMouseScroll mousewheel keyup ".split(" ").join(a.namespace+ " "),function(b){(0").css({position:"absolute",visibility:"hidden",top:c(document).scrollTop()+"px"}).attr("id",f).appendTo(document.body)),a.setHash("#"+f),e.length&&(d.remove(),e.attr("id",f)))};a.setHash=function(b){a.winLoc.hash!==b&&"#"!==b&&(a.winLoc.replace?null!==a.history?a.history.replaceState({},"",b):a.winLoc.replace(b):a.winLoc.hash=b)};a.completed= function(c){b.useHash&&a.setHash("#"+a.curHash);a.initialized?"function"===typeof b.complete&&b.complete(a,a.$curContent):c&&("function"===typeof b.initialized&&b.initialized(a,a.$curContent),a.initialized=!0);a.flag=!1};a.findLocation=function(){var d,e,f,g,l,h,k,p,m=a.$win.width(),q=a.$win.scrollLeft(),r=a.$win.scrollTop(),t=q+m,n=r+a.$win.height(),u=a.$doc.height();a.$items.removeClass(b.inViewClass);b.fitContent&&a.$content.width(m-a.leftMargin-a.rightMargin);a.$links.each(function(m){g=c(this).attr(b.targetAttr); d="#"===g||1>=g.length?"":c(g);d.length&&(f=Math.ceil(d.offset().top),e=Math.ceil(d.offset().left),h=d.outerHeight(),l=f+h+b.bottomMargin,k=d.outerWidth(),p=e+k,fr||l>n)&&eq||p>t)&&a.$items.eq(m).addClass(b.inViewClass))});g=n+b.bottomMargin>=u?":last":":first";a.$items.removeClass(b.selectedClass);a.$curItem=a.$items.filter("."+b.inViewClass+g).addClass(b.selectedClass);a.$curItem[0]!==a.$lastItem[0]&&(a.$lastItem=a.$curItem,a.$content.removeClass(b.currentContent), g="."+b.selectedClass+(b.selectedAppliedTo===b.link?"":" "+b.link),d=a.$el.find(g).attr(b.targetAttr),a.$curContent=c(d).closest("."+b.contentClass).addClass(b.currentContent),a.initialized&&"function"===typeof b.changed&&b.changed(a,a.$curContent));b.useHash&&a.initialized&&a.updateHash()};a.init()};c.visualNav.defaultOptions={link:"a",targetAttr:"href",selectedAppliedTo:"li",contentClass:"content",contentLinks:"visualNav",externalLinks:"external",useHash:!0,inViewClass:"inView",selectedClass:"selected", currentContent:"current",bottomMargin:100,fitContent:!1,offsetTop:0,scrollOnInit:!1,animationTime:1200,stopOnInteraction:!0,easing:["swing","swing"],initialized:null,beforeAnimation:null,complete:null,changed:null};c.fn.visualNav=function(h){return this.each(function(){var k=c(this).data("visualNav");(typeof h).match("object|undefined")?k?k.update():new c.visualNav(this,h):"string"===typeof h&&/^(#|\.)/.test(h)&&k.animate(h)})};c.fn.getvisualNav=function(){return this.data("visualNav")}})(jQuery);