12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- 'use strict';
- /**
- * Licensed Materials - Property of IBM
- * IBM Cognos Products: Storytelling
- * (C) Copyright IBM Corp. 2019
- * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- */
- define(['baglass/core-client/js/core-client/ui/core/Class'], function (Class) {
- var WidgetHelper = Class.extend({
- init: function init(options) {
- this.dashboardApi = options.dashboardApi;
- },
- /**
- * @param {string} widgetId
- * @return WidgetAPI object
- */
- getWidget: function getWidget(widgetId) {
- var content = this.getContent(widgetId);
- return content ? content.getFeature('WidgetAPI.deprecated') : null;
- },
- /**
- * @param {string} contentId
- * @return ContentAPI object
- */
- getContent: function getContent(contentId) {
- var canvas = this.dashboardApi.getCanvas();
- return canvas ? canvas.getContent(contentId) : null;
- },
- /**
- * @param {string} contentId
- * @return {Number} event group id
- */
- getEventGroupId: function getEventGroupId(contentId) {
- var eventGroups = this.dashboardApi.getFeature('EventGroups');
- return eventGroups.getGroupId(contentId);
- },
- /**
- * Recursively walk the content and it's parent to find the page content
- * @param {ContentAPI} content
- * @returns {ContentAPI} page content. If a page can not be found, returns null
- */
- getPageContent: function getPageContent(content) {
- var pageContent = null;
- while (content) {
- if (content.getType() === 'page') {
- pageContent = content;
- }
- content = content.getContainer();
- }
- return pageContent;
- },
- /**
- * @param {string} contentId
- * @return DOM node
- */
- getContentNode: function getContentNode(contentId) {
- var content = this.getContent(contentId);
- return content ? content.getFeature('ContentViewDOM').getNode() : null;
- },
- /**
- * @param {string} contentId
- * @return DOM node
- */
- getContentState: function getContentState(contentId) {
- var content = this.getContent(contentId);
- return content ? content.getFeature('state.internal') : null;
- }
- });
- return WidgetHelper;
- });
- //# sourceMappingURL=WidgetHelper.js.map
|