'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: Storytelling (C) Copyright IBM Corp. 2018, 2020 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['./PlaceholderView', 'text!./IconPlaceholder.html', '../../util/TextFitUtil', '../../../lib/@waca/core-client/js/core-client/utils/Utils', '../../../app/nls/StringResources', '../../../lib/@waca/dashboard-common/dist/lib/@ba-ui-toolkit/ba-graphics/dist/illustrations-js/text-widget_128', '../../../lib/@waca/dashboard-common/dist/lib/@ba-ui-toolkit/ba-graphics/dist/illustrations-js/build-visualization_200'], function (BaseClass, Template, TextFitUtil, Utils, stringResources, textWidget128, buildVis200) { var IconPlaceholderView = null; var ICON_PLACEHOLDERS = { text: { iconName: textWidget128.default.id, text: stringResources.get('textWidgetIconPlaceholderText') }, list: { iconName: textWidget128.default.id, text: '\u2022 ' + stringResources.get('textWidgetIconPlaceholderText') }, vis: { iconName: buildVis200.default.id, text: stringResources.get('visIconPlaceholderText') } }; IconPlaceholderView = BaseClass.extend({ templateString: Template, init: function init() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; IconPlaceholderView.inherited('init', this, arguments); this.type = options.iconType || 'text'; }, render: function render() { var sHtml = this.dotTemplate({ placeholderText: ICON_PLACEHOLDERS[this.type].text }); this.$el.append(sHtml); this.resize(); Utils.setIcon(this.$el.find('.placeholder .iconContainer'), ICON_PLACEHOLDERS[this.type].iconName); }, show: function show() { IconPlaceholderView.inherited('show', this, arguments); this.fillText(); }, resize: function resize() { var maxHeight = 170; var maxWidth = 180; if (this.$el.height() < maxHeight || this.$el.width() < maxWidth) { this.$el.find('.placeholder').addClass('compact'); } else { this.$el.find('.placeholder').removeClass('compact'); } this.fillText(); }, fillText: function fillText() { var node = this.el.querySelector('.instructionText'); // Return if node doesn't exist or its parent is hidden if (!node || node.parentElement.style.display === 'none') { return; } var options = { maxFontSize: 14, minFontSize: 1, multiLine: false, detectMultiLine: false, alignHoriz: true, widthOnly: true }; TextFitUtil.fillText(node, options); } }); return IconPlaceholderView; }); //# sourceMappingURL=IconPlaceholderView.js.map