Skip to content
Eric edited this page Jul 25, 2018 · 129 revisions

OGX.App is the core of the application. It can hold multi stages, windows, popups and an overlay per stage.

OGX.JS stack

OGX.App requires a configuration file app.config that must exist in the www folder of your project. If you are using the CLI, the file is automatically created when initialiazing the project by doing ogx init. Otherwise, create that file by hand, here is the skeleton

 {
     "routing":{},
     "stages":{},
     "templates":{},
     "scopes":["public"]         
 }

Routing

The routing for the entire application must be defined in this file. To learn more about the routing system, out the page dedicated to this.

To prevent any navigation including the use of the back button, you can lock (and unlock) the core by doing

 app.lock(); 
 app.unlock();
 app.isLocked(); //Returns true or false

Stages

The stages to be added to your app upon start. For instance, if your app is going to have one stage that you have named stage1, and will be using the Stage object Stage1 and the HTML template Stage, then your configuration will look like this

 {
     ...
     "stage1":{"stage":"Stage1", "template":"Stage", "observe":false, "use":true, "home":"stage1/news"}
     ...
 }

The home attribute defines the default route upon start of the application. It MUST have a default route.

Templates

To load and store your HTML templates into the core, add them to the configuration file, such as

 {
     ...
     "templates":{
          "Stage1":"template.Stage1.html",
          "News":"template.News.html",
          "User":"template.User.html",
          ...         
     },
     ...
 }

Note that templates must be placed in the www/html/templates folder.

Scopes

An array of available scopes for the entire application. If your application doesn't handle multiple types of users with different permissions, leave it to ["public"]

Instantiate

 let app = new OGX.App();

Stages

Add a stage to the app

 app.addStage(_STAGE_NAME_, _STAGE_OBJECT, _CONFIG_);

Remove that stage from the app

 app.removeStage(_STAGE_NAME_);

Use another stage (to add/remove views for instance)

 app.useStage(_STAGE_NAME_);

Snooze a stage (all views, windows of this stage)

 app.snoozeStage(_STAGE_NAME_);

Wake a stage (all views, windows of this stage)

 app.wakeStage(_STAGE_NAME_);

Show a stage (and hide the current one if any)

 app.showStage(_STAGE_NAME_, _ANIMATION_);

Add a view to the stage in use

 app.addToStage(_CONFIG_);

Remove a view from the stage in use

 app.removeFromStage(_SELECTOR_);

Clone this wiki locally