Widget.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. 'use strict';
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2013, 2018
  5. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  6. */
  7. define(['./LayoutBaseView'], function (BaseClass) {
  8. var Widget = null;
  9. Widget = BaseClass.extend({
  10. init: function init(options) {
  11. Widget.inherited('init', this, arguments);
  12. this.widgetChromeEventRouter = options.widgetChromeEventRouter || this.consumeView.widgetChromeEventRouter;
  13. //overrides
  14. this.specializeConsumeView(['getContextToolbarItems', 'onSelect', 'onDeselect', 'onShow']);
  15. this._aHandles = [];
  16. if (this.widgetChromeEventRouter) {
  17. this.widgetChromeEventRouter.trigger('widget:onAuthoringMode');
  18. }
  19. },
  20. destroy: function destroy() {
  21. this.commonAuthoringFeature.destroy();
  22. for (var i = 0, iLen = this._aHandles.length; i < iLen; i++) {
  23. this._aHandles[i].off();
  24. }
  25. this._aHandles = null;
  26. Widget.inherited('destroy', this, arguments);
  27. if (this.widgetChromeEventRouter) {
  28. var eventName;
  29. if (this.layoutController.isEventGroupMode) {
  30. eventName = 'widget:onEventGroupMode';
  31. } else {
  32. eventName = 'widget:onConsumeMode';
  33. }
  34. this.widgetChromeEventRouter.trigger(eventName);
  35. }
  36. },
  37. onResizeStep: function onResizeStep() {
  38. this.commonAuthoringFeature.onResizeStep();
  39. },
  40. getContextToolbarItems: function getContextToolbarItems() {
  41. var includeToolbaritems = this.consumeView.widgetAPI && !this.consumeView.widgetAPI.getError();
  42. return {
  43. items: includeToolbaritems ? this.consumeView.widgetAPI.getContextToolbarItems() : []
  44. };
  45. },
  46. onSelect: function onSelect(isGroupSelect) {
  47. if (this.widgetChromeEventRouter) {
  48. this.widgetChromeEventRouter.trigger('widgetchrome:selected', isGroupSelect);
  49. }
  50. },
  51. onDeselect: function onDeselect() {
  52. if (this.widgetChromeEventRouter) {
  53. this.widgetChromeEventRouter.trigger('widgetchrome:deselected');
  54. }
  55. },
  56. onShow: function onShow(options) {
  57. this.overridden.onShow(options);
  58. }
  59. });
  60. return Widget;
  61. });
  62. //# sourceMappingURL=Widget.js.map