af661a92365ad3372f06255b49ebea173a643c56
[babeltrace.git] / doc / bindings / python / source / _themes / sphinx_rtd_theme / static / js / theme.js
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: false
17 };
18
19 nav.enable = function () {
20 var self = this;
21
22 if (!self.isRunning) {
23 self.isRunning = true;
24 jQuery(function ($) {
25 self.init($);
26
27 self.reset();
28 self.win.on('hashchange', self.reset);
29
30 // Set scroll monitor
31 self.win.on('scroll', function () {
32 if (!self.linkScroll) {
33 self.winScroll = true;
34 }
35 });
36 setInterval(function () { if (self.winScroll) self.onScroll(); }, 25);
37
38 // Set resize monitor
39 self.win.on('resize', function () {
40 self.winResize = true;
41 });
42 setInterval(function () { if (self.winResize) self.onResize(); }, 25);
43 self.onResize();
44 });
45 };
46 };
47
48 nav.init = function ($) {
49 var doc = $(document),
50 self = this;
51
52 this.navBar = $('div.wy-side-scroll:first');
53 this.win = $(window);
54
55 // Set up javascript UX bits
56 $(document)
57 // Shift nav in mobile when clicking the menu.
58 .on('click', "[data-toggle='wy-nav-top']", function() {
59 $("[data-toggle='wy-nav-shift']").toggleClass("shift");
60 $("[data-toggle='rst-versions']").toggleClass("shift");
61 })
62
63 // Nav menu link click operations
64 .on('click', ".wy-menu-vertical .current ul li a", function() {
65 var target = $(this);
66 // Close menu when you click a link.
67 $("[data-toggle='wy-nav-shift']").removeClass("shift");
68 $("[data-toggle='rst-versions']").toggleClass("shift");
69 // Handle dynamic display of l3 and l4 nav lists
70 self.toggleCurrent(target);
71 self.hashChange();
72 })
73 .on('click', "[data-toggle='rst-current-version']", function() {
74 $("[data-toggle='rst-versions']").toggleClass("shift-up");
75 })
76
77 // Make tables responsive
78 $("table.docutils:not(.field-list)")
79 .wrap("<div class='wy-table-responsive'></div>");
80
81 // Add expand links to all parents of nested ul
82 $('.wy-menu-vertical ul').not('.simple').siblings('a').each(function () {
83 var link = $(this);
84 expand = $('<span class="toctree-expand"></span>');
85 expand.on('click', function (ev) {
86 self.toggleCurrent(link);
87 ev.stopPropagation();
88 return false;
89 });
90 link.prepend(expand);
91 });
92 };
93
94 nav.reset = function () {
95 // Get anchor from URL and open up nested nav
96 var anchor = encodeURI(window.location.hash);
97 if (anchor) {
98 try {
99 var link = $('.wy-menu-vertical')
100 .find('[href="' + anchor + '"]');
101 // If we didn't find a link, it may be because we clicked on
102 // something that is not in the sidebar (eg: when using
103 // sphinxcontrib.httpdomain it generates headerlinks but those
104 // aren't picked up and placed in the toctree). So let's find
105 // the closest header in the document and try with that one.
106 if (link.length === 0) {
107 var doc_link = $('.document a[href="' + anchor + '"]');
108 var closest_section = doc_link.closest('div.section');
109 // Try again with the closest section entry.
110 link = $('.wy-menu-vertical')
111 .find('[href="#' + closest_section.attr("id") + '"]');
112
113 }
114 $('.wy-menu-vertical li.toctree-l1 li.current')
115 .removeClass('current');
116 link.closest('li.toctree-l2').addClass('current');
117 link.closest('li.toctree-l3').addClass('current');
118 link.closest('li.toctree-l4').addClass('current');
119 }
120 catch (err) {
121 console.log("Error expanding nav for anchor", err);
122 }
123 }
124 };
125
126 nav.onScroll = function () {
127 this.winScroll = false;
128 var newWinPosition = this.win.scrollTop(),
129 winBottom = newWinPosition + this.winHeight,
130 navPosition = this.navBar.scrollTop(),
131 newNavPosition = navPosition + (newWinPosition - this.winPosition);
132 if (newWinPosition < 0 || winBottom > this.docHeight) {
133 return;
134 }
135 this.navBar.scrollTop(newNavPosition);
136 this.winPosition = newWinPosition;
137 };
138
139 nav.onResize = function () {
140 this.winResize = false;
141 this.winHeight = this.win.height();
142 this.docHeight = $(document).height();
143 };
144
145 nav.hashChange = function () {
146 this.linkScroll = true;
147 this.win.one('hashchange', function () {
148 this.linkScroll = false;
149 });
150 };
151
152 nav.toggleCurrent = function (elem) {
153 var parent_li = elem.closest('li');
154 parent_li.siblings('li.current').removeClass('current');
155 parent_li.siblings().find('li.current').removeClass('current');
156 parent_li.find('> ul li.current').removeClass('current');
157 parent_li.toggleClass('current');
158 }
159
160 return nav;
161 };
162
163 module.exports.ThemeNav = ThemeNav();
164
165 if (typeof(window) != 'undefined') {
166 window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav };
167 }
168
169 },{"jquery":"jquery"}]},{},["sphinx-rtd-theme"]);
This page took 0.037399 seconds and 4 git commands to generate.