-
Notifications
You must be signed in to change notification settings - Fork 9
/
sketchup.js
37 lines (33 loc) · 1.23 KB
/
sketchup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(function() {
var localStorage = {}, sessionStorage = {};
try { localStorage = window.localStorage; } catch (e) { }
try { sessionStorage = window.sessionStorage; } catch (e) { }
// Kludge: This isn't a clean way to do it. But it works for now.
// It doesn't take into account collapsed state change that happen when expandTo
// is called. User must click the un-collapse arrow for that.
// This also relies on this file being loaded after full_list.js so that the
// original YARD enableToggles function is called before this one.
function persistentToggles() {
// Remember the collapsed state when toggling the first two levels.
$('#full_list a.toggle').on('click', function(evt) {
console.log('persistentToggles');
var $item = $(this).parent().parent();
var key = $item.attr('id');
var value = $item.hasClass('collapsed');
localStorage.setItem(key, value);
});
// Load initial state.
$('#full_list a.toggle').each(function() {
var $item = $(this).parent().parent();
var key = $item.attr('id');
var value = localStorage.getItem(key);
if (value === 'true') {
$item.addClass('collapsed');
}
});
}
$(document).ready(function() {
console.log('READY: sketchup.js');
persistentToggles();
});
})();