new app()
A class which has methods for launching application. This class is singleton and make automatically. You can use this just caph.app.[METHOD]
- Since:
-
- 2.0.0
Example
caph.app.initialize(function(surface){ (new UIComponent({ dom : { innerHTML:'surface object', style: { width: 100, height: 100, color: 'white', backgroundColor: 'green' } } })).addTo(surface); }); caph.app.addScene('main',$class({ $extends : caph.require('ui.base.Scene'), oncreate: function() { (new UIComponent({ 'dom.innerHTML': 'scene object', 'dom.style' : { width: 100, height: 100, color: 'white', backgroundColor: 'blue' } })).position(100).addTo(this); } })).run();
Methods
-
add(sceneID, scene) → {caph.app}
-
Adds a scene definition. This function is enabled once a scene is added.
Parameters:
Name Type Argument Description sceneID
String <optional>
A unique ID represents a scene. If nothing, caph will start with the first added scene.
scene
caph.ui.base.Scene A scene difinition bound with the give scene ID.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.app
Example
var UIComponent = caph.require('ui.base.Component'); caph.app.addScene('main',$class({ $extends : caph.require('ui.base.Scene'), oncreate: function() { (new UIComponent({ 'dom.innerHTML': 'scene object', 'dom.style' : { width: 100, height: 100, color: 'white', backgroundColor: 'blue' } })).position(100).addTo(this); } })).run();
-
initialize(userInitFunc) → {caph.app}
-
Registers a function callback which will be invoked in app's initializing sequence.
Parameters:
Name Type Description userInitFunc
callbackInitFunc A function will be invoked in app's initializing sequence.
- Since:
-
- 2.0.0
Returns:
- Type
- caph.app
Example
var UIComponent = caph.require('ui.base.Component'); caph.app.initialize(function(surface){ (new UIComponent({ dom : { innerHTML:'surface object', style: { width: 100, height: 100, color: 'white', backgroundColor: 'green' } } })).addTo(surface); });
-
run(option, sceneID, mount)
-
; Runs caph engine with user's predefined scenes and option. This function is enabled once a scene is added.
Parameters:
Name Type Argument Description option
Object <optional>
option
sceneID
String <optional>
A unique ID represents a scene. If nothing, caph will start with the first added scene.
mount
String | HTMLElement | function <optional>
A target DOM Element where caph elements run, a function returning a HTML element, or else a HTML element's id.
- Since:
-
- 2.1.0
Example
var UIComponent = caph.require('ui.base.Component'); caph.app.addScene('main',$class({ $extends : caph.require('ui.base.Scene'), oncreate: function() { (new UIComponent({ 'dom.innerHTML': 'scene object', 'dom.style' : { width: 100, height: 100, color: 'white', backgroundColor: 'blue' } })).position(100).addTo(this); } })).run();