Skip to content
This repository has been archived by the owner on Oct 18, 2018. It is now read-only.

Commit

Permalink
Merge pull request #105 from dglol/issue-104
Browse files Browse the repository at this point in the history
Widget's onclick handler for logger can run out of sync  (#105)
  • Loading branch information
whimboo committed Mar 20, 2012
2 parents 6a128c7 + 8fed29e commit 85b8a1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
9 changes: 7 additions & 2 deletions extension/data/widget/widget.js
Expand Up @@ -7,8 +7,7 @@ var bindEvents = function () {
let tooltipElements = [].slice.call(document.querySelectorAll("[data-tooltip]"));

logger.onclick = function () {
logger.className = (logger.className === "enabled") ? "disabled" : "enabled";
self.port.emit("logging_changed");
self.port.emit("logger_click");
self.port.emit("update_tooltip", this.dataset.tooltip);
};

Expand All @@ -27,6 +26,12 @@ var hideSplashText = function () {
hideSplashText = function () { return; }
};

self.port.on("logger_update", function (data) {
let logger = document.getElementById("logger");

logger.className = (data["active"]) ? "enabled" : "disabled";
});

self.port.on("update_garbage_collector", function (data) {
hideSplashText();

Expand Down
14 changes: 8 additions & 6 deletions extension/lib/main.js
Expand Up @@ -92,23 +92,25 @@ exports.main = function (options, callbacks) {
});

// If logger is clicked, then the state must be changed
widget.port.on("logging_changed", function () {
widget.port.on("logger_click", function () {
if (logger.active) {
logger.stop();
} else {
logger.start();
}

widget.port.emit("logger_update", { "active": logger.active });
});

widget.port.on("update_tooltip", function (data) {
if (data === 'logger' && logger.active) {
data = 'logger_enabled';
if (data === "logger" && logger.active) {
data = "logger_enabled";
}
else if (data === 'logger') {
data = 'logger_disabled';
else if (data === "logger") {
data = "logger_disabled";
}

widget.tooltip = config.extensions.wiget_tooltips[data];
widget.tooltip = config.extension.widget_tooltips[data];
});
};

Expand Down

0 comments on commit 85b8a1c

Please sign in to comment.