initial commit
This commit is contained in:
12
WebRoot/js/Highcharts-2.2.1/adapters/mootools-adapter.js
Normal file
12
WebRoot/js/Highcharts-2.2.1/adapters/mootools-adapter.js
Normal file
@@ -0,0 +1,12 @@
|
||||
/*
|
||||
Highcharts JS v2.2.1 (2012-03-15)
|
||||
MooTools adapter
|
||||
|
||||
(c) 2010-2011 Torstein H?nsi
|
||||
|
||||
License: www.highcharts.com/license
|
||||
*/
|
||||
(function(){var e=window,i=document,f=e.MooTools.version.substring(0,3),g=f==="1.2"||f==="1.1",j=g||f==="1.3",h=e.$extend||function(){return Object.append.apply(Object,arguments)};e.HighchartsAdapter={init:function(a){var b=Fx.prototype,c=b.start,d=Fx.Morph.prototype,e=d.compute;b.start=function(b,d){var e=this.element;if(b.d)this.paths=a.init(e,e.d,this.toD);c.apply(this,arguments);return this};d.compute=function(b,c,d){var f=this.paths;if(f)this.element.attr("d",a.step(f[0],f[1],d,this.toD));else return e.apply(this,
|
||||
arguments)}},getScript:function(a,b){var c=i.getElementsByTagName("head")[0],d=i.createElement("script");d.type="text/javascript";d.src=a;d.onload=b;c.appendChild(d)},animate:function(a,b,c){var d=a.attr,f=c&&c.complete;if(d&&!a.setStyle)a.getStyle=a.attr,a.setStyle=function(){var b=arguments;a.attr.call(a,b[0],b[1][0])},a.$family=function(){return!0};e.HighchartsAdapter.stop(a);c=new Fx.Morph(d?a:$(a),h({transition:Fx.Transitions.Quad.easeInOut},c));if(d)c.element=a;if(b.d)c.toD=b.d;f&&c.addEvent("complete",
|
||||
f);c.start(b);a.fx=c},each:function(a,b){return g?$each(a,b):Array.each(a,b)},map:function(a,b){return a.map(b)},grep:function(a,b){return a.filter(b)},merge:function(){var a=arguments,b=[{}],c=a.length;if(g)a=$merge.apply(null,a);else{for(;c--;)typeof a[c]!=="boolean"&&(b[c+1]=a[c]);a=Object.merge.apply(Object,b)}return a},offset:function(a){a=$(a).getOffsets();return{left:a.x,top:a.y}},extendWithEvents:function(a){a.addEvent||(a.nodeName?$(a):h(a,new Events))},addEvent:function(a,b,c){typeof b===
|
||||
"string"&&(b==="unload"&&(b="beforeunload"),e.HighchartsAdapter.extendWithEvents(a),a.addEvent(b,c))},removeEvent:function(a,b,c){typeof a!=="string"&&(e.HighchartsAdapter.extendWithEvents(a),b?(b==="unload"&&(b="beforeunload"),c?a.removeEvent(b,c):a.removeEvents(b)):a.removeEvents())},fireEvent:function(a,b,c,d){b={type:b,target:a};b=j?new Event(b):new DOMEvent(b);b=h(b,c);b.preventDefault=function(){d=null};a.fireEvent&&a.fireEvent(b.type,b);d&&d(b)},stop:function(a){a.fx&&a.fx.cancel()}}})();
|
||||
298
WebRoot/js/Highcharts-2.2.1/adapters/mootools-adapter.src.js
Normal file
298
WebRoot/js/Highcharts-2.2.1/adapters/mootools-adapter.src.js
Normal file
@@ -0,0 +1,298 @@
|
||||
/**
|
||||
* @license Highcharts JS v2.2.1 (2012-03-15)
|
||||
* MooTools adapter
|
||||
*
|
||||
* (c) 2010-2011 Torstein Hønsi
|
||||
*
|
||||
* License: www.highcharts.com/license
|
||||
*/
|
||||
|
||||
// JSLint options:
|
||||
/*global Fx, $, $extend, $each, $merge, Events, Event, DOMEvent */
|
||||
|
||||
(function () {
|
||||
|
||||
var win = window,
|
||||
doc = document,
|
||||
mooVersion = win.MooTools.version.substring(0, 3), // Get the first three characters of the version number
|
||||
legacy = mooVersion === '1.2' || mooVersion === '1.1', // 1.1 && 1.2 considered legacy, 1.3 is not.
|
||||
legacyEvent = legacy || mooVersion === '1.3', // In versions 1.1 - 1.3 the event class is named Event, in newer versions it is named DOMEvent.
|
||||
$extend = win.$extend || function () {
|
||||
return Object.append.apply(Object, arguments);
|
||||
};
|
||||
|
||||
win.HighchartsAdapter = {
|
||||
/**
|
||||
* Initialize the adapter. This is run once as Highcharts is first run.
|
||||
* @param {Object} pathAnim The helper object to do animations across adapters.
|
||||
*/
|
||||
init: function (pathAnim) {
|
||||
var fxProto = Fx.prototype,
|
||||
fxStart = fxProto.start,
|
||||
morphProto = Fx.Morph.prototype,
|
||||
morphCompute = morphProto.compute;
|
||||
|
||||
// override Fx.start to allow animation of SVG element wrappers
|
||||
/*jslint unparam: true*//* allow unused parameters in fx functions */
|
||||
fxProto.start = function (from, to) {
|
||||
var fx = this,
|
||||
elem = fx.element;
|
||||
|
||||
// special for animating paths
|
||||
if (from.d) {
|
||||
//this.fromD = this.element.d.split(' ');
|
||||
fx.paths = pathAnim.init(
|
||||
elem,
|
||||
elem.d,
|
||||
fx.toD
|
||||
);
|
||||
}
|
||||
fxStart.apply(fx, arguments);
|
||||
|
||||
return this; // chainable
|
||||
};
|
||||
|
||||
// override Fx.step to allow animation of SVG element wrappers
|
||||
morphProto.compute = function (from, to, delta) {
|
||||
var fx = this,
|
||||
paths = fx.paths;
|
||||
|
||||
if (paths) {
|
||||
fx.element.attr(
|
||||
'd',
|
||||
pathAnim.step(paths[0], paths[1], delta, fx.toD)
|
||||
);
|
||||
} else {
|
||||
return morphCompute.apply(fx, arguments);
|
||||
}
|
||||
};
|
||||
/*jslint unparam: false*/
|
||||
},
|
||||
|
||||
/**
|
||||
* Downloads a script and executes a callback when done.
|
||||
* @param {String} scriptLocation
|
||||
* @param {Function} callback
|
||||
*/
|
||||
getScript: function (scriptLocation, callback) {
|
||||
// We cannot assume that Assets class from mootools-more is available so instead insert a script tag to download script.
|
||||
var head = doc.getElementsByTagName('head')[0];
|
||||
var script = doc.createElement('script');
|
||||
|
||||
script.type = 'text/javascript';
|
||||
script.src = scriptLocation;
|
||||
script.onload = callback;
|
||||
|
||||
head.appendChild(script);
|
||||
},
|
||||
|
||||
/**
|
||||
* Animate a HTML element or SVG element wrapper
|
||||
* @param {Object} el
|
||||
* @param {Object} params
|
||||
* @param {Object} options jQuery-like animation options: duration, easing, callback
|
||||
*/
|
||||
animate: function (el, params, options) {
|
||||
var isSVGElement = el.attr,
|
||||
effect,
|
||||
complete = options && options.complete;
|
||||
|
||||
if (isSVGElement && !el.setStyle) {
|
||||
// add setStyle and getStyle methods for internal use in Moo
|
||||
el.getStyle = el.attr;
|
||||
el.setStyle = function () { // property value is given as array in Moo - break it down
|
||||
var args = arguments;
|
||||
el.attr.call(el, args[0], args[1][0]);
|
||||
};
|
||||
// dirty hack to trick Moo into handling el as an element wrapper
|
||||
el.$family = function () { return true; };
|
||||
}
|
||||
|
||||
// stop running animations
|
||||
win.HighchartsAdapter.stop(el);
|
||||
|
||||
// define and run the effect
|
||||
effect = new Fx.Morph(
|
||||
isSVGElement ? el : $(el),
|
||||
$extend({
|
||||
transition: Fx.Transitions.Quad.easeInOut
|
||||
}, options)
|
||||
);
|
||||
|
||||
// Make sure that the element reference is set when animating svg elements
|
||||
if (isSVGElement) {
|
||||
effect.element = el;
|
||||
}
|
||||
|
||||
// special treatment for paths
|
||||
if (params.d) {
|
||||
effect.toD = params.d;
|
||||
}
|
||||
|
||||
// jQuery-like events
|
||||
if (complete) {
|
||||
effect.addEvent('complete', complete);
|
||||
}
|
||||
|
||||
// run
|
||||
effect.start(params);
|
||||
|
||||
// record for use in stop method
|
||||
el.fx = effect;
|
||||
},
|
||||
|
||||
/**
|
||||
* MooTool's each function
|
||||
*
|
||||
*/
|
||||
each: function (arr, fn) {
|
||||
return legacy ?
|
||||
$each(arr, fn) :
|
||||
Array.each(arr, fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Map an array
|
||||
* @param {Array} arr
|
||||
* @param {Function} fn
|
||||
*/
|
||||
map: function (arr, fn) {
|
||||
return arr.map(fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Grep or filter an array
|
||||
* @param {Array} arr
|
||||
* @param {Function} fn
|
||||
*/
|
||||
grep: function (arr, fn) {
|
||||
return arr.filter(fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Deep merge two objects and return a third
|
||||
*/
|
||||
merge: function () {
|
||||
var args = arguments,
|
||||
args13 = [{}], // MooTools 1.3+
|
||||
i = args.length,
|
||||
ret;
|
||||
|
||||
if (legacy) {
|
||||
ret = $merge.apply(null, args);
|
||||
} else {
|
||||
while (i--) {
|
||||
// Boolean argumens should not be merged.
|
||||
// JQuery explicitly skips this, so we do it here as well.
|
||||
if (typeof args[i] !== 'boolean') {
|
||||
args13[i + 1] = args[i];
|
||||
}
|
||||
}
|
||||
ret = Object.merge.apply(Object, args13);
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the offset of an element relative to the top left corner of the web page
|
||||
*/
|
||||
offset: function (el) {
|
||||
var offsets = $(el).getOffsets();
|
||||
return {
|
||||
left: offsets.x,
|
||||
top: offsets.y
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Extends an object with Events, if its not done
|
||||
*/
|
||||
extendWithEvents: function (el) {
|
||||
// if the addEvent method is not defined, el is a custom Highcharts object
|
||||
// like series or point
|
||||
if (!el.addEvent) {
|
||||
if (el.nodeName) {
|
||||
el = $(el); // a dynamically generated node
|
||||
} else {
|
||||
$extend(el, new Events()); // a custom object
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add an event listener
|
||||
* @param {Object} el HTML element or custom object
|
||||
* @param {String} type Event type
|
||||
* @param {Function} fn Event handler
|
||||
*/
|
||||
addEvent: function (el, type, fn) {
|
||||
if (typeof type === 'string') { // chart broke due to el being string, type function
|
||||
|
||||
if (type === 'unload') { // Moo self destructs before custom unload events
|
||||
type = 'beforeunload';
|
||||
}
|
||||
|
||||
win.HighchartsAdapter.extendWithEvents(el);
|
||||
|
||||
el.addEvent(type, fn);
|
||||
}
|
||||
},
|
||||
|
||||
removeEvent: function (el, type, fn) {
|
||||
if (typeof el === 'string') {
|
||||
// el.removeEvents below apperantly calls this method again. Do not quite understand why, so for now just bail out.
|
||||
return;
|
||||
}
|
||||
win.HighchartsAdapter.extendWithEvents(el);
|
||||
if (type) {
|
||||
if (type === 'unload') { // Moo self destructs before custom unload events
|
||||
type = 'beforeunload';
|
||||
}
|
||||
|
||||
if (fn) {
|
||||
el.removeEvent(type, fn);
|
||||
} else {
|
||||
el.removeEvents(type);
|
||||
}
|
||||
} else {
|
||||
el.removeEvents();
|
||||
}
|
||||
},
|
||||
|
||||
fireEvent: function (el, event, eventArguments, defaultFunction) {
|
||||
var eventArgs = {
|
||||
type: event,
|
||||
target: el
|
||||
};
|
||||
// create an event object that keeps all functions
|
||||
event = legacyEvent ? new Event(eventArgs) : new DOMEvent(eventArgs);
|
||||
event = $extend(event, eventArguments);
|
||||
// override the preventDefault function to be able to use
|
||||
// this for custom events
|
||||
event.preventDefault = function () {
|
||||
defaultFunction = null;
|
||||
};
|
||||
// if fireEvent is not available on the object, there hasn't been added
|
||||
// any events to it above
|
||||
if (el.fireEvent) {
|
||||
el.fireEvent(event.type, event);
|
||||
}
|
||||
|
||||
// fire the default if it is passed and it is not prevented above
|
||||
if (defaultFunction) {
|
||||
defaultFunction(event);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop running animations on the object
|
||||
*/
|
||||
stop: function (el) {
|
||||
if (el.fx) {
|
||||
el.fx.cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}());
|
||||
15
WebRoot/js/Highcharts-2.2.1/adapters/prototype-adapter.js
vendored
Normal file
15
WebRoot/js/Highcharts-2.2.1/adapters/prototype-adapter.js
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
Highcharts JS v2.2.1 (2012-03-15)
|
||||
Prototype adapter
|
||||
|
||||
@author Michael Nelson, Torstein H?nsi.
|
||||
|
||||
Feel free to use and modify this script.
|
||||
Highcharts license: www.highcharts.com/license.
|
||||
*/
|
||||
var HighchartsAdapter=function(){var g=typeof Effect!=="undefined";return{init:function(c){if(g)Effect.HighchartsTransition=Class.create(Effect.Base,{initialize:function(a,b,d,e){var f;this.element=a;this.key=b;f=a.attr?a.attr(b):$(a).getStyle(b);if(b==="d")this.paths=c.init(a,a.d,d),this.toD=d,f=0,d=1;this.start(Object.extend(e||{},{from:f,to:d,attribute:b}))},setup:function(){HighchartsAdapter._extend(this.element);if(!this.element._highchart_animation)this.element._highchart_animation={};this.element._highchart_animation[this.key]=
|
||||
this},update:function(a){var b=this.paths,d=this.element;b&&(a=c.step(b[0],b[1],a,this.toD));d.attr?d.attr(this.options.attribute,a):(b={},b[this.options.attribute]=a,$(d).setStyle(b))},finish:function(){delete this.element._highchart_animation[this.key]}})},getScript:function(c,a){var b=$$("head")[0];b&&b.appendChild((new Element("script",{type:"text/javascript",src:c})).observe("load",a))},addNS:function(c){var a=/^(?:click|mouse(?:down|up|over|move|out))$/;return/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/.test(c)||
|
||||
a.test(c)?c:"h:"+c},addEvent:function(c,a,b){c.addEventListener||c.attachEvent?Event.observe($(c),HighchartsAdapter.addNS(a),b):(HighchartsAdapter._extend(c),c._highcharts_observe(a,b))},animate:function(c,a,b){var d,b=b||{};b.delay=0;b.duration=(b.duration||500)/1E3;b.afterFinish=b.complete;if(g)for(d in a)new Effect.HighchartsTransition($(c),d,a[d],b);else{if(c.attr)for(d in a)c.attr(d,a[d]);b.complete&&b.complete()}c.attr||$(c).setStyle(a)},stop:function(c){var a;if(c._highcharts_extended&&c._highchart_animation)for(a in c._highchart_animation)c._highchart_animation[a].cancel()},
|
||||
each:function(c,a){$A(c).each(a)},offset:function(c){return $(c).cumulativeOffset()},fireEvent:function(c,a,b,d){c.fire?c.fire(HighchartsAdapter.addNS(a),b):c._highcharts_extended&&(b=b||{},c._highcharts_fire(a,b));b&&b.defaultPrevented&&(d=null);d&&d(b)},removeEvent:function(c,a,b){$(c).stopObserving&&(a&&(a=HighchartsAdapter.addNS(a)),$(c).stopObserving(a,b));window===c?Event.stopObserving(c,a,b):(HighchartsAdapter._extend(c),c._highcharts_stop_observing(a,b))},grep:function(c,a){return c.findAll(a)},
|
||||
map:function(c,a){return c.map(a)},merge:function(){function c(a,b){var d,e;for(e in b)d=b[e],a[e]=d&&typeof d==="object"&&d.constructor!==Array&&typeof d.nodeType!=="number"?c(a[e]||{},d):b[e];return a}return function(){var a=arguments,b,d={};for(b=0;b<a.length;b++)d=c(d,a[b]);return d}.apply(this,arguments)},_extend:function(c){c._highcharts_extended||Object.extend(c,{_highchart_events:{},_highchart_animation:null,_highcharts_extended:!0,_highcharts_observe:function(a,b){this._highchart_events[a]=
|
||||
[this._highchart_events[a],b].compact().flatten()},_highcharts_stop_observing:function(a,b){a?b?this._highchart_events[a]=[this._highchart_events[a]].compact().flatten().without(b):delete this._highchart_events[a]:this._highchart_events={}},_highcharts_fire:function(a,b){(this._highchart_events[a]||[]).each(function(a){if(!b.stopped)b.preventDefault=function(){b.defaultPrevented=!0},a.bind(this)(b)===!1&&b.preventDefault()}.bind(this))}})}}}();
|
||||
364
WebRoot/js/Highcharts-2.2.1/adapters/prototype-adapter.src.js
vendored
Normal file
364
WebRoot/js/Highcharts-2.2.1/adapters/prototype-adapter.src.js
vendored
Normal file
@@ -0,0 +1,364 @@
|
||||
/**
|
||||
* @license Highcharts JS v2.2.1 (2012-03-15)
|
||||
* Prototype adapter
|
||||
*
|
||||
* @author Michael Nelson, Torstein Hønsi.
|
||||
*
|
||||
* Feel free to use and modify this script.
|
||||
* Highcharts license: www.highcharts.com/license.
|
||||
*/
|
||||
|
||||
// JSLint options:
|
||||
/*global Effect, Class, Event, Element, $, $$, $A */
|
||||
|
||||
// Adapter interface between prototype and the Highcharts charting library
|
||||
var HighchartsAdapter = (function () {
|
||||
|
||||
var hasEffect = typeof Effect !== 'undefined';
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* Initialize the adapter. This is run once as Highcharts is first run.
|
||||
* @param {Object} pathAnim The helper object to do animations across adapters.
|
||||
*/
|
||||
init: function (pathAnim) {
|
||||
if (hasEffect) {
|
||||
/**
|
||||
* Animation for Highcharts SVG element wrappers only
|
||||
* @param {Object} element
|
||||
* @param {Object} attribute
|
||||
* @param {Object} to
|
||||
* @param {Object} options
|
||||
*/
|
||||
Effect.HighchartsTransition = Class.create(Effect.Base, {
|
||||
initialize: function (element, attr, to, options) {
|
||||
var from,
|
||||
opts;
|
||||
|
||||
this.element = element;
|
||||
this.key = attr;
|
||||
from = element.attr ? element.attr(attr) : $(element).getStyle(attr);
|
||||
|
||||
// special treatment for paths
|
||||
if (attr === 'd') {
|
||||
this.paths = pathAnim.init(
|
||||
element,
|
||||
element.d,
|
||||
to
|
||||
);
|
||||
this.toD = to;
|
||||
|
||||
|
||||
// fake values in order to read relative position as a float in update
|
||||
from = 0;
|
||||
to = 1;
|
||||
}
|
||||
|
||||
opts = Object.extend((options || {}), {
|
||||
from: from,
|
||||
to: to,
|
||||
attribute: attr
|
||||
});
|
||||
this.start(opts);
|
||||
},
|
||||
setup: function () {
|
||||
HighchartsAdapter._extend(this.element);
|
||||
// If this is the first animation on this object, create the _highcharts_animation helper that
|
||||
// contain pointers to the animation objects.
|
||||
if (!this.element._highchart_animation) {
|
||||
this.element._highchart_animation = {};
|
||||
}
|
||||
|
||||
// Store a reference to this animation instance.
|
||||
this.element._highchart_animation[this.key] = this;
|
||||
},
|
||||
update: function (position) {
|
||||
var paths = this.paths,
|
||||
element = this.element,
|
||||
obj;
|
||||
|
||||
if (paths) {
|
||||
position = pathAnim.step(paths[0], paths[1], position, this.toD);
|
||||
}
|
||||
|
||||
if (element.attr) { // SVGElement
|
||||
element.attr(this.options.attribute, position);
|
||||
|
||||
} else { // HTML, #409
|
||||
obj = {};
|
||||
obj[this.options.attribute] = position;
|
||||
$(element).setStyle(obj);
|
||||
}
|
||||
|
||||
},
|
||||
finish: function () {
|
||||
// Delete the property that holds this animation now that it is finished.
|
||||
// Both canceled animations and complete ones gets a 'finish' call.
|
||||
delete this.element._highchart_animation[this.key];
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Downloads a script and executes a callback when done.
|
||||
* @param {String} scriptLocation
|
||||
* @param {Function} callback
|
||||
*/
|
||||
getScript: function (scriptLocation, callback) {
|
||||
var head = $$('head')[0]; // Returns an array, so pick the first element.
|
||||
if (head) {
|
||||
// Append a new 'script' element, set its type and src attributes, add a 'load' handler that calls the callback
|
||||
head.appendChild(new Element('script', { type: 'text/javascript', src: scriptLocation}).observe('load', callback));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Custom events in prototype needs to be namespaced. This method adds a namespace 'h:' in front of
|
||||
* events that are not recognized as native.
|
||||
*/
|
||||
addNS: function (eventName) {
|
||||
var HTMLEvents = /^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,
|
||||
MouseEvents = /^(?:click|mouse(?:down|up|over|move|out))$/;
|
||||
return (HTMLEvents.test(eventName) || MouseEvents.test(eventName)) ?
|
||||
eventName :
|
||||
'h:' + eventName;
|
||||
},
|
||||
|
||||
// el needs an event to be attached. el is not necessarily a dom element
|
||||
addEvent: function (el, event, fn) {
|
||||
if (el.addEventListener || el.attachEvent) {
|
||||
Event.observe($(el), HighchartsAdapter.addNS(event), fn);
|
||||
|
||||
} else {
|
||||
HighchartsAdapter._extend(el);
|
||||
el._highcharts_observe(event, fn);
|
||||
}
|
||||
},
|
||||
|
||||
// motion makes things pretty. use it if effects is loaded, if not... still get to the end result.
|
||||
animate: function (el, params, options) {
|
||||
var key,
|
||||
fx;
|
||||
|
||||
// default options
|
||||
options = options || {};
|
||||
options.delay = 0;
|
||||
options.duration = (options.duration || 500) / 1000;
|
||||
options.afterFinish = options.complete;
|
||||
|
||||
// animate wrappers and DOM elements
|
||||
if (hasEffect) {
|
||||
for (key in params) {
|
||||
// The fx variable is seemingly thrown away here, but the Effect.setup will add itself to the _highcharts_animation object
|
||||
// on the element itself so its not really lost.
|
||||
fx = new Effect.HighchartsTransition($(el), key, params[key], options);
|
||||
}
|
||||
} else {
|
||||
if (el.attr) { // #409 without effects
|
||||
for (key in params) {
|
||||
el.attr(key, params[key]);
|
||||
}
|
||||
}
|
||||
if (options.complete) {
|
||||
options.complete();
|
||||
}
|
||||
}
|
||||
|
||||
if (!el.attr) { // HTML element, #409
|
||||
$(el).setStyle(params);
|
||||
}
|
||||
},
|
||||
|
||||
// this only occurs in higcharts 2.0+
|
||||
stop: function (el) {
|
||||
var key;
|
||||
if (el._highcharts_extended && el._highchart_animation) {
|
||||
for (key in el._highchart_animation) {
|
||||
// Cancel the animation
|
||||
// The 'finish' function in the Effect object will remove the reference
|
||||
el._highchart_animation[key].cancel();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// um.. each
|
||||
each: function (arr, fn) {
|
||||
$A(arr).each(fn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the cumulative offset relative to the top left of the page. This method, unlike its
|
||||
* jQuery and MooTools counterpart, still suffers from issue #208 regarding the position
|
||||
* of a chart within a fixed container.
|
||||
*/
|
||||
offset: function (el) {
|
||||
return $(el).cumulativeOffset();
|
||||
},
|
||||
|
||||
// fire an event based on an event name (event) and an object (el).
|
||||
// again, el may not be a dom element
|
||||
fireEvent: function (el, event, eventArguments, defaultFunction) {
|
||||
if (el.fire) {
|
||||
el.fire(HighchartsAdapter.addNS(event), eventArguments);
|
||||
} else if (el._highcharts_extended) {
|
||||
eventArguments = eventArguments || {};
|
||||
el._highcharts_fire(event, eventArguments);
|
||||
}
|
||||
|
||||
if (eventArguments && eventArguments.defaultPrevented) {
|
||||
defaultFunction = null;
|
||||
}
|
||||
|
||||
if (defaultFunction) {
|
||||
defaultFunction(eventArguments);
|
||||
}
|
||||
},
|
||||
|
||||
removeEvent: function (el, event, handler) {
|
||||
if ($(el).stopObserving) {
|
||||
if (event) {
|
||||
event = HighchartsAdapter.addNS(event);
|
||||
}
|
||||
$(el).stopObserving(event, handler);
|
||||
} if (window === el) {
|
||||
Event.stopObserving(el, event, handler);
|
||||
} else {
|
||||
HighchartsAdapter._extend(el);
|
||||
el._highcharts_stop_observing(event, handler);
|
||||
}
|
||||
},
|
||||
|
||||
// um, grep
|
||||
grep: function (arr, fn) {
|
||||
return arr.findAll(fn);
|
||||
},
|
||||
|
||||
// um, map
|
||||
map: function (arr, fn) {
|
||||
return arr.map(fn);
|
||||
},
|
||||
|
||||
// deep merge. merge({a : 'a', b : {b1 : 'b1', b2 : 'b2'}}, {b : {b2 : 'b2_prime'}, c : 'c'}) => {a : 'a', b : {b1 : 'b1', b2 : 'b2_prime'}, c : 'c'}
|
||||
/*merge: function(){
|
||||
function doCopy(copy, original) {
|
||||
var value,
|
||||
key,
|
||||
undef,
|
||||
nil,
|
||||
same,
|
||||
obj,
|
||||
arr,
|
||||
node;
|
||||
|
||||
for (key in original) {
|
||||
value = original[key];
|
||||
undef = typeof(value) === 'undefined';
|
||||
nil = value === null;
|
||||
same = original === copy[key];
|
||||
|
||||
if (undef || nil || same) {
|
||||
continue;
|
||||
}
|
||||
|
||||
obj = typeof(value) === 'object';
|
||||
arr = value && obj && value.constructor == Array;
|
||||
node = !!value.nodeType;
|
||||
|
||||
if (obj && !arr && !node) {
|
||||
copy[key] = doCopy(typeof copy[key] == 'object' ? copy[key] : {}, value);
|
||||
}
|
||||
else {
|
||||
copy[key] = original[key];
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
var args = arguments, retVal = {};
|
||||
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
retVal = doCopy(retVal, args[i]);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
},*/
|
||||
merge: function () { // the built-in prototype merge function doesn't do deep copy
|
||||
function doCopy(copy, original) {
|
||||
var value, key;
|
||||
|
||||
for (key in original) {
|
||||
value = original[key];
|
||||
if (value && typeof value === 'object' && value.constructor !== Array &&
|
||||
typeof value.nodeType !== 'number') {
|
||||
copy[key] = doCopy(copy[key] || {}, value); // copy
|
||||
|
||||
} else {
|
||||
copy[key] = original[key];
|
||||
}
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
function merge() {
|
||||
var args = arguments,
|
||||
i,
|
||||
retVal = {};
|
||||
|
||||
for (i = 0; i < args.length; i++) {
|
||||
retVal = doCopy(retVal, args[i]);
|
||||
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
return merge.apply(this, arguments);
|
||||
},
|
||||
|
||||
// extend an object to handle highchart events (highchart objects, not svg elements).
|
||||
// this is a very simple way of handling events but whatever, it works (i think)
|
||||
_extend: function (object) {
|
||||
if (!object._highcharts_extended) {
|
||||
Object.extend(object, {
|
||||
_highchart_events: {},
|
||||
_highchart_animation: null,
|
||||
_highcharts_extended: true,
|
||||
_highcharts_observe: function (name, fn) {
|
||||
this._highchart_events[name] = [this._highchart_events[name], fn].compact().flatten();
|
||||
},
|
||||
_highcharts_stop_observing: function (name, fn) {
|
||||
if (name) {
|
||||
if (fn) {
|
||||
this._highchart_events[name] = [this._highchart_events[name]].compact().flatten().without(fn);
|
||||
} else {
|
||||
delete this._highchart_events[name];
|
||||
}
|
||||
} else {
|
||||
this._highchart_events = {};
|
||||
}
|
||||
},
|
||||
_highcharts_fire: function (name, args) {
|
||||
(this._highchart_events[name] || []).each(function (fn) {
|
||||
// args is never null here
|
||||
if (args.stopped) {
|
||||
return; // "throw $break" wasn't working. i think because of the scope of 'this'.
|
||||
}
|
||||
|
||||
// Attach a simple preventDefault function to skip default handler if called
|
||||
args.preventDefault = function () {
|
||||
args.defaultPrevented = true;
|
||||
};
|
||||
|
||||
// If the event handler return false, prevent the default handler from executing
|
||||
if (fn.bind(this)(args) === false) {
|
||||
args.preventDefault();
|
||||
}
|
||||
}
|
||||
.bind(this));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}());
|
||||
Reference in New Issue
Block a user