A small hash and history api router suitable for hybrid web apps which use both the SPA and traditional approach at the same time.
var router = new Router();
or
var router = new Router({hybrid:true});
In the second example the router will only work for links with push-state class.
<a href="/awesome" class="push-state" data-push-state='{"title":"Awesome","foo":"bar"}'>Click me</a>
Adding routes
router.addHash('#foo', function() {
//Do something
});
router.addRoute('/foo', function() {
//Do something
});
Adding routes with variables
router.addHash('#foo/{bar}', function(bar) {
//Do something
});
router.addRoute('/foo/{bar}', function(bar) {
//Do something
});
Turning the listeners (router) on
router.listen();
Set a default action for empty hash
router.defaultHashAction = function() {
//Do something
};
Getters
router.getRoutes();
router.getRoute(0);
router.getRoute('/foo');
router.getRouteAction(router.getRoute(0));