jquery_cheats 2.2.1 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/jqueryCheats.js +46 -28
- data/jquery_cheats.gemspec +1 -1
- metadata +1 -1
@@ -1,6 +1,3 @@
|
|
1
|
-
//I KNOW it is global but, I am unsure of another way to do it.
|
2
|
-
var links = [];
|
3
|
-
//global variable used to iterate
|
4
1
|
var categoryPos = 0;
|
5
2
|
$(document).ready(function(){
|
6
3
|
//make select boxes ajax-compatible by adding two params data-onchange=true and data-url="/path/to"
|
@@ -45,10 +42,17 @@ $(document).ready(function(){
|
|
45
42
|
/* window.open(data[2]); */
|
46
43
|
/* To open in the same window use: */
|
47
44
|
for(i = 0; i < data.length; i++) $("#debug").append("\nData["+i+"]:"+data[i]);
|
48
|
-
$("#debug").append("\nlink: "+
|
49
|
-
window.location =
|
45
|
+
$("#debug").append("\nlink: "+data[2]);
|
46
|
+
window.location = data[2]
|
50
47
|
}
|
51
48
|
);
|
49
|
+
|
50
|
+
//#TO PREVENT PROBLEMS WITH DEBUG IF IT DOES NOT EXIST
|
51
|
+
if(!$("#debug"))
|
52
|
+
{
|
53
|
+
$("html").append("<div id=\"debug\"></div>");
|
54
|
+
$("div#debug").css("display","none");
|
55
|
+
}
|
52
56
|
});
|
53
57
|
|
54
58
|
///some helpter functions here
|
@@ -64,11 +68,11 @@ function BarChart(name,xmlurl)
|
|
64
68
|
//we have the URL object as xml
|
65
69
|
var width = XMLWidth(xml);//The width of the chart
|
66
70
|
var height = XMLHeight(xml);
|
67
|
-
bars = getBars(xml);
|
71
|
+
var bars = getBars(xml);
|
68
72
|
//append these to the div
|
69
73
|
$("div#"+name).css("width",width);
|
70
74
|
$("div#"+name).css("height",height);
|
71
|
-
$.jqplot(name,
|
75
|
+
$.jqplot(name,getBars(xml),{ seriesDefaults:{
|
72
76
|
renderer:$.jqplot.BarRenderer,
|
73
77
|
rendererOptions: {fillToZero: true, barWidth: barWidth(xml)}
|
74
78
|
},
|
@@ -124,17 +128,25 @@ function getTicks(xml)
|
|
124
128
|
});
|
125
129
|
return ticks;
|
126
130
|
}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
131
|
+
function loadBars(categoryid, xml) {
|
132
|
+
var bar = [];
|
133
|
+
var bars = [];
|
134
|
+
$(xml).find("bar").each(function() {
|
135
|
+
bar.push(parseInt(categoryid, 10));
|
136
|
+
bar.push(parseInt($(this).attr("size"), 10));
|
137
|
+
bar.push($(this).attr("link"));
|
138
|
+
bars.push(bar);
|
139
|
+
});
|
140
|
+
return bars; //moved from end of "each" iterator to here.
|
141
|
+
}
|
142
|
+
function getBars(xml) {
|
143
|
+
var categoryid = 1;
|
144
|
+
var bars = [];
|
145
|
+
$(xml).find("category").each(function() {
|
146
|
+
bars.push(loadBars(categoryid, $(this)));
|
147
|
+
categoryid++;
|
148
|
+
});
|
149
|
+
return bars;
|
138
150
|
}
|
139
151
|
|
140
152
|
function XMLWidth(xml)
|
@@ -148,26 +160,30 @@ function XMLHeight(xml)
|
|
148
160
|
return $(xml).find("size").attr("height");
|
149
161
|
}
|
150
162
|
|
151
|
-
function loadBars(xml)
|
163
|
+
/*function loadBars(xml,categoryid)
|
152
164
|
{
|
153
|
-
bars = []
|
165
|
+
bars = [];//the category to put the bar...probably shouldn't go here.
|
154
166
|
$(xml).find("bar").each(
|
155
167
|
function(){
|
156
168
|
//categoryPos = categoryPos+1;
|
157
169
|
//$("#debug").append("\nCATEGORY POSSITION:"+categoryPos)
|
158
170
|
//bars.push(categoryPos);
|
159
|
-
|
171
|
+
bar= new Array();
|
172
|
+
bar.push(parseInt(categoryid));
|
173
|
+
bar.push(parseInt($(this).attr("size")));
|
160
174
|
link = $(this).attr("link");
|
161
|
-
if(link)
|
175
|
+
if(link)bar.push(link); else links.push("#");
|
176
|
+
bars.push(bar);
|
162
177
|
});
|
178
|
+
$("#debug").append("\nDEBUG bars Array in Loadbars:");
|
179
|
+
debug2dArray(bars);
|
163
180
|
return bars;
|
164
|
-
}
|
181
|
+
}*/
|
165
182
|
|
166
183
|
|
167
184
|
function getTickInterval(xml)
|
168
185
|
{
|
169
186
|
var interval = $(xml).find("yaxis").attr("tickInterval");
|
170
|
-
alert("INTERVAL IS: "+interval)
|
171
187
|
if(interval) return interval;
|
172
188
|
else return null;
|
173
189
|
}
|
@@ -208,10 +224,12 @@ function pieChart(name,xmlurl)
|
|
208
224
|
{
|
209
225
|
seriesDefaults:{
|
210
226
|
renderer: $.jqplot.PieRenderer,
|
211
|
-
rendererOptions:{
|
212
|
-
|
213
|
-
|
214
|
-
|
227
|
+
rendererOptions: {
|
228
|
+
// Put data labels on the pie slices.
|
229
|
+
// By default, labels show the percentage of the slice.
|
230
|
+
showDataLabels: true
|
231
|
+
}
|
232
|
+
},
|
215
233
|
legend:{show: true, location: 'e'}
|
216
234
|
});
|
217
235
|
});//end get AJAX request
|
data/jquery_cheats.gemspec
CHANGED