'use strict'; /** * Licensed Materials - Property of IBM * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2016, 2019 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define(['./staticwidget/StaticWidget', 'jquery'], function (Base, $) { var CustomWidget = Base.extend({ init: function init(options) { CustomWidget.inherited('init', this, arguments); this.registry = options.registry; this.eventRouter = options.eventRouter; // initialize the root nodes this._initContentRoot(); this._initWidgetProperties(options.initialConfigJSON); this.onInit(options.registry.params); }, destroy: function destroy() { this.onDestroy(); CustomWidget.inherited('destroy', this, arguments); }, _initContentRoot: function _initContentRoot() { var contentRoot = this.getContentRootNode(); contentRoot.addClass('staticContent'); var scroll = this.registry.scroll || 'scrollY'; contentRoot.addClass('customWidget_' + scroll); }, _initWidgetProperties: function _initWidgetProperties(config) { var root = this.getWidgetStyleNode(); if (config.fillColor) { root.addClass('fill-' + config.fillColor); } if (config.borderColor) { root.addClass('border-' + config.borderColor); } }, render: function render() { this.onRender(); return Promise.resolve(); }, /** * API * * Initialize the custom widget * * @param params - object which contains the parameters to initialize the custom widget */ onInit: function onInit() /*params*/{}, /** * API * * Destroy the custom widget */ onDestroy: function onDestroy() {}, /** * API * * Render the custom widget */ onRender: function onRender() {}, getWidgetStyleNode: function getWidgetStyleNode() { return $(this.el); }, getContentRootNode: function getContentRootNode() { return this.$el; }, /** * Register an event with the handler and context. * * @param eventName - name of the event * @param handler - event handler * @param context - context of the event handler */ on: function on(eventName, handler, context) { this.eventRouter.on(eventName, handler, context); }, /** * Unregister an event with the handler and context * * @param eventName - name of the event * @param handler - event handler * @param context - context of the event handler */ off: function off(eventName, handler, context) { this.eventRouter.off(eventName, handler, context); }, /** * Triggers an event * * @param eventName - name of the event * @param event - event object */ trigger: function trigger(eventName, event) { this.eventRouter.trigger(eventName, event); } }); return CustomWidget; }); //# sourceMappingURL=CustomWidget.js.map