]> git.proxmox.com Git - extjs.git/blame - extjs/examples/modern/geocongress/app/controller/Legislator.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / modern / geocongress / app / controller / Legislator.js
CommitLineData
6527f429
DM
1Ext.define('GeoCon.controller.Legislator', {\r
2 extend: 'Ext.app.Controller',\r
3\r
4 requires: ['GeoCon.view.legislator.TabPanel', 'GeoCon.view.bill.Show'],\r
5\r
6 config: {\r
7 control: {\r
8 '#legislatorTabPanel': {\r
9 activate: 'onLegislatorShow'\r
10 },\r
11 '#legislatorList': {\r
12 itemtap: 'onLegislatorTap'\r
13 },\r
14 '#billList': {\r
15 activate: 'onBillListActivate',\r
16 itemtap: 'onBillTap'\r
17 },\r
18 '#voteList': {\r
19 activate: 'onVoteListActivate'\r
20 },\r
21 '#legislatorBackButton': {\r
22 tap: function() {\r
23 Ext.getCmp('splashScreen').animateTo('right');\r
24 Ext.getCmp('viewport').setActiveItem(Ext.getCmp('splashScreen'));\r
25 }\r
26 },\r
27 '#billSummaryBackButton': {\r
28 tap: function() {\r
29 Ext.getCmp('splashScreen').animateTo('right');\r
30 Ext.getCmp('viewport').setActiveItem(Ext.getCmp('legislatorTabPanel'));\r
31 }\r
32 }\r
33 }\r
34 },\r
35\r
36 onLegislatorShow: function() {\r
37 Ext.getCmp('viewport').getLayout().getAnimation().setReverse(false);\r
38 },\r
39\r
40 onBillListActivate: function() {\r
41\r
42 if (this.currentBills != this.currentLegislator.bioguide_id) {\r
43 Ext.getStore('Bills').load({\r
44 params: {\r
45 sponsor_id: this.currentLegislator.bioguide_id\r
46 }\r
47 });\r
48 this.currentBills = this.currentLegislator.bioguide_id;\r
49 }\r
50 },\r
51\r
52 onBillTap: function(dataview, index, target, record) {\r
53\r
54 var billSummary = Ext.getCmp('billSummary');\r
55 Ext.getCmp('splashScreen').animateTo('left');\r
56\r
57 if (billSummary) {\r
58 billSummary.setData(record.data);\r
59 Ext.getCmp('viewport').setActiveItem(billSummary);\r
60 } else {\r
61 Ext.getCmp('viewport').setActiveItem({\r
62 xclass: 'GeoCon.view.bill.Show',\r
63 data: record.data\r
64 });\r
65 }\r
66\r
67 Ext.getCmp('billSummaryToolbar').setTitle(record.data.bill_id);\r
68 },\r
69\r
70 onVoteListActivate: function() {\r
71\r
72 if (this.currentVotes != this.currentLegislator.bioguide_id) {\r
73\r
74 var storeParams = {};\r
75 storeParams['voter_ids.' + this.currentLegislator.bioguide_id + '__exists'] = true;\r
76\r
77 Ext.getStore('Votes').load({\r
78 params: storeParams\r
79 });\r
80\r
81 this.currentVotes = this.currentLegislator.bioguide_id;\r
82 }\r
83 },\r
84\r
85 onLegislatorTap: function(dataview, index, target, record) {\r
86\r
87 if (this.currentLegislator == record.data) {\r
88 Ext.getCmp('viewport').setActiveItem(1);\r
89 return;\r
90 }\r
91\r
92 this.currentLegislator = record.data;\r
93\r
94 this.currentLegislator.committees = Ext.getStore('Committees').load({\r
95 params: {\r
96 member_ids: this.currentLegislator.bioguide_id\r
97 }\r
98 });\r
99\r
100 var legislator = Ext.getCmp('legislatorTabPanel');\r
101 Ext.getCmp('splashScreen').animateTo('left');\r
102\r
103 if (legislator) {\r
104 legislator.setData(this.currentLegislator);\r
105 Ext.getCmp('viewport').setActiveItem(1);\r
106 } else {\r
107 Ext.getCmp('viewport').setActiveItem({\r
108 xclass: 'GeoCon.view.legislator.TabPanel'\r
109 });\r
110 }\r
111\r
112 Ext.getCmp('legislatorBio').setData(this.currentLegislator);\r
113 Ext.getCmp('legislatorToolbar').setTitle(this.currentLegislator.title + " " + this.currentLegislator.last_name);\r
114 Ext.getCmp('legislatorTabPanel').setActiveItem(0);\r
115 }\r
116\r
117});\r