blob: 081d77bdf4a9785394aee0eca20b63cfbb75ddbb [file] [log] [blame]
Master Yodac25d56f2015-09-21 07:17:40 -07001$(document).ready(function () {
David Wosnitza25be1422014-12-12 15:37:28 +01002 // Shift nav in mobile when clicking the menu.
Master Yodac25d56f2015-09-21 07:17:40 -07003 $(document).on('click', "[data-toggle='wy-nav-top']", function () {
4 $("[data-toggle='wy-nav-shift']").toggleClass("shift");
5 $("[data-toggle='rst-versions']").toggleClass("shift");
David Wosnitza25be1422014-12-12 15:37:28 +01006 });
7 // Close menu when you click a link.
Master Yodac25d56f2015-09-21 07:17:40 -07008 $(document).on('click', ".wy-menu-vertical .current ul li a", function () {
9 $("[data-toggle='wy-nav-shift']").removeClass("shift");
10 $("[data-toggle='rst-versions']").toggleClass("shift");
David Wosnitza25be1422014-12-12 15:37:28 +010011 });
Master Yodac25d56f2015-09-21 07:17:40 -070012 $(document).on('click', "[data-toggle='rst-current-version']", function () {
13 $("[data-toggle='rst-versions']").toggleClass("shift-up");
14 });
David Wosnitza25be1422014-12-12 15:37:28 +010015 // Make tables responsive
Master Yodac25d56f2015-09-21 07:17:40 -070016 $("table.docutils:not(.field-list)").wrap("<div class='wy-table-responsive'></div>");
17 // ---
18 // START DOC MODIFICATION BY RUFNEX
19 // v1.0 04.02.2015
20 // Add ToogleButton to get FullWidth-View by Johannes Gamperl codeigniter.de
Master Yodac25d56f2015-09-21 07:17:40 -070021
Master Yodac25d56f2015-09-21 07:17:40 -070022 $('#openToc').click(function () {
23 $('#nav').slideToggle();
24 });
Master Yodac25d56f2015-09-21 07:17:40 -070025 $('#closeMe').toggle(
Andrey Andreevb079ae92015-10-02 16:50:04 +030026 function ()
27 {
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070028 setCookie('ciNav', 'yes', 365);
Andrey Andreevb079ae92015-10-02 16:50:04 +030029 $('#nav2').show();
30 $('#topMenu').remove();
31 $('body').css({background: 'none'});
32 $('.wy-nav-content-wrap').css({background: 'none', 'margin-left': 0});
33 $('.wy-breadcrumbs').append('<div style="float:right;"><div style="float:left;" id="topMenu">' + $('.wy-form').parent().html() + '</div></div>');
34 $('.wy-nav-side').toggle();
35 },
36 function ()
37 {
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070038 setCookie('ciNav', 'no', 365);
Andrey Andreevb079ae92015-10-02 16:50:04 +030039 $('#topMenu').remove();
40 $('#nav').hide();
41 $('#nav2').hide();
42 $('body').css({background: '#edf0f2;'});
43 $('.wy-nav-content-wrap').css({background: 'none repeat scroll 0 0 #fcfcfc;', 'margin-left': '300px'});
44 $('.wy-nav-side').show();
45 }
Master Yodac25d56f2015-09-21 07:17:40 -070046 );
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070047 if (getCookie('ciNav') == 'yes')
Master Yodac25d56f2015-09-21 07:17:40 -070048 {
49 $('#closeMe').trigger('click');
50 //$('#nav').slideToggle();
51 }
52 // END MODIFICATION ---
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070053
David Wosnitza25be1422014-12-12 15:37:28 +010054});
55
jim7efcd702015-02-04 14:23:33 -080056// Rufnex Cookie functions
Master Yodac25d56f2015-09-21 07:17:40 -070057function setCookie(cname, cvalue, exdays) {
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070058 // expire the old cookie if existed to avoid multiple cookies with the same name
59 if (getCookie(cname)) {
60 document.cookie = cname + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
61 }
jim7efcd702015-02-04 14:23:33 -080062 var d = new Date();
Master Yodac25d56f2015-09-21 07:17:40 -070063 d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
jim7efcd702015-02-04 14:23:33 -080064 var expires = "expires=" + d.toGMTString();
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070065 document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
jim7efcd702015-02-04 14:23:33 -080066}
67function getCookie(cname) {
68 var name = cname + "=";
69 var ca = document.cookie.split(';');
Master Yodac25d56f2015-09-21 07:17:40 -070070 for (var i = 0; i < ca.length; i++) {
jim7efcd702015-02-04 14:23:33 -080071 var c = ca[i];
Master Yodac25d56f2015-09-21 07:17:40 -070072 while (c.charAt(0) == ' ')
73 c = c.substring(1);
jim7efcd702015-02-04 14:23:33 -080074 if (c.indexOf(name) == 0) {
75 return c.substring(name.length, c.length);
76 }
77 }
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070078 return '';
jim7efcd702015-02-04 14:23:33 -080079}
80// End
81
Instructor, Computer Systems Technology29b90f72015-10-21 06:10:32 -070082// resize window
83$(window).on('resize', function(){
84 // show side nav on small screens when pulldown is enabled
85 if (getCookie('ciNav') == 'yes' && $(window).width() <= 768) { // 768px is the tablet size defined by the theme
86 $('.wy-nav-side').show();
87 }
88 // changing css with jquery seems to override the default css media query
89 // change margin
90 else if (getCookie('ciNav') == 'no' && $(window).width() <= 768) {
91 $('.wy-nav-content-wrap').css({'margin-left': 0});
92 }
93 // hide side nav on large screens when pulldown is enabled
94 else if (getCookie('ciNav') == 'yes' && $(window).width() > 768) {
95 $('.wy-nav-side').hide();
96 }
97 // change margin
98 else if (getCookie('ciNav') == 'no' && $(window).width() > 768) {
99 $('.wy-nav-content-wrap').css({'margin-left': '300px'});
100 }
101});
102
David Wosnitza25be1422014-12-12 15:37:28 +0100103window.SphinxRtdTheme = (function (jquery) {
104 var stickyNav = (function () {
105 var navBar,
Master Yodac25d56f2015-09-21 07:17:40 -0700106 win,
107 stickyNavCssClass = 'stickynav',
108 applyStickNav = function () {
109 if (navBar.height() <= win.height()) {
110 navBar.addClass(stickyNavCssClass);
111 } else {
112 navBar.removeClass(stickyNavCssClass);
113 }
114 },
115 enable = function () {
116 applyStickNav();
117 win.on('resize', applyStickNav);
118 },
119 init = function () {
120 navBar = jquery('nav.wy-nav-side:first');
121 win = jquery(window);
122 };
David Wosnitza25be1422014-12-12 15:37:28 +0100123 jquery(init);
124 return {
Master Yodac25d56f2015-09-21 07:17:40 -0700125 enable: enable
David Wosnitza25be1422014-12-12 15:37:28 +0100126 };
127 }());
128 return {
Master Yodac25d56f2015-09-21 07:17:40 -0700129 StickyNav: stickyNav
David Wosnitza25be1422014-12-12 15:37:28 +0100130 };
131}($));