1 /*
2 * application
3 * */
4 window.Trot = Ember.Application.create();
5
6 /*
7 * router
8 */
9 Trot.Router.map(function() {
10 this.resource('index', {
11 path : '/'
12 });
13 this.resource('list', {
14 path : '/list'
15 });
16 this.resource('content', {
17 path : '/person/:person_id'
18 });
19 });
20 Trot.ListRoute = Ember.Route.extend({
21 model : function() {
22 return Trot.Person.find();
23 },
24 setupController : function(controller, model) {
25 controller.set('list', model);
26 }
27 });
28
29 /*
30 * store
31 */
32 Trot.Store = DS.Store.extend({
33 revision : 12,
34 adapter : 'DS.FixtureAdapter'
35 });
36
37 /*
38 * model
39 */
40 Trot.Person = DS.Model.extend({
41 firstName : DS.attr('string'),
42 lastName : DS.attr('string'),
43 fullName : function() {
44 return this.get('firstName') + ' ' + this.get('lastName');
45 }.property('firstName', 'lastName')
46 });
47 Trot.Person.FIXTURES = [ {
48 id : 1,
49 firstName : 'Emily',
50 lastName : 'Zhang'
51 }, {
52 id : 2,
53 firstName : 'Wendy',
54 lastName : 'Wang'
55 }, {
56 id : 3,
57 firstName : 'Joy',
58 lastName : 'Li'
59 } ];