postal.js/example/node/client/js/infrastructure/router.js
2012-04-20 01:53:46 -04:00

52 lines
No EOL
956 B
JavaScript

define([
'jquery',
'backbone',
'bus'
], function( $, Backbone, bus ){
return Backbone.Router.extend({
routes: {
"" : "home",
"requests" : "requests",
"wiretap" : "wiretap",
"*anything" : "redirect"
},
initialize: function() {
var self = this;
_.bindAll( self );
$( document ).delegate( "a.ps-nav", "click", function( e ){
e.preventDefault();
self.navigate( $( this ).attr( 'href' ), { trigger: true });
});
bus.router.publish( "initialized" );
},
activateUI: function( uiName, context ) {
bus.viewManager.publish({
topic: "ui.show",
data: {
name: uiName,
context: context
}
});
},
home: function() {
this.activateUI( "homeUI" );
},
requests: function() {
this.activateUI( "searchRequestUI" );
},
wiretap: function() {
this.activateUI( "wireTapLogUI" );
},
redirect: function() {
this.navigate( "/", { trigger: true });
}
});
});