Bitsmist Frameworks
Docs » ClassUtil

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

ParameterTypeDescription
className
required
FunctionA 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

ParameterTypeDescription
className
required
FunctionA class name.

Return value

A Function object.

inherit(subClass, superClass)

Type:undefined Static

Inherits the subclass from the super class.

Parameters

ParameterTypeDescription
subClass
required
FunctionA class that inherits the super class.
superClass
required
FunctionA 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

ParameterTypeDescription
className requiredStringA class name for the new component.
settings
required
ObjectA component settings object. This settings will be returned in Component._getSettings().
superClass
Default:BITSMIST.v1.Component
FunctionThe Super class to inherit.
tagNameStringA 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>
Previous Next

© 2019-2023 Masaki Yasutake

Bitsmist Frameworks

Table of Contents

Table of Contents

  • ClassUtil
    • Overview
    • Methods
      • createObject(className, ...args)
      • getClass(className)
      • inherit(subClass, superClass)
      • newComponent(className, settings, superClass, tagName)

GENERAL

  • Overview
  • Installation
  • Create a sample component

COMPONENT

  • Loading
  • Settings
  • Events
  • Extending with organizers

REFERENCE - COMPONENT

  • Component

REFERENCE - ORGANIZER

  • EventOrganizer
  • LoaderOrganizer
  • OrganizerOrganizer
  • SettingOrganizer
  • StateOrganizer
  • TemplateOrganizer

REFERENCE - STORE

  • Store
  • ChainableStore

REFERENCE - UTILITY

  • AjaxUtil
  • ClassUtil
  • Util