Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.8 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.onReady(function() {
  8. // The only requirement for this to work is that you must have a hidden field and
  9. // an iframe available in the page with ids corresponding to Ext.History.fieldId
  10. // and Ext.History.iframeId. See history.html for an example.
  11. Ext.History.init();
  12. // Needed if you want to handle history for multiple components in the same page.
  13. // Should be something that won't be in component ids.
  14. var tokenDelimiter = ':';
  15. var tp = new Ext.TabPanel({
  16. renderTo: Ext.getBody(),
  17. id: 'main-tabs',
  18. height: 300,
  19. width: 600,
  20. activeTab: 0,
  21. items: [{
  22. xtype: 'tabpanel',
  23. title: 'Tab 1',
  24. id: 'tab1',
  25. activeTab: 0,
  26. tabPosition: 'bottom',
  27. items: [{
  28. title: 'Sub-tab 1',
  29. id: 'subtab1'
  30. },{
  31. title: 'Sub-tab 2',
  32. id: 'subtab2'
  33. },{
  34. title: 'Sub-tab 3',
  35. id: 'subtab3'
  36. }],
  37. listeners: {
  38. 'tabchange': function(tabPanel, tab){
  39. Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
  40. }
  41. }
  42. },{
  43. title: 'Tab 2',
  44. id: 'tab2'
  45. },{
  46. title: 'Tab 3',
  47. id: 'tab3'
  48. },{
  49. title: 'Tab 4',
  50. id: 'tab4'
  51. },{
  52. title: 'Tab 5',
  53. id: 'tab5'
  54. }],
  55. listeners: {
  56. 'tabchange': function(tabPanel, tab){
  57. // Ignore tab1 since it is a separate tab panel and we're managing history for it also.
  58. // We'll use its handler instead in that case so we don't get duplicate nav events for sub tabs.
  59. if(tab.id != 'tab1'){
  60. Ext.History.add(tabPanel.id + tokenDelimiter + tab.id);
  61. }
  62. }
  63. }
  64. });
  65. // Handle this change event in order to restore the UI to the appropriate history state
  66. Ext.History.on('change', function(token){
  67. if(token){
  68. var parts = token.split(tokenDelimiter);
  69. var tabPanel = Ext.getCmp(parts[0]);
  70. var tabId = parts[1];
  71. tabPanel.show();
  72. tabPanel.setActiveTab(tabId);
  73. }else{
  74. // This is the initial default state. Necessary if you navigate starting from the
  75. // page without any existing history token params and go back to the start state.
  76. tp.setActiveTab(0);
  77. tp.getItem(0).setActiveTab(0);
  78. }
  79. });
  80. });