'use strict'; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /* * Licensed Materials - Property of IBM * IBM Business Analytics (C) Copyright IBM Corp. 2019, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /** * @class VisExpandMode * @hideconstructor * @classdesc Implements VisExpandModeAPI */ define(['./api/VisExpandModeAPI', 'text!./VisExpandMode.template', '../../../../visualizations/vipr/VIPRLibraries', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory', 'doT'], function (VisExpandModeAPI, template, VIPRLibraries, APIFactory, dot) { var VisExpandMode = function () { function VisExpandMode(options) { _classCallCheck(this, VisExpandMode); this.dashboard = options.dashboardAPI; this.content = options.content; } VisExpandMode.prototype.getAPI = function getAPI() { if (!this._api) { this._api = APIFactory.createAPI(this, [VisExpandModeAPI]); } return this._api; }; /** * @implements VisExpandModeAPI.renderExpandedModeContent */ VisExpandMode.prototype.renderExpandedModeContent = function renderExpandedModeContent(containerNode) { // add two class one by one because adding multiple classes does not support in IE containerNode.classList.add('liveWidget'); containerNode.classList.add('widgetExpanded'); var contentNode = this.content.getFeature('ContentViewDOM').getNode(); this.el = contentNode.querySelector('.widgetContent'); this._parentNode = this.el.parentNode; var boardFillColor = this.dashboard.getCanvas().getPropertyValue('fillColor'); var colorFeature = this.dashboard.getFeature('Colors'); var boardBackgroundColorClass = boardFillColor ? 'fill-' + colorFeature.getColorClassName(boardFillColor) : ''; var contentHtml = dot.template(template)({ boardBackgroundColorClass: boardBackgroundColorClass }); this.headerNode = this._parentNode.querySelector('.widgetHeader'); this.previewMessageNode = this._parentNode.querySelector('.customVisPreviewMessage'); this.contentNode = document.createElement('div'); this.contentNode.classList.add('expandModeContainer'); this.contentNode.innerHTML = contentHtml; this.placeHolderNode = document.createElement('div'); this.placeHolderNode.style.width = this.el.offsetWidth; this.placeHolderNode.style.height = this.el.offsetHeight; var widgetNode = this.contentNode.querySelector('.widget'); if (this.previewMessageNode) { widgetNode.appendChild(this.previewMessageNode); } widgetNode.appendChild(this.headerNode); widgetNode.appendChild(this.el); this.el.parentNode.appendChild(this.placeHolderNode); this._applyCommonProperties(); containerNode.appendChild(this.contentNode); var state = this.content && this.content.getFeature('state.internal'); if (state) { var error = state.getError(); if (error && error.getParams) { var params = error.getParams() || {}; if (params.errorInfo && params.errorInfo.errorCode === VIPRLibraries.LOAD_DEFINITION_ERROR) { state.clearError(); } } } }; /** * @implements VisExpandModeAPI.restore */ VisExpandMode.prototype.restore = function restore() { if (this._parentNode && this.headerNode) { this._parentNode.insertBefore(this.headerNode, this._parentNode.firstChild); } this.placeHolderNode.parentNode.removeChild(this.placeHolderNode); this.contentNode.parentNode.removeChild(this.contentNode); }; /* replaces the fill and border color of the widget. Similar to applyCommonProperties in VisView which is to be removed*/ VisExpandMode.prototype._applyCommonProperties = function _applyCommonProperties() { var contentFillColor = this.content.getPropertyValue('fillColor'); var contentBorderColor = this.content.getPropertyValue('borderColor'); var colorFeature = this.dashboard.getFeature('Colors'); // We set the class name this way so that it works for svg elements. JQuery add/removeClass does not work with svg elements. // clear previous fill color var re = new RegExp('\\s*\\b' + 'fill|border' + '-[^\\s]*\\b', 'g'); var parentNode = this.el.parentNode; // different from this.parentNode at this point var className = parentNode.getAttribute('class') || ''; className = className.replace(re, ''); if (contentFillColor) { className += ' fill-' + colorFeature.getColorClassName(contentFillColor); } if (contentBorderColor) { className += ' border-' + colorFeature.getColorClassName(contentBorderColor); } parentNode.setAttribute('class', className); }; return VisExpandMode; }(); return VisExpandMode; }); //# sourceMappingURL=VisExpandMode.js.map