123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- 'use strict';
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Dashboard
- *| (C) Copyright IBM Corp. 2018, 2021
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['../../../lib/@waca/upgrades/UpgradeBase', './utils/WidgetUpgradeUtils', 'jquery'], function (UpgradeBase, WidgetUpgradeUtils, $) {
- var TEXT_WIDGET_TYPE = 'text';
- var TextWidgetParagraphUpgrade = function (_UpgradeBase) {
- _inherits(TextWidgetParagraphUpgrade, _UpgradeBase);
- function TextWidgetParagraphUpgrade() {
- _classCallCheck(this, TextWidgetParagraphUpgrade);
- var _this = _possibleConstructorReturn(this, _UpgradeBase.call(this));
- _this.VERSION = 1026;
- return _this;
- }
- /**
- * Perform upgrades for TextWidgets before support for numbered and unordered lists were added.
- * The default classes previously applied to the paragraph tag need to be moved up because adding
- * list replaces the paragraph tag.
- *
- * @param {object} spec - spec to perform upgrade on
- *
- * @return {Promise} Promise to be resolved when upgrade performed
- */
- TextWidgetParagraphUpgrade.prototype.up = function up(spec) {
- if (!spec) {
- return Promise.resolve(spec);
- }
- if (!WidgetUpgradeUtils.specHasWidgets(spec)) {
- return Promise.resolve(spec);
- }
- return this._upgradeWidgets(spec);
- };
- TextWidgetParagraphUpgrade.prototype._upgradeWidgets = function _upgradeWidgets(spec) {
- for (var widget in spec.widgets) {
- var model = spec.widgets[widget];
- if (model.type === TEXT_WIDGET_TYPE && model.content) {
- this._upgradeTextWidget(model);
- }
- }
- return Promise.resolve(spec);
- };
- TextWidgetParagraphUpgrade.prototype._upgradeTextWidget = function _upgradeTextWidget(model) {
- var table = model.content.translationTable;
- if (table) {
- for (var lang in table) {
- table[lang] = this._upgradeContent(table[lang]);
- }
- } else if (typeof model.content === 'string') {
- model.content = this._upgradeContent(model.content);
- }
- };
- TextWidgetParagraphUpgrade.prototype._upgradeContent = function _upgradeContent(content) {
- var $content = $(content);
- var $paragraphs = $content.find('p');
- var $textFitted = $content.find('.textFitted');
- var className = $paragraphs.first().attr('class');
- $paragraphs.removeAttr('class');
- if ($textFitted.length) {
- $textFitted.addClass(className);
- } else {
- var $span = $('<span class=\'textFitted ' + className + '\'></span>');
- $paragraphs.wrapAll($span);
- }
- return $content.wrap('<div></div>').parent().html();
- };
- return TextWidgetParagraphUpgrade;
- }(UpgradeBase);
- return new TextWidgetParagraphUpgrade();
- });
- //# sourceMappingURL=TextWidgetParagraphUpgrade.js.map
|