Template:Montgomery Cougars NJUSA/Common JS

From 2014hs.igem.org

Revision as of 06:57, 20 June 2014 by Casey.chow (Talk | contribs)
$(document).ready(function(){if($("p").filter(function(){return""==$.trim($(this).html())}).remove(),$("br:only-child").remove(),0!=$("#slider").length&&($(".generic-image").remove(),$("#slider").unslider({delay:3250,fluid:!0})),0!=$("#toc").length){$("#toc").remove(),$("body").addClass("with-toc");{$('
').prependTo("#main").toc({container:"#inner-content",headerText:function(t,e,i){return i.text().replace(/\[edit\]/g,"")},selectors:"h1, h2"})}$("#jqtoc > ul").stickySidebar({breakingPoint1:401,contentSelector:"#inner-content",footerThreshold:150,sidebarTopMargin:0})}}),function(t,e){if(!t)return e;var i=function(){this.el=e,this.items=e,this.sizes=[],this.max=[0,0],this.current=0,this.interval=e,this.opts={speed:500,delay:3e3,complete:e,keys:!e,dots:e,fluid:e};var i=this;this.init=function(e,i){return this.el=e,this.ul=e.children("ul"),this.max=[e.outerWidth(),e.outerHeight()],this.items=this.ul.children("li").each(this.calculate),this.opts=t.extend(this.opts,i),this.setup(),this},this.calculate=function(e){var s=t(this),n=s.outerWidth(),o=s.outerHeight();i.sizes[e]=[n,o],n>i.max[0]&&(i.max[0]=n),o>i.max[1]&&(i.max[1]=o)},this.setup=function(){if(this.el.css({overflow:"hidden",width:i.max[0],height:this.items.first().outerHeight()}),this.ul.css({width:100*this.items.length+"%",position:"relative"}),this.items.css("width",100/this.items.length+"%"),this.opts.delay!==e&&(this.start(),this.el.hover(this.stop,this.start)),this.opts.keys&&t(document).keydown(this.keys),this.opts.dots&&this.dots(),this.opts.fluid){var s=function(){i.el.css("width",Math.min(Math.round(i.el.outerWidth()/i.el.parent().outerWidth()*100),100)+"%")};s(),t(window).resize(s)}this.opts.arrows&&this.el.parent().append('

←→

').find(".arrows span").click(function(){t.isFunction(i[this.className])&&i[this.className]()}),t.event.swipe&&this.el.on("swipeleft",i.prev).on("swiperight",i.next)},this.move=function(e,s){this.items.eq(e).length||(e=0),0>e&&(e=this.items.length-1);var n=this.items.eq(e),o={height:n.outerHeight()},r=s?5:this.opts.speed;this.ul.is(":animated")||(i.el.find(".dot:eq("+e+")").addClass("active").siblings().removeClass("active"),this.el.animate(o,r)&&this.ul.animate(t.extend({left:"-"+e+"00%"},o),r,function(){i.current=e,t.isFunction(i.opts.complete)&&!s&&i.opts.complete(i.el)}))},this.start=function(){i.interval=setInterval(function(){i.move(i.current+1)},i.opts.delay)},this.stop=function(){return i.interval=clearInterval(i.interval),i},this.keys=function(e){var s=e.which,n={37:i.prev,39:i.next,27:i.stop};t.isFunction(n[s])&&n[s]()},this.next=function(){return i.stop().move(i.current+1)},this.prev=function(){return i.stop().move(i.current-1)},this.dots=function(){var e='
    ';t.each(this.items,function(t){e+='
  1. t?" active":"")+'">'+(t+1)+"
  2. "}),e+="
",this.el.addClass("has-dots").append(e).find(".dot").click(function(){i.move(t(this).index())})}};t.fn.unslider=function(e){var s=this.length;return this.each(function(n){var o=t(this),r=(new i).init(o,e);o.data("unslider"+(s>1?"-"+(n+1):""),r)})}}(window.jQuery,!1),function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(t){function e(t){var e,i,s;e=t.currentTarget.offsetWidth,i=t.currentTarget.offsetHeight,s={distX:t.distX,distY:t.distY,velocityX:t.velocityX,velocityY:t.velocityY,finger:t.finger},t.distX>t.distY?t.distX>-t.distY?(t.distX/e>r.threshold||t.velocityX*t.distX/e*r.sensitivity>1)&&(s.type="swiperight",o(t.currentTarget,s)):(-t.distY/i>r.threshold||t.velocityY*t.distY/e*r.sensitivity>1)&&(s.type="swipeup",o(t.currentTarget,s)):t.distX>-t.distY?(t.distY/i>r.threshold||t.velocityY*t.distY/e*r.sensitivity>1)&&(s.type="swipedown",o(t.currentTarget,s)):(-t.distX/e>r.threshold||t.velocityX*t.distX/e*r.sensitivity>1)&&(s.type="swipeleft",o(t.currentTarget,s))}function i(e){var i=t.data(e,"event_swipe");return i||(i={count:0},t.data(e,"event_swipe",i)),i}var s=t.event.add,n=t.event.remove,o=function(e,i,s){t.event.trigger(i,s,e)},r={threshold:.4,sensitivity:6};t.event.special.swipe=t.event.special.swipeleft=t.event.special.swiperight=t.event.special.swipeup=t.event.special.swipedown={setup:function(t){var t=i(this);if(!(t.count++>0))return s(this,"moveend",e),!0},teardown:function(){var t=i(this);if(!(--t.count>0))return n(this,"moveend",e),!0},settings:r}}),!function(t){t.fn.smoothScroller=function(e){e=t.extend({},t.fn.smoothScroller.defaults,e);var i=t(this);return t(e.scrollEl).animate({scrollTop:i.offset().top-t(e.scrollEl).offset().top-e.offset},e.speed,e.ease,function(){var t=i.attr("id");t.length&&(history.pushState?history.pushState(null,null,"#"+t):document.location.hash=t),i.trigger("smoothScrollerComplete")}),this},t.fn.smoothScroller.defaults={speed:400,ease:"swing",scrollEl:"body,html",offset:0},t("body").on("click","[data-smoothscroller]",function(e){e.preventDefault();var i=t(this).attr("href");0===i.indexOf("#")&&t(i).smoothScroller()})}(jQuery),function(t){var e={};t.fn.toc=function(e){var i,s=this,n=t.extend({},jQuery.fn.toc.defaults,e),o=t(n.container),r=t(n.selectors,o),l=[],a=n.activeClass,h=function(e,i){if(n.smoothScrolling&&"function"==typeof n.smoothScrolling){e.preventDefault();var o=t(e.target).attr("href");n.smoothScrolling(o,n,i)}t("li",s).removeClass(a),t(e.target).parent().addClass(a)},c=function(){i&&clearTimeout(i),i=setTimeout(function(){for(var e,i=t(window).scrollTop(),o=Number.MAX_VALUE,r=0,h=0,c=l.length;c>h;h++){var d=Math.abs(l[h]-i);o>d&&(r=h,o=d)}t("li",s).removeClass(a),e=t("li:eq("+r+")",s).addClass(a),n.onHighlight(e)},50)};return n.highlightOnScroll&&(t(window).bind("scroll",c),c()),this.each(function(){var e=t(this),i=t(n.listType);r.each(function(s,o){var r=t(o);l.push(r.offset().top-n.highlightOffset);var a=n.anchorName(s,o,n.prefix);o.id!==a&&t("<span/>").attr("id",a).insertBefore(r);var d=t("<a/>").text(n.headerText(s,o,r)).attr("href","#"+a).bind("click",function(i){t(window).unbind("scroll",c),h(i,function(){t(window).bind("scroll",c)}),e.trigger("selected",t(this).attr("href"))}),u=t("
  • ").addClass(n.itemClass(s,o,r,n.prefix)).append(d);i.append(u)}),e.html(i)})},jQuery.fn.toc.defaults={container:"body",listType:"<ul/>",selectors:"h1,h2,h3",smoothScrolling:function(e,i,s){t(e).smoothScroller({offset:i.scrollToOffset}).on("smoothScrollerComplete",function(){s()})},scrollToOffset:0,prefix:"toc",activeClass:"toc-active",onHighlight:function(){},highlightOnScroll:!0,highlightOffset:100,anchorName:function(i,s,n){if(s.id.length)return s.id;var o=t(s).text().replace(/[^a-z0-9]/gi," ").replace(/\s+/g,"-").toLowerCase();if(e[o]){for(var r=2;e[o+r];)r++;o=o+"-"+r}return e[o]=!0,n+"-"+o},headerText:function(t,e,i){return i.text()},itemClass:function(t,e,i,s){return s+"-"+i[0].tagName.toLowerCase()}}}(jQuery),function(t){t.fn.stickySidebar=function(e){var i=t.extend({headerSelector:"header",navSelector:"nav",contentSelector:"#content",footerSelector:"footer",sidebarTopMargin:20,footerThreshold:40},e),s=function(){var e=t(this),s=t(window).height(),n=(t(window).width(),t(document).height()),o=t(i.headerSelector).outerHeight(),r=t(i.navSelector).outerHeight(),l=e.outerHeight(),a=t(i.contentSelector).outerHeight(),h=t(i.footerSelector).outerHeight(),c=t(window).scrollTop(),d=i.breakingPoint1||o+r,u=n-(l+h+i.footerThreshold);if(a>l&&s>l)if(d>c)e.removeClass("sticky");else if(c>=d&&u>c)e.addClass("sticky").css("top",i.sidebarTopMargin);else{var f=u-c;e.addClass("sticky").css("top",f)}};return this.each(function(){t(window).on("scroll",t.proxy(s,this)),t(window).on("resize",t.proxy(s,this)),t.proxy(s,this)()})}}(jQuery);