/
Router.js
42 lines (35 loc) · 913 Bytes
/
Router.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
34
35
36
37
38
39
40
41
42
// OsciTk Namespace Initialization //
if (typeof OsciTk === 'undefined'){OsciTk = {};}
// OsciTk Namespace Initialization //
jQuery(function() {
OsciTk.router = Backbone.Router.extend({
routes: {
'' : 'root',
'section/:section_id' : 'section' // TODO: add params for paragraph, etc.
},
initialize: function() {
app.dispatcher.on('layoutComplete', function(section) {
//TODO: router should decide if going to a selector or the first page
app.dispatcher.trigger("navigate", {page: 1});
}, this);
},
/**
* Route to root location
*/
root: function() {
app.dispatcher.trigger('routedToRoot');
},
/**
* Route to the given section
*/
section: function(section_id) {
app.dispatcher.trigger('routedToSection', section_id);
},
/**
* Route to search
*/
search: function(query) {
app.dispatcher.trigger('routedToSearch', query);
}
});
});