@@ -25,7 +25,7 @@ $(document).ready(function () {
25
25
$ ( '#closeMe' ) . toggle (
26
26
function ( )
27
27
{
28
- setCookie ( 'ciNav' , true , 365 ) ;
28
+ setCookie ( 'ciNav' , 'yes' , 365 ) ;
29
29
$ ( '#nav2' ) . show ( ) ;
30
30
$ ( '#topMenu' ) . remove ( ) ;
31
31
$ ( 'body' ) . css ( { background : 'none' } ) ;
@@ -35,7 +35,7 @@ $(document).ready(function () {
35
35
} ,
36
36
function ( )
37
37
{
38
- setCookie ( 'ciNav' , false , 365 ) ;
38
+ setCookie ( 'ciNav' , 'no' , 365 ) ;
39
39
$ ( '#topMenu' ) . remove ( ) ;
40
40
$ ( '#nav' ) . hide ( ) ;
41
41
$ ( '#nav2' ) . hide ( ) ;
@@ -44,20 +44,25 @@ $(document).ready(function () {
44
44
$ ( '.wy-nav-side' ) . show ( ) ;
45
45
}
46
46
) ;
47
- if ( getCookie ( 'ciNav' ) == 'true ' )
47
+ if ( getCookie ( 'ciNav' ) == 'yes ' )
48
48
{
49
49
$ ( '#closeMe' ) . trigger ( 'click' ) ;
50
50
//$('#nav').slideToggle();
51
51
}
52
52
// END MODIFICATION ---
53
+
53
54
} ) ;
54
55
55
56
// Rufnex Cookie functions
56
57
function setCookie ( cname , cvalue , exdays ) {
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
+ }
57
62
var d = new Date ( ) ;
58
63
d . setTime ( d . getTime ( ) + ( exdays * 24 * 60 * 60 * 1000 ) ) ;
59
64
var expires = "expires=" + d . toGMTString ( ) ;
60
- document . cookie = cname + "=" + cvalue + "; " + expires ;
65
+ document . cookie = cname + "=" + cvalue + "; " + expires + "; path=/" ;
61
66
}
62
67
function getCookie ( cname ) {
63
68
var name = cname + "=" ;
@@ -70,10 +75,31 @@ function getCookie(cname) {
70
75
return c . substring ( name . length , c . length ) ;
71
76
}
72
77
}
73
- return false ;
78
+ return '' ;
74
79
}
75
80
// End
76
81
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
+
77
103
window . SphinxRtdTheme = ( function ( jquery ) {
78
104
var stickyNav = ( function ( ) {
79
105
var navBar ,
0 commit comments