Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

tabs.html 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <!--
  2. Main Tabs
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: tabs.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <div id='tabMainContent' class='vboxInvisible' style='overflow: auto;'></div>
  7. <script type='text/javascript'>
  8. // Create UL
  9. $('#vboxTabsList').append($('<ul />').attr({'id':'tablistMain'}));
  10. var tabs = [
  11. // Details
  12. {
  13. name:'vboxTabVMDetails',
  14. content:'tabVMDetails',
  15. label:'Details',
  16. icon:'vm_settings'
  17. // Snapshots
  18. },{
  19. name:'vboxTabVMSnapshots',
  20. content:'tabVMSnapshots',
  21. label:'Snapshots',
  22. icon:'snapshot_take',
  23. default_disabled: true
  24. // Console
  25. },{
  26. name:'vboxTabVMConsole',
  27. content:'tabVMConsole',
  28. label:'Console',
  29. icon:'vrdp',
  30. default_disabled: true
  31. }
  32. ];
  33. // Tab object. Defined in this file
  34. var tabsMain = new vboxTabs('tabMainContent');
  35. // Loader that will load our tab panes
  36. var tabLoader = new vboxLoader();
  37. // Load each tab and create tab link
  38. for(var i = 0; i < tabs.length; i++) {
  39. // Tab disabled?
  40. if($('#vboxPane').data('vboxConfig')['disable' + tabs[i].name.substring(4)])
  41. continue;
  42. // Tab link
  43. $('<li />').attr({'class':'ui-corner-all','id':'tabsMain-'+tabs[i].name}).html('<a href="#'+tabs[i].name+'"><span><img src="images/vbox/'+tabs[i].icon+'_16px.png" border="0" /> <span id="'+tabs[i].name+'Title">'+trans(tabs[i].label, 'UIVMDesktop')+'</span></span></a>').appendTo('#tablistMain');
  44. tabLoader.addFileToDOM('panes/'+tabs[i].content+'.html',$('#tabMainContent'));
  45. }
  46. // Once tabs are loaded run this..
  47. tabLoader.onLoad = function(){
  48. for(var i = 0; i < tabs.length; i++) {
  49. // Tab disabled?
  50. if($('#vboxPane').data('vboxConfig')['disable' + tabs[i].name.substring(4)])
  51. continue;
  52. tabsMain.addTab(tabs[i]);
  53. }
  54. // Add "click" functionality to each tab
  55. $('#tablistMain').children().click(function(){
  56. if(!$(this).hasClass('vboxDisabled'))
  57. tabsMain.showTab($(this).children().first().attr('href'));
  58. return false;
  59. // Mouseover
  60. }).hover(function(){
  61. if($(this).hasClass('vboxDisabled')) return false;
  62. $(this).addClass('vboxHover');
  63. },function(){
  64. $(this).removeClass('vboxHover');
  65. });
  66. // Watch for tabs asking to be enabled / disabled
  67. $('#tabMainContent').on('enableTab',function(e,tabName) {
  68. tabsMain.enableTab(tabsMain.getTabByName(tabName));
  69. }).on('disableTab',function(e,tabName) {
  70. tabsMain.disableTab(tabsMain.getTabByName(tabName));
  71. });
  72. };
  73. tabLoader.run();
  74. /*
  75. * Tabs pane JavaScript code for main tabs. This
  76. * class listens for a vmlist selection change and tells
  77. * the tabs to update themselves with new data
  78. *
  79. */
  80. function vboxTabs(id) {
  81. var self = this;
  82. this.ref = null;
  83. this.vm = null;
  84. this.tabs = new Array();
  85. this.tabSelected = null;
  86. this.id = id;
  87. // Add a tab to list
  88. this.addTab = function (tab) {
  89. if(!this.tabSelected) {
  90. this.tabSelected = '#'+tab.name;
  91. $('#tablistMain').find('a[href=#'+tab.name+']').parent().addClass('selected');
  92. }
  93. this.tabs[this.tabs.length] = tab;
  94. // Initially Disable tab
  95. if(tab.default_disabled) {
  96. self.disableTab(tab);
  97. }
  98. };
  99. // Get a tab by name
  100. this.getTabByName = function(name) {
  101. for(var i = 0; i < self.tabs.length; i++) {
  102. if(self.tabs[i].name == name) return self.tabs[i];
  103. }
  104. };
  105. // Show a tab
  106. this.showTab = function (tab) {
  107. // Do nothing if it is already shown
  108. if(self.tabSelected == tab) return;
  109. // Hide each tab
  110. for(var i = 0; i < self.tabs.length; i++) {
  111. $('#'+self.tabs[i].name).css({'display':'none'}).trigger('hide');
  112. }
  113. // Show tab
  114. $(''+tab).css('display','').trigger('show');
  115. self.tabSelected = tab;
  116. $('#tablistMain').children().removeClass('selected');
  117. $('#tablistMain').find('a[href='+tab+']').parent().addClass('selected');
  118. };
  119. // Disable a tab
  120. this.disableTab = function(tab) {
  121. // Was this tab selected?
  122. if(self.tabSelected == '#'+tab.name)
  123. self.showTab('#'+self.tabs[0].name);
  124. $('#tabsMain-'+tab.name).addClass('vboxDisabled').find('img').attr('src','images/vbox/'+(tab.disabled_icon ? tab.disabled_icon : tab.icon+'_disabled')+'_16px.png');
  125. };
  126. // Enable a tab
  127. this.enableTab = function(tab) {
  128. $('#tabsMain-'+tab.name).removeClass('vboxDisabled').find('img').attr('src','images/vbox/'+tab.icon+'_16px.png');
  129. };
  130. }
  131. </script>