123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- '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
|