Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial noodling baby steps

  • Loading branch information...
commit eb40ef8921745e55f12cdf18c61e5dcaa8b875f5 1 parent 7e75c82
Bill add0n authored
64 index.html
View
@@ -0,0 +1,64 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<!-- ================================================================= -->
+<!--
+NAME: index.html
+AUTH: William J Edney (wje)
+NOTE: Copyright (C) 2012 Yahoo! Inc.
+-->
+<!-- ================================================================= -->
+
+<html>
+ <head>
+
+ <title>A Mojito / YAF integration test project</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+ <style type="text/css">
+ #Message
+ {
+ position: absolute;
+ border: solid 1px black;
+
+ left: 10%;
+ right: 10%;
+ bottom: 0px;
+
+ height: 2em;
+ }
+ </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="./scripts/mojitoDriver.js"></script>
+ <script type="text/javascript" src="./scripts/mojitoMojits.js"></script>
+ <script type="text/javascript" src="./scripts/mojitoTest.js"></script>
+ <script type="text/javascript">
+ YUI().use(['app', 'mojitoDriver', 'testMojit1', 'mojitoTest'], function (Y) {
+ var app = new Y.App();
+ Y.appObj = app;
+
+ Y.mojito.mojitoDriver.init();
+
+ // This may be poor form...
+ window.Y = Y;
+ });
+ </script>
+
+ </head>
+ <body>
+ <button onclick="window.Y.mojito.mojitoTest.test1()">Dispatch to mojit #1</button>
+ <span id="Message"></span>
+ </body>
+</html>
47 scripts/mojitoDriver.js
View
@@ -0,0 +1,47 @@
+YUI.add('mojitoDriver', function (Y, NAME) {
+
+ Y.namespace('mojito')[NAME] = {
+ init: function() {
+
+ var mojitNames = ['testMojit1'],
+ mojitActions = ['index'],
+ i;
+
+ var mojitDispatcher = function (req, res, next) {
+ var fullMojitID,
+ mojitParts,
+ mojitName,
+ mojitAction;
+
+ fullMojitID = req.path.slice(req.path.lastIndexOf('/') + 1);
+ mojitParts = fullMojitID.split(':');
+ mojitName = mojitParts[0];
+ mojitAction = mojitParts[1];
+
+ // Dispatch to the mojit. Right now a Function call, but that'll
+ // need to change - heh ;-)
+ Y.mojito[mojitName][mojitAction]();
+
+ // Call the next most-specific handler.
+ next();
+ };
+
+ for (i=0; i < mojitNames.length; i++) {
+ Y.appObj.route('/' + mojitNames[i] + ':' + mojitActions[i],
+ mojitDispatcher);
+ }
+
+ Y.appObj.route('*', function (req) {
+ Y.mojito.mojitoDriver.logMessage('Got to: ' + req.path);
+ });
+
+ Y.appObj.on('navigate', function (e) {
+ Y.mojito.mojitoDriver.logMessage('Navigated to: ' + e.url);
+ });
+ },
+ logMessage: function(msg) {
+ Y.one('#Message').set('text', Y.one('#Message').get('text') +
+ ' || ' + msg);
+ }
+ };
+}, '0.0.1');
8 scripts/mojitoMojits.js
View
@@ -0,0 +1,8 @@
+YUI.add('testMojit1', function (Y, NAME) {
+
+ Y.namespace('mojito')[NAME] = {
+ index: function () {
+ Y.mojito.mojitoDriver.logMessage('Got to index function of testMojit1');
+ }
+ };
+}, '0.0.1');
8 scripts/mojitoTest.js
View
@@ -0,0 +1,8 @@
+YUI.add('mojitoTest', function (Y, NAME) {
+
+ Y.namespace('mojito')[NAME] = {
+ test1: function () {
+ Y.appObj.navigate('/testMojit1:index');
+ }
+ };
+}, '0.0.1');
Please sign in to comment.
Something went wrong with that request. Please try again.