highcharts-rails 0.1.1 → 2.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,243 +1,264 @@
1
- /**
2
- * @license Highcharts JS v2.1.6 (2011-07-08)
3
- * MooTools adapter
4
- *
5
- * (c) 2010-2011 Torstein Hønsi
6
- *
7
- * License: www.highcharts.com/license
8
- */
9
-
10
- // JSLint options:
11
- /*global Highcharts, Fx, $, $extend, $each, $merge, Events, Event */
12
-
13
- (function() {
14
-
15
- var win = window,
16
- legacy = !!win.$merge,
17
- $extend = win.$extend || function() {
18
- return Object.append.apply(Object, arguments)
19
- };
20
-
21
- win.HighchartsAdapter = {
22
- /**
23
- * Initialize the adapter. This is run once as Highcharts is first run.
24
- */
25
- init: function() {
26
- var fxProto = Fx.prototype,
27
- fxStart = fxProto.start,
28
- morphProto = Fx.Morph.prototype,
29
- morphCompute = morphProto.compute;
30
-
31
- // override Fx.start to allow animation of SVG element wrappers
32
- fxProto.start = function(from, to) {
33
- var fx = this,
34
- elem = fx.element;
35
-
36
- // special for animating paths
37
- if (from.d) {
38
- //this.fromD = this.element.d.split(' ');
39
- fx.paths = Highcharts.pathAnim.init(
40
- elem,
41
- elem.d,
42
- fx.toD
43
- );
44
- }
45
- fxStart.apply(fx, arguments);
46
-
47
- return this; // chainable
48
- };
49
-
50
- // override Fx.step to allow animation of SVG element wrappers
51
- morphProto.compute = function(from, to, delta) {
52
- var fx = this,
53
- paths = fx.paths;
54
-
55
- if (paths) {
56
- fx.element.attr(
57
- 'd',
58
- Highcharts.pathAnim.step(paths[0], paths[1], delta, fx.toD)
59
- );
60
- } else {
61
- return morphCompute.apply(fx, arguments);
62
- }
63
- };
64
-
65
- },
66
-
67
- /**
68
- * Animate a HTML element or SVG element wrapper
69
- * @param {Object} el
70
- * @param {Object} params
71
- * @param {Object} options jQuery-like animation options: duration, easing, callback
72
- */
73
- animate: function (el, params, options) {
74
- var isSVGElement = el.attr,
75
- effect,
76
- complete = options && options.complete;
77
-
78
- if (isSVGElement && !el.setStyle) {
79
- // add setStyle and getStyle methods for internal use in Moo
80
- el.getStyle = el.attr;
81
- el.setStyle = function() { // property value is given as array in Moo - break it down
82
- var args = arguments;
83
- el.attr.call(el, args[0], args[1][0]);
84
- }
85
- // dirty hack to trick Moo into handling el as an element wrapper
86
- el.$family = el.uid = true;
87
- }
88
-
89
- // stop running animations
90
- HighchartsAdapter.stop(el);
91
-
92
- // define and run the effect
93
- effect = new Fx.Morph(
94
- isSVGElement ? el : $(el),
95
- $extend({
96
- transition: Fx.Transitions.Quad.easeInOut
97
- }, options)
98
- );
99
-
100
- // special treatment for paths
101
- if (params.d) {
102
- effect.toD = params.d;
103
- }
104
-
105
- // jQuery-like events
106
- if (complete) {
107
- effect.addEvent('complete', complete);
108
- }
109
-
110
- // run
111
- effect.start(params);
112
-
113
- // record for use in stop method
114
- el.fx = effect;
115
- },
116
-
117
- /**
118
- * MooTool's each function
119
- *
120
- */
121
- each: function(arr, fn) {
122
- return legacy ?
123
- $each(arr, fn) :
124
- arr.each(fn);
125
- },
126
-
127
- /**
128
- * Map an array
129
- * @param {Array} arr
130
- * @param {Function} fn
131
- */
132
- map: function (arr, fn){
133
- return arr.map(fn);
134
- },
135
-
136
- /**
137
- * Grep or filter an array
138
- * @param {Array} arr
139
- * @param {Function} fn
140
- */
141
- grep: function(arr, fn) {
142
- return arr.filter(fn);
143
- },
144
-
145
- /**
146
- * Deep merge two objects and return a third
147
- */
148
- merge: function() {
149
- var args = arguments,
150
- args13 = [{}], // MooTools 1.3+
151
- i = args.length,
152
- ret;
153
-
154
- if (legacy) {
155
- ret = $merge.apply(null, args);
156
- } else {
157
- while (i--) {
158
- args13[i + 1] = args[i];
159
- }
160
- ret = Object.merge.apply(Object, args13);
161
- }
162
-
163
- return ret;
164
- },
165
-
166
- /**
167
- * Add an event listener
168
- * @param {Object} el HTML element or custom object
169
- * @param {String} type Event type
170
- * @param {Function} fn Event handler
171
- */
172
- addEvent: function (el, type, fn) {
173
- if (typeof type == 'string') { // chart broke due to el being string, type function
174
-
175
- if (type == 'unload') { // Moo self destructs before custom unload events
176
- type = 'beforeunload';
177
- }
178
-
179
- // if the addEvent method is not defined, el is a custom Highcharts object
180
- // like series or point
181
- if (!el.addEvent) {
182
- if (el.nodeName) {
183
- el = $(el); // a dynamically generated node
184
- } else {
185
- $extend(el, new Events()); // a custom object
186
- }
187
- }
188
-
189
- el.addEvent(type, fn);
190
- }
191
- },
192
-
193
- removeEvent: function(el, type, fn) {
194
- if (type) {
195
- if (type == 'unload') { // Moo self destructs before custom unload events
196
- type = 'beforeunload';
197
- }
198
-
199
- if (defined(fn)) {
200
- el.removeEvent(type, fn);
201
- } else {
202
- el.removeEvents(type);
203
- }
204
- } else {
205
- el.removeEvents();
206
- }
207
- },
208
-
209
- fireEvent: function(el, event, eventArguments, defaultFunction) {
210
- // create an event object that keeps all functions
211
- event = new Event({
212
- type: event,
213
- target: el
214
- });
215
- event = $extend(event, eventArguments);
216
- // override the preventDefault function to be able to use
217
- // this for custom events
218
- event.preventDefault = function() {
219
- defaultFunction = null;
220
- };
221
- // if fireEvent is not available on the object, there hasn't been added
222
- // any events to it above
223
- if (el.fireEvent) {
224
- el.fireEvent(event.type, event);
225
- }
226
-
227
- // fire the default if it is passed and it is not prevented above
228
- if (defaultFunction) {
229
- defaultFunction(event);
230
- }
231
- },
232
-
233
- /**
234
- * Stop running animations on the object
235
- */
236
- stop: function (el) {
237
- if (el.fx) {
238
- el.fx.cancel();
239
- }
240
- }
241
- }
242
-
243
- })();
1
+ /**
2
+ * @license Highcharts JS v2.1.9 (2011-11-11)
3
+ * MooTools adapter
4
+ *
5
+ * (c) 2010-2011 Torstein Hønsi
6
+ *
7
+ * License: www.highcharts.com/license
8
+ */
9
+
10
+ // JSLint options:
11
+ /*global Fx, $, $extend, $each, $merge, Events, Event, DOMEvent */
12
+
13
+ (function () {
14
+
15
+ var win = window,
16
+ mooVersion = win.MooTools.version.substring(0, 3), // Get the first three characters of the version number
17
+ legacy = mooVersion === '1.2' || mooVersion === '1.1', // 1.1 && 1.2 considered legacy, 1.3 is not.
18
+ legacyEvent = legacy || mooVersion === '1.3', // In versions 1.1 - 1.3 the event class is named Event, in newer versions it is named DOMEvent.
19
+ $extend = win.$extend || function () {
20
+ return Object.append.apply(Object, arguments);
21
+ };
22
+
23
+ win.HighchartsAdapter = {
24
+ /**
25
+ * Initialize the adapter. This is run once as Highcharts is first run.
26
+ * @param {Object} pathAnim The helper object to do animations across adapters.
27
+ */
28
+ init: function (pathAnim) {
29
+ var fxProto = Fx.prototype,
30
+ fxStart = fxProto.start,
31
+ morphProto = Fx.Morph.prototype,
32
+ morphCompute = morphProto.compute;
33
+
34
+ // override Fx.start to allow animation of SVG element wrappers
35
+ /*jslint unparam: true*//* allow unused parameters in fx functions */
36
+ fxProto.start = function (from, to) {
37
+ var fx = this,
38
+ elem = fx.element;
39
+
40
+ // special for animating paths
41
+ if (from.d) {
42
+ //this.fromD = this.element.d.split(' ');
43
+ fx.paths = pathAnim.init(
44
+ elem,
45
+ elem.d,
46
+ fx.toD
47
+ );
48
+ }
49
+ fxStart.apply(fx, arguments);
50
+
51
+ return this; // chainable
52
+ };
53
+
54
+ // override Fx.step to allow animation of SVG element wrappers
55
+ morphProto.compute = function (from, to, delta) {
56
+ var fx = this,
57
+ paths = fx.paths;
58
+
59
+ if (paths) {
60
+ fx.element.attr(
61
+ 'd',
62
+ pathAnim.step(paths[0], paths[1], delta, fx.toD)
63
+ );
64
+ } else {
65
+ return morphCompute.apply(fx, arguments);
66
+ }
67
+ };
68
+ /*jslint unparam: false*/
69
+ },
70
+
71
+ /**
72
+ * Animate a HTML element or SVG element wrapper
73
+ * @param {Object} el
74
+ * @param {Object} params
75
+ * @param {Object} options jQuery-like animation options: duration, easing, callback
76
+ */
77
+ animate: function (el, params, options) {
78
+ var isSVGElement = el.attr,
79
+ effect,
80
+ complete = options && options.complete;
81
+
82
+ if (isSVGElement && !el.setStyle) {
83
+ // add setStyle and getStyle methods for internal use in Moo
84
+ el.getStyle = el.attr;
85
+ el.setStyle = function () { // property value is given as array in Moo - break it down
86
+ var args = arguments;
87
+ el.attr.call(el, args[0], args[1][0]);
88
+ };
89
+ // dirty hack to trick Moo into handling el as an element wrapper
90
+ el.$family = el.uid = true;
91
+ }
92
+
93
+ // stop running animations
94
+ win.HighchartsAdapter.stop(el);
95
+
96
+ // define and run the effect
97
+ effect = new Fx.Morph(
98
+ isSVGElement ? el : $(el),
99
+ $extend({
100
+ transition: Fx.Transitions.Quad.easeInOut
101
+ }, options)
102
+ );
103
+
104
+ // special treatment for paths
105
+ if (params.d) {
106
+ effect.toD = params.d;
107
+ }
108
+
109
+ // jQuery-like events
110
+ if (complete) {
111
+ effect.addEvent('complete', complete);
112
+ }
113
+
114
+ // run
115
+ effect.start(params);
116
+
117
+ // record for use in stop method
118
+ el.fx = effect;
119
+ },
120
+
121
+ /**
122
+ * MooTool's each function
123
+ *
124
+ */
125
+ each: function (arr, fn) {
126
+ return legacy ?
127
+ $each(arr, fn) :
128
+ arr.each(fn);
129
+ },
130
+
131
+ /**
132
+ * Map an array
133
+ * @param {Array} arr
134
+ * @param {Function} fn
135
+ */
136
+ map: function (arr, fn) {
137
+ return arr.map(fn);
138
+ },
139
+
140
+ /**
141
+ * Grep or filter an array
142
+ * @param {Array} arr
143
+ * @param {Function} fn
144
+ */
145
+ grep: function (arr, fn) {
146
+ return arr.filter(fn);
147
+ },
148
+
149
+ /**
150
+ * Deep merge two objects and return a third
151
+ */
152
+ merge: function () {
153
+ var args = arguments,
154
+ args13 = [{}], // MooTools 1.3+
155
+ i = args.length,
156
+ ret;
157
+
158
+ if (legacy) {
159
+ ret = $merge.apply(null, args);
160
+ } else {
161
+ while (i--) {
162
+ // Boolean argumens should not be merged.
163
+ // JQuery explicitly skips this, so we do it here as well.
164
+ if (typeof args[i] !== 'boolean') {
165
+ args13[i + 1] = args[i];
166
+ }
167
+ }
168
+ ret = Object.merge.apply(Object, args13);
169
+ }
170
+
171
+ return ret;
172
+ },
173
+
174
+ /**
175
+ * Extends an object with Events, if its not done
176
+ */
177
+ extendWithEvents: function (el) {
178
+ // if the addEvent method is not defined, el is a custom Highcharts object
179
+ // like series or point
180
+ if (!el.addEvent) {
181
+ if (el.nodeName) {
182
+ el = $(el); // a dynamically generated node
183
+ } else {
184
+ $extend(el, new Events()); // a custom object
185
+ }
186
+ }
187
+ },
188
+
189
+ /**
190
+ * Add an event listener
191
+ * @param {Object} el HTML element or custom object
192
+ * @param {String} type Event type
193
+ * @param {Function} fn Event handler
194
+ */
195
+ addEvent: function (el, type, fn) {
196
+ if (typeof type === 'string') { // chart broke due to el being string, type function
197
+
198
+ if (type === 'unload') { // Moo self destructs before custom unload events
199
+ type = 'beforeunload';
200
+ }
201
+
202
+ win.HighchartsAdapter.extendWithEvents(el);
203
+
204
+ el.addEvent(type, fn);
205
+ }
206
+ },
207
+
208
+ removeEvent: function (el, type, fn) {
209
+ if (typeof el === 'string') {
210
+ // el.removeEvents below apperantly calls this method again. Do not quite understand why, so for now just bail out.
211
+ return;
212
+ }
213
+ win.HighchartsAdapter.extendWithEvents(el);
214
+ if (type) {
215
+ if (type === 'unload') { // Moo self destructs before custom unload events
216
+ type = 'beforeunload';
217
+ }
218
+
219
+ if (fn) {
220
+ el.removeEvent(type, fn);
221
+ } else {
222
+ el.removeEvents(type);
223
+ }
224
+ } else {
225
+ el.removeEvents();
226
+ }
227
+ },
228
+
229
+ fireEvent: function (el, event, eventArguments, defaultFunction) {
230
+ var eventArgs = {
231
+ type: event,
232
+ target: el
233
+ };
234
+ // create an event object that keeps all functions
235
+ event = legacyEvent ? new Event(eventArgs) : new DOMEvent(eventArgs);
236
+ event = $extend(event, eventArguments);
237
+ // override the preventDefault function to be able to use
238
+ // this for custom events
239
+ event.preventDefault = function () {
240
+ defaultFunction = null;
241
+ };
242
+ // if fireEvent is not available on the object, there hasn't been added
243
+ // any events to it above
244
+ if (el.fireEvent) {
245
+ el.fireEvent(event.type, event);
246
+ }
247
+
248
+ // fire the default if it is passed and it is not prevented above
249
+ if (defaultFunction) {
250
+ defaultFunction(event);
251
+ }
252
+ },
253
+
254
+ /**
255
+ * Stop running animations on the object
256
+ */
257
+ stop: function (el) {
258
+ if (el.fx) {
259
+ el.fx.cancel();
260
+ }
261
+ }
262
+ };
263
+
264
+ }());