12
12
< link rel ="stylesheet " type ="text/css " href ="print.css " media ="print ">
13
13
< link rel ="stylesheet " type ="text/css " href ="../common/js_disabled.css " media ="all ">
14
14
< link rel ="stylesheet " type ="text/css " href ="../common/doc_formatting.css " media ="all ">
15
+ < script type ="text/javascript " src ="../common/storage.js "> </ script >
15
16
< script type ="text/javascript " src ="../rebot/util.js "> </ script > <!-- TODO: Should util.js be moved under common? -->
16
17
< script type ="text/javascript " src ="../lib/jquery.min.js "> </ script >
17
18
< script type ="text/javascript " src ="../lib/jquery.tmpl.min.js "> </ script >
@@ -39,13 +40,16 @@ <h1>Opening library documentation failed</h1>
39
40
$ ( document ) . ready ( function ( ) {
40
41
parseTemplates ( ) ;
41
42
document . title = libdoc . name ;
43
+ storage . init ( 'libdoc' ) ;
42
44
renderTemplate ( 'base' , libdoc , $ ( 'body' ) ) ;
43
45
if ( libdoc . inits . length ) {
44
46
renderTemplate ( 'importing' , libdoc ) ;
45
47
}
46
48
renderTemplate ( 'shortcuts' , libdoc ) ;
49
+ initShortcutListStyle ( 'shortcut' ) ;
47
50
if ( libdoc . contains_tags ) {
48
51
renderTemplate ( 'tags' , libdoc ) ;
52
+ initShortcutListStyle ( 'tag' ) ;
49
53
}
50
54
renderTemplate ( 'keywords' , libdoc ) ;
51
55
renderTemplate ( 'footer' , libdoc ) ;
@@ -81,9 +85,17 @@ <h1>Opening library documentation failed</h1>
81
85
$ ( '.shortcuts a' ) . width ( 'max-content' ) ;
82
86
}
83
87
84
- function toggleListStyle ( locator ) {
85
- var separator = $ ( locator ) . text ( ) [ 0 ] ;
86
- $ ( locator ) . html ( separator == '\u00b7' ? '<br>' : '·' ) ;
88
+ function initShortcutListStyle ( name ) {
89
+ if ( storage . get ( name + '-list-style' , 'compact' ) != 'compact' ) {
90
+ $ ( '.' + name + '-list-separator' ) . html ( '<br>' ) ;
91
+ $ ( '.' + name + '-list-toggle .switch' ) . prop ( 'checked' , true ) ;
92
+ }
93
+ }
94
+
95
+ function setShortcutListStyle ( name ) {
96
+ var compact = ! $ ( '.' + name + '-list-toggle .switch' ) . prop ( 'checked' ) ;
97
+ $ ( '.' + name + '-list-separator' ) . html ( compact ? '·' : '<br>' ) ;
98
+ storage . set ( name + '-list-style' , compact ? 'compact' : 'expanded' ) ;
87
99
}
88
100
89
101
function handleKeyDown ( event ) {
@@ -325,10 +337,10 @@ <h2 id="Importing">Importing</h2>
325
337
< script type ="text/x-jquery-tmpl " id ="shortcuts-template ">
326
338
< h2 id = "Shortcuts" > Shortcuts</ h2 >
327
339
{ { if keywords . length > 3 } }
328
- < div class = "list-style -toggle" >
340
+ < div class = "shortcut-list -toggle" >
329
341
< b > List style:</ b > Compact
330
342
< label title = "Switch between compact list and expanded list" >
331
- < input type = "checkbox" class = "switch" onclick = "toggleListStyle('. shortcut-separator ');" >
343
+ < input type = "checkbox" class = "switch" onclick = "setShortcutListStyle(' shortcut');" >
332
344
< span class = "slider" > </ span >
333
345
</ label >
334
346
Expanded
@@ -340,7 +352,7 @@ <h2 id="Shortcuts">Shortcuts</h2>
340
352
class = "{{if $value.matched === false}}no-{{/if}}match"
341
353
title = "${$value.shortdoc}" > ${ $value . name } </ a >
342
354
{ { if $index < keywords . length - 1 } }
343
- < span class = "shortcut-separator" > ·</ span >
355
+ < span class = "shortcut-list- separator" > ·</ span >
344
356
{ { / i f } }
345
357
{ { / e a c h } }
346
358
</div >
@@ -349,10 +361,10 @@ <h2 id="Shortcuts">Shortcuts</h2>
349
361
< script type ="text/x-jquery-tmpl " id ="tags-template ">
350
362
< h2 id = "Tags" > Tags</ h2 >
351
363
{ { if all_tags . length > 3 } }
352
- < div class = "list-style -toggle" >
364
+ < div class = "tag-list -toggle" >
353
365
< b > List style:</ b > Compact
354
366
< label title = "Switch between compact list and expanded list" >
355
- < input type = "checkbox" class = "switch" onclick = "toggleListStyle('. tag-separator ');" >
367
+ < input type = "checkbox" class = "switch" onclick = "setShortcutListStyle(' tag');" >
356
368
< span class = "slider" > </ span >
357
369
</ label >
358
370
Expanded
@@ -362,7 +374,7 @@ <h2 id="Tags">Tags</h2>
362
374
{ { each all_tags} }
363
375
< a href = "javascript:tagSearch('${$value}')"
364
376
title = "Show keywords with this tag" > ${ $value } </ a >
365
- < span class = "tag-separator" > ·</ span >
377
+ < span class = "tag-list- separator" > ·</ span >
366
378
{ { / each} }
367
379
< a href = "javascript:resetKeywords()" class = "normal-first-letter"
368
380
title = "Show all keywords" > [Reset]</ a >
0 commit comments