-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzscript.js
220 lines (192 loc) · 7.13 KB
/
zscript.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
jQuery.noConflict();
jQuery(document).ready(function ($) {
var token = Math.random();
/* ============= @@ general ======================== */
$('a[href^="out.php"], a[href^="http://"], a[href^="https://"], a[href^="mailto:"], a[href^="tel:"], a[href*="lib.php"]').attr({ target: "_blank" });
/* ============= @@ forms ======================== */
jQuery.validator.addMethod("notDefault", function(value, element) { return value != element.defaultValue; }, "Required");
if( $('#feedback').length ) {
$("#feedback").validate({errorContainer: ".errorBox" , errorPlacement: function(error, element) { }, rules: { txtCaptcha: {required: true, remote: "apps/captchajx/ajax_process.php"}}, messages: { txtCaptcha: "Correct captcha is required." }});
}
doFormsValidate();
});
function hc_pieChartDrill(cElement, cLabel, cData, cDrillData){
jQuery(document).ready(function($) {
var piechart = new Highcharts.chart(cElement, {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null, plotShadow: false,
type: 'pie'
,events: {
drilldown: function(e) {
piechart.setTitle({ text: cLabel + ' >> ' + e.point.name });
},
drillup: function(e) {
piechart.setTitle({ text: cLabel });
}
}
},
title: { text: cLabel },
colors: ['red', 'orange', 'green', 'blue', 'purple', 'brown', 'black', 'gray', 'maroon', 'orchid', 'burlywood', 'darkblue', 'magenta', 'olivegreen', 'yellow', 'orchid', 'seagreen', 'cyan', 'slategray', 'violet', 'pink'],
tooltip: { pointFormat: '{series.name}: {point.y}, <br/>Percentage: <b>{point.percentage:.1f}%</b> ' },
plotOptions: {
pie: { allowPointSelect: true, cursor: 'pointer',
dataLabels: { enabled: true, format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' }
}
}
},
series: [{
name: cLabel, colorByPoint: true,
data: cData
}]
, drilldown: {
series: cDrillData
}
, credits : { enabled : false}
, exporting : { enabled : false}
});
});
}
function hc_pieChart(cElement, cLabel, cData, cLegend = false){
jQuery(document).ready(function($) {
var cDataLabel = (cLegend) ? false : true;
Highcharts.chart(cElement, {
chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' },
title: { text: cLabel },
colors: ['red', 'orange', 'green', 'blue', 'purple', 'brown', 'black', 'gray', 'maroon', 'orchid', 'burlywood', 'darkblue', 'magenta', 'olivegreen', 'yellow', 'orchid', 'seagreen', 'cyan', 'slategray', 'violet', 'pink'],
tooltip: { pointFormat: '{series.name}: {point.y}, <br/>Percentage: <b>{point.percentage:.1f}%</b> ' },
legend: {
enabled: cLegend,
useHTML: true,
labelFormatter: function() {
return '<span style="color:' + this.color + '">' + this.name + ': ' + this.percentage.toFixed(2) + '%</span><br/>';
},
borderWidth: 0,
itemStyle: {
fontWeight: 'normal !important',
fontSize: '12px'
}
},
plotOptions: {
pie: { allowPointSelect: true, cursor: 'pointer', showInLegend: cLegend,
dataLabels: { enabled: cDataLabel, format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: { color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black' }
}
}
},
series: [{
name: 'Total', colorByPoint: true,
data: cData
}]
, credits : { enabled : false}
, exporting : { enabled : false}
});
});
}
function hc_barChartDrill(cElement, cLabel, cCategory, cData, cDrillData){
jQuery(document).ready(function($) {
var defaultTitle = cLabel;
var drilldownTitle = "More about ";
// Create the chart
var chart = new Highcharts.chart(cElement, {
chart: {
type: 'bar'
, height: 500
,events: {
drilldown: function(e) {
chart.setTitle({ text: defaultTitle + ' >> ' + e.point.name });
},
drillup: function(e) {
chart.setTitle({ text: defaultTitle });
}
}
},
title: {
text: cLabel
},
subtitle: {
text: 'Click columns or categories to drill down.'
},
colors: ['red', 'orange', 'green', 'blue', 'purple', 'brown', 'black', 'gray', 'maroon', 'orchid', 'burlywood', 'darkblue', 'magenta', 'olivegreen', 'yellow', 'orchid', 'seagreen', 'cyan', 'slategray', 'violet', 'pink'],
xAxis: {
type: 'category'
},
plotOptions: {
series: {
borderWidth: 0,
dataLabels: {
enabled: true
}
}
},
series: cData,
drilldown: {
drillUpButton: {
position: {
y: -50,
x: -80
}
},
series: cDrillData
},
credits : { enabled : false},
exporting : { enabled : false},
// Legend edit
legend: {
itemStyle: {
fontWeight: 'normal',
fontSize: '14px'
}
}
});
});
}
function hc_barChart(cElement, cLabel, cCategory, cData){
jQuery(document).ready(function($) {
Highcharts.chart(cElement, {
chart: { type: 'bar' },
title: { text: cLabel },
subtitle: { text: '' },
colors: ['red', 'orange', 'green', 'blue', 'purple', 'brown', 'black', 'gray', 'maroon', 'orchid', 'burlywood', 'darkblue', 'magenta', 'olivegreen', 'yellow', 'orchid', 'seagreen', 'cyan', 'slategray', 'violet', 'pink'],
xAxis: {
categories: cCategory,
title: { text: '' }
},
yAxis: {
min: 0,
title: { text: 'Amount in KES (millions)', align: 'high' },
labels: { overflow: 'justify' }
},
tooltip: { valueSuffix: ' M' },
plotOptions: { bar: { dataLabels: { enabled: true } } },
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
shadow: true
},
series: cData
, credits : { enabled : false}
, exporting : { enabled : false}
});
});
}
function doFormsValidate() {
jQuery(document).ready(function($) {
if($('.rwdvalid').length)
{ /* Multiselect - require one*/
$.validator.addMethod("needsSelection", function (value, element) { var count = $(element).find('option:selected').length; return count > 0; });
/* Multicheckbox - require one*/
$.validator.addMethod("require-one", function (value, element) { return $('.require-one:checked').size() > 0; })
/* WYSIWYG - required */
$.validator.addMethod("wysi_required", function (value, element) { return $('.wysi-required').val() !== ''; })
$(".rwdvalid").validate({errorContainer: ".errorBox" , errorPlacement: function(error, element) { } });
}
});
}