Skip to content
Browse files

Fixed namespace aliasing and added a few error checks

  • Loading branch information...
1 parent e177114 commit ae4e4f2eb3603ba98eea3f3671225f89cf25906a @add0n add0n committed Nov 8, 2012
View
20 lib/mojito-yaf.js
@@ -86,7 +86,7 @@ YUI.add('mojito-yaf', function (Y, NAME) {
MOJITO_NS.View = Y.Base.create('View', Y.View, [],
{
- templateEngine: new Y.mojito.Template(),
+ templateEngine: new MOJITO_NS.Template(),
initializer: function (params) {
var model,
@@ -200,7 +200,8 @@ YUI.add('mojito-yaf', function (Y, NAME) {
mojitAction = req.params.action;
// Fire an event - the mojits should be listening
- this.fire('mojit:' + mojitAction);
+ this.fire('mojit:' + mojitAction,
+ {params: req.params});
// Call the next most-specific handler.
next();
@@ -245,17 +246,20 @@ YUI.add('mojito-yaf', function (Y, NAME) {
// Now, get any specifically defined routes, loop over them and
// add routing entries
- routes = this.get('routes');
+ if (!(routes = this.get('routes'))) {
+ return;
+ }
handlerInst = this;
for (i = 0; i < routes.length; i++) {
evtName = routes[i].event;
- appInst.route(routes[i].route,
- function (req, res, next) {
- handlerInst.fire(evtName);
- next();
- });
+ appInst.route(
+ routes[i].route,
+ function (req, res, next) {
+ handlerInst.fire(evtName, {params: req.params});
+ next();
+ });
}
}
}, {
View
12 lib/mojits/HTMLMojit/controller.client.js
@@ -8,7 +8,7 @@ YUI.add('HTMLMojit', function (Y, NAME) {
var MOJITO_NS = Y.namespace('mojito');
- MOJITO_NS.HTMLMojitView = Y.Base.create('HTMLMojitView', Y.mojito.View, [],
+ MOJITO_NS.HTMLMojitView = Y.Base.create('HTMLMojitView', MOJITO_NS.View, [],
{
}, {
ATTRS: {
@@ -19,26 +19,26 @@ YUI.add('HTMLMojit', function (Y, NAME) {
// ---
- MOJITO_NS.HTMLMojitHandler = Y.Base.create('HTMLMojitHandler', Y.mojito.Handler, [],
+ MOJITO_NS.HTMLMojitHandler = Y.Base.create('HTMLMojitHandler', MOJITO_NS.Handler, [],
{
}, {
ATTRS: {
- routes: {value: [{route: '/', event: 'mojit:index'}]}
+ routes: {value: null}
}
}
);
// ---
- MOJITO_NS.HTMLMojit = Y.Base.create('HTMLMojit', Y.mojito.Mojit, [],
+ MOJITO_NS.HTMLMojit = Y.Base.create('HTMLMojit', MOJITO_NS.Mojit, [],
{
initializer: function () {
var msgView;
- msgView = new Y.mojito.HTMLMojitView({id: this.get('id'),
+ msgView = new MOJITO_NS.HTMLMojitView({id: this.get('id'),
mojit: this});
msgView.set('templateEngine',
- new Y.mojito.Template(Y.Handlebars));
+ new MOJITO_NS.Template(Y.Handlebars));
msgView.loadTemplate();
msgView.render();
View
12 tests/mojits/MsgMojit/controller.client.js
@@ -8,7 +8,7 @@ YUI.add('MsgMojit', function (Y, NAME) {
var MOJITO_NS = Y.namespace('mojito');
- MOJITO_NS.MsgView = Y.Base.create('MsgView', Y.mojito.View, [],
+ MOJITO_NS.MsgView = Y.Base.create('MsgView', MOJITO_NS.View, [],
{
initializer: function () {
// Regular Y.Lang sub template
@@ -22,7 +22,7 @@ YUI.add('MsgMojit', function (Y, NAME) {
// ---
- MOJITO_NS.MsgHandler = Y.Base.create('MsgHandler', Y.mojito.Handler, [],
+ MOJITO_NS.MsgHandler = Y.Base.create('MsgHandler', MOJITO_NS.Handler, [],
{
setupEventBindings: function () {
// Make sure and set up the auto bindings
@@ -57,20 +57,20 @@ YUI.add('MsgMojit', function (Y, NAME) {
// ---
- MOJITO_NS.MsgMojit = Y.Base.create('MsgMojit', Y.mojito.Mojit, [],
+ MOJITO_NS.MsgMojit = Y.Base.create('MsgMojit', MOJITO_NS.Mojit, [],
{
initializer: function () {
var msgModel;
var msgView;
- msgModel = new Y.mojito.MsgModel({msg: 'Howdy!'});
+ msgModel = new MOJITO_NS.MsgModel({msg: 'Howdy!'});
this.get('models')['msgHolder'] = msgModel;
- msgView = new Y.mojito.MsgView({model: msgModel,
+ msgView = new MOJITO_NS.MsgView({model: msgModel,
id: this.get('id'),
mojit: this});
msgView.set('templateEngine',
- new Y.mojito.Template(Y.Handlebars));
+ new MOJITO_NS.Template(Y.Handlebars));
msgView.render();
this.addViewNamed(msgView, 'msgView');
View
10 tests/mojits/TestRootMojit/controller.client.js
@@ -8,7 +8,7 @@ YUI.add('TestRootMojit', function (Y, NAME) {
var MOJITO_NS = Y.namespace('mojito');
- MOJITO_NS.TestRootMojitView = Y.Base.create('TestRootMojitView', Y.mojito.View, [],
+ MOJITO_NS.TestRootMojitView = Y.Base.create('TestRootMojitView', MOJITO_NS.View, [],
{
getDOMAttachPoint: function () {
return Y.one('#mainMojit');
@@ -22,7 +22,7 @@ YUI.add('TestRootMojit', function (Y, NAME) {
// ---
- MOJITO_NS.TestRootMojitHandler = Y.Base.create('TestRootMojitHandler', Y.mojito.Handler, [],
+ MOJITO_NS.TestRootMojitHandler = Y.Base.create('TestRootMojitHandler', MOJITO_NS.Handler, [],
{
}, {
ATTRS: {
@@ -33,15 +33,15 @@ YUI.add('TestRootMojit', function (Y, NAME) {
// ---
- MOJITO_NS.TestRootMojit = Y.Base.create('TestRootMojit', Y.mojito.Mojit, [],
+ MOJITO_NS.TestRootMojit = Y.Base.create('TestRootMojit', MOJITO_NS.Mojit, [],
{
initializer: function () {
var msgView;
- msgView = new Y.mojito.TestRootMojitView({id: this.get('id'),
+ msgView = new MOJITO_NS.TestRootMojitView({id: this.get('id'),
mojit: this});
msgView.set('templateEngine',
- new Y.mojito.Template(Y.Handlebars));
+ new MOJITO_NS.Template(Y.Handlebars));
msgView.loadTemplate();
msgView.render();

0 comments on commit ae4e4f2

Please sign in to comment.
Something went wrong with that request. Please try again.