1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- '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 LiveWidgetDOM
- * @hideconstructor
- * @classdesc Implements LiveWidgetDOMAPI
- */
- define(['./api/LiveWidgetDOMAPI', 'jquery', '../../../../lib/@waca/dashboard-common/dist/core/APIFactory'], function (LiveWidgetDOMAPI, $, APIFactory) {
- var LiveWidgetDOM = function () {
- function LiveWidgetDOM(options) {
- _classCallCheck(this, LiveWidgetDOM);
- this._domNode = options.features.ContentViewDOM.getNode();
- this.providers = [];
- }
- LiveWidgetDOM.prototype.getAPI = function getAPI() {
- if (!this._api) {
- this._api = APIFactory.createAPI(this, [LiveWidgetDOMAPI]);
- }
- return this._api;
- };
- /**
- * @implements LiveWidgetDOMAPI.getUIJSON
- */
- LiveWidgetDOM.prototype.getUIJSON = function getUIJSON() {
- var UIJSON = {
- widgetIcons: this._retrieveWidgetIcons(),
- title: this._retrieveTitle()
- };
- this.providers.forEach(function (provider) {
- Object.assign(UIJSON, provider.getUIJSON());
- });
- return UIJSON;
- };
- LiveWidgetDOM.prototype.registerProvider = function registerProvider(providerAPI) {
- this.providers.push(providerAPI);
- };
- LiveWidgetDOM.prototype._retrieveWidgetIcons = function _retrieveWidgetIcons() {
- var $widgetIcons = $(this._domNode).find('.widgetHeader div.widgetIcons .dataWidgetIcon');
- var icons = [];
- if ($widgetIcons.length) {
- $widgetIcons.each(function (index, icon) {
- var $icon = $(icon);
- var title = $icon.attr('title');
- var ariaLabel = $icon.attr('aria-label');
- if ($icon.is(':visible')) {
- if (title && ariaLabel && title === ariaLabel) {
- icons.push({
- label: title
- });
- } else icons.push({ label: null });
- }
- });
- }
- return icons.length ? icons : undefined;
- };
- LiveWidgetDOM.prototype._retrieveTitle = function _retrieveTitle() {
- var $title = $(this._domNode).find('.widgetHeader .widgetTitle .textArea');
- var title = void 0;
- if ($title && $title.length && $title.is(':visible')) {
- var $textNode = $title.find('span.textFitted p span');
- title = {
- value: $textNode.text(),
- fontSize: $textNode.css('font-size'),
- fontFamily: $textNode.css('font-family'),
- alignment: $textNode.css('text-align')
- };
- }
- return title;
- };
- return LiveWidgetDOM;
- }();
- return LiveWidgetDOM;
- });
- //# sourceMappingURL=LiveWidgetDOM.js.map
|