'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2017 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['underscore', '../../../lib/@waca/dashboard-common/dist/ui/WidgetBase'], function (_, WidgetBase) { /** * The static widget object is a generic class for "static" widget types (e.g. image, text, shapes) that don't require * interactivity during consumption mode, but do require some (e.g. to set properties) in authoring mode. */ var StaticWidget = WidgetBase.extend({ focusOn: false, init: function init() { StaticWidget.inherited('init', this, arguments); }, onContainerReady: function onContainerReady() { StaticWidget.inherited('onContainerReady', this, arguments); }, /** * Notify Properties pane on chrome getting selected as well */ onChromeSelected: function onChromeSelected() { StaticWidget.inherited('onChromeSelected', this, arguments); this.onFocus(); }, /** * Handler for Widget chrome deselect event */ onChromeDeselected: function onChromeDeselected() { StaticWidget.inherited('onChromeDeselected', this, arguments); this.focusOn = false; }, /** * Handler for Focus event * Gets spec for the widget properties and notifies Property pane so that it can * show properties to change */ onFocus: function onFocus() { if (!this.focusOn) { this.focusOn = true; } }, /** * Virtual Method: Based on properties, generate the HTML for the static content */ getHtmlRender: function getHtmlRender() { return null; }, /** * Get the node where we can apply style changes like border and fill colors * @returns */ getWidgetStyleNode: function getWidgetStyleNode() { return this.$el.children('.staticContent'); }, /** * Update the model when a property is changed for this widget, in the properties side panel. */ onPropertyUpdate: function onPropertyUpdate() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; StaticWidget.inherited('onPropertyUpdate', this, arguments); // update model content this.updateModelContent(null, options.transactionId, options.sender); }, /** * Updates the model version of the markup of this widget * @param updatedHtml An optional parameter of the markup. * This is to avoid regenerating the markup if it is already known. */ updateModelContent: function updateModelContent(updatedHtml, transactionId) { // regenerate the HTML if not passed if (!updatedHtml) { updatedHtml = this.getHtmlRender(); } // update the model to persist the changes. Use transactionId to combine undos var data = {}; if (transactionId) { _.extend(data, { payloadData: { undoRedoTransactionId: transactionId } }); } else { _.extend(data, { silent: true }); } this.set({ content: updatedHtml }, data); } }); return StaticWidget; }); //# sourceMappingURL=StaticWidget.js.map