From bdce4a71b6642f65a7d768d5a52d2366fd59614c Mon Sep 17 00:00:00 2001
From: Stephen Birarda
Date: Wed, 23 Dec 2015 15:10:16 -0700
Subject: [PATCH] fix button click events when stopped
---
console/src/css/style.less | 4 +++-
console/src/index.html | 4 ++--
console/src/index.js | 25 ++++++++++++++++++-------
3 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/console/src/css/style.less b/console/src/css/style.less
index 64c202482b..b156b990e0 100644
--- a/console/src/css/style.less
+++ b/console/src/css/style.less
@@ -203,6 +203,7 @@ header {
margin-left: @title-margin-left;
#go-server-button {
+ text-align: center;
float: left;
box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.5);
cursor: pointer;
@@ -225,7 +226,7 @@ header {
#server-stopped-text {
float: left;
margin: 20px 0px 0px 20px;
- color: red;
+ color: #D42043;
}
}
}
@@ -276,6 +277,7 @@ header {
&.disabled {
opacity: 0.3;
+ cursor: default;
}
}
diff --git a/console/src/index.html b/console/src/index.html
index 8a54567c14..3c9e4a6a5d 100644
--- a/console/src/index.html
+++ b/console/src/index.html
@@ -73,9 +73,9 @@
to build, explore, and share. We’ve started you off with a
home full of goodies to help you learn the ropes. Enjoy!
-
+
Server stopped
Click "Restart"
diff --git a/console/src/index.js b/console/src/index.js
index 6da2986a0f..082ade194c 100755
--- a/console/src/index.js
+++ b/console/src/index.js
@@ -4,11 +4,14 @@ $(function() {
var settingsButton = $('#manage-server #settings');
+ const DISABLED_HREF_ATTR = 'data-disabled-href';
function toggleManageButton(button, enabled) {
if (enabled) {
- button.attr('href', '#');
+ button.attr('href', button.attr(DISABLED_HREF_ATTR));
+ button.removeAttr(DISABLED_HREF_ATTR);
button.removeClass('disabled');
} else {
+ button.attr(DISABLED_HREF_ATTR, button.attr('href'));
button.removeAttr('href');
button.addClass('disabled');
}
@@ -65,7 +68,7 @@ $(function() {
toggleManageButton(stopButton, false);
// disable the go button
- goButton.addClass('disabled');
+ toggleManageButton(goButton, false);
// show the server stopped text
serverStopped.show();
@@ -76,7 +79,7 @@ $(function() {
toggleManageButton(stopButton, true);
// enable the go button
- goButton.removeClass('disabled');
+ toggleManageButton(goButton, true);
// hide the server stopped text
serverStopped.hide();
@@ -89,15 +92,23 @@ $(function() {
ipcRenderer.send('start-interface');
});
- $('#go-server-button:not(.disabled)').click(function(){
- ipcRenderer.send('start-interface', { url: 'hifi://localhost' });
+ $('#go-server-button').click(function(e){
+ if ($(this).hasClass('disabled')) {
+ e.preventDefault();
+ } else {
+ ipcRenderer.send('start-interface', { url: 'hifi://localhost' });
+ }
})
$('#manage-server #restart').click(function() {
ipcRenderer.send('restart-server', { name: 'home' });
});
- $('#manage-server #stop').click(function() {
- ipcRenderer.send('stop-server', { name: 'home' });
+ $('#manage-server #stop').click(function(e) {
+ if ($(this).hasClass('disabled')) {
+ e.preventDefault();
+ } else {
+ ipcRenderer.send('stop-server', { name: 'home' });
+ }
});
$('#open-logs').click(function() {
ipcRenderer.send('open-logs');