Permalink
Browse files

- Reworked builder to use config map. - Changed routing to be respons…

…ibility of the controller
  • Loading branch information...
1 parent ba9c198 commit 5a2bbb350a6619fe2d21b6882c81b2ec0b7bd423 @add0n add0n committed Dec 13, 2012
Showing with 425 additions and 234 deletions.
  1. +326 −217 lib/mojito-yaf.js
  2. +90 −9 test.html
  3. +7 −6 tests/mojits/MsgMojit/controller.client.js
  4. +2 −2 tests/mojits/TestRootMojit/controller.client.js
View
Oops, something went wrong.
View
@@ -34,17 +34,17 @@
</style>
<!-- The fully minified version of YUI -->
- <!--
<script type="text/javascript"
src="http://yui.yahooapis.com/3.7.2/build/yui/yui-min.js"></script>
- -->
<!-- The debug version of YUI -->
+ <!--
<script type="text/javascript">
// Put YUI in debug mode so that we can step through it.
YUI_config = {filter: 'debug', useConsoleOutput: true};
</script>
<script type="text/javascript" src="http://yui.yahooapis.com/3.7.2/build/yui/yui-debug.js"></script>
+ -->
<script type="text/javascript" src="./lib/mojito-yaf.js"></script>
<script type="text/javascript" src="./lib/mojits/HTMLMojit/controller.client.js"></script>
@@ -60,16 +60,97 @@
// !TODO! Hardcoded data in lieu of application.json / routes.json
// This is a hack for this test!
- var instanceMap = {
- 'mainMojit' : 'HTMLMojit',
- 'rootMojit' : 'mojito.TestRootMojit',
- 'msgMojit' : 'mojito.MsgMojit'
- };
+
+ var configData = {
+ "context":{
+ },
+ "binderMap":{
+ "mainMojit":{
+ "base":null,
+ "name":"HTMLMojitBinder",
+ "action":"index",
+ "config":{
+
+ },
+ "type":"HTMLMojit",
+ "viewId":"mainMojit",
+ "instanceId":"mainMojitA"
+ },
+ "rootMojit":{
+ "base":null,
+ "name":"TestRootMojitBinder",
+ "action":"index",
+ "config":{
+
+ },
+ "type":"mojito.TestRootMojit",
+ "viewId":"rootMojit",
+ "instanceId":"rootMojitA"
+ },
+ "msgMojit":{
+ "base":null,
+ "name":"MsgMojitBinder",
+ "action":"index",
+ "config":{
+
+ },
+ "type":"mojito.MsgMojit",
+ "viewId":"msgMojit",
+ "instanceId":"msgMojitA"
+ }
+ },
+ "routes":{
+ "root":{
+ "verbs":{
+ "GET":true
+ },
+ "path":"/",
+ "call":"frame.index",
+ "name":"root",
+ "params":{
+
+ },
+ "regex":{
+
+ },
+ "query":{
+
+ },
+ "requires":{
+
+ },
+ "ext_match":"^/$",
+ "int_match":"^$"
+ },
+ "msg":{
+ "verbs":{
+ "GET":true
+ },
+ "path":"/foo",
+ "call":"foo.bar",
+ "name":"msg",
+ "params":{
+
+ },
+ "regex":{
+
+ },
+ "query":{
+
+ },
+ "requires":{
+
+ },
+ "ext_match":"^/foo$",
+ "int_match":"^$"
+ }
+ }
+ };
// !END TODO!
var app = new Y.App();
- new Y.mojito.Builder({instData: instanceMap, app: app});
+ new Y.mojito.Builder({configData: configData, appObj: app});
app.navigate('/');
@@ -87,7 +168,7 @@
Y.one('#alertAllMojits').on('click',
function () {
- var stuff = Y.mojito.Controller.findAllMojits();
+ var stuff = Y.mojito.Controller.findAllControllers();
alert(Object.keys(stuff));
});
});
@@ -41,8 +41,7 @@ YUI.add('MsgMojit', function (Y, NAME) {
eventBindings: {value:
[{selector: '#saveMsgButton',
domEvent: 'click',
- mojitEvent: 'mojit:saveMsg'}]},
- routes: {value: [{route: '/foo', event: 'foo:fooEvent'}]}
+ mojitEvent: 'mojit:saveMsg'}]}
}
}
);
@@ -90,15 +89,17 @@ YUI.add('MsgMojit', function (Y, NAME) {
this.get('models')['msgHolder'].save();
},
- onFooFooEvent: function (evt) {
- console.log('got to "foo:fooEvent" event handler');
+ onFooBar: function (evt) {
+ console.log('got to "foo:bar" event handler');
}
}, {
ATTRS: {
+ name: {value: 'msg'},
controllerEvents: {value:
['mojit:index', 'mojit:setMsg', 'mojit:saveMsg',
- 'foo:fooEvent']},
- handlerType: {value: MOJITO_NS.MsgMojitHandler}
+ 'foo:bar']},
+ handlerType: {value: MOJITO_NS.MsgMojitHandler},
+ routes: {value: [{route: '/foo', event: 'foo:bar'}]}
}
}
);
@@ -26,7 +26,6 @@ YUI.add('TestRootMojit', function (Y, NAME) {
{
}, {
ATTRS: {
- routes: {value: [{route: '/', event: 'mojit:index'}]}
}
}
);
@@ -58,7 +57,8 @@ YUI.add('TestRootMojit', function (Y, NAME) {
}, {
ATTRS: {
controllerEvents: {value: ['mojit:index']},
- handlerType: {value: MOJITO_NS.TestRootMojitHandler}
+ handlerType: {value: MOJITO_NS.TestRootMojitHandler},
+ routes: {value: [{route: '/', event: 'mojit:index'}]}
}
}
);

0 comments on commit 5a2bbb3

Please sign in to comment.