1
+ /*\
2
+ |*|
3
+ |*| :: cookies.js ::
4
+ |*|
5
+ |*| A complete cookies reader/writer framework with full unicode support.
6
+ |*|
7
+ |*| Revision #1 - September 4, 2014
8
+ |*|
9
+ |*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie
10
+ |*| https://developer.mozilla.org/User:fusionchess
11
+ |*|
12
+ |*| This framework is released under the GNU Public License, version 3 or later.
13
+ |*| http://www.gnu.org/licenses/gpl-3.0-standalone.html
14
+ |*|
15
+ |*| Syntaxes:
16
+ |*|
17
+ |*| * docCookies.setItem(name, value[, end[, path[, domain[, secure]]]])
18
+ |*| * docCookies.getItem(name)
19
+ |*| * docCookies.removeItem(name[, path[, domain]])
20
+ |*| * docCookies.hasItem(name)
21
+ |*| * docCookies.keys()
22
+ |*|
23
+ \*/
24
+
25
+ var docCookies = {
26
+ getItem : function ( sKey ) {
27
+ if ( ! sKey ) { return null ; }
28
+ return decodeURIComponent ( document . cookie . replace ( new RegExp ( "(?:(?:^|.*;)\\s*" + encodeURIComponent ( sKey ) . replace ( / [ \- \. \+ \* ] / g, "\\$&" ) + "\\s*\\=\\s*([^;]*).*$)|^.*$" ) , "$1" ) ) || null ;
29
+ } ,
30
+ setItem : function ( sKey , sValue , vEnd , sPath , sDomain , bSecure ) {
31
+ if ( ! sKey || / ^ (?: e x p i r e s | m a x \- a g e | p a t h | d o m a i n | s e c u r e ) $ / i. test ( sKey ) ) { return false ; }
32
+ var sExpires = "" ;
33
+ if ( vEnd ) {
34
+ switch ( vEnd . constructor ) {
35
+ case Number :
36
+ sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd ;
37
+ break ;
38
+ case String :
39
+ sExpires = "; expires=" + vEnd ;
40
+ break ;
41
+ case Date :
42
+ sExpires = "; expires=" + vEnd . toUTCString ( ) ;
43
+ break ;
44
+ }
45
+ }
46
+ document . cookie = encodeURIComponent ( sKey ) + "=" + encodeURIComponent ( sValue ) + sExpires + ( sDomain ? "; domain=" + sDomain : "" ) + ( sPath ? "; path=" + sPath : "" ) + ( bSecure ? "; secure" : "" ) ;
47
+ return true ;
48
+ } ,
49
+ removeItem : function ( sKey , sPath , sDomain ) {
50
+ if ( ! this . hasItem ( sKey ) ) { return false ; }
51
+ document . cookie = encodeURIComponent ( sKey ) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + ( sDomain ? "; domain=" + sDomain : "" ) + ( sPath ? "; path=" + sPath : "" ) ;
52
+ return true ;
53
+ } ,
54
+ hasItem : function ( sKey ) {
55
+ if ( ! sKey ) { return false ; }
56
+ return ( new RegExp ( "(?:^|;\\s*)" + encodeURIComponent ( sKey ) . replace ( / [ \- \. \+ \* ] / g, "\\$&" ) + "\\s*\\=" ) ) . test ( document . cookie ) ;
57
+ } ,
58
+ keys : function ( ) {
59
+ var aKeys = document . cookie . replace ( / ( (?: ^ | \s * ; ) [ ^ \= ] + ) (? = ; | $ ) | ^ \s * | \s * (?: \= [ ^ ; ] * ) ? (?: \1| $ ) / g, "" ) . split ( / \s * (?: \= [ ^ ; ] * ) ? ; \s * / ) ;
60
+ for ( var nLen = aKeys . length , nIdx = 0 ; nIdx < nLen ; nIdx ++ ) { aKeys [ nIdx ] = decodeURIComponent ( aKeys [ nIdx ] ) ; }
61
+ return aKeys ;
62
+ }
63
+ } ;
64
+
1
65
$ ( document ) . ready ( function ( ) {
2
66
3
67
get_data = {
@@ -52,6 +116,14 @@ $(document).ready(function () {
52
116
} else if ( ! data [ 'version_supported' ] ) {
53
117
//$('.rst-current-version').addClass('rst-active-old-version')
54
118
}
119
+
120
+ /// Read the Docs theme code
121
+ if ( docCookies . hasItem ( 'menu' ) ) {
122
+ menu_cookie = docCookies . getItem ( 'menu' )
123
+ if ( menu_cookie == 'open' ) {
124
+ $ ( "[data-toggle='rst-versions']" ) . addClass ( "shift-up" ) ;
125
+ }
126
+ }
55
127
} ,
56
128
error : function ( ) {
57
129
console . log ( 'Error loading Read the Docs footer' )
@@ -72,6 +144,16 @@ $(document).ready(function () {
72
144
} ) ;
73
145
$ ( document ) . on ( 'click' , "[data-toggle='rst-current-version']" , function ( ) {
74
146
$ ( "[data-toggle='rst-versions']" ) . toggleClass ( "shift-up" ) ;
147
+ if ( docCookies . hasItem ( 'menu' ) ) {
148
+ menu_cookie = docCookies . getItem ( 'menu' )
149
+ if ( menu_cookie == 'open' ) {
150
+ docCookies . setItem ( 'menu' , 'close' )
151
+ } else {
152
+ docCookies . setItem ( 'menu' , 'open' )
153
+ }
154
+ } else {
155
+ docCookies . setItem ( 'menu' , 'open' )
156
+ }
75
157
} ) ;
76
158
// Make tables responsive
77
159
$ ( "table.docutils:not(.field-list)" ) . wrap ( "<div class='wy-table-responsive'></div>" ) ;
0 commit comments