EventChainLocal.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. var EventChainLocal = null;
  9. /**
  10. * Provide ability to store local variables that can be accessed
  11. * by event handlers that are handling the same event down the chain.
  12. *
  13. */
  14. EventChainLocal = Class.extend({
  15. init: function init(event) {
  16. this.event = event;
  17. },
  18. _getSourceEvent: function _getSourceEvent() {
  19. var srcEvent;
  20. if (this.event.gesture) {
  21. srcEvent = this.event.gesture.srcEvent;
  22. } else if (this.event.originalEvent) {
  23. srcEvent = this.event.originalEvent;
  24. } else {
  25. srcEvent = this.event;
  26. }
  27. return srcEvent;
  28. },
  29. _getPropertyMap: function _getPropertyMap() {
  30. var evt = this._getSourceEvent();
  31. if (!evt._eventChainLocalMap) {
  32. evt._eventChainLocalMap = {};
  33. }
  34. return evt._eventChainLocalMap;
  35. },
  36. setProperty: function setProperty(name, value) {
  37. this._getPropertyMap()[name] = value;
  38. },
  39. getProperty: function getProperty(name) {
  40. return this._getPropertyMap()[name];
  41. }
  42. });
  43. return EventChainLocal;
  44. });
  45. //# sourceMappingURL=EventChainLocal.js.map