Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Fixed namespace aliasing and added a few error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
add0n committed Nov 8, 2012
1 parent e177114 commit ae4e4f2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
20 changes: 12 additions & 8 deletions lib/mojito-yaf.js
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
});
}
}
}, {
Expand Down
12 changes: 6 additions & 6 deletions lib/mojits/HTMLMojit/controller.client.js
Expand Up @@ -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: {
Expand All @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions tests/mojits/MsgMojit/controller.client.js
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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');
Expand Down
10 changes: 5 additions & 5 deletions tests/mojits/TestRootMojit/controller.client.js
Expand Up @@ -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');
Expand All @@ -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: {
Expand All @@ -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();
Expand Down

0 comments on commit ae4e4f2

Please sign in to comment.