]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('Pandora.controller.Song', {\r |
2 | extend: 'Ext.app.Controller',\r | |
3 | \r | |
4 | refs: [{\r | |
5 | ref: 'songInfo',\r | |
6 | selector: 'songinfo'\r | |
7 | }, {\r | |
8 | ref: 'recentlyPlayedScroller',\r | |
9 | selector: 'recentlyplayedscroller'\r | |
10 | }],\r | |
11 | \r | |
12 | stores: ['RecentSongs'],\r | |
13 | \r | |
14 | init: function() {\r | |
15 | this.control({\r | |
16 | 'recentlyplayedscroller': {\r | |
17 | selectionchange: this.onSongSelect\r | |
18 | }\r | |
19 | });\r | |
20 | \r | |
21 | this.application.on({\r | |
22 | stationstart: this.onStationStart,\r | |
23 | scope: this\r | |
24 | });\r | |
25 | },\r | |
26 | \r | |
27 | onStationStart: function(station) {\r | |
28 | var store = this.getRecentSongsStore();\r | |
29 | \r | |
30 | store.load({\r | |
31 | callback: this.onRecentSongsLoad,\r | |
32 | params: {\r | |
33 | station: station.get('id')\r | |
34 | }, \r | |
35 | scope: this\r | |
36 | });\r | |
37 | },\r | |
38 | \r | |
39 | onRecentSongsLoad: function(songs, request) {\r | |
40 | var store = this.getRecentSongsStore(),\r | |
41 | selModel = this.getRecentlyPlayedScroller().getSelectionModel();\r | |
42 | \r | |
43 | // The data should already be filtered on the serverside but since we\r | |
44 | // are loading static data we need to do this after we loaded all the data\r | |
45 | store.filter('station', request.params.station);\r | |
46 | store.sort('played_date', 'ASC'); \r | |
47 | \r | |
48 | selModel.select(store.last());\r | |
49 | },\r | |
50 | \r | |
51 | onSongSelect: function(selModel, selection) {\r | |
52 | this.getSongInfo().update(selection[0]);\r | |
53 | }\r | |
54 | });\r |