postal.js/example/node/client/js/infrastructure/router.js
2012-05-20 19:22:54 -04:00

53 lines
No EOL
977 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 } );
}
} );
} );