]> git.proxmox.com Git - pve-manager-legacy.git/commitdiff
copy panel/SubConfigPanel.js from manager to manager5
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 3 Jul 2015 09:29:11 +0000 (11:29 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 3 Jul 2015 09:29:11 +0000 (11:29 +0200)
www/manager5/panel/SubConfigPanel.js [new file with mode: 0644]

diff --git a/www/manager5/panel/SubConfigPanel.js b/www/manager5/panel/SubConfigPanel.js
new file mode 100644 (file)
index 0000000..849fd04
--- /dev/null
@@ -0,0 +1,80 @@
+Ext.define('PVE.panel.SubConfig', {
+    extend: 'Ext.tab.Panel',
+    alias: ['widget.pvePanelSubConfig'],
+
+    configPrefix: undefined,
+
+    getHState: function(itemId) {
+        /*jslint confusion: true */
+        var me = this;
+       
+       if (!itemId) {
+           itemId = me.getActiveTab().itemId;
+       }
+
+       var first =  me.items.get(0);
+       var ntab;
+
+       // Note: '' is alias for first tab.
+       if (itemId === first.itemId) {
+           ntab = me.configPrefix;
+       } else {
+           ntab = me.configPrefix + '-' + itemId;
+       }
+
+       return { value: ntab };
+    },
+
+    initComponent: function() {
+        var me = this;
+
+       if (!me.phstateid) {
+           throw "no parent history state specified";
+       }
+
+       var sp = Ext.state.Manager.getProvider();
+       var state = sp.get(me.phstateid);
+       
+       var hsregex =  /^([^\-\s]+)-(\S+)?$/;
+
+       if (state && state.value) {
+           var res = hsregex.exec(state.value);
+           if (res && res[1] && res[2] && res[1] === me.configPrefix) {
+               me.activeTab = res[2];
+           }
+       }
+
+       Ext.apply(me, {
+           plain: true,
+           tabPosition: 'bottom',
+           listeners: {
+               afterrender: function(tp) {
+                   var first =  tp.items.get(0);
+                   if (first) {
+                       first.fireEvent('show', first);
+                   }
+               },
+               tabchange: function(tp, newcard, oldcard) {
+                   var state = me.getHState(newcard.itemId);
+                   sp.set(me.phstateid, state);
+               }
+           }
+       });
+
+       me.callParent();
+
+       var statechange = function(sp, key, state) {
+           if ((key === me.phstateid) && state) {
+               var first = me.items.get(0);
+               var atab = me.getActiveTab().itemId;
+               var res = hsregex.exec(state.value);
+               var ntab = (res && res[1]) ? res[1] : first.itemId;
+               if (ntab && (atab != ntab)) {
+                   me.setActiveTab(ntab);
+               }
+           }
+       };
+
+       me.mon(sp, 'statechange', statechange);
+    }
+});