Station.js
1.28 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
Ext.define('Pandora.controller.Station', {
extend: 'Ext.app.Controller',
refs: [{
ref: 'stationsList',
selector: 'stationslist'
}],
stores: ['Stations', 'RecentSongs'],
init: function() {
this.control({
'stationslist': {
selectionchange: this.onStationSelect
},
'newstation': {
select: this.onNewStationSelect
}
});
},
onLaunch: function() {
var stationsStore = this.getStationsStore();
stationsStore.load({
callback: this.onStationsLoad,
scope: this
});
},
onStationsLoad: function() {
var stationsList = this.getStationsList();
stationsList.getSelectionModel().select(0);
},
onStationSelect: function(selModel, selection) {
this.application.fireEvent('stationstart', selection[0]);
},
onNewStationSelect: function(field, selection) {
var selected = selection[0],
store = this.getStationsStore(),
list = this.getStationsList();
if (selected && !store.getById(selected.get('id'))) {
store.add(selected);
list.getSelectionModel().select(selected);
}
}
});