forked from loadavg/loadavg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharts.js
161 lines (102 loc) · 4.05 KB
/
charts.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
//used to get status of accordions - collapsed or visable as well as postion
//from the loadUI cookie
$(function () {
//this hack is used to disable drag and drop of charts on mobile devices
var weAreMobile = false;
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
weAreMobile = true;
//console.log ("we are mobile in charts");
}
if (weAreMobile != true)
{
//desktop version is sortable
$( "#accordion" )
.accordion({
header: "> div > h3",
activate: function( event, ui){
}
})
.sortable({
connectWith: ".accordion",
//items: ":not(.separator)",
cancel: ".separator",
start: function( event, ui ){
},
stop: function( event, ui ) {
//ui.item.children( "h3" ).triggerHandler( "focusout" );
$(this).accordion("refresh");
//do we do accordian above or srtable below ?
//$(this).sortable("refresh");
storeState();
}
});
$('div.accordion-body').on('shown', function () {
//console.log( $(this).parents().attr('data-collapse-closed') + ' open' );
$(this).parents().attr('cookie-closed', true);
storeState();
});
$('div.accordion-body').on('hidden', function () {
//console.log( $(this).parents().attr('data-collapse-closed') + ' close' );
$(this).parents().attr('cookie-closed', false);
storeState();
});
} else {
//mobile version is not sortable
$( "#accordion" )
.accordion({
header: "> div > h3",
activate: function( event, ui){
}
});
$('div.accordion-body').on('shown', function () {
//console.log( $(this).parents().attr('data-collapse-closed') + ' open' );
$(this).parents().attr('cookie-closed', true);
storeState();
});
$('div.accordion-body').on('hidden', function () {
//console.log( $(this).parents().attr('data-collapse-closed') + ' close' );
$(this).parents().attr('cookie-closed', false);
storeState();
});
}
});
// $( "#accordion" ).draggable();
/*
* used to save status of accordions for the charting module
* data is saved in a cookie
*/
function storeState() {
var loadCookie = "loadUIcookie";
var myCookie = [];
var jsonObj = {};
//mine
var toggled_div = $('#accordion');
$(toggled_div).children().each(function() {
var id = $(this).attr('id');
if (id != 'separator' )
{
var moduleName = $(this).attr('data-collapse-closed');
//console.log("moduleName " + moduleName);
//if (moduleName != 'undefined' && (moduleName) )
if ( (moduleName) )
{
var status = $(this).attr('cookie-closed');
if ( status == null || !status )
status = "open";
//for when nothinbg has been set its open
if ( status == "true" || status == "open" )
status = "open";
else
status = "closed";
jsonObj[moduleName] = status;
}
}
});
myCookie.push( jsonObj );
// then to get the JSON string
myCookie = JSON.stringify(myCookie);
//get rid of extra brackets on string
var newStr = myCookie.substring(1, myCookie .length-1);
$.cookie(loadCookie, newStr, {expires:365, path: '/'});
// console.log(check_open_divs);
}