forked from sendgrid/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.js
More file actions
53 lines (43 loc) · 1.15 KB
/
Copy pathmenu.js
File metadata and controls
53 lines (43 loc) · 1.15 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var saveTreeState = function(){
parent_nodes = $('.sidebar-nav .parent');
parent_nodes.each(function(i){
open = $(this).hasClass('collapsibleListOpen');
$.jStorage.set($(this).attr('id'), open)
});
}
var loadTreeState = function(){
parent_nodes = $('.sidebar-nav .parent');
parent_nodes.each(function(i){
node = $(this);
open = $.jStorage.get(node.attr('id'))
// the toggle flips between states on load, so need to set them to the opposite
if (open){
node.addClass('collapsibleListClosed');
}
else {
node.addClass('collapsibleListOpen');
}
});
}
$(function() {
loadTreeState();
if($('#nav-menu').length) {
CollapsibleLists.applyTo(document.getElementById('nav-menu'));
$('.collapsibleListOpen, .collapsibleListClosed').click(saveTreeState);
}
$.ajax({
url: "https://sendgrid.com/user/checkLogin",
method: "GET",
success: function (data) {
if(data.logged_in === true){
$("#user-state").html('<a href="https://sendgrid.com/account/overview">Your Account</a>');
}
},
dataType: "jsonp"
});
$(".sidebar-nav").click(function (e) {
if(e.target == this){
$(this).toggleClass("shown");
}
});
});