SplitPaneView.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2019
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['../../lib/@waca/core-client/js/core-client/ui/core/View', 'jquery', '../../app/ui/Splitter'], function (View, $) {
  11. return function (_View) {
  12. _inherits(SplitPaneView, _View);
  13. function SplitPaneView() {
  14. _classCallCheck(this, SplitPaneView);
  15. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  16. args[_key] = arguments[_key];
  17. }
  18. return _possibleConstructorReturn(this, _View.call.apply(_View, [this].concat(args)));
  19. }
  20. SplitPaneView.prototype.init = function init() {
  21. var _View$prototype$init;
  22. for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  23. args[_key2] = arguments[_key2];
  24. }
  25. (_View$prototype$init = _View.prototype.init).call.apply(_View$prototype$init, [this].concat(args));
  26. this.$bottom = null;
  27. this.$top = null;
  28. this.$content = null;
  29. this.splitter = null;
  30. var options = args[0];
  31. this._splitterItems = options.splitterItems || [];
  32. this.handlers = options.handlers;
  33. this.services = options.services;
  34. this.dashboard = options.dashboardApi;
  35. this.glassContext = options.services.biGlass.glassContext;
  36. };
  37. SplitPaneView.prototype.render = function render() {
  38. var _View$prototype$rende;
  39. for (var _len3 = arguments.length, args = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
  40. args[_key3] = arguments[_key3];
  41. }
  42. (_View$prototype$rende = _View.prototype.render).call.apply(_View$prototype$rende, [this].concat(args));
  43. var content = {};
  44. if (this.glassContext.appController.currentAppView.content) {
  45. content = this.glassContext.appController.currentAppView.content;
  46. }
  47. this.splitter = this.$el.splitter({
  48. items: this._splitterItems,
  49. panel: this.getBottomBarNode(),
  50. content: content,
  51. handlers: {
  52. getParentSize: this.handlers.getParentSize
  53. }
  54. }).data('splitter');
  55. this._setupEvents();
  56. return Promise.resolve();
  57. };
  58. SplitPaneView.prototype._setupEvents = function _setupEvents() {
  59. this.dashboard.on('enter:fullscreen', this.hideSplitter.bind(this));
  60. this.dashboard.on('exit:fullscreen', this.restoreSplitter.bind(this));
  61. };
  62. SplitPaneView.prototype.getBottomBarNode = function getBottomBarNode() {
  63. if (this.$bottom === null) {
  64. var $bottomPane = $('.bottomPane', this.el);
  65. if ($bottomPane.length === 0) {
  66. $bottomPane = $('<div class="bottomPane"></div>').appendTo(this.el);
  67. }
  68. this.$bottom = $bottomPane;
  69. }
  70. return this.$bottom;
  71. };
  72. SplitPaneView.prototype.getContentNode = function getContentNode() {
  73. if (this.$content === null) {
  74. var $contentNode = this.$('.pageViewContent', this.el);
  75. if ($contentNode.length === 0) {
  76. $contentNode = $('<div class="pageViewContent"></div>').prependTo(this.el);
  77. }
  78. this.$content = $contentNode;
  79. }
  80. return this.$content;
  81. };
  82. SplitPaneView.prototype.close = function close() {
  83. this.splitter.close();
  84. };
  85. SplitPaneView.prototype.open = function open() {
  86. this.splitter.open();
  87. };
  88. SplitPaneView.prototype.getSplitter = function getSplitter() {
  89. return this.splitter;
  90. };
  91. SplitPaneView.prototype.showHandle = function showHandle(handle) {
  92. this.splitter.showHandle(handle);
  93. };
  94. SplitPaneView.prototype.hideHandle = function hideHandle(handle) {
  95. this.splitter.hideHandle(handle);
  96. };
  97. SplitPaneView.prototype.onContainerReady = function onContainerReady() {
  98. var promises = [];
  99. this._splitterItems.forEach(function (item) {
  100. if (item.view.onContainerReady && typeof item.view.onContainerReady === 'function') {
  101. promises.push(item.view.onContainerReady());
  102. }
  103. }, this);
  104. return Promise.all(promises);
  105. };
  106. SplitPaneView.prototype.hideSplitter = function hideSplitter() {
  107. var _this2 = this;
  108. var result = void 0;
  109. if (this.splitter.isOpen()) {
  110. this._splitterWasOpen = true;
  111. result = this.splitter.close().then(function () {
  112. _this2._hideBottomPanel();
  113. });
  114. } else {
  115. this._hideBottomPanel();
  116. result = Promise.resolve();
  117. }
  118. return result.then(function () {
  119. _this2.splitter.hide();
  120. });
  121. };
  122. SplitPaneView.prototype.slideSplitterToMinSize = function slideSplitterToMinSize() {
  123. if (this.splitter.isOpen()) {
  124. this._splitterWasOpen = true;
  125. this.splitter.setPaneSize(120);
  126. }
  127. };
  128. SplitPaneView.prototype.restoreSplitter = function restoreSplitter() {
  129. var _this3 = this;
  130. this._showBottomPanel();
  131. return this.splitter.show().then(function () {
  132. if (_this3._splitterWasOpen) {
  133. _this3.splitter.open();
  134. _this3._splitterWasOpen = false;
  135. }
  136. });
  137. };
  138. SplitPaneView.prototype._hideBottomPanel = function _hideBottomPanel() {
  139. this.getBottomBarNode().hide();
  140. };
  141. SplitPaneView.prototype._showBottomPanel = function _showBottomPanel() {
  142. this.getBottomBarNode().show();
  143. };
  144. SplitPaneView.prototype.remove = function remove() {
  145. var _View$prototype$remov;
  146. this.dashboard.off('enter:fullscreen', this.hideSplitter.bind(this));
  147. this.dashboard.off('exit:fullscreen', this.restoreSplitter.bind(this));
  148. this.$el.destroySplitter();
  149. this.splitter = null;
  150. this.$bottom = null;
  151. this.$top = null;
  152. this.$content = null;
  153. this._splitterItems = null;
  154. this.handlers = null;
  155. this.services = null;
  156. this.glassContext = null;
  157. for (var _len4 = arguments.length, args = Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
  158. args[_key4] = arguments[_key4];
  159. }
  160. (_View$prototype$remov = _View.prototype.remove).call.apply(_View$prototype$remov, [this].concat(args));
  161. };
  162. return SplitPaneView;
  163. }(View);
  164. });
  165. //# sourceMappingURL=SplitPaneView.js.map