mirror of https://github.com/istio/istio.io.git
1 line
3.1 KiB
JavaScript
1 line
3.1 KiB
JavaScript
function setupTabs(n){n=n||document;var i=$(n).find("div.tabs");i.length>0&&i.tabs()}$(document).ready(function(){var n=$(window),i=0;n.scroll(function(){var n=$(this).scrollTop();n>i?$("#sticky-nav").visible()&&$("#sticky-nav").removeClass("on-page"):$(".nav-hero-container").visible(!0)&&$("#sticky-nav").visible()?$("#sticky-nav").removeClass("on-page"):$(".nav-hero-container").visible(!0)||$("#sticky-nav").addClass("on-page"),i=n}),$(".toc").click(function(){setTimeout(function(){$("#sticky-nav").addClass("on-page")},1e3)}),setTimeout(function(){-1!=document.URL.indexOf("#")&&-1==document.URL.indexOf("contribute")&&$("#sticky-nav").addClass("on-page")},1e3),$(".btn-floating").on("click",function(){$("html, body").scrollTo("#"+$(this).data("target"),350)}),$("#toc").toc({listType:"ul"}),$(".nav-toggle, .hamburger").on("click",function(){$(".top-nav").toggleClass("right")}),$(".nav-doc-toggle").on("click",function(){$(".doc-list").toggleClass("active")}),$(window).on("resize",function(){$(window).width()>=768&&!$(".top-nav").hasClass("right")&&$(".top-nav").addClass("right")}),$(".toggle").on("click",function(){$(this).toggleClass("active")}),$(".hero-down-arrow").on("click",function(){var n=$(".hero-wrapper:eq(0)").position().top;$("html,body").animate({scrollTop:n},300)}),window.Prism&&window.Prism.hooks.add("complete",function(n){var i=$(n.element).closest("pre"),o=$('<div class="code-block">');i.wrap(o)})}),$.getScript("/v0.4/js/jquery.collapsible.min.js",function(){highlightActive(),$(".submenu").collapsible()}),function(n){n.fn.toc=function(o){function e(n){return encodeURIComponent(n).replace(/[!'()*]/g,function(n){return"%"+n.charCodeAt(0).toString(16)})}var t={noBackToTopLinks:!1,title:"",minimumHeaders:2,headers:"h2, h3, h4, h5, h6",listType:"ol",showEffect:"none",showSpeed:"0"},a=n.extend(t,o),s=n(a.headers).filter(function(){var i=n(this).prev().attr("name");return!this.id&&i&&(this.id=n(this).attr("id",i.replace(/\./g,"-"))),this.id}),c=n(this);if(s.length&&!(s.length<a.minimumHeaders)&&c.length){0===a.showSpeed&&(a.showEffect="none");var l,r={show:function(){n("#toc").addClass("toc"),c.hide().html(p).show(a.showSpeed)},slideDown:function(){c.hide().html(p).slideDown(a.showSpeed)},fadeIn:function(){c.hide().html(p).fadeIn(a.showSpeed)},none:function(){c.html(p)}},d=function(n){return parseInt(n.nodeName.replace("H",""),10)},h=s.map(function(n,i){return d(i)}).get().sort()[0],f='<i class="icon-arrow-up back-to-top"> </i>',u=d(s[0]),p=a.title+" <"+a.listType+">";s.on("click",function(){a.noBackToTopLinks||(window.location.hash=this.id)}).addClass("clickable-header").each(function(o,t){if(l=d(t),a.noBackToTopLinks||l!==h||n(t).addClass("top-level-header").after(f),l===u)p+="<li><a href='#"+e(t.id)+"'>"+t.innerHTML+"</a>";else if(u>=l){for(i=l;i<u;i++)p+="</li></"+a.listType+">";p+="<li><a href='#"+e(t.id)+"'>"+t.innerHTML+"</a>"}else if(l>u){for(i=l;i>u;i--)p+="<"+a.listType+"><li>";p+="<a href='#"+e(t.id)+"'>"+t.innerHTML+"</a>"}u=l}),p+="</"+a.listType+">",a.noBackToTopLinks||n(document).on("click",".back-to-top",function(){n(window).scrollTop(0),window.location.hash=""}),r[a.showEffect]()}}}(jQuery); |