------------------------------------------------------------------------------- DojoX app ------------------------------------------------------------------------------- Version 0.1 Release date: 05/08/2011 ------------------------------------------------------------------------------- Project state: EXPERIMENTAL / Under Construction This project is under active development with increasing capabilities beginning in dojo 1.7, but is not yet capable or stable enough to use in production. This project is licensed under the Dojo Tookit licensing scheme and contributions provided under the Dojo CLA. ------------------------------------------------------------------------------- Project authors Dustin Machi Stephen Zhang Eric Wang Ed Chatelain Christophe Jolif ------------------------------------------------------------------------------- Project description dojox/app is a small application framework providing a set of classes to manage the the lifecycle and behavior of a single page application delivered to a mobile or desktop platform. The main class, Application, is responsible for providing the lifecycle of the application and is designed to be easily modified with additional custom behaviors. An application instance contains views which provide the visible user interface. The available views, module dependencies, and other information about the application are all passed into the Application class through a JSON configuration file. ------------------------------------------------------------------------------- Dependencies: Dojo Core (dijit, dojox/mobile). ------------------------------------------------------------------------------- Documentation config.json The config file defines all of the dependencies, application behaviors, top level views, and any other information required for the application to function. Example Config: ```javascript { /* any object that complies with Dojo AMD loader configuration. */ "loaderConfig" : { "paths": { "mypackage" : "can/be/found/here" } }, /* global application dependencies */ "dependencies": [ "dojox/mobile/Heading", "dojo/mobile/RoundRect", "my/custom/module" ], /* Application Modules. These are implicitly added to the above set of dependencies */ modules: [ "dojox/app/module/history", "my/custom/appModule" ], /* Application Controllers. */ "controllers": [ "dojox/app/controllers/History", "my/custom/appController" ], /* The Application level HTML template. template files store in application's templates folder by default */ template: "./templates/example.html", /* Application level view definition. Application will have a root view even if it has no template. "none" -- no definition for this view, "./views/myView.js" -- load definition from "./views/myView.js", no definition (by default) -- load definition from "./views/example.js" */ "definition": "none", /* the view to start on by default */ "defaultView": "home", /* transition to use if none has been provided */ "defaultTransition": "slide", /* Views */ "views": { /* home is a top level dojox.app.view */ "home": { /* dependencies specific to this view */ "dependencies: [ "dojox/mobile/ListItem", "dojox/mobile/EdgeToEdgeCategory" ], /* template to use for this view */ template: "./templates/home.html", /* view definition. "none" -- no definition for this view, "./views/myHome.js" -- load definition from "./views/myHome.js", no definition (by default) -- load definition from "./views/home.js" */ "definition": "none" }, /* tabs view contains three child views */ "tabs": { /* the tabs view template */ "template": "./templates/tabScene.html", "definition": "none", /* the default view within tabs view */ "defaultView": "tab1", /* when transitioning between tabs, use a flip animation by default */ "defaultTransition": "flip", //the views available to tabs view "views": { "tab1":{ "template": "./templates/tabs/tab1.html" /* no definition define for tab1 view, load tab1 view definition from "views/tabs/tab1.js" */ }, "tab2":{ "template": "./templates/tabs/tab2.html" }, "tab3":{ "template": "./templates/tabs/tab3.html" } }, /* dependencies specific to tabs view */ "dependencies":["dojox/mobile/RoundRectList","dojox/mobile/ListItem", "dojox/mobile/EdgeToEdgeCategory"] } } } ``` Property descriptions - loaderConfig - This is the configuration that will be passed to the Dojo AMD loader. This allows to specify for example where the loader needs to find modules. See: http://livedocs.dojotoolkit.org/loader/amd#module-identifiers - dependencies - These are the modules that are required for the application to run when defined at the root of the configuration. When defined inside of a view, the dependency property defines modules which must be loaded before that view can be instantiated. - modules - The modules property defines application modules that will mixed into the Application class to control the lifecycle and behavior of the application. This property will become the array of mixins provided to a dojo/declare extending the base Application class. In other words, the Application class that is instantiated dynamically is created at run time using the base class and this list of modules. - controllers - The controllers property defines application controllers that will be loaded during application startup to respond to events of the application. The controllers bind events on application's root domNode and the events can be triggered by application's trigger() method and documented actions. - template - This is the template/HTML that is used for the application when defined at the root of the configuration. Within the context of a view, it is the template/HTML for defining the view. - definition - This is the view definition that is used for the application template view when defined at the root of the configuration. It implements the view's life cycle interface like init(), beforeActivate(), destroy(), etc. and allows one to control the view. - defaultView - The defaultView defines the startup view for the application. - defaultTransition - This is the default transition method for top level views when defined at the root of the configuration. When defined within a view, it is the default transition method for the associated views only. - views - The views property is a nested set of objects defining the views available to the application. Details of views classes is discussed below. - stores - The dojo/store implementations that will be used by the application - models - The models (potentially dojox/mvc models) connecting to the stores and exposing data to the application. - id - The identifier of the application, a global variable with the id name is created by the application. Some additional properties, such as name and description are reserved for future use, but their exact use is still under development. The Application module: The Application class itself doesn't currently exist as an exported class. This module exports a generation function, which when provided a configuration file will declare & instantiate the application class that will actually be used on a page. Finally it then starts it up at a specific node: ```javascript require(["dojox/json/ref", "dojox/app/main", "dojo/text!app/config.json"],function(json, Application, config){ app = Application(json.parse(config)); }); ``` The View module: The View module provides a View class to construct View instances, a template rendering engine to render view template and view lifecycle APIs. Each View can have one parent view and several children views. It provides a templated container to host the domNodes for the children views. Its purpose is to allow the layout of the view to be provided through an html template and to have a set of children views which the view transitions between. For example, to display a set of tabs, you would use a View with a child view for each tab. The view's template would define where within the view the children views are displayed and where any tab buttons and such are displayed. In this case the "template", for the base View is pretty simple. It is a simple HTML content. However, nodes within the template can be tagged with data-app-region="top" (bottom, left, right) to define where that node and its children should be displayed. For example: ```html