Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 1 | $(document).ready(function () { |
David Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 2 | // Shift nav in mobile when clicking the menu. |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 3 | $(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 Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 6 | }); |
| 7 | // Close menu when you click a link. |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 8 | $(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 Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 11 | }); |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 12 | $(document).on('click', "[data-toggle='rst-current-version']", function () { |
| 13 | $("[data-toggle='rst-versions']").toggleClass("shift-up"); |
| 14 | }); |
David Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 15 | // Make tables responsive |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 16 | $("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 Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 21 | |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 22 | $('#openToc').click(function () { |
| 23 | $('#nav').slideToggle(); |
| 24 | }); |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 25 | $('#closeMe').toggle( |
Andrey Andreev | b079ae9 | 2015-10-02 16:50:04 +0300 | [diff] [blame] | 26 | function () |
| 27 | { |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 28 | setCookie('ciNav', 'yes', 365); |
Andrey Andreev | b079ae9 | 2015-10-02 16:50:04 +0300 | [diff] [blame] | 29 | $('#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 Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 38 | setCookie('ciNav', 'no', 365); |
Andrey Andreev | b079ae9 | 2015-10-02 16:50:04 +0300 | [diff] [blame] | 39 | $('#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 Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 46 | ); |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 47 | if (getCookie('ciNav') == 'yes') |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 48 | { |
| 49 | $('#closeMe').trigger('click'); |
| 50 | //$('#nav').slideToggle(); |
| 51 | } |
| 52 | // END MODIFICATION --- |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 53 | |
David Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 54 | }); |
| 55 | |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 56 | // Rufnex Cookie functions |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 57 | function setCookie(cname, cvalue, exdays) { |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 58 | // 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 | } |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 62 | var d = new Date(); |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 63 | d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 64 | var expires = "expires=" + d.toGMTString(); |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 65 | document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/"; |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 66 | } |
| 67 | function getCookie(cname) { |
| 68 | var name = cname + "="; |
| 69 | var ca = document.cookie.split(';'); |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 70 | for (var i = 0; i < ca.length; i++) { |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 71 | var c = ca[i]; |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 72 | while (c.charAt(0) == ' ') |
| 73 | c = c.substring(1); |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 74 | if (c.indexOf(name) == 0) { |
| 75 | return c.substring(name.length, c.length); |
| 76 | } |
| 77 | } |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 78 | return ''; |
jim | 7efcd70 | 2015-02-04 14:23:33 -0800 | [diff] [blame] | 79 | } |
| 80 | // End |
| 81 | |
Instructor, Computer Systems Technology | 29b90f7 | 2015-10-21 06:10:32 -0700 | [diff] [blame] | 82 | // 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 Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 103 | window.SphinxRtdTheme = (function (jquery) { |
| 104 | var stickyNav = (function () { |
| 105 | var navBar, |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 106 | 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 Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 123 | jquery(init); |
| 124 | return { |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 125 | enable: enable |
David Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 126 | }; |
| 127 | }()); |
| 128 | return { |
Master Yoda | c25d56f | 2015-09-21 07:17:40 -0700 | [diff] [blame] | 129 | StickyNav: stickyNav |
David Wosnitza | 25be142 | 2014-12-12 15:37:28 +0100 | [diff] [blame] | 130 | }; |
| 131 | }($)); |