-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathapp.js
125 lines (116 loc) · 3.26 KB
/
app.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
var RocknCoder = RocknCoder || {};
RocknCoder.Pages = RocknCoder.Pages || {};
RocknCoder.Pages.Kernel = function (event) {
var that = this,
eventType = event.type,
pageName = $(this).attr("data-rockncoder-jspage");
if (RocknCoder && RocknCoder.Pages && pageName && RocknCoder.Pages[pageName] && RocknCoder.Pages[pageName][eventType]) {
RocknCoder.Pages[pageName][eventType].call(that);
}
};
RocknCoder.Pages.Events = function () {
$("div[data-rockncoder-jspage]").on(
'pagebeforecreate pagecreate pagebeforeload pagebeforeshow pageshow pagebeforechange pagechange pagebeforehide pagehide pageinit',
RocknCoder.Pages.Kernel).on(
"pageinit", RocknCoder.hideAddressBar);
} ();
RocknCoder.Pages.manageBarChart = function () {
var pageshow = function () {
updateChart();
$("#refreshBarChart").click(function(){
updateChart();
});
},
pagehide = function () {
$("#refreshBarChart").unbind('click');
},
updateChart= function(){
var barA = parseInt($("#pageBarSliderA").val(),10),
barB = parseInt($("#pageBarSliderB").val(),10),
barC = parseInt($("#pageBarSliderC").val(),10);
showChart(barA, barB, barC);
},
showChart = function(barA, barB, barC){
$.jqplot('barChart', [[[barA,1], [barB,3], [barC,5]]], {
seriesDefaults:{
renderer:$.jqplot.BarRenderer,
shadowAngle: 135,
rendererOptions: {
barDirection: 'horizontal'
},
pointLabels: {show: true, formatString: '%d'}
},
axes: {
yaxis: {
renderer: $.jqplot.CategoryAxisRenderer
}
}
}).replot({clear: true, resetAxes:true});
};
return {
pageshow: pageshow,
pagehide: pagehide
}
}();
RocknCoder.Pages.managePieChart = function () {
var pageshow = function () {
updateChart();
$("#refreshPieChart").click(function(){
updateChart();
});
},
pagehide = function () {
$("#refreshPieChart").unbind('click');
},
updateChart= function(){
var sliceA = parseInt($("#pagePieSliderA").val(),10),
sliceB = parseInt($("#pagePieSliderB").val(),10),
sliceC = parseInt($("#pagePieSliderC").val(),10);
showChart(sliceA, sliceB, sliceC);
},
showChart = function(sliceA, sliceB, sliceC){
var plot2 = $.jqplot('pieChart', [[['a',sliceA],['b',sliceB],['c',sliceC]]], {
grid: {
drawBorder: false,
shadow: false
},
seriesDefaults:{
renderer:$.jqplot.PieRenderer,
trendline:{ show: true }
},
legend:{ show: false }
});
};
return {
pageshow: pageshow,
pagehide: pagehide
}
}();
RocknCoder.Pages.managePlotChart = function () {
var pageshow = function () {
updateChart();
$("#refreshPlotChart").click(function(){
updateChart();
$.mobile.silentScroll();
});
},
pagehide = function () {
$("#refreshPlotChart").unbind('click');
},
updateChart= function(){
var sliders = $($.mobile.activePage).find("input"),
vals = [];
_.each(sliders,function(element, index){
vals.push([index+1, parseInt(element.value, 10)]);
});
showChart(vals);
},
showChart = function(vals){
$.jqplot('plotChart',[vals]).replot({clear: true, resetAxes:true});
};
return {
pageshow: pageshow,
pagehide: pagehide
}
}();