ClassUtil
Overview
ClassUtil is a utility class that handles class-related tasks such as creating new classes.
Methods
createObject(className, ...args)
Type:Object
Static
Instantiates a class.
Parameters
Parameter | Type | Description |
---|---|---|
className required | Function | A class name to instantiate. |
…args | Arguments to the class constructor. |
Return Value
A created instance.
getClass(className)
Type:Function
Static
Returns the Function object that has the specified class name.
Parameters
Parameter | Type | Description |
---|---|---|
className required | Function | A class name. |
Return value
A Function object.
inherit(subClass, superClass)
Type:undefined
Static
Inherits the subclass from the super class.
Parameters
Parameter | Type | Description |
---|---|---|
subClass required | Function | A class that inherits the super class. |
superClass required | Function | A super class. |
Return Value
undefined
newComponent(className, settings, superClass, tagName)
Type:Component
Static
Creates a new Function object. Note that the created object is not an instance. The component is instantiated by placing a tag specified in the parameter in the HTML file.
This function exists for older browser support. You can use the class notation for modern browsers.
Parameters
Parameter | Type | Description |
---|---|---|
className required | String | A class name for the new component. |
settings required | Object | A component settings object. This settings will be returned in Component._getSettings(). |
superClass Default:BITSMIST.v1.Component | Function | The Super class to inherit. |
tagName | String | A tag name for this component. By inserting this tag to HTML the component will be instantiated. |
Return Value
A created function object.
Examples
// Create a search pad component. var PadSearch = BITSMIST.v1.ClassUtil.newComponent("PadSearch", { "settings": { "name": "PadSearch", "path": "common" } }, BITSMIST.v1.Component, "pad-search"); // Add search() method to the created component. PadSearch.prototype.search = function(keyword) { ... };
<html> ... <body> <!-- Instantiation --> <pad-search></pad-search> </body> </html>