forked from Jibo-Revival-Group/JiboOs
94 lines
4.4 KiB
JavaScript
94 lines
4.4 KiB
JavaScript
/**
|
|
* Instance used for singleton.
|
|
* @name jibo.face.views.ComponentCreator._instance
|
|
* @type {jibo.face.views.ComponentCreator}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Hash table for registered classes.
|
|
* To be able to create Classes dynamically must first keep reference to them
|
|
* that can later be retrieved by key value pairing.
|
|
* @name jibo.face.views.ComponentCreator#_classRegistry
|
|
* @type {any}
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Default view to create if none is specified in creation methods.
|
|
* @name jibo.face.views.ComponentCreator.DEFAULT_VIEW
|
|
* @type {String}
|
|
* @default 'View'
|
|
* @readonly
|
|
* @private
|
|
*/
|
|
|
|
/**
|
|
* Create a View from its class and configuration data.
|
|
* @method jibo.face.views.ComponentCreator#createView
|
|
* @param {any} [viewClass] Can be the class Object or the string name of the class (name must match class names in registry).
|
|
* @param {any} [config] Can config as an Object or a string of the path the JSON config file.
|
|
* @returns {jibo.face.views.View} The View created.
|
|
*/
|
|
|
|
/**
|
|
* Creates a view from a config.
|
|
* @method jibo.face.views.ComponentCreator#createViewFromConfigObject
|
|
* @param {Object} config The configuration Object for the Component.
|
|
* @returns {jibo.face.views.View} The View created.
|
|
*/
|
|
|
|
/**
|
|
* Create a View from its configuration path.
|
|
* This process requires a load, the {@link jibo.face.views.View} will be returned within the given callback
|
|
* @method jibo.face.views.ComponentCreator#createViewFromConfigPath
|
|
* @param {String} configPath Path to the configuration file defining the View to create.
|
|
* @param {jibo.face.views~ViewCallback} complete Callback called once when View is created.
|
|
* @param {Function} [failure] Callback called if View fails to be created.
|
|
*/
|
|
|
|
/**
|
|
* Creates a {@link jibo.face.views.ViewState} that represent a {@link jibo.face.views.View}.
|
|
* ComponentCreator keeps a registry of known View classes, which allows the classes to be constructed.
|
|
* @method jibo.face.views.ComponentCreator#createViewState
|
|
* @param {Object|String} viewClass Can be View class or string name of View class.
|
|
* @param {Object|String} [config] Can be configuration Object or the path to JSON config file.
|
|
* @returns {jibo.face.views.ViewState} The created ViewState.
|
|
*/
|
|
|
|
/**
|
|
* Create a {@link jibo.face.views.View} from a {@link jibo.face.views.ViewState}.
|
|
* @method jibo.face.views.ComponentCreator#createViewFromState
|
|
* @param {jibo.face.views.ViewState} viewState The ViewState associated with the View to create.
|
|
* @returns {jibo.face.views.View} The created View.
|
|
*/
|
|
|
|
/**
|
|
* Create a {@link jibo.face.views.Component} from configuration data.
|
|
* @method jibo.face.views.ComponentCreator#createComponentFromConfig
|
|
* @param {Object} componentConfig Configuration Object for the Component, generally derived from JSON.
|
|
* @returns {jibo.face.views.Component} The Component defined by the configuration Object.
|
|
*/
|
|
|
|
/**
|
|
* Register class so it can be referenced later for dynamic creation.
|
|
* A `key` must be provided to retrieve the class, if none is provided
|
|
* then the method looks for a `DEFAULT_TYPE` property on the class.
|
|
* When creating a custom class it is helpful to define `DEFAULT_TYPE`.
|
|
* This `key` is also used within the JSON configuration to specify the component Class.
|
|
* @method jibo.face.views.ComponentCreator#registerClass
|
|
* @param {any} componentClass The Class to register. Class must be or extend {@link jibo.face.views.View}.
|
|
* @param {String} [classType] If specified the given string will be used as the registry key,
|
|
* otherwise registry key is derived from the Class's name.
|
|
* classNameOverride allows for multiple registries for the same Class,
|
|
* which can be used for type variation within the same Class.
|
|
* @example
|
|
* static public static get DEFAULT_TYPE():string {return 'YourClassName';}
|
|
*/
|
|
|
|
/**
|
|
* Unregister a class from the class registry.
|
|
* Pass the 'key' used to register the class.
|
|
* @method jibo.face.views.ComponentCreator#unregisterClass
|
|
* @param {String} [classType] The string used to identify the class, often this is defined by the class via DEFAULT_TYPE
|
|
*/ |