define([], function() {
'use strict';
/**
* ThemeProvider is the SPI implemented by themes to allow them to be
* integrated into ABCS. ThemeProvider instances are registered on the
* ThemeProviderRegistry to make them available for use in ABCS.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @exports layout.dt/js/spi/ThemeProvider
* @constructor
*
* @example <caption>An example of a simple theme provider.</caption>
* define([
* 'layout.dt/js/api/ThemeAssets',
* 'layout.dt/js/api/ThemeComponentMap',
* 'layout.dt/js/api/ThemeDescriptor',
* 'text!API.Example/theme/layout.html',
* 'text!API.Example/manifest.json'
* ], function(
* ThemeAssets,
* ThemeComponentMap,
* ThemeDescriptor,
* theme,
* manifestJSON) {
*
* 'use strict';
*
* var SimpleThemeProvider = function () {
* var self = this;
*
* var manifest = JSON.parse(manifestJSON);
*
* self._descriptor =
* new ThemeDescriptor({
* id: manifest.id,
* title: manifest.displayName,
* description: manifest.description,
* preview: manifest.image,
* link: null,
* linkText: null});
*
* self._template = theme;
* self._package = manifest.package;
* };
*
* SimpleThemeProvider.prototype.getDescriptor = function() {
* return this._descriptor;
* };
*
* SimpleThemeProvider.prototype.getComponentMap = function() {
* var componentMap = new ThemeComponentMap();
* componentMap.addFavicon('abcs-tpl-app-favicon');
* componentMap.addThemeArea('abcs-tpl-header-bar');
* componentMap.addThemeArea('abcs-tpl-footer-bar');
* componentMap.addTitle('abcs-tpl-app-title');
* componentMap.addLogo('abcs-tpl-app-logo');
* componentMap.addCopyright('abcs-tpl-app-copyright');
* componentMap.addUserArea('abcs-tpl-app-user-area');
*
* var options = {boundIds: ['abcs-tpl-phone-menu'],
* alternateIds: ['abcs-tpl-app-main-menu-mobile']};
*
* componentMap.addMenuArea('abcs-tpl-app-main-menu', options);
*
* return componentMap;
* };
*
* SimpleThemeProvider.prototype.getAssets = function() {
* var assets = new ThemeAssets();
* assets.addAsset(ThemeAssets.Type.STYLE, 'style.css');
* assets.addAsset(ThemeAssets.Type.TEMPLATE, 'layout.html');
* assets.addAsset(ThemeAssets.Type.TEMPLATE, 'menu-horizontal-main.html');
* assets.addAsset(ThemeAssets.Type.TEMPLATE, 'menu-horizontal.html');
* assets.addAsset(ThemeAssets.Type.TEMPLATE, 'menu-mobile.html');
* assets.addAsset(ThemeAssets.Type.TEMPLATE, 'user-area.html');
* assets.addAsset(ThemeAssets.Type.IMAGE, 'menu-arrow.png');
*
* return assets;
* };
*
* SimpleThemeProvider.prototype.getTemplate = function() {
* return this._template;
* };
*
* SimpleThemeProvider.prototype.getAssetPath = function() {
* return '' + this._package + '/theme';
* };
*
* SimpleThemeProvider.prototype.generateViewModelRuntimeCode = function() {
* // Insert method to return view model runtime code here
* };
*
* SimpleThemeProvider.prototype.initializeViewModel = function() {
* // Insert code to initialize view model at design time and return a
* // promise to be resolved once the initialization is done.
* return Promise.resolve();
* };
*
* return new SimpleThemeProvider();
* });
* @see {@link layout.dt/js/api/ThemeProviderRegistry Example ThemeExtensionManager}
* on how to register/unregister a theme
*/
var ThemeProvider = function () {};
/**
* Returns a {@link layout.dt/js/api/ThemeDescriptor ThemeDescriptor} that
* describes this theme. The descriptor includes the ID of the theme, along
* with additional information that may be presented to the user.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {layout.dt/js/api/ThemeDescriptor} The theme's descriptor
*
* @see {@link layout.dt/js/api/ThemeDescriptor ThemeDescriptor}
*/
ThemeProvider.prototype.getDescriptor = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Returns the HTML template that defines the view of the theme. This should
* be a String containing an HTML body fragment. The best way to do this is
* to place the markup in its own file, and then require it with a <code>
* text!</code> prefix in the ThemeProvider (see example in constructor).
*
* <p>This template must contain an empty <code><div></code> element with
* ID <code>abcs-app-content</code> and must not include
* <code><html></code>, <code><body></code>, or
* <code><head></code>.</p>
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {String} HTML string representing the view
*
* @see {@link https://github.com/requirejs/text RequireJS loader plugin}
* for loading resources (<code>text!</code>)
*/
ThemeProvider.prototype.getTemplate = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Returns a {@link layout.dt/js/api/ThemeComponentMap ThemeComponentMap}
* which defines where certain ABCS components (title, logo, copyright,
* menu, etc) should be inserted into the HTML template.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {layout.dt/js/api/ThemeComponentMap} Content map for this theme
*
* @see {@link layout.dt/js/api/ThemeComponentMap ThemeComponentMap}
*/
ThemeProvider.prototype.getComponentMap = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Returns a {@link layout.dt/js/api/ThemeAssets ThemeAssets} object
* representing the assets provided by this theme (other HTML templates,
* images, css files etc).
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {layout.dt/js/api/ThemeAssets} Assets for this theme
*
* @see {@link layout.dt/js/api/ThemeAssets ThemeAssets}
*/
ThemeProvider.prototype.getAssets = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Returns the base path to the assets supplied by this theme. Each asset
* supplies a path relative to this base path. The base path itself should
* be a relative path from the extensions directory.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {String} base path for assets
*/
ThemeProvider.prototype.getAssetPath = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Returns the ID of an element in the HTML template into which ABCS should
* inject the application content.
*
* Note: currently this is not used, and content will be injected into an
* element with id <code>"abcs-app-content"</code>.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {String} element ID for application content
*/
ThemeProvider.prototype.getApplicationContentId = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Returns a String containing Javascript code to be executed in the
* generated application after the DOM has been prepared. This code should
* be used to initialize the view model for the theme, if required.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {String} code to initialize view model in generated application
*/
ThemeProvider.prototype.generateViewModelRuntimeCode = function() {
AbcsLib.throwMustBeOverriddenError();
};
/**
* Initializes the view model for the theme, if required. This code will be
* executed at design time, when the theme has been refreshed.
*
* @AbcsExtension stable
* @version 17.1.5
*
* @returns {Promise} A promise that is resolved when the view model has
* been initialized.
*/
ThemeProvider.prototype.initializeViewModel = function() {
AbcsLib.throwMustBeOverriddenError();
};
return ThemeProvider;
});