github.com/jbking/gohan@v0.0.0-20151217002006-b41ccf1c2a96/docs/source/_templates/cloudwan/static/js/theme.js (about) 1 require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"sphinx-rtd-theme":[function(require,module,exports){ 2 var jQuery = (typeof(window) != 'undefined') ? window.jQuery : require('jquery'); 3 4 // Sphinx theme nav state 5 function ThemeNav () { 6 7 var nav = { 8 navBar: null, 9 win: null, 10 winScroll: false, 11 winResize: false, 12 linkScroll: false, 13 winPosition: 0, 14 winHeight: null, 15 docHeight: null, 16 isRunning: null 17 }; 18 19 nav.enable = function () { 20 var self = this; 21 22 jQuery(function ($) { 23 self.init($); 24 25 self.reset(); 26 self.win.on('hashchange', self.reset); 27 28 // Set scroll monitor 29 self.win.on('scroll', function () { 30 if (!self.linkScroll) { 31 self.winScroll = true; 32 } 33 }); 34 setInterval(function () { if (self.winScroll) self.onScroll(); }, 25); 35 36 // Set resize monitor 37 self.win.on('resize', function () { 38 self.winResize = true; 39 }); 40 setInterval(function () { if (self.winResize) self.onResize(); }, 25); 41 self.onResize(); 42 }); 43 }; 44 45 nav.init = function ($) { 46 var doc = $(document), 47 self = this; 48 49 this.navBar = $('div.wy-side-scroll:first'); 50 this.win = $(window); 51 52 // Set up javascript UX bits 53 $(document) 54 // Shift nav in mobile when clicking the menu. 55 .on('click', "[data-toggle='wy-nav-top']", function() { 56 $("[data-toggle='wy-nav-shift']").toggleClass("shift"); 57 $("[data-toggle='rst-versions']").toggleClass("shift"); 58 }) 59 60 // Nav menu link click operations 61 .on('click', ".wy-menu-vertical .current ul li a", function() { 62 var target = $(this); 63 // Close menu when you click a link. 64 $("[data-toggle='wy-nav-shift']").removeClass("shift"); 65 $("[data-toggle='rst-versions']").toggleClass("shift"); 66 // Handle dynamic display of l3 and l4 nav lists 67 self.toggleCurrent(target); 68 self.hashChange(); 69 }) 70 .on('click', "[data-toggle='rst-current-version']", function() { 71 $("[data-toggle='rst-versions']").toggleClass("shift-up"); 72 }) 73 74 // Make tables responsive 75 $("table.docutils:not(.field-list)") 76 .wrap("<div class='wy-table-responsive'></div>"); 77 78 // Add expand links to all parents of nested ul 79 $('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () { 80 var link = $(this); 81 expand = $('<span class="toctree-expand"></span>'); 82 expand.on('click', function (ev) { 83 self.toggleCurrent(link); 84 ev.stopPropagation(); 85 return false; 86 }); 87 link.prepend(expand); 88 }); 89 }; 90 91 nav.reset = function () { 92 // Get anchor from URL and open up nested nav 93 var anchor = encodeURI(window.location.hash); 94 if (anchor) { 95 try { 96 var link = $('.wy-menu-vertical') 97 .find('[href="' + anchor + '"]'); 98 $('.wy-menu-vertical li.toctree-l1 li.current') 99 .removeClass('current'); 100 link.closest('li.toctree-l2').addClass('current'); 101 link.closest('li.toctree-l3').addClass('current'); 102 link.closest('li.toctree-l4').addClass('current'); 103 } 104 catch (err) { 105 console.log("Error expanding nav for anchor", err); 106 } 107 } 108 }; 109 110 nav.onScroll = function () { 111 this.winScroll = false; 112 var newWinPosition = this.win.scrollTop(), 113 winBottom = newWinPosition + this.winHeight, 114 navPosition = this.navBar.scrollTop(), 115 newNavPosition = navPosition + (newWinPosition - this.winPosition); 116 if (newWinPosition < 0 || winBottom > this.docHeight) { 117 return; 118 } 119 this.navBar.scrollTop(newNavPosition); 120 this.winPosition = newWinPosition; 121 }; 122 123 nav.onResize = function () { 124 this.winResize = false; 125 this.winHeight = this.win.height(); 126 this.docHeight = $(document).height(); 127 }; 128 129 nav.hashChange = function () { 130 this.linkScroll = true; 131 this.win.one('hashchange', function () { 132 this.linkScroll = false; 133 }); 134 }; 135 136 nav.toggleCurrent = function (elem) { 137 var parent_li = elem.closest('li'); 138 parent_li.siblings('li.current').removeClass('current'); 139 parent_li.siblings().find('li.current').removeClass('current'); 140 parent_li.find('> ul li.current').removeClass('current'); 141 parent_li.toggleClass('current'); 142 } 143 144 return nav; 145 }; 146 147 module.exports.ThemeNav = ThemeNav(); 148 149 if (typeof(window) != 'undefined') { 150 window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav }; 151 } 152 153 },{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);