Permalink
Browse files

Removed the init methods from controolers. Still many more to go.

  • Loading branch information...
1 parent 877b201 commit 9275476fefd71ed2e93967a8b4889c3e7ec2afb1 Joe Catera committed Nov 13, 2012
@@ -1,5 +1,3 @@
-
-
==============
Action Context
==============
@@ -29,9 +27,6 @@ the ``done`` method sends the ``data`` object to the ``index`` template.
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
/**
* Method corresponding to the 'index' action.
*
@@ -1,5 +1,4 @@
-
======
Addons
======
@@ -19,8 +18,10 @@ Addons allow you to do the following:
- get and set HTTP headers
- create URLs
+.. _mojito_addons-syntax:
+
Syntax
-######
+======
Using the ActionContext object ``ac``, you would call a ``{method}`` from an ``{addon}`` with the
following syntax:
@@ -32,8 +33,10 @@ For example, to get all of the query string parameters, you would use the ``Para
``ac.params.url()``
+.. _mojito_addons-exs:
+
Addon Examples
-##############
+==============
The following code examples use the addons in parentheses:
@@ -44,8 +47,10 @@ The following code examples use the addons in parentheses:
- `Internationalizing Your Application <../code_exs/i18n_apps.html>`_ (``Intl``)
- `Using Multiple Mojits <../code_exs/multiple_mojits.html>`_ (``Composite``)
+.. _mojito_addons-create:
+
Creating Addons
-###############
+===============
Because customized addons are not part of the standard API, but an extension of the API, the
instructions for creating addons can be found in
@@ -1,5 +1,3 @@
-
-
=============
Client Object
=============
@@ -9,17 +7,21 @@ created. The ``client`` object can be used to pause and resume mojits running wi
See `Class Y.mojito.Client <../../api/classes/Y.mojito.Client.html>`_ in the
`Mojito API Reference <../../api/>`_ for more details.
+.. _mojito_client_obj-pause:
+
Pausing Mojits
-##############
+==============
From the ``client`` object, you call the ``pause`` method as seen below to prevent any code from
executing outside of the individual binders (within the Mojito framework) and to call ``onPause()``
on all binders.
``Y.mojito.client.pause()``
+.. _mojito_client_obj-resume:
+
Resuming Mojits
-###############
+===============
From the ``client`` object, you call the ``resume`` method as seen below to immediately execute all
cached operations and notify all of the binders through the ``onResume`` function.
@@ -1,5 +1,3 @@
-
-
============
REST Library
============
@@ -8,8 +6,10 @@ Mojito has a library to make it easier to make a REST calls to Web services from
implementation details, see `Class Y.mojito.lib.REST <../../api/classes/Y.mojito.lib.REST.html>`_
in the Mojito API documentation.
+.. _mojito_rest_lib-incl:
+
Including Library
-#################
+=================
To use the REST library, include the string 'mojito-rest-lib' in the ``requires`` array, which
instructs YUI to load the library. Once the library is loaded, you can use
@@ -25,8 +25,11 @@ instructs YUI to load the library. Once the library is loaded, you can use
// Ask YUI to load the library w/ 'mojito-rest-lib'.
}, '0.0.1', {requires: ['mojito', 'mojito-rest-lib']});
+
+.. _mojito_rest_lib-ex:
+
Example
-#######
+=======
In the model for the ``recipeSearch`` mojit below, the REST library is used to make a GET call to
the Recipe Puppy API.
@@ -35,9 +38,6 @@ the Recipe Puppy API.
YUI.add('ProductSearchModel', function(Y, NAME) {
Y.namespace('mojito.models')[NAME] = {
- init: function(config) {
- this.config = config;
- },
recipeSearch: function(count, cb) {
var url = 'http://www.recipepuppy.com/api/';
var params = {
@@ -184,14 +184,11 @@ To create and run ``simple_assets``:
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
- /**
- * Method corresponding to the 'index' action.
- * @param ac {Object} The action context that
- * provides access to the Mojito API.
- */
+ /**
+ * Method corresponding to the 'index' action.
+ * @param ac {Object} The action context that
+ * provides access to the Mojito API.
+ */
index: function(ac) {
var data = {
title: "Simple Assets",
@@ -411,6 +411,7 @@ the ``requires`` array.
}
};
}, '0.0.1', {requires: ['yql', 'io', 'dump']});
+
Using Paging
------------
@@ -546,9 +547,7 @@ create URLs for the **next** and **prev** links.
* @constructor
*/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(actionContext) {
var page = actionContext.params.getFromMerged('page');
var start;
@@ -730,9 +729,7 @@ To set up and run ``binding_events``:
* @constructor
*/
Y.namespace('mojito.models')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
getData: function(query, start, count, callback) {
var q = null;
// Get Flickr API key: http://www.flickr.com/services/api/keys/apply/
@@ -1,4 +1,3 @@
-
========================
Calling YQL from a Mojit
========================
@@ -178,9 +177,7 @@ the ``index`` template.
YUI.add('flickr', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
var q = ac.params.getFromUrl('q') || 'muppet',
page = (ac.params.getFromUrl('page') || 0) / 1,
@@ -343,9 +340,7 @@ To set up and run ``model_yql``:
YUI.add('flickr', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
// Use aliases to params addon
// if they exist.
@@ -36,9 +36,6 @@ these methods for getting and setting cookies should be familiar as Mojito uses
YUI.add('CookieMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
index: function(actionContext) {
var requestCookieValue = actionContext.cookie.get('request_cookie');
// Or use this API to set a session cookie
@@ -143,9 +140,7 @@ To set up and run ``using_cookies``:
YUI.add('CookieMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(actionContext) {
var requestCookieValue = actionContext.cookie.get('request_cookie');
// Or use this API to set a session cookie
@@ -94,9 +94,7 @@ The appropriate CSS file is dynamically attached to the template with ``ac.asset
YUI.add('device', function(Y, NAME){
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
var device = ac.context.device, css = '/static/device/assets/simple';
if (device === 'iphone') {
@@ -233,9 +231,7 @@ To create and run ``device_assets``:
YUI.add('device', function(Y, NAME){
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
var device = ac.context.device, css = '/static/device/assets/simple';
if (device === 'iphone') {
@@ -154,9 +154,7 @@ To create and run ``framed_assets``:
YUI.add('framed', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
var data = {
title: "Framed Assets",
@@ -79,9 +79,7 @@ pass the instance and action to ``url.make`` to create the URL based on the path
YUI.add('GenURLMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(actionContext) {
var url = actionContext.url.make('mymojit', 'contactus', '');
actionContext.done({contactus_url: url});
@@ -149,9 +147,7 @@ To set up and run ``generating_urls``:
YUI.add('GenURLMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(actionContext) {
var url = actionContext.url.make('mymojit', 'contactus', '');
actionContext.done({contactus_url: url});
@@ -156,9 +156,6 @@ To set up and run ``htmlframe_mojit``:
YUI.add('framed', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
index: function(ac) {
ac.done({app_name:'Framed Mojit'});
}
@@ -80,9 +80,7 @@ include the `Intl addon <../../api/classes/Intl.common.html>`_ by adding the str
YUI.add('i18n', function(Y, NAME) {/
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
// Default.
ac.done(
@@ -187,9 +185,7 @@ To set up and run ``locale_i18n``:
YUI.add('i18n', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
+
index: function(ac) {
// Default.
ac.done(
@@ -116,9 +116,6 @@ can execute the ``index`` functions of the child mojits by calling the ``done``
YUI.add('MasterMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
"index": function(actionContext) {
actionContext.composite.done();
}
@@ -258,9 +255,6 @@ binder, which we'll look at next.
YUI.add('ReceiverMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
index: function(actionContext) {
actionContext.done({title: 'This is the receiver mojit'});
},
@@ -395,9 +389,6 @@ To set up and run ``inter-mojit``:
YUI.add('MasterMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(spec) {
- this.spec=spec;
- },
"index": function(actionContext) {
actionContext.composite.done();
}
@@ -462,9 +453,6 @@ To set up and run ``inter-mojit``:
YUI.add('SenderMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(config) {
- this.config = config;
- },
index: function(actionContext) {
actionContext.done({title: 'List of images for testing'});
}
@@ -525,9 +513,6 @@ To set up and run ``inter-mojit``:
YUI.add('ReceiverMojit', function(Y, NAME) {
Y.namespace('mojito.controllers')[NAME] = {
- init: function(spec) {
- this.spec = spec;
- },
"index": function(actionContext) {
actionContext.done({title: 'This is the receiver mojit'});
},
Oops, something went wrong.

0 comments on commit 9275476

Please sign in to comment.