]>
Commit | Line | Data |
---|---|---|
6527f429 DM |
1 | /**\r |
2 | * This plugin allow you to reorder tabs of a TabPanel.\r | |
3 | */\r | |
4 | Ext.define('Ext.ux.TabReorderer', {\r | |
5 | \r | |
6 | extend: 'Ext.ux.BoxReorderer',\r | |
7 | alias: 'plugin.tabreorderer',\r | |
8 | \r | |
9 | itemSelector: '.' + Ext.baseCSSPrefix + 'tab',\r | |
10 | \r | |
11 | init: function(tabPanel) {\r | |
12 | var me = this;\r | |
13 | \r | |
14 | me.callParent([tabPanel.getTabBar()]);\r | |
15 | \r | |
16 | // Ensure reorderable property is copied into dynamically added tabs\r | |
17 | tabPanel.onAdd = Ext.Function.createSequence(tabPanel.onAdd, me.onAdd);\r | |
18 | },\r | |
19 | \r | |
20 | onBoxReady: function() {\r | |
21 | var tabs,\r | |
22 | len,\r | |
23 | i = 0,\r | |
24 | tab;\r | |
25 | \r | |
26 | this.callParent(arguments);\r | |
27 | \r | |
28 | // Copy reorderable property from card into tab\r | |
29 | for (tabs = this.container.items.items, len = tabs.length; i < len; i++) {\r | |
30 | tab = tabs[i];\r | |
31 | if (tab.card) {\r | |
32 | tab.reorderable = tab.card.reorderable;\r | |
33 | }\r | |
34 | }\r | |
35 | },\r | |
36 | \r | |
37 | onAdd: function(card, index) {\r | |
38 | card.tab.reorderable = card.reorderable;\r | |
39 | },\r | |
40 | \r | |
41 | afterBoxReflow: function() {\r | |
42 | var me = this;\r | |
43 | \r | |
44 | // Cannot use callParent, this is not called in the scope of this plugin, but that of its Ext.dd.DD object\r | |
45 | Ext.ux.BoxReorderer.prototype.afterBoxReflow.apply(me, arguments);\r | |
46 | \r | |
47 | // Move the associated card to match the tab order\r | |
48 | if (me.dragCmp) {\r | |
49 | me.container.tabPanel.setActiveTab(me.dragCmp.card);\r | |
50 | me.container.tabPanel.move(me.dragCmp.card, me.curIndex);\r | |
51 | }\r | |
52 | }\r | |
53 | }); |