This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.js
72 lines (59 loc) · 1.96 KB
/
module.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(function() {
define([
'backbone.marionette',
'app',
'apps/lesson/learn/structure/list/list_controller',
'apps/lesson/learn/structure/list/list_view'
],
function(Marionette, App){
// Define our Module under App
var StructureApp = App.module("LessonApp.LearnApp.StructureApp");
/*
** Configure the Module
*/
StructureApp.startWithParent = false;
/*
** Setup the Router for this module
*/
StructureApp.Router = Backbone.Marionette.AppRouter.extend({
appRoutes: {
'lessons/:id/learn/structure': 'listStructure',
'lessons/:id/learn/structure/:page': 'listStructure',
}
});
/*
** Setup our module's API
*/
var API = {
listStructure: function(id, page) {
App.trigger("lesson:setup:layout", id);
App.trigger('lesson:learn:setup:layout', id);
//Forcing page number in url
if (page === undefined) {
var page = 1;
App.navigate('/lessons/'+ id + '/learn/structure/' + page);
}
StructureApp.List.Controller.listStructure(page);
}
};
/*
** Listen for events on the app
*/
App.on("lesson:learn:structure:list", function(id, page, options) {
var id = id || 1; //If a lesson id is not passed, set id to 1
var page = page || 1;
App.navigate("lessons/" + id + "/learn/structure/" + page);
API.listStructure(id, page, options);
});
/*
** Add application initializers
*/
StructureApp.addInitializer(function() {
var router = new StructureApp.Router({
controller: API
});
});
// Return the module
return StructureApp;
});
}).call(this);