Permalink
Browse files

Added event binding and fixed double used symbols (Achim Hasenmueller).

git-svn-id: http://vboxweb.googlecode.com/svn/trunk@33 729376a8-6c6b-11de-afdd-bb9f892af8c1
  • Loading branch information...
1 parent 76ebdd5 commit 82f16208f3ce0cfcdcb4296d968238cc216541e8 vboxweb committed Aug 10, 2009
Showing with 42 additions and 10 deletions.
  1. +38 −6 www/static/js/vboxVMToolbar.js
  2. +4 −4 www/templates/index.html
@@ -27,6 +27,8 @@ var vboxVMToolbar = Class.create(
{
initialize: function()
{
+ /* bind the static new VM toolbar button */
+ jQuery("#toolbar-button-new").bind("click", this.buttonClicked);
},
setParent: function(parent)
@@ -39,6 +41,32 @@ var vboxVMToolbar = Class.create(
this.selectionChanged();
},
+ buttonClicked: function(event)
+ {
+ /* where does it come from? */
+ switch (event.target.id)
+ {
+ case "toolbar-button-new":
+ console.log("New VM not implemented!");
+ break;
+
+ case "toolbar-button-settings":
+ console.log("Change VM settings not implemented!");
+ break;
+
+ case "toolbar-button-start":
+ console.log("start vm!!!");
+ break;
+
+ case "toolbar-button-discard":
+ console.log("Discard VM state not implemented!");
+ break;
+
+ default:
+ console.log("vboxVMToolbar::buttonClicked: unknown source ID: " + event.target.id);
+ }
+ },
+
selectionChanged: function()
{
var curItem = this.mParent.curItem();
@@ -52,23 +80,27 @@ var vboxVMToolbar = Class.create(
/* settings can only be changed for powered off and aborted VMs */
if (curItem.state() == VMState.PoweredOff ||
curItem.state() == VMState.Aborted)
- jQuery("#toolbar-button-vm-settings").html('<img src="/images/vbox/vm_settings_32px.png"/>');
+ jQuery("#toolbar-button-vm-settings-span").html('<img id="toolbar-button-settings" src="/images/vbox/vm_settings_32px.png"/>');
else
- jQuery("#toolbar-button-vm-settings").html('<img src="/images/vbox/vm_settings_disabled_32px.png"/>');
+ jQuery("#toolbar-button-vm-settings-span").html('<img src="/images/vbox/vm_settings_disabled_32px.png"/>');
/* powered off / aborted and saved VMs can be started */
/** @todo when saved, start means "show" in the Qt GUI, we can go to the RDP console */
if (curItem.state() == VMState.PoweredOff ||
curItem.state() == VMState.Aborted ||
curItem.state() == VMState.Saved)
- jQuery("#toolbar-button-vm-start").html('<img src="/images/vbox/vm_start_32px.png"/>');
+ jQuery("#toolbar-button-vm-start-span").html('<img id="toolbar-button-start" src="/images/vbox/vm_start_32px.png"/">');
else
- jQuery("#toolbar-button-vm-start").html('<img src="/images/vbox/vm_start_disabled_32px.png"/>');
+ jQuery("#toolbar-button-vm-start-span").html('<img src="/images/vbox/vm_start_disabled_32px.png"/>');
/* saved VMs can be discarded */
if (curItem.state() == VMState.Saved)
- jQuery("#toolbar-button-vm-discard").html('<img src="/images/vbox/vm_discard_32px.png"/>');
+ jQuery("#toolbar-button-vm-discard-span").html('<img id="toolbar-button-discard" src="/images/vbox/vm_discard_32px.png"/>');
else
- jQuery("#toolbar-button-vm-discard").html('<img src="/images/vbox/vm_discard_disabled_32px.png"/>');
+ jQuery("#toolbar-button-vm-discard-span").html('<img src="/images/vbox/vm_discard_disabled_32px.png"/>');
+
+ jQuery("#toolbar-button-settings").bind("click", this.buttonClicked);
+ jQuery("#toolbar-button-start").bind("click", this.buttonClicked);
+ jQuery("#toolbar-button-discard").bind("click", this.buttonClicked);
}
});
View
@@ -238,10 +238,10 @@
<body font="Verdana" onload="onDocumentLoad()">
<div id="vmToolbar" class="outer-layout-north" style="display: none;">
- <img src="/images/vbox/vm_new_32px.png"/>
- <span id="toolbar-button-vm-settings"></span>
- <span id="toolbar-button-vm-start"></span>
- <span id="toolbar-button-vm-discard"></span>
+ <img id="toolbar-button-new" src="/images/vbox/vm_new_32px.png"/>
+ <span id="toolbar-button-vm-settings-span"></span>
+ <span id="toolbar-button-vm-start-span"></span>
+ <span id="toolbar-button-vm-discard-span"></span>
</div>
<ol id="vmList" class="outer-layout-west" style="display: none; list-style-type: none;"></ol>

0 comments on commit 82f1620

Please sign in to comment.