Table of Contents

ClassUtil

Overview

ClassUtil is a utility class that handles class-related tasks such as creating new classes.

Methods

getClass(className)

Type:Function Static

Returns the Function object that has the specified class name, not the instance.

Parameters

ParameterTypeDescription
className
Required
FunctionThe class name.

Return Value

The Function object.


inherit(subClass, superClass)

Type:undefined Static

Makes the subclass inherits the super class.

Parameters

ParameterTypeDescription
subClass
Required
FunctionThe class that inherits the super class.
superClass
Required
FunctionThe super class.

Return Value

Undefined.


newUnit(className, settings, superClass, tagName)

Type:Unit Static

Creates a new Function object that inherits the super class given. Note that the created object is not an instance. If the tagName option is set, the tag name will be tied to the newly created class.

Parameters

ParameterTypeDescription
className
Required
StringThe class name of the unit to create.
settings
Required
ObjectThe unit's settings object. This settings will be returned in Unit._getSettings().
superClass
Default:Unit
FunctionThe super class to inherit.
tagNameStringThe tag name for the new unit. By inserting this tag into the HTML the unit will be instantiated.

Return Value

A created function object.

Examples

// Create Search pad unit.
var PadSearch = BITSMIST.v1.ClassUtil.newUnit("PadSearch", {
    "setting": {
        "path": "common"
    }
}, BITSMIST.v1.Unit, "pad-search");
 
// Add search() method to the created unit
PadSearch.prototype.search = function(keyword)
{
   ...
};
<html>
...
<body>
<!-- Instantiation -->
<pad-search></pad-search>
</body>
</html>