Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

tabVMDetails.html 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. <!--
  2. VM Details Pane
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: tabVMDetails.html 596 2015-04-19 11:50:53Z imoore76 $
  5. -->
  6. <div id='vboxTabVMDetails' style='height: 100%; width: 100%; display: none;' class='vboxInvisible'>
  7. <!-- VM Details -->
  8. <div id='vboxVMDetails' style='height: 100%; width: 100%; display: table; min-height:100px;' class='vboxInvisible'></div>
  9. <!-- Loading... -->
  10. <div id='vboxDetailsLoading' class='vboxInvisible' style='#position:absolute;#top:50%;display:none;vertical-align:middle;width:100%;height:100%;padding:0px;margin:0px'>
  11. <div style='#position:relative;#top:-50%;padding:4px;text-align:center;width:100%'>
  12. <span class='ui-corner-all translate' style='padding:8px;background:#fff;border:2px solid #ddd'>Loading ...</span>
  13. </div>
  14. </div>
  15. <!-- Welcome -->
  16. <div id='vboxDetailsWelcome' style='#position:absolute;#top:50%;display:table-cell;vertical-align:middle;width:50%;height:50%;text-align:center'>
  17. <div style='#position:relative;#top:-50%;padding:0px;text-align:center;width:100%'>
  18. <img src='images/vbox/welcome.png' />
  19. </div>
  20. </div>
  21. <script type='text/javascript'>
  22. // Translate loading div
  23. $('#vboxDetailsLoading').find('span.translate').html(trans('Loading ...','UIVMDesktop')).removeClass('translate');
  24. // Last selection list was none
  25. $('#vboxTabVMDetails').data('vboxLastSelectionList',[]);
  26. // Listen for events
  27. /////////////////////////////
  28. $('#vboxPane').on('vmSelectionListChanged',function(){
  29. // No VMs?
  30. if(!vboxChooser || vboxChooser.selectionMode == vboxSelectionModeNone) {
  31. // Hide all tab children first
  32. $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
  33. // Display Welcome div
  34. $('#vboxDetailsWelcome').show().css('display','table-cell');
  35. $('#vboxTabVMDetails').data('showingWelcome', true);
  36. $('#vboxTabVMDetails').data('vboxLastSelectionList',[]);
  37. return;
  38. // Were we showing the welcome screen before?
  39. } else if($('#vboxTabVMDetails').data('showingWelcome')) {
  40. $('#vboxTabVMDetails').css({'display':''})
  41. .data({'showingWelcome':false}).children().hide();
  42. $('#vboxVMDetails').html('').css({'display':''});
  43. }
  44. // We have VMs to load
  45. if(vboxChooser.selectionMode != vboxSelectionModeNone) {
  46. var targetDiv = $('#vboxVMDetails');
  47. // Loading scren
  48. if(vboxChooser.selectedVMs.length == 1 && $('#vboxTabVMDetails').css('display') != 'none') {
  49. // Hide all tab children first
  50. $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
  51. // Display loading div
  52. $('#vboxDetailsLoading').show().css('display','table-cell');
  53. }
  54. if(vboxChooser.getSingleSelectedId() == 'host') {
  55. $('#vboxTabVMDetails').data('vboxLastSelectionList',['host']);
  56. targetDiv.children().empty().remove();
  57. $.when(vboxVMDataMediator.getVMDetails('host')).done(function(d) {
  58. // Hide loading screen
  59. targetDiv.siblings().hide();
  60. targetDiv.show();
  61. __vboxDisplayHostDetailsData(d, targetDiv);
  62. });
  63. return;
  64. }
  65. // Remove anything that is not a details table
  66. targetDiv.children(':not(table)').remove();
  67. // Last list of selected vms
  68. var lastSelectionList = $('#vboxTabVMDetails').data('vboxLastSelectionList');
  69. $('#vboxTabVMDetails').data('vboxLastSelectionList', vboxChooser.selectedVMs);
  70. // Remove any that aren't in list
  71. $(lastSelectionList).not(vboxChooser.selectedVMs).each(function(idx,vmid){
  72. $('#vboxVMDetails .vboxVMDetailsBox-vm-'+vmid).empty().remove();
  73. });
  74. // Placeholders so vms are listed in order
  75. for(var i = 0; i < vboxChooser.selectedVMs.length; i++) {
  76. if(jQuery.inArray(vboxChooser.selectedVMs[i], lastSelectionList) > -1) {
  77. $('#vboxDetailsGeneralTable-'+vboxChooser.selectedVMs[i]).detach().appendTo(targetDiv);
  78. } else {
  79. $('<table />').attr({'id':'vboxDetailsGeneralTable-'+vboxChooser.selectedVMs[i],'class':'vboxInvisible vboxVMDetailsBox-vm-'+vboxChooser.selectedVMs[i],'style':'display:none'})
  80. .appendTo(targetDiv);
  81. }
  82. }
  83. var oneLoaded = false;
  84. var skipTable = false; // skip drawing multi-section details table
  85. for(var i = 0; i < vboxChooser.selectedVMs.length; i++) {
  86. // Already drawn and we are showing more than one vm
  87. if(jQuery.inArray(vboxChooser.selectedVMs[i], lastSelectionList) > -1) {
  88. if(vboxChooser.selectedVMs.length > 1) {
  89. oneLoaded = true;
  90. targetDiv.siblings().hide();
  91. targetDiv.show();
  92. continue;
  93. }
  94. skipTable = true;
  95. }
  96. $.when(vboxChooser.selectedVMs[i], vboxVMDataMediator.getVMDataCombined(vboxChooser.selectedVMs[i])).done(function(vmid, d) {
  97. // Remove placeholder and don't draw
  98. // if this vm is no longer selected
  99. if(!d || !vboxChooser.isVMSelected(vmid)) {
  100. $('#vboxDetailsGeneralTable-'+vmid).empty().remove();
  101. return;
  102. }
  103. // Clear target div if we only have one vm
  104. if(!oneLoaded) {
  105. oneLoaded = true;
  106. targetDiv.siblings().hide();
  107. targetDiv.show();
  108. }
  109. __vboxDisplayDetailsData(d, (vboxChooser.selectedVMs.length > 1), targetDiv, skipTable);
  110. });
  111. }
  112. }
  113. /////////////////////////////////
  114. //
  115. // Redraw section logic
  116. //
  117. //////////////////////////////////
  118. }).on('vboxEvents', function(e, eventList) {
  119. // Multiple vms selected
  120. var multiSelect = (vboxChooser.selectedVMs.length > 1);
  121. // Keep track of details to redraw
  122. var vmRedrawDetails = {};
  123. var vmRedrawSections = {};
  124. var vmTriggerEventSection = {};
  125. // Each event in list
  126. for(var i = 0; i < eventList.length; i++) {
  127. // Nothing to do if VM is not selected
  128. if(!eventList[i].machineId || !vboxChooser.isVMSelected(eventList[i].machineId))
  129. continue;
  130. switch(eventList[i].eventType) {
  131. // These trigger complete redraws
  132. case 'OnMachineDataChanged':
  133. vmRedrawDetails[eventList[i].machineId] = true;
  134. break;
  135. default:
  136. // already redrawing all vm details
  137. if(vmRedrawDetails[eventList[i].machineId])
  138. break;
  139. // Check for specific section redraws or events
  140. for(var s in vboxVMDetailsSections) {
  141. if(typeof(s) != 'string') continue;
  142. if(multiSelect && !vboxVMDetailsSections[s].multiSelectDetailsTable) continue;
  143. // Redraw this section?
  144. if(vboxVMDetailsSections[s].redrawMachineEvents && jQuery.inArray(eventList[i].eventType, vboxVMDetailsSections[s].redrawMachineEvents) > -1) {
  145. if(!vmRedrawSections[eventList[i].machineId])
  146. vmRedrawSections[eventList[i].machineId] = {};
  147. vmRedrawSections[eventList[i].machineId][s] = true;
  148. // Specific event handler
  149. } else if(vboxVMDetailsSections[s]['vboxEvent'+eventList[i].eventType]) {
  150. if(!vmTriggerEventSection[eventList[i].machineId])
  151. vmTriggerEventSection[eventList[i].machineId] = {};
  152. if(!vmTriggerEventSection[eventList[i].machineId][s])
  153. vmTriggerEventSection[eventList[i].machineId][s] = [];
  154. vmTriggerEventSection[eventList[i].machineId][s][vmTriggerEventSection[eventList[i].machineId][s].length] = eventList[i];
  155. }
  156. }
  157. } // </ switch eventType >
  158. } // </ foreach event >
  159. // Target for actions
  160. var targetDiv = $('#vboxVMDetails');
  161. // Redraw each details table
  162. /////////////////////////////////
  163. for(var vmid in vmRedrawDetails) {
  164. if(typeof(vmid) != 'string') continue;
  165. // Get and show details and runtime data again
  166. $.when(vboxVMDataMediator.getVMDataCombined(vmid)).done(function(d) {
  167. // Do nothing if VM is no longer selected
  168. if(!vboxChooser.isVMSelected(d.id)) return;
  169. // if there's only one, we'll have to remove existing data
  170. if(vboxChooser.selectedVMs.length == 1) {
  171. targetDiv.children().empty().remove();
  172. }
  173. // Special case for host
  174. if(d.id == 'host') __vboxDisplayHostDetailsData(d, targetDiv);
  175. else __vboxDisplayDetailsData(d, (vboxChooser.selectedVMs.length > 1), targetDiv);
  176. });
  177. };
  178. // Redraw each section
  179. ////////////////////////////
  180. for(var vmid in vmRedrawSections) {
  181. if(typeof(vmid) != 'string') continue;
  182. if(vmRedrawDetails[vmid]) continue; // already redrew entire details
  183. // Get and show details and runtime data again
  184. $.when(vboxVMDataMediator.getVMDataCombined(vmid),vmRedrawSections[vmid]).done(function(d,sections) {
  185. // Do nothing if VM is no longer selected
  186. if(!vboxChooser.isVMSelected(d.id)) return;
  187. // Redraw each section in list
  188. for(var s in sections) {
  189. if(typeof(s) != 'string') continue;
  190. $('#vboxDetailsSectionId-'+s+'-'+d.id).replaceWith(
  191. __vboxCreateDetailsSection(d, s)
  192. );
  193. if(vboxVMDetailsSections[s].onRender)
  194. vboxVMDetailsSections[s].onRender(d);
  195. }
  196. });
  197. }
  198. // Specific event handlers for each section
  199. for(var vmid in vmTriggerEventSection) {
  200. if(typeof(vmid) != 'string') continue;
  201. if(vmRedrawDetails[vmid]) continue; // already redrew entire details
  202. // Do nothing if VM is no longer selected
  203. if(!vboxChooser.isVMSelected(vmid)) return;
  204. for(var s in vmTriggerEventSection[vmid]) {
  205. if(typeof(s) != 'string') continue;
  206. if(vmRedrawSections[vmid] && vmRedrawSections[vmid][s]) continue; // already redrew this section
  207. // Call each event handler
  208. for(var i = 0; i < vmTriggerEventSection[vmid][s].length; i++) {
  209. var event = vmTriggerEventSection[vmid][s][i];
  210. vboxVMDetailsSections[s]['vboxEvent'+event.eventType](event);
  211. }
  212. }
  213. }
  214. });
  215. // Hide context menus when hiding tab
  216. $('#vboxTabVMDetails').on('hide',function(){
  217. $('ul.contextMenu').hide();
  218. });
  219. //Base function that returns a table row of machine detail data
  220. //Called from other functions
  221. function __vboxDetailRow(name, value, cssClass, html) {
  222. // convert to strings
  223. if(typeof(value) == 'undefined') value = '';
  224. name = ''+name;
  225. value = ''+value;
  226. var tr = $('<tr />').attr({'class':'vboxDetailRow'});
  227. $('<th />').html(name + (value && value.length && name.length ? ':' : ''))
  228. .attr({'class':'vboxDetailContent ' + cssClass})
  229. .appendTo(tr);
  230. $('<td />').attr({'class':'vboxDetailsValue'}).html(value).appendTo(tr);
  231. return tr;
  232. }
  233. //Draw rows to table
  234. function __vboxDetailAddRows(data, rows, table) {
  235. // Is rows a function?
  236. if(typeof(rows) == 'function') rows = rows(data);
  237. for(var i = 0; i < rows.length; i++) {
  238. // Check if row has condition
  239. if(rows[i].condition && !rows[i].condition(data)) continue;
  240. // hold row data
  241. var rowData = '';
  242. // Check for row attribute
  243. if(rows[i].attrib) {
  244. if(!data[rows[i].attrib]) continue;
  245. rowData = data[rows[i].attrib];
  246. // Check for row callback
  247. } else if(rows[i].callback) {
  248. rowData = rows[i].callback(data);
  249. // Static data
  250. } else {
  251. rowData = rows[i].data;
  252. }
  253. if(rows[i].rawRow) {
  254. $(table).append(rowData);
  255. } else {
  256. var title = trans(rows[i].title, rows[i].language_context);
  257. $(table).append(__vboxDetailRow(
  258. title,
  259. rowData,
  260. 'vboxDetailName ' + (rows[i].indented ? ' vboxDetailNameIndent' : '') + ' ' + (rows[i].cssClass ? rows[i].cssClass : ''),
  261. rows[i].html));
  262. }
  263. }
  264. }
  265. // Details section
  266. ////////////////////////////
  267. function __vboxCreateDetailsSection(data, sectionName, section) {
  268. if(!section)
  269. section = vboxVMDetailsSections[sectionName];
  270. var links = true;
  271. // No link if VM is not in valid state
  272. if(!((vboxVMStates.isRunning(data) || vboxVMStates.isPaused(data) || vboxVMStates.isEditable(data)) && !vboxVMStates.isSaved(data))) {
  273. links = false;
  274. }
  275. var title = trans(section.title, section.language_context);
  276. var vboxDetailsTable = $('<table />')
  277. .attr({'class':'vboxDetailsTable vboxDetailsTableBox'})
  278. .append($('<thead />')
  279. .append($('<tr />').attr({'class':'vboxDetailsHead'})
  280. .append($('<th />').attr({'class':'vboxDetailsSection','colspan':'2'})
  281. .append($('<div />')
  282. .append(
  283. $('<img />').attr({'style':'float:left;margin-right:3px','src':'images/vbox/'+section.icon,'class':'vboxDetailsSectionIcon'})
  284. ).append(
  285. $('<span />').css({'float':'left'}).addClass((links ? 'vboxDetailsSectionLink' : '')).click(function(){
  286. if($(this).hasClass('vboxDetailsSectionLink'))
  287. vboxVMsettingsDialog(data,section.settingsLink);
  288. }).html(title)
  289. ).append(
  290. $('<span />').addClass('vboxArrowImage')
  291. .click(function(){ $(this).parent().trigger("dblclick"); })
  292. )
  293. )
  294. ).disableSelection()
  295. )
  296. );
  297. var tbody = $('<tbody />');
  298. __vboxDetailAddRows(data, section.rows, tbody);
  299. // Class added to last row to aid in rounded corners
  300. if(section.noFooter) {
  301. tbody.children().last().addClass('vboxTableLastRow');
  302. } else {
  303. tbody.append($('<tr />').addClass('vboxTableLastRow').append($('</td >')).append('<td />'));
  304. }
  305. vboxDetailsTable.append(tbody);
  306. var vboxDetailsSection = $('<div />')
  307. .attr({'class':'vboxDetailsBorder vboxVMDetailsBox'+sectionName+ ' vboxVMDetailsBox-vm-'+data.id,'id':'vboxDetailsSectionId-'+sectionName+'-'+data.id})
  308. .dblclick(__vboxDetailsSectionCollapse)
  309. .hoverClass('vboxHover').disableSelection().data({'sectionName':sectionName});
  310. if(vboxGetLocalDataItem("vboxSectionCollapse"+sectionName)) {
  311. vboxDetailsSection.addClass('vboxDetailsSectionCollapsed');
  312. }
  313. if(!vboxGetLocalDataItem("vboxSectionHide"+sectionName)) {
  314. $(vboxDetailsSection).show();
  315. } else {
  316. $(vboxDetailsSection).hide();
  317. }
  318. /* Context menu for section ? */
  319. if(section.contextMenu) {
  320. var menu = section.contextMenu();
  321. $(vboxDetailsSection).mouseup({'vmid':data.id},function(e) {
  322. $('ul.contextMenu').hide();
  323. if(e.button == 2) {
  324. $(menu).trigger('beforeshow', e.data.vmid);
  325. vboxPositionEvent(menu, e);
  326. $(menu).show();
  327. e.preventDefault();
  328. e.stopPropagation();
  329. return false;
  330. }
  331. });
  332. $(vboxDetailsSection)
  333. .on('contextmenu', function() { return false; })
  334. .on('click',function(e){return e.button!=2;});
  335. }
  336. return vboxDetailsSection.append(vboxDetailsTable);
  337. }
  338. //Display details data table for VM
  339. //////////////////////////////////
  340. function __vboxDisplayDetailsData(data, multiSelect, targetDiv, skipTable) {
  341. // No data? Should never happen
  342. if(typeof data == 'undefined') return;
  343. // Accessibility check
  344. if(data.state == 'Inaccessible') {
  345. var reasonDiv = $('<div />')
  346. .attr({'class':'vboxVMDetailsBox-vm-'+data.id})
  347. .html('<div style="width: 50%">'+trans('The selected virtual machine is <i>inaccessible</i>. Please inspect the error message shown below and press the <b>Refresh</b> button if you want to repeat the accessibility check:','UIDetailsPagePrivate')+'</div>');
  348. // Details Table
  349. $('<table />').attr({'style':'width: 50%','class':'vboxDetailsTable vboxDetailsTableError vboxVMDetailsBox-vm-'+data.id}).append(__vboxDetailRow(trans("VirtualBox - Error",'UIMessageCenter'), data.accessError['text'])).append(__vboxDetailRow(trans('Result Code: ','UIMessageCenter'), data.accessError['resultCode'])).append(__vboxDetailRow(trans("Component: ",'UIMessageCenter'), data.accessError['component'])).appendTo(targetDiv);
  350. var d = $('<div />').attr({'style':'width: 50%; padding: 4px;'});
  351. $('<input />').attr({'type':'button',
  352. 'value':trans('Refresh','UIVMLogViewer'),
  353. 'style':'background: url(images/vbox/refresh_16px.png) 2px 2px no-repeat; padding: 2px 2px 2px 18px; border: 1px solid #000; background-color: #eee;'
  354. }).click({vmid:data.id},function(e){
  355. var l = new vboxLoader();
  356. l.showLoading();
  357. $.when(vboxVMDataMediator.refreshVMData(e.data.vmid)).always(function(){
  358. l.removeLoading();
  359. });
  360. }).appendTo(d);
  361. $(reasonDiv).append(d).appendTo(targetDiv);
  362. return;
  363. }
  364. // Multi-select details table sections
  365. ////////////////////////////////////////
  366. if(!skipTable) {
  367. var tbl = $('<table />').attr({'id':'vboxDetailsGeneralTable-'+data.id,'class':'vboxInvisible vboxVMDetailsBox-vm-'+data.id,'style':'width: 100%;'}).append(
  368. $('<tr />').attr({'style':'vertical-align: top'})
  369. .append(
  370. $('<td />').css({'width':'100%'})
  371. .append(__vboxCreateDetailsSection(data,'general'))
  372. .append(__vboxCreateDetailsSection(data,'system'))
  373. ).append(
  374. vboxVMDetailsSections['preview'].condition() ?
  375. $('<td />')
  376. .append(__vboxCreateDetailsSection(data,'preview')) :
  377. null
  378. )
  379. ).data({'vmid':data.id});
  380. // If already exists, replace the table, else append to div
  381. if($('#vboxDetailsGeneralTable-'+data.id)[0]) {
  382. $('#vboxDetailsGeneralTable-'+data.id).replaceWith(tbl);
  383. } else {
  384. tbl.appendTo(targetDiv);
  385. }
  386. for(var s in {'general':1,'system':1,'preview':1}) {
  387. if(vboxVMDetailsSections[s].onRender)
  388. vboxVMDetailsSections[s].onRender(data);
  389. }
  390. }
  391. // Other sections
  392. ///////////////////////////
  393. // Not shown if multiple vms are selected
  394. if(multiSelect) return;
  395. for(var s in vboxVMDetailsSections) {
  396. if(vboxVMDetailsSections[s].multiSelectDetailsTable) continue;
  397. if(vboxVMDetailsSections[s].condition && !vboxVMDetailsSections[s].condition(data))
  398. continue;
  399. $(targetDiv).append(__vboxCreateDetailsSection(data, s));
  400. if(vboxVMDetailsSections[s].onRender)
  401. vboxVMDetailsSections[s].onRender(data);
  402. }
  403. }
  404. //Display details data for VirtualBox Host
  405. /////////////////////////////////////////////
  406. function __vboxDisplayHostDetailsData(data, targetDiv) {
  407. for(var s in vboxHostDetailsSections) {
  408. if(vboxHostDetailsSections[s].condition && !vboxHostDetailsSections[s].condition(data))
  409. continue;
  410. $(targetDiv).append(__vboxCreateDetailsSection(data, s, vboxHostDetailsSections[s]));
  411. if(vboxHostDetailsSections[s].onRender)
  412. vboxHostDetailsSections[s].onRender(data);
  413. }
  414. }
  415. //Collapse section used on dblclick of sections
  416. function __vboxDetailsSectionCollapse(e) {
  417. // Save section name
  418. var sectionName = $(this).data('sectionName');
  419. vboxSetLocalDataItem('vboxSectionCollapse'+sectionName,
  420. ($(this).hasClass('vboxDetailsSectionCollapsed') ? '' : '1')
  421. );
  422. var collapsed = $(this).hasClass('vboxDetailsSectionCollapsed');
  423. // IE8 doesn't display this animation
  424. if(!($.browser.msie && $.browser.version.substring(0,1) < 9)) {
  425. // Get image span of current section only
  426. var vboxArrowImage = $(this).find('span.vboxArrowImage');
  427. // Only animate the span that is part of this section header
  428. // All others just get switched
  429. $.when($('<div />').animate({left:90},
  430. {
  431. duration: 300,
  432. step: function(currentStep) {
  433. if(collapsed) {
  434. currentStep = (180 - currentStep);
  435. } else {
  436. currentStep = currentStep+90;
  437. }
  438. vboxArrowImage.css({
  439. 'transform':'rotate('+currentStep+'deg)',
  440. '-moz-transform': 'rotate('+currentStep+'deg)',
  441. '-webkit-transform': 'rotate('+currentStep+'deg)',
  442. '-o-transform': 'rotate('+currentStep+'deg)',
  443. '-ms-transform': 'rotate('+currentStep+'deg)'
  444. });
  445. },
  446. queue: true
  447. })).done(function(){
  448. vboxArrowImage.css({
  449. 'transform':'',
  450. '-moz-transform': '',
  451. '-webkit-transform': '',
  452. '-o-transform': '',
  453. '-ms-transform': ''
  454. });
  455. });
  456. }
  457. $('#vboxVMDetails').find('div.vboxVMDetailsBox'+sectionName)
  458. .toggleClass('vboxDetailsSectionCollapsed', (($.browser.msie && $.browser.version.substring(0,1) < 9) ? undefined : 300));
  459. return false;
  460. }
  461. /*
  462. *
  463. * Show / Hide boxes menu
  464. *
  465. */
  466. var ul = $('<ul />')
  467. .attr({'class':'contextMenu contextMenuNoBG','style':'display: none','id':'vboxDetailsShowMenu'})
  468. .on('contextmenu', function() { return false; });
  469. for(var i in vboxVMDetailsSections) {
  470. if(typeof(i) != 'string') continue;
  471. // Skip if we shouldn't display
  472. if(vboxVMDetailsSections[i].condition && !vboxVMDetailsSections[i].condition())
  473. continue;
  474. $('<li />').attr('id','vboxDetailsShowMenuItem'+i).append(
  475. $('<label />').append(
  476. $('<input />')
  477. .attr({'type':'checkbox','class':'vboxCheckbox','name':i})
  478. .prop('checked',!vboxGetLocalDataItem("vboxSectionHide"+i))
  479. .on('click',{'sectionName':i},function(e){
  480. vboxSetLocalDataItem("vboxSectionHide"+$(this).attr('name'),(this.checked ? '' : '1'));
  481. $('#vboxTabVMDetails .vboxVMDetailsBox'+$(this).attr('name')).css('display',(this.checked ? '' : 'none'));
  482. var sectionName = e.data.sectionName;
  483. // Run section's onShow function
  484. if(this.checked && vboxVMDetailsSections[sectionName].onShow) {
  485. vboxVMDetailsSections[sectionName].onShow();
  486. } else if(!this.checked && vboxVMDetailsSections[sectionName].onHide) {
  487. vboxVMDetailsSections[sectionName].onHide();
  488. }
  489. })
  490. ).append(
  491. $('<span />').html(trans(vboxVMDetailsSections[i].title, vboxVMDetailsSections[i].language_context))
  492. ).disableSelection()
  493. ).appendTo(ul);
  494. }
  495. $('#vboxTabVMDetails').append(ul);
  496. /* Menu functionality */
  497. $("#vboxVMDetails").mouseup( function(e) {
  498. $('ul.contextMenu').hide();
  499. if(e.button == 2 && vboxChooser.getSingleSelectedId() != 'host') {
  500. var menu = $('#vboxDetailsShowMenu');
  501. vboxPositionEvent(menu, e);
  502. $(menu).show();
  503. e.preventDefault();
  504. e.stopPropagation();
  505. return false;
  506. }
  507. }).on('contextmenu', function() { return false; })
  508. .on('click',function(e){return e.button!=2;});
  509. //Display Welcome div
  510. $('#vboxTabVMDetails').css({'display':'table','width':'100%'}).children().hide();
  511. $('#vboxDetailsWelcome').show().css('display','table-cell');
  512. $('#vboxTabVMDetails').data('showingWelcome', true);
  513. </script>
  514. </div>