define([
'components.dt/js/utils/UploaderUtils',
'core/js/api/utils/StringUtils'
], function (
UploaderUtils,
StringUtils
) {
'use strict';
/**
* Theme description holder. This object contains pairs of strings that will
* be used to present information about a theme to the user (e.g. in the
* theme palette and in the new application wizard).
*
* @AbcsExtension stable
* @version 17.1.5
*
* @exports layout.dt/js/api/ThemeDescriptor
* @constructor
*
* @param {Object} descriptor Object literal describing a theme.
* @param {String} descriptor.id Theme's identifier.
* @param {String} descriptor.title Theme's display name.
* @param {String} [descriptor.description] Theme's description.
* @param {String} [descriptor.preview] Path to theme's preview image.
*
* @example <caption>An example of a basic theme descriptor.</caption>
* return new ThemeDescriptor({
* id: 'myTheme',
* title: 'My Theme',
* description: 'My theme created on purpose for this example',
* preview: 'myTheme/theme/preview.png'
* });
* @see {@link layout.dt/js/spi/ThemeProvider Example of a complete
* ThemeProvider} which generates its descriptor from a JSON file
*/
var ThemeDescriptor = function (descriptor) {
AbcsLib.checkThis(this);
AbcsLib.checkParameterCount(arguments, 1);
AbcsLib.checkDefined(descriptor);
AbcsLib.checkObjectLiteral(descriptor,
['id', 'title', 'description', 'preview', 'link', 'linkText', 'hint'], // Allowed fields
['id', 'title']); // Mandatory fields
this._id = descriptor.id;
this._title = descriptor.title;
this._description = descriptor.description;
this._link = descriptor.link ? descriptor.link : '';
this._linkText = descriptor.linkText ? descriptor.linkText : '';
this._hint = descriptor.hint ? descriptor.hint : '';
// See BUFP-11506.
this._preview = (!descriptor.preview || StringUtils.endsWith(descriptor.preview, UploaderUtils.UPLOAD_IMAGE_PATH))
? ThemeDescriptor.DEFAULT_PREVIEW_IMAGE : descriptor.preview;
this._internal = false;
};
ThemeDescriptor._LOGGER = Logger.get('ThemeDescriptor');
ThemeDescriptor.DEFAULT_PREVIEW_IMAGE = 'style/images/composer/no_theme_image.png';
/**
* Gets theme's ID.
*
* @returns {String} ID
*/
ThemeDescriptor.prototype.getId = function () {
return this._id;
};
/**
* Gets theme's title.
*
* @returns {String} title
*/
ThemeDescriptor.prototype.getTitle = function () {
return this._title;
};
/**
* Gets theme's description.
*
* @returns {String} description
*/
ThemeDescriptor.prototype.getDescription = function () {
return this._description;
};
/**
* Gets theme's preview image.
*
* @returns {String} preview image
*/
ThemeDescriptor.prototype.getPreview = function () {
return this._preview;
};
/*
* Gets link to page with more details about the theme.
*
* @returns {String} URL
*/
ThemeDescriptor.prototype.getLink = function () {
return this._link;
};
/*
* Gets the text to be shown for the details page link
*
* @returns {String} The text for the link
*/
ThemeDescriptor.prototype.getLinkText = function () {
return this._linkText;
};
/*
* Gets a hint about what to use this theme for
*
* @returns {String} Hint
*/
ThemeDescriptor.prototype.getHint = function () {
return this._hint;
};
/*
* Gets whether this theme is internal (provided by ABCS).
*
* @returns {Boolean}
*/
ThemeDescriptor.prototype.isInternal = function() {
return this._internal;
};
return ThemeDescriptor;
});