API Docs for: 0.1.0
Show:

zerk Class

Defined in: src/zerk/zerk.js:24
Module: zerk

The Zerk main object and namespace

Methods

_classLoaded

(
  • className
)
Boolean private

Checks if a class is loaded and defined already

Parameters:

  • className String

    The name of the class

Returns:

Boolean: Returns true if the class is loaded and defined already

_classLoading

(
  • className
)
Boolean private

Checks if a class is loading already

Parameters:

  • className String

    The name of the class

Returns:

Boolean: Returns true if the class is currently loading

_createObject

(
  • parent
)
Object private

Creates an object from parent object definition

This is an implementation of Douglas Crockfords prototypal inheritance in JavaScript.

http://javascript.crockford.com/prototypal.html

Parameters:

  • parent Object

Returns:

Object: The created object

_defineClass

(
  • meta
  • body
  • callback
)
Object private

Defines a class

Parameters:

  • meta Object

    Class meta object

  • body Object

    Class body

  • callback Function

    Callback function that fires after the class was defined

Returns:

Object: Class definition

_delayDefine

(
  • meta
  • body
  • callback
  • waitFor
)
Object private

Creates a delayed define entry and returns its handle

Parameters:

  • meta Object

    Class meta object

  • body Object

    Class body

  • callback Function

    Callback function

  • waitFor Array

Returns:

Object: The handle for the delayed define

_getClassURL

(
  • className
)
String private

Returns the url for given class name

Parameters:

  • className String

    The name of the class

Returns:

String: Class name in object key notation

_loadScript

(
  • url
)
private

Loads a JavaScript file

Parameters:

  • url String

    The target url of the script to be loaded

_onLoad

() private

Fires when all classes ever required are loaded and defined

_parseClassName

(
  • className
)
Object private

Parses given class name and returns detailed information

Parameters:

  • className String

    The name of the class

Returns:

Object: An object containing namespace information

_parseMeta

(
  • meta
)
Object private

Normalize meta data

Parameters:

  • meta String | Object

    A class meta data object or name

Returns:

Object: The parsed meta data object

_processLoadedClass

(
  • className
)
private

Process delayed defines after dependencies are resolved

Parameters:

  • className String

    The name of the class

_ready

() private

Fires when all classes ever required are loaded and defined and the document is ready

_requireClass

(
  • className
)
private

Loads the related script file of the given class name

Parameters:

  • className String

apply

(
  • obj
  • props
)

Apply properties to an object/class

Parameters:

  • obj Object

    The object witch the properties should be applied to

  • props Object

    A JSON property structure

create

(
  • name
)
Object

Creates a class instance

All arguments after 'name' are passed to the init method of the class.

Parameters:

  • name String

    The name of the class

Returns:

Object: Class instance

define

(
  • name
  • body
  • callback
)

Defined in src/zerk/zerk.js:86

Defines a new class

// Class definition without meta object
zerk.define('myNamespace.myClass',{
    // ...
}); 

// Class definition with meta object
zerk.define({
    name: 'myNamespace.myClass',
    extend: 'myNamespace.myParentClass'
    require: [
        'myNamespace.myParentClass'
    ]
},{
    // ...
});

Parameters:

  • name String | Object

    The name of the class or a meta object

  • body Object

    The body of the class

  • callback Function

    Callback function that fires when the class definition is done

init

(
  • config
)

Defined in src/zerk/zerk.js:72

The main bootstrap method

Parameters:

  • config Object

    Configuration object

parent

(
  • name
)
Object

Method for inheritance like parent class calls

Use this with the apply method to inject the local scope.

zerk.parent('myClass').myMethod.apply(
    this,
    arguments
);

Parameters:

  • name String

    The name of the class

Returns:

Object: The parent class

Properties

_classMap

Object private

Defined in src/zerk/zerk.js:54

Class name to instance map

_classState

Object private

Defined in src/zerk/zerk.js:45

Load state of classes

_config

Object private

Defined in src/zerk/zerk.js:36

The game engine configuration

_delayedDefine

Object private

Defined in src/zerk/zerk.js:63

Defines that got delayed by requires