EventChainLocal.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2017
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['../lib/@waca/core-client/js/core-client/ui/core/Class'], function (Class) {
  8. /**
  9. * Provide ability to store local variables that can be accessed
  10. * by event handlers that are handling the same event down the chain.
  11. *
  12. */
  13. var EventChainLocal = Class.extend({
  14. init: function init(event) {
  15. this.event = event;
  16. },
  17. _getSourceEvent: function _getSourceEvent() {
  18. var srcEvent;
  19. if (this.event.gesture) {
  20. srcEvent = this.event.gesture.srcEvent;
  21. } else if (this.event.originalEvent) {
  22. srcEvent = this.event.originalEvent;
  23. } else {
  24. srcEvent = this.event;
  25. }
  26. return srcEvent;
  27. },
  28. _getPropertyMap: function _getPropertyMap() {
  29. var evt = this._getSourceEvent();
  30. if (!evt._eventChainLocalMap) {
  31. evt._eventChainLocalMap = {};
  32. }
  33. return evt._eventChainLocalMap;
  34. },
  35. setProperty: function setProperty(name, value) {
  36. this._getPropertyMap()[name] = value;
  37. },
  38. getProperty: function getProperty(name) {
  39. return this._getPropertyMap()[name];
  40. }
  41. });
  42. return EventChainLocal;
  43. });
  44. //# sourceMappingURL=EventChainLocal.js.map