EventTarget.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. *| Licensed Materials - Property of IBM
  5. *|
  6. *| IBM Cognos Products: dashboard
  7. *|
  8. *| (C) Copyright IBM Corp. 2019
  9. *|
  10. *| US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  11. */
  12. define([], function () {
  13. var ProvideImplementionError = 'Must provide implementation';
  14. var EventTarget = function () {
  15. function EventTarget() {
  16. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17. _classCallCheck(this, EventTarget);
  18. this.$el = options.$el;
  19. this.visAPI = options.visAPI;
  20. this.visualization = options.visualization;
  21. this.content = options.content;
  22. }
  23. /**
  24. * Determine whether visualization state (ie. zoom, pan, scroll) can be restored
  25. * @return {boolean} true if the visualization state can be restored, otherwise false
  26. */
  27. EventTarget.prototype.canRestore = function canRestore() {
  28. return false;
  29. };
  30. /**
  31. * Restore the visualization state
  32. * @param {Object} state object containing the state of the visualization
  33. */
  34. EventTarget.prototype.restore = function restore() /* state */{};
  35. /**
  36. * Get the target JQuery element
  37. *
  38. * @return {object} The target JQuery element
  39. */
  40. EventTarget.prototype.getTargetElement = function getTargetElement() {
  41. return this.$el;
  42. };
  43. /**
  44. * Get the axis items from event and offset
  45. * @param event - the event as generated by visEventHandler
  46. * @param offset - an optional offset (in pixels) to ensure the line does not become the target of selections etc.
  47. * @return {object} The axis items
  48. */
  49. EventTarget.prototype.getValuesAtPoint = function getValuesAtPoint() /* event, offset */{
  50. throw new Error(ProvideImplementionError);
  51. };
  52. /**
  53. * Get the array of event targets based on the event.
  54. * Event target represents a data point object that corresponds to the event.
  55. *
  56. * @param event Event object
  57. *
  58. * @return {array} An arrey of event targets
  59. */
  60. EventTarget.prototype.getEventTargets = function getEventTargets() /* event */{
  61. throw new Error(ProvideImplementionError);
  62. };
  63. EventTarget.prototype.getTargetsByCords = function getTargetsByCords() {
  64. throw new Error(ProvideImplementionError);
  65. };
  66. /*
  67. * Visually decorate the targets. (Not used on grid - we use the old logic for this)
  68. *
  69. * @return {boolean} Return a boolean indicating whether the target is decorated or not
  70. */
  71. EventTarget.prototype.decorateTarget = function decorateTarget() {
  72. throw new Error(ProvideImplementionError);
  73. };
  74. /**
  75. * Obtain the decoration value from the given target item and decoration name
  76. * @param item event target item containing the decoration
  77. * @param decorationName common decoration name defined by VisEventHandler.DECORATIONS
  78. *
  79. * @return {string} The decorated vale
  80. */
  81. EventTarget.prototype.getDecoration = function getDecoration() /* item, decorationName */{
  82. throw new Error(ProvideImplementionError);
  83. };
  84. /**
  85. * Complete the series of decorations.
  86. * After clearing and adding multiple decorations, complete the decorations by rendering the visualization.
  87. */
  88. EventTarget.prototype.completeDecorations = function completeDecorations() {
  89. throw new Error(ProvideImplementionError);
  90. };
  91. /**
  92. * Apply selection on customdata target.
  93. *
  94. * @param target - Event target
  95. */
  96. EventTarget.prototype.applyCustomDataSelection = function applyCustomDataSelection() /* targets */{
  97. throw new Error(ProvideImplementionError);
  98. };
  99. /**
  100. * Return the list of custom data selections in label/value pair
  101. * @param {Object} target event target item of the selected custom data
  102. *
  103. * @return {array} Array of custom data selections
  104. */
  105. EventTarget.prototype.getCustomDataSelections = function getCustomDataSelections() /* target */{
  106. throw new Error(ProvideImplementionError);
  107. };
  108. /**
  109. * Determine whether the vipr visualization supports pan and zoom
  110. */
  111. EventTarget.prototype.canZoom = function canZoom() {
  112. throw new Error(ProvideImplementionError);
  113. };
  114. /**
  115. * Apply zooming
  116. *
  117. * @param event Event object
  118. */
  119. EventTarget.prototype.zoom = function zoom() /* event */{
  120. throw new Error(ProvideImplementionError);
  121. };
  122. /**
  123. * Start the zooming session
  124. *
  125. * @param event Event object
  126. */
  127. EventTarget.prototype.zoomStart = function zoomStart() /* event */{
  128. throw new Error(ProvideImplementionError);
  129. };
  130. /**
  131. * End the zooming session
  132. *
  133. * @param event Event object
  134. * @returns {Object|undefined} interactivity state containing the zoom level OR undefined if state is not supported
  135. */
  136. EventTarget.prototype.zoomEnd = function zoomEnd() /* event */{
  137. throw new Error(ProvideImplementionError);
  138. };
  139. /**
  140. * Apply panning movements
  141. *
  142. * @param event Event object
  143. */
  144. EventTarget.prototype.pan = function pan() /* event */{
  145. throw new Error(ProvideImplementionError);
  146. };
  147. /**
  148. * Start the panning session
  149. *
  150. * @param event Event object
  151. */
  152. EventTarget.prototype.panStart = function panStart() /* event */{
  153. throw new Error(ProvideImplementionError);
  154. };
  155. /**
  156. * End the panning session
  157. *
  158. * @param event Event object
  159. * @returns {Object|undefined} interactivity state containing the pan OR undefined if state is not supported
  160. */
  161. EventTarget.prototype.panEnd = function panEnd() /* event */{
  162. throw new Error(ProvideImplementionError);
  163. };
  164. EventTarget.prototype.processKeyDown = function processKeyDown() /* event */{
  165. throw new Error(ProvideImplementionError);
  166. };
  167. /**
  168. * explicitly remove unused object to prevent from memory leak
  169. */
  170. EventTarget.prototype.remove = function remove() {
  171. this.$el = null;
  172. this.visualization = null;
  173. this.visAPI = null;
  174. this.content = null;
  175. };
  176. EventTarget.prototype.getAPI = function getAPI() {
  177. return {
  178. canRestore: this.canRestore.bind(this),
  179. restore: this.restore.bind(this),
  180. getTargetElement: this.getTargetElement.bind(this),
  181. getEventTargets: this.getEventTargets.bind(this),
  182. getTargetsByCords: this.getTargetsByCords.bind(this),
  183. getValuesAtPoint: this.getValuesAtPoint.bind(this),
  184. decorateTarget: this.decorateTarget.bind(this),
  185. completeDecorations: this.completeDecorations.bind(this),
  186. getDecoration: this.getDecoration.bind(this),
  187. applyCustomDataSelection: this.applyCustomDataSelection.bind(this),
  188. getCustomDataSelections: this.getCustomDataSelections.bind(this),
  189. canZoom: this.canZoom.bind(this),
  190. zoom: this.zoom.bind(this),
  191. zoomStart: this.zoomStart.bind(this),
  192. zoomEnd: this.zoomEnd.bind(this),
  193. pan: this.pan.bind(this),
  194. panStart: this.panStart.bind(this),
  195. panEnd: this.panEnd.bind(this),
  196. processKeyDown: this.processKeyDown.bind(this),
  197. remove: this.remove.bind(this)
  198. };
  199. };
  200. return EventTarget;
  201. }();
  202. return EventTarget;
  203. });
  204. //# sourceMappingURL=EventTarget.js.map