]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | Ext.define('KitchenSink.view.tab.AdvancedTabsController', {\r |
2 | extend: 'Ext.app.ViewController',\r | |
3 | alias: 'controller.advanced-tabs',\r | |
4 | \r | |
5 | counter: 3,\r | |
6 | positions: [ 'top', 'right', 'bottom', 'left' ],\r | |
7 | rotations: [ 'default', 0, 1, 2 ],\r | |
8 | position: 0,\r | |
9 | rotation: 0,\r | |
10 | \r | |
11 | onAddTabClick: function() {\r | |
12 | var tabPanel = this.lookupReference('tabpanel'),\r | |
13 | counter = ++this.counter,\r | |
14 | html = counter % 2 ? KitchenSink.DummyText.longText :\r | |
15 | KitchenSink.DummyText.extraLongText,\r | |
16 | tab = tabPanel.add({\r | |
17 | title: 'Tab ' + counter,\r | |
18 | html: html\r | |
19 | });\r | |
20 | \r | |
21 | tabPanel.setActiveTab(tab);\r | |
22 | },\r | |
23 | \r | |
24 | onAutoCycleToggle: function(button, pressed) {\r | |
25 | var me = this;\r | |
26 | \r | |
27 | if (pressed) {\r | |
28 | me.cycleInterval = setInterval(function() {\r | |
29 | me.doCycle()\r | |
30 | }, 500);\r | |
31 | me.doCycle()\r | |
32 | } else {\r | |
33 | clearInterval(me.cycleInterval);\r | |
34 | }\r | |
35 | },\r | |
36 | \r | |
37 | doCycle: function() {\r | |
38 | var rotation = this.rotation = (++this.rotation % 4),\r | |
39 | position = this.position;\r | |
40 | \r | |
41 | if (rotation === 0) {\r | |
42 | position = this.position = (++position % 4);\r | |
43 | }\r | |
44 | \r | |
45 | Ext.suspendLayouts();\r | |
46 | this.lookupReference('positionBtn').setValue(this.positions[position]);\r | |
47 | this.lookupReference('rotationBtn').setValue(this.rotations[rotation]);\r | |
48 | Ext.resumeLayouts(true);\r | |
49 | },\r | |
50 | \r | |
51 | destroy: function() {\r | |
52 | clearInterval(this.cycleInterval);\r | |
53 | this.callParent(arguments);\r | |
54 | }\r | |
55 | });\r |