-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
33 lines (27 loc) · 1.07 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import './setup';
import { Router } from 'marionette.routing';
import ApplicationRoute from './application/route';
import ContactsRoute from './contacts/route';
import ContactDetailRoute from './contactdetail/route';
import ContactNoSelectionView from './noselection/view';
import { Application } from 'backbone.marionette';
import Radio from 'backbone.radio';
const app = new Application({
region: '#app'
});
const router = new Router({log: true, logError: true}, app.getRegion());
router.map(function (route) {
route('application', {path: '/', routeClass: ApplicationRoute}, function () {
route('contacts', {routeClass: ContactsRoute, abstract: true}, function () {
route('contacts.default', {path: '', viewClass: ContactNoSelectionView,
viewOptions: {message: 'Please Select a Contact.'}})
route('contactdetail', {path: ':contactid', routeClass: ContactDetailRoute})
})
})
});
Radio.channel('router').on('before:transition', function (transition) {
if (transition.path === '/') {
transition.redirectTo('contacts.default')
}
});
router.listen();