Song.js
1.45 KB
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
Ext.define('Pandora.controller.Song', {
extend: 'Ext.app.Controller',
refs: [{
ref: 'songInfo',
selector: 'songinfo'
}, {
ref: 'recentlyPlayedScroller',
selector: 'recentlyplayedscroller'
}],
stores: ['RecentSongs'],
init: function() {
this.control({
'recentlyplayedscroller': {
selectionchange: this.onSongSelect
}
});
this.application.on({
stationstart: this.onStationStart,
scope: this
});
},
onStationStart: function(station) {
var store = this.getRecentSongsStore();
store.load({
callback: this.onRecentSongsLoad,
params: {
station: station.get('id')
},
scope: this
});
},
onRecentSongsLoad: function(songs, request) {
var store = this.getRecentSongsStore(),
selModel = this.getRecentlyPlayedScroller().getSelectionModel();
// The data should already be filtered on the serverside but since we
// are loading static data we need to do this after we loaded all the data
store.filter('station', request.params.station);
store.sort('played_date', 'ASC');
selModel.select(store.last());
},
onSongSelect: function(selModel, selection) {
this.getSongInfo().update(selection[0]);
}
});