Base.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.charting.action2d.Base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.charting.action2d.Base"] = true;
  8. dojo.provide("dojox.charting.action2d.Base");
  9. dojo.require("dojo.fx.easing");
  10. dojo.require("dojox.lang.functional.object");
  11. dojo.require("dojox.gfx.fx");
  12. /*=====
  13. dojox.charting.action2d.__BaseCtorArgs = function(duration, easing){
  14. // summary:
  15. // The base keyword arguments object for creating an action2d.
  16. // duration: Number?
  17. // The amount of time in milliseconds for an animation to last. Default is 400.
  18. // easing: dojo.fx.easing.*?
  19. // An easing object (see dojo.fx.easing) for use in an animation. The
  20. // default is dojo.fx.easing.backOut.
  21. this.duration = duration;
  22. this.easing = easing;
  23. }
  24. =====*/
  25. (function(){
  26. var DEFAULT_DURATION = 400, // ms
  27. DEFAULT_EASING = dojo.fx.easing.backOut,
  28. df = dojox.lang.functional;
  29. dojo.declare("dojox.charting.action2d.Base", null, {
  30. overOutEvents: {onmouseover: 1, onmouseout: 1},
  31. constructor: function(chart, plot, kwargs){
  32. // summary:
  33. // Create a new base Action.
  34. // chart: dojox.charting.Chart2D
  35. // The chart this action applies to.
  36. // plot: String?
  37. // The name of the plot this action belongs to. If none is passed "default" is assumed.
  38. // kwargs: dojox.charting.action2d.__BaseCtorArgs?
  39. // Optional arguments for the action.
  40. this.chart = chart;
  41. this.plot = plot || "default";
  42. this.anim = {};
  43. // process common optional named parameters
  44. if(!kwargs){ kwargs = {}; }
  45. this.duration = kwargs.duration ? kwargs.duration : DEFAULT_DURATION;
  46. this.easing = kwargs.easing ? kwargs.easing : DEFAULT_EASING;
  47. },
  48. connect: function(){
  49. // summary:
  50. // Connect this action to the given plot.
  51. this.handle = this.chart.connectToPlot(this.plot, this, "process");
  52. },
  53. disconnect: function(){
  54. // summary:
  55. // Disconnect this action from the given plot, if connected.
  56. if(this.handle){
  57. dojo.disconnect(this.handle);
  58. this.handle = null;
  59. }
  60. },
  61. reset: function(){
  62. // summary:
  63. // Reset the action.
  64. },
  65. destroy: function(){
  66. // summary:
  67. // Do any cleanup needed when destroying parent elements.
  68. this.disconnect();
  69. df.forIn(this.anim, function(o){
  70. df.forIn(o, function(anim){
  71. anim.action.stop(true);
  72. });
  73. });
  74. this.anim = {};
  75. }
  76. });
  77. })();
  78. }