This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
navi.min.js
8 lines (8 loc) · 7.54 KB
/
navi.min.js
1
2
3
4
5
6
7
8
/*
* jQuery: Navi.js Content Switcher - v1.9.1 - 7/15/2013
* http://navi.grantcr.com
* https://github.com/tgrant54/Navi.js
* Copyright (c) 2013 Tyler Grant
* Dual licensed under the MIT & Creative Commons Attribution-ShareAlike 3.0 Unported License.
*/
;(function(e){e.fn.navi=function(t){this.each(function(){var n=e(this),r=n.data("navi"),i={hash:"#!/",content:e("#content"),contentSubSelector:">ul>li",activeClass:"active",defaultPage:true,useAnimation:true,useBreadCrumbs:true,animationSpeed:100,animationType:"slideUp",usePageTitle:true,defaultPageTitle:"Navi.js",useAjax:true,ajaxExtension:".html",ajaxFolder:"./",init:function(){i.contentSubSelector?true:i.contentSubSelector=">ul>li";i.menu=e(">ul>li",i.me);i.cont=e(i.contentSubSelector,i.content);i.hashLen=i.hash.length;i.defaultPage?location.hash===""?i.loadDefault():false:false;i.setActive()},loadDefault:function(){i.menu.each(function(t,n){if(e(n).hasClass(i.activeClass)){location.hash=e(">a",n).attr("href")}})},setActive:function(t){i.cont.each(function(n,r){if(e(r).attr("id")==location.hash.slice(i.hashLen)&&location.hash.slice(0,i.hashLen)==i.hash){var s;i.useAjax?s=String(i.ajaxFolder+e(r).attr("id")+i.ajaxExtension):false;s?i.useAnimation?e(r).fadeIn(t).load(s,function(){e(r).addClass(i.activeClass).siblings().html("").css("display","none").removeClass(i.activeClass);if(typeof _gaq!=="undefined"&&_gaq!==null){_gaq.push(["_trackPageview",location.hash])}}):e(r).fadeIn(0).load(s,function(){e(r).addClass(i.activeClass).siblings().html("").css("display","none").removeClass(i.activeClass);if(typeof _gaq!=="undefined"&&_gaq!==null){_gaq.push(["_trackPageview",location.hash])}}):i.useAnimation?e(r).fadeIn(t).addClass(i.activeClass).siblings().css("display","none").removeClass(i.activeClass).removeAttr("class"):e(r).fadeIn(0).addClass(i.activeClass).siblings().css("display","none").removeClass(i.activeClass)}});i.useBreadCrumbs?i.setBreadCrumbs():i.menu.each(function(t,n){if(e(">a",n).attr("href")==location.hash){e(n).addClass(i.activeClass).siblings().removeClass(i.activeClass)}});i.setPageTitle()},setPageTitle:function(){if(i.usePageTitle){i.menu.each(function(t,n){if(e(n).hasClass(i.activeClass)){e("title").text(i.defaultPageTitle+e(n).attr("data-title"))}})}},setBreadCrumbs:function(){e("[href]").each(function(t,n){if(e(n).attr("href")==location.hash){e(n).parent().addClass("active").siblings().removeClass("active").removeAttr("class")}})},animation:function(e,t,n){typeof t=="number"?t=t:t=Number(t);switch(e){case"slideUp":i.content.slideUp(t,function(){i.setActive();i.content.slideDown(t,function(){i.content.css("height","")})});break;case"slideUpLeft":i.content.stop().animate({width:"0",height:"0"},t,function(){i.setActive();i.content.stop().animate({width:"100%",height:"100%"},t)});break;case"slideLeft":i.content.stop().animate({width:"0"},t,function(){i.setActive(t);i.content.stop().animate({width:"100%"},t)});break;case"fade":i.content.fadeOut(t,i.setActive).fadeIn(t);break;case"rotateOutDownLeft":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated rotateOutDownLeft");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated rotateOutDownLeft").addClass("animated rotateInUpLeft")});break;case"bounceOutDown":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated bounceOutDown");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated bounceOutDown").addClass("animated bounceInUp")});break;case"bounceOut":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated bounceOut");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated bounceOut").addClass("animated bounceIn")});break;case"lightSpeed":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated lightSpeedOut");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated lightSpeedOut").addClass("animated lightSpeedIn")});break;case"roll":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated rollOut");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated rollOut").addClass("animated rollIn")});break;case"flipX":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated flipOutX").removeClass("flipInX");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated flipOutX").addClass("animated flipInX")});break;case"flipY":i.content.css({"-webkit-animation-duration":Number(t)+"ms","-moz-animation-duration":Number(t)+"ms","-o-animation-duration":Number(t)+"ms","animation-duration":Number(t)+"ms"});i.content.addClass("animated flipOutY").removeClass("flipInY");i.content.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(e){i.setActive();i.content.removeClass("animated flipOutY").addClass("animated flipInY")});break}}};r?i=r:n.data({navi:i});if(typeof t=="object"){e.extend(i,t)}i.me||i.init(i.me=n);if("onhashchange"in window){window.onhashchange=function(){var e=location.hash;i.useAnimation?i.animation(i.animationType,i.animationSpeed):false}}else{(function(e,t,n){function f(e){e=e||location.href;return"#"+e.replace(/^[^#]*#?(.*)$/,"$1")}var r="hashchange",i=document,s,o=e.event.special,u=i.documentMode,a="on"+r in t&&(u===n||u>7);e.fn[r]=function(e){return e?this.bind(r,e):this.trigger(r)};e.fn[r].delay=50;o[r]=e.extend(o[r],{setup:function(){if(a){return false}e(s.start)},teardown:function(){if(a){return false}e(s.stop)}});s=function(){function m(){var n=f(),i=v(u);if(n!==u){p(u=n,i);e(t).trigger(r)}else{if(i!==u){location.href=location.href.replace(/#.*/,"")+i}}o=setTimeout(m,e.fn[r].delay)}var s={},o,u=f(),l=function(e){return e},p=l,v=l;s.start=function(){o||m()};s.stop=function(){o&&clearTimeout(o);o=n};e.browser.msie&&!a&&function(){var t,n;s.start=function(){if(!t){n=e.fn[r].src;n=n&&n+f();t=e('<iframe tabindex="-1" title="empty"/>').hide().one("load",function(){n||p(f());m()}).attr("src",n||"javascript:0").insertAfter("body")[0].contentWindow;i.onpropertychange=function(){try{if(event.propertyName==="title"){t.document.title=i.title}}catch(e){}}}};s.stop=l;v=function(){return f(t.location.href)};p=function(n,s){var o=t.document,u=e.fn[r].domain;if(n!==s){o.title=i.title;o.open();u&&o.write('<script>document.domain="'+u+'"</script>');o.close();t.location.hash=n}}}();return s}()})(jQuery,this);e(window).hashchange(function(){location.hash.slice(0,i.hashLen)==i.hash?i.useAnimation?i.animation(i.animationType,i.animationSpeed,location.hash):i.setActive():false})}});return this}})(jQuery)