Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Removed the examples from the readme and better fleshed out the doc…
…umentation + Added a basic routing example app.
- Loading branch information
Robert Hurst
authored and
Robert Hurst
committed
Feb 8, 2012
1 parent
291c607
commit d7aadf0
Showing
5 changed files
with
128 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
BASIC ROUTES EXAMPLE | ||
This file should give you an idea of how to get started | ||
*/ | ||
|
||
bind('load', window, function() { | ||
|
||
//get the page div | ||
var page = document.getElementById('page'); | ||
|
||
//setup the routes | ||
|
||
//home route | ||
OriginJS.bind('/', function() { | ||
|
||
//load the home content | ||
page.innerHTML = '<h2>Home</h2><p>This is an example of OriginJS routing. You may use it to learn how to effectivley use the library.</p><p>OriginJS is avalible on <a href="http://github.com/RobertWHurst/OriginJS" target="_blank">GitHub</a></p>'; | ||
}); | ||
|
||
//about route | ||
OriginJS.bind('/about', function() { | ||
|
||
//load the about content | ||
page.innerHTML = '<h2>About</h2><p>OriginJS is am awesome clent slide router. It\'s lightweight, easy to use, and has a lot of very powerful features. If your building a single page application, and javascript game, or anything else heavy in javascript, OriginJS will make your application more accessable and might even help you code in a more organized way.</p>'; | ||
}); | ||
|
||
//contact route | ||
OriginJS.bind('/contact', function() { | ||
|
||
//load the contact content | ||
page.innerHTML = '<h2>Contact</h2><p>If you find any issues or you have a request regarding OriginJS please post an issue on the <a href="http://github.com/RobertWHurst/OriginJS/issues" target="_blank">issue tracker</a>.</p>'; | ||
}); | ||
|
||
//load the current route | ||
OriginJS.update(); | ||
|
||
}); | ||
|
||
|
||
//DO NOT USE IN YOUR PROJECT! | ||
//This is pollyfill for binding to the load event in ms's old browsers (not needed for oigin) | ||
function bind(eventName, element, callback) {if(element.addEventListener){element.addEventListener(eventName,callback,false);}else{element.attachEvent("on"+eventName,function(event){return callback.call(element,event);});}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Basic Routes Example App</title> | ||
|
||
<link rel="stylesheet" href="style.css"> | ||
|
||
<script src="../../origin.js"></script> | ||
<script src="app.js"></script> | ||
</head> | ||
<body> | ||
<h1>Basic Routes Example App</h1> | ||
<nav> | ||
<a href="#/">Home</a><a href="#/about">About</a><a href="#/contact">Contact</a> | ||
</nav> | ||
<div id="page"> | ||
|
||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
body { | ||
font-family: Helvetica, Arial, sans-serif; | ||
font-size: 16px; | ||
padding: 40px; | ||
} | ||
h1 { | ||
text-align: center; | ||
} | ||
#page, | ||
nav { | ||
width: 720px; | ||
margin: 0 auto; | ||
} | ||
nav a { | ||
margin-right: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters