This repository has been archived by the owner on Mar 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
application_route.js
71 lines (60 loc) · 1.9 KB
/
application_route.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
Noted.Router.map(function() {
this.route("static/404", {path: "404"});
this.route("static/about", {path: "about"})
this.resource('note', {path: "/notes/:note_id"});
});
// this is a little weird but convenient at least
Noted.renderWindow = function(ctx, showImport) {
var notesController = ctx.controllerFor('notes');
notesController.set('content', Noted.Note.find());
var dropboxController = ctx.controllerFor("dropbox");
dropboxController.set('notes', notesController.get("content"));
dropboxController.set('showImport', showImport);
ctx.render('app_window');
ctx.render('controls/bottom', {
controller: notesController,
into: 'app_window',
outlet: 'bottom_controls'
});
ctx.render('controls/dropbox', {
controller: dropboxController,
into: 'controls/bottom',
outlet: 'dropbox_controls'
});
ctx.render('note_list', {
controller: notesController,
into: 'app_window',
outlet: 'sidebar'
});
}
Noted.IndexRoute = Ember.Route.extend({
renderTemplate: function(controller, model) {
Noted.renderWindow(this, true);
if (this.controllerFor('note').get('content')) {
this.controllerFor('notes').set('selected', undefined);
}
this.render('static/index', {
into: "app_window",
outlet: "content"
});
}
});
Noted.NoteRoute = Noted.IndexRoute.extend({
setupController: function(controller, note) {
controller.set('content', note)
},
model: function(params) {
return Noted.Note.find(params.note_id);
},
renderTemplate: function(some_controller, note) {
var notesController = this.controllerFor('notes').set('content', Noted.Note.find());
var noteController = this.controllerFor('note').set('content', note);
notesController.set("selected", note);
Noted.renderWindow(this, false);
this.render('note', {
controller: noteController,
into: 'app_window',
outlet: 'content'
});
}
})