jquery_cheats 2.2.1 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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: "+links[data[0]-1]);
49
- window.location = links[data[0]-1]
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,bars,{ seriesDefaults:{
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
- function getBars(xml)
129
- {
130
- //this function aims at translating the data into a 2d array for rendering
131
- var twoDArray = [];
132
- $(xml).find("category").each(
133
- function(){
134
- twoDArray.push(loadBars($(this)));
135
- });
136
- debug2dArray(twoDArray);
137
- return twoDArray;
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
- bars.push($(this).attr("size"));
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)links.push(link); else links.push("#");
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
- showDataLables: true
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jquery_cheats"
5
- s.version = "2.2.1"
5
+ s.version = "2.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Travis Pessettto"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery_cheats
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: