Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(85)

Unified Diff: app/app.js

Issue 6783049: Enable yuidoc and add a start to docs.
Patch Set: Enable yuidoc and add a start to docs. Created 12 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « [revision details] ('k') | app/views/unit.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: app/app.js
=== modified file 'app/app.js'
--- app/app.js 2012-10-23 19:54:44 +0000
+++ app/app.js 2012-10-26 15:27:45 +0000
@@ -1,4 +1,9 @@
'use strict';
+/**
+ * Provides the main app class.
+ *
+ * @module app
+ */
// Create a global for debug console access to YUI context.
var yui;
@@ -12,6 +17,11 @@
models = Y.namespace('juju.models'),
views = Y.namespace('juju.views');
+ /**
+ * The main app class.
+ *
+ * @class App
+ */
var JujuGUI = Y.Base.create('juju-gui', Y.App, [], {
views: {
environment: {
@@ -74,8 +84,11 @@
/*
* Data driven behaviors
- * This is a placehold for real behaviors associated with
- * DOM Node data-* attributes.
+ *
+ * This is a placeholder for real behaviors associated with DOM Node data-*
+ * attributes.
+ *
+ * @attribute behaviors
*/
behaviors: {
timestamp: {
@@ -92,6 +105,9 @@
}
},
+ /**
+ * @method initializer
+ */
initializer: function() {
// If this flag is true, start the application with the console activated
if (this.get('consoleEnabled')) {
@@ -199,6 +215,11 @@
});
},
+ /**
+ * Hook up all of the declared behaviors.
+ *
+ * @method enableBehaviors
+ */
enableBehaviors: function() {
Y.each(this.behaviors, function(behavior) {
behavior.callback.call(this);
@@ -206,14 +227,19 @@
},
+ /**
+ * @method on_database_changed
+ */
on_database_changed: function(evt) {
Y.log(evt, 'debug', 'App: Database changed');
// Redispatch to current view to update.
this.dispatch();
},
- /*
+ /**
* When services are added we update endpoints here.
+ *
+ * @method updateEndpoints
*/
updateEndpoints: function(callback) {
var self = this;
@@ -235,29 +261,46 @@
},
// Event handlers
+
+ /**
+ * @method navigate_to_unit
+ */
navigate_to_unit: function(e) {
console.log('Evt.Nav.Router unit target', e.unit_id);
this.navigate('/unit/' + e.unit_id.replace('/', '-') + '/');
},
+ /**
+ * @method navigate_to_service
+ */
navigate_to_service: function(e) {
var service = e.service;
console.log(service.get('id'), 'Evt.Nav.Router service target');
this.navigate('/service/' + service.get('id') + '/');
},
+ /**
+ * @method navigate_to_charm
+ */
navigate_to_charm: function(e) {
console.log('Evt.Nav.Router charm');
var charm_url = e.charm_data_url;
this.navigate('/charms/' + charm_url);
},
+ /**
+ * @method navigate_to_environment
+ */
navigate_to_environment: function(e) {
console.log('Evt.Nav.Router environment');
this.navigate('/');
},
// Route handlers
+
+ /**
+ * @method show_unit
+ */
show_unit: function(req) {
console.log(
'App: Route: Unit', req.params.id, req.path, req.pendingRoutes);
@@ -278,6 +321,10 @@
querystring: req.query });
},
+ /**
+ * @method _prefetch_service
+ * @private
+ */
_prefetch_service: function(service) {
// only prefetch once
// we redispatch to the service view after we have status
@@ -301,6 +348,10 @@
}
},
+ /**
+ * @method _buildServiceView
+ * @private
+ */
_buildServiceView: function(req, viewName) {
console.log('App: Route: Service',
viewName, req.params.id, req.path, req.pendingRoutes);
@@ -320,22 +371,37 @@
});
},
+ /**
+ * @method show_service
+ */
show_service: function(req) {
this._buildServiceView(req, 'service');
},
+ /**
+ * @method show_service_config
+ */
show_service_config: function(req) {
this._buildServiceView(req, 'service_config');
},
+ /**
+ * @method show_service_relations
+ */
show_service_relations: function(req) {
this._buildServiceView(req, 'service_relations');
},
+ /**
+ * @method show_service_constraints
+ */
show_service_constraints: function(req) {
this._buildServiceView(req, 'service_constraints');
},
+ /**
+ * @method show_charm_collection
+ */
show_charm_collection: function(req) {
console.log('App: Route: Charm Collection', req.path, req.query);
this.showView('charm_collection', {
@@ -344,6 +410,9 @@
});
},
+ /**
+ * @method show_charm
+ */
show_charm: function(req) {
console.log('App: Route: Charm', req.path, req.params);
var charm_url = req.params.charm_store_path;
@@ -354,6 +423,9 @@
});
},
+ /**
+ * @method show_notifications_overview
+ */
show_notifications_overview: function(req) {
this.showView('notifications_overview', {
app: this,
@@ -361,12 +433,14 @@
notifications: this.db.notifications});
},
- /*
+ /**
* Persistent Views
*
* 'notifications' is a preserved views that remains rendered on all main
* views. we manually create an instance of this view and insert it into
* the App's view metadata.
+ *
+ * @method show_notifications_view
*/
show_notifications_view: function(req, res, next) {
var view = this.getViewInfo('notifications'),
@@ -382,11 +456,14 @@
next();
},
- /* Display the provider type.
+ /**
+ * Display the provider type.
*
* The provider type arrives asynchronously. Instead of updating the
* display from the environment code (a separation of concerns violation)
* we update it here.
+ *
+ * @method onProviderTypeChange
*/
onProviderTypeChange: function(evt) {
var providerType = evt.newVal,
@@ -396,6 +473,9 @@
}
},
+ /**
+ * @method show_environment
+ */
show_environment: function(req, res, next) {
var view = this.getViewInfo('environment'),
instance = view.instance;
@@ -428,7 +508,11 @@
next();
},
- // Model interactions -> move to db layer
+ /**
+ * Model interactions -> move to db layer
+ *
+ * @method load_service
+ */
load_service: function(evt) {
console.log('load service', evt);
if (evt.err) {
@@ -457,30 +541,31 @@
this.dispatch();
},
- /*
- * Object routing support
- * This is a utility that helps map from model objects to routes
- * defined on the App object.
+ /**
+ * Object routing support
*
- * getModelURL(model, [intent])
- * :model: the model to determine a route url for
- * :intent: (optional) the name of an intent associated with
- * a route. When more than one route can match a model
- * the route w/o an intent is matched when this attribute
- * is missing. If intent is provided as a string it
- * is matched to the 'intent' attribute specified on the
- * route. This is effectively a tag.
+ * This is a utility that helps map from model objects to routes
+ * defined on the App object.
*
* To support this we supplement our routing information with
* additional attributes as follows:
*
- * :model: model.name (required)
- * :reverse_map: (optional) route_path_key: str
- * reverse map can map :id to the name of attr on model
- * if no value is provided its used directly as attribute name
- * :intent: (optional) A string named intent for which this route
- * should be used. This can be used to select which subview
- * is selected to resolve a models route.
+ * model: model.name (required)
+ * reverse_map: (optional) A reverse mapping of route_path_key to the
+ * name of the attribute on the model. If no value is provided its
+ * used directly as attribute name.
+ * intent: (optional) A string named intent for which this route should
+ * be used. This can be used to select which subview is selected to
+ * resolve a models route.
+ *
+ * @method getModelURL
+ * @param {object} model The model to determine a route url for.
+ * @param {object} [intent] the name of an intent associated with a route.
+ * When more than one route can match a model the route w/o an intent is
+ * matched when this attribute is missing. If intent is provided as a
+ * string it is matched to the 'intent' attribute specified on the route.
+ * This is effectively a tag.
+ *
*/
getModelURL: function(model, intent) {
var matches = [],
@@ -533,8 +618,13 @@
return matches[idx] && matches[idx].path;
},
- // Override Y.Router.route (and setter) to allow inclusion
- // of additional routing params
+ /**
+ * Override Y.Router.route (and setter) to allow inclusion of additional
+ * routing params
+ *
+ * @method _setRoutes
+ * @private
+ */
_setRoutes: function(routes) {
this._routes = [];
Y.Array.each(routes, function(route) {
@@ -544,6 +634,10 @@
}, this);
return this._routes.concat();
},
+
+ /**
+ * @method route
+ */
route: function(path, callback, options) {
JujuGUI.superclass.route.call(this, path, callback);
« no previous file with comments | « [revision details] ('k') | app/views/unit.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b