1 | /**
|
2 | * @class Alloy
|
3 | * Top-level module for Alloy functions.
|
4 | *
|
5 | * Alloy is an application framework built on top of the Titanium SDK designed to help rapidly
|
6 | * develop high quality applications and reduce maintenance.
|
7 | *
|
8 | * Alloy uses the model-view-controller architecture to separate the application into three
|
9 | * components:
|
10 | *
|
11 | * * **Models** provide the data of the application. Alloy utilizes **Backbone Model and Collection**
|
12 | * objects for this functionality.
|
13 | *
|
14 | * * **Views** provide the UI components to interact with the application, written using **XML markup**
|
15 | * and **Titanium Stylesheets (TSS)**, which abstracts the UI components of the Titanium API.
|
16 | *
|
17 | * * **Controllers** provide the glue layer between the Model and View components as well as
|
18 | * additional application logic using the **Alloy API** and **Titanium API**.
|
19 | *
|
20 | * The API documentation provided here is used with Alloy Controllers and Widget Controllers to
|
21 | * interact with the View and Model components of the application or widget.
|
22 | *
|
23 | * For guides on using Alloy, see
|
24 | * [Alloy Framework](http://docs.appcelerator.com/platform/latest/#!/guide/Alloy_Framework).
|
25 | */
|
26 |
|
27 | /**
|
28 | * @method createWidget
|
29 | * Factory method for instantiating a widget controller. Creates and returns an instance of the
|
30 | * named widget.
|
31 | * @param {String} id Id of widget to instantiate.
|
32 | * @param {String} [name="widget"] Name of the view within the widget to instantiate ('widget' by default)
|
33 | * @param {Object} [args] Arguments to pass to the widget.
|
34 | * @return {Alloy.Controller} Alloy widget controller object.
|
35 | */
|
36 |
|
37 | /**
|
38 | * @method createController
|
39 | * Factory method for instantiating a controller. Creates and returns an instance of the
|
40 | * named controller.
|
41 | * @param {String} name Name of controller to instantiate.
|
42 | * @param {Object} [args] Arguments to pass to the controller.
|
43 | * @return {Alloy.Controller} Alloy controller object.
|
44 | */
|
45 |
|
46 | /**
|
47 | * @method createModel
|
48 | * Factory method for instantiating a Backbone Model object. Creates and returns an instance of the
|
49 | * named model.
|
50 | *
|
51 | * See [Backbone.Model](http://docs.appcelerator.com/backbone/0.9.2/#Model) in the Backbone.js documentation for
|
52 | * information on the methods and properties provided by the Model object.
|
53 | * @param {String} name Name of model to instantiate.
|
54 | * @param {Object} [args] Arguments to pass to the model.
|
55 | * @return {Backbone.Model} Backbone model object.
|
56 | */
|
57 |
|
58 | /**
|
59 | * @method createCollection
|
60 | * Factory method for instantiating a Backbone collection of model objects. Creates and returns a
|
61 | * collection for holding the named type of model objects.
|
62 | *
|
63 | * See [Backbone.Collection](http://docs.appcelerator.com/backbone/0.9.2/#Collection) in the Backbone.js
|
64 | * documentation for information on the methods and properties provided by the
|
65 | * Collection object.
|
66 | * @param {String} name Name of model to hold in this collection.
|
67 | * @param {Object} [args] Arguments to pass to the collection.
|
68 | * @return {Backbone.Collection} Backbone collection object.
|
69 | */
|
70 |
|
71 | /**
|
72 | * @property {Boolean} isTablet
|
73 | * `true` if the current device is a tablet.
|
74 | *
|
75 | */
|
76 |
|
77 | /**
|
78 | * @property {Boolean} isHandheld
|
79 | * `true` if the current device is a handheld device (not a tablet).
|
80 | *
|
81 | */
|
82 |
|
83 |
|
84 | /**
|
85 | * @property {Object} Globals
|
86 | * An object for storing globally accessible variables and functions.
|
87 | * Alloy.Globals is accessible in any controller in your app:
|
88 | *
|
89 | * Alloy.Globals.someGlobalObject = { key: 'value' };
|
90 | * Alloy.Globals.someGlobalFunction = function(){};
|
91 | *
|
92 | * Alloy.Globals can be accessed in other non-controller Javascript files
|
93 | * like this:
|
94 | *
|
95 | * var theObject = require('/alloy').Globals.someGlobalObject;
|
96 | *
|
97 | */
|
98 |
|
99 | /**
|
100 | * @property {Object} Models
|
101 | * An object for storing globally accessible Alloy models. Singleton models
|
102 | * created via markup will be stored on this object.
|
103 | *
|
104 | * <Model src="myModel"/>
|
105 | *
|
106 | * The above markup would effectively generate the following code:
|
107 | *
|
108 | * Alloy.Models.myModel = Alloy.createModel('MyModel');
|
109 | *
|
110 | * Alloy.Models.myModel would then be accessible in any controller in your app.
|
111 | *
|
112 | */
|
113 |
|
114 | /*
|
115 | * Creates a singleton instance of a Model based on the given model, or
|
116 | * returns an existing instance if one has already been created.
|
117 | * Documented in docs/apidoc/model.js for docs site.
|
118 | */
|
119 |
|
120 | /**
|
121 | * @property {Object} Collections
|
122 | * An object for storing globally accessible Alloy collections. Singleton collections
|
123 | * created via markup will be stored on this object.
|
124 | *
|
125 | * <Collection src="myModel"/>
|
126 | *
|
127 | * The above markup would effectively generate the following code:
|
128 | *
|
129 | * Alloy.Collections.myModel = Alloy.createCollection('MyModel');
|
130 | *
|
131 | * Alloy.Collections.myModel would then be accessible in any controller in your app.
|
132 | *
|
133 | */
|
134 |
|
135 | /*
|
136 | * Creates a singleton instance of a Collection based on the given model, or
|
137 | * returns an existing instance if one has already been created.
|
138 | * Documented in docs/apidoc/collection.js for docs site.
|
139 | */
|
140 |
|
141 | /**
|
142 | * @property {Object} CFG
|
143 | * An object that stores Alloy configuration values as defined in your app's
|
144 | * app/config.json file. Here's what a typical config.json file might look
|
145 | * like in an Alloy app.
|
146 | *
|
147 | * {
|
148 | * "global": { "key": "defaultValue", "anotherKey": 12345 },
|
149 | * "env:development": {},
|
150 | * "env:test": {},
|
151 | * "env:production": {},
|
152 | * "os:ios": { "key": "iosValue" },
|
153 | * "os:android": { "key": "androidValue" },
|
154 | * "dependencies": {}
|
155 | * }
|
156 | *
|
157 | * If this app was compiled for iOS, the Alloy.CFG would look like this:
|
158 | *
|
159 | * Alloy.CFG = {
|
160 | * "key": "iosValue",
|
161 | * "anotherKey": 12345
|
162 | * }
|
163 | *
|
164 | * Alloy.CFG is accessible in any controller in your app, and can be accessed
|
165 | * in other non-controller Javascript files like this:
|
166 | *
|
167 | * var theKey = require('/alloy').CFG.key;
|
168 | *
|
169 | */
|