123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- (function() {
-
- var win = window,
- legacy = !!win.$merge
- $extend = win.$extend || function() {
- return Object.append.apply(Object, arguments)
- };
- win.HighchartsAdapter = {
-
- init: function() {
- var fxProto = Fx.prototype,
- fxStart = fxProto.start,
- morphProto = Fx.Morph.prototype,
- morphCompute = morphProto.compute;
-
-
- fxProto.start = function(from, to) {
- var fx = this,
- elem = fx.element;
-
-
- if (from.d) {
-
- fx.paths = Highcharts.pathAnim.init(
- elem,
- elem.d,
- fx.toD
- );
- }
- fxStart.apply(fx, arguments);
- };
-
-
- morphProto.compute = function(from, to, delta) {
- var fx = this,
- paths = fx.paths;
-
- if (paths) {
- fx.element.attr(
- 'd',
- Highcharts.pathAnim.step(paths[0], paths[1], delta, fx.toD)
- );
- } else {
- return morphCompute.apply(fx, arguments);
- }
- };
-
- },
-
-
- animate: function (el, params, options) {
- var isSVGElement = el.attr,
- effect,
- complete = options && options.complete;
-
- if (isSVGElement && !el.setStyle) {
-
- el.getStyle = el.attr;
- el.setStyle = function() {
- var args = arguments;
- el.attr.call(el, args[0], args[1][0]);
- }
-
- el.$family = el.uid = true;
- }
-
-
- HighchartsAdapter.stop(el);
-
-
- effect = new Fx.Morph(
- isSVGElement ? el : $(el),
- $extend({
- transition: Fx.Transitions.Quad.easeInOut
- }, options)
- );
-
-
- if (params.d) {
- effect.toD = params.d;
- }
-
-
- if (complete) {
- effect.addEvent('complete', complete);
- }
-
-
- effect.start(params);
-
-
- el.fx = effect;
- },
-
-
- each: function(arr, fn) {
- return legacy ?
- $each(arr, fn) :
- arr.each(fn);
- },
-
-
- map: function (arr, fn){
- return arr.map(fn);
- },
-
-
- grep: function(arr, fn) {
- return arr.filter(fn);
- },
-
-
- merge: function() {
- var args = arguments,
- args13 = [{}],
- i = args.length,
- ret;
-
- if (legacy) {
- ret = $merge.apply(null, args);
- } else {
- while (i--) {
- args13[i + 1] = args[i];
- }
- ret = Object.merge.apply(Object, args13);
- }
-
- return ret;
- },
-
-
- hyphenate: function (str){
- return str.hyphenate();
- },
-
-
- addEvent: function (el, type, fn) {
- if (typeof type == 'string') {
-
- if (type == 'unload') {
- type = 'beforeunload';
- }
-
-
- if (!el.addEvent) {
- if (el.nodeName) {
- el = $(el);
- } else {
- $extend(el, new Events());
- }
- }
-
- el.addEvent(type, fn);
- }
- },
-
- removeEvent: function(el, type, fn) {
- if (type) {
- if (type == 'unload') {
- type = 'beforeunload';
- }
- el.removeEvent(type, fn);
- }
- },
-
- fireEvent: function(el, event, eventArguments, defaultFunction) {
-
- m_event = new Event({
- type: event,
- target: el
- });
- m_event = $extend(event, eventArguments);
-
-
- m_event.preventDefault = function() {
- defaultFunction = null;
- };
-
-
- if (el.fireEvent) {
- el.fireEvent(m_event.type, m_event);
- }
-
-
- if (defaultFunction) {
- defaultFunction(m_event);
- }
- },
-
-
- stop: function (el) {
- if (el.fx) {
- el.fx.cancel();
- }
- }
- }
- })();
|