SlideoutHelper.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. /*
  3. *+------------------------------------------------------------------------+
  4. *| Licensed Materials - Property of IBM
  5. *| IBM Cognos Products: Content Explorer
  6. *| (C) Copyright IBM Corp. 2017, 2019
  7. *|
  8. *| US Government Users Restricted Rights - Use, duplication or disclosure
  9. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  10. *+------------------------------------------------------------------------+
  11. */
  12. define(['jquery', '../../lib/@waca/core-client/js/core-client/ui/core/Class'], function ($, Class) {
  13. var SlideoutHelper = Class.extend({
  14. createAndShowSlideout: function createAndShowSlideout(slideoutSpec, context) {
  15. var _this = this;
  16. this._slideout = this.glassContext.appController.showSlideOut(slideoutSpec);
  17. this._slideout.$el.addClass('dashboardPane');
  18. // force a resize after we show/hide so that we can resize the visualizations
  19. var resize = function resize() {
  20. try {
  21. $(window).resize();
  22. } catch (e) {
  23. console.error(e);
  24. }
  25. };
  26. this._slideout.on('done:show', resize);
  27. this._slideout.on('hide', function () {
  28. _this._closeSlideout();
  29. if (context && context.target && context.target.plugin && context.target.plugin.setUnpressed) {
  30. context.target.plugin.setUnpressed();
  31. }
  32. resize();
  33. });
  34. },
  35. isSlideoutOpen: function isSlideoutOpen() {
  36. return this._slideout && this._slideout.isOpen();
  37. },
  38. _closeSlideout: function _closeSlideout() {
  39. if (!this._slideout) {
  40. return;
  41. }
  42. this._slideout.hide({
  43. force: true
  44. });
  45. delete this._slideout;
  46. },
  47. onHide: function onHide() {
  48. if (this.isSlideoutOpen()) {
  49. this._closeSlideout();
  50. }
  51. }
  52. });
  53. return SlideoutHelper;
  54. });
  55. //# sourceMappingURL=SlideoutHelper.js.map