From e2bf12ac6dcb6e3dcc829f3297e3163aa5c8853e Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 8 May 2015 02:07:37 +0300 Subject: [PATCH 1/4] Popup regression fix: click style name to toggle the style --- popup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/popup.js b/popup.js index 6d4937fc..98a5b6ec 100644 --- a/popup.js +++ b/popup.js @@ -122,12 +122,12 @@ function createStyleElement(style) { var styleName = e.querySelector(".style-name"); styleName.appendChild(document.createTextNode(style.name)); styleName.setAttribute("for", "style-" + style.id); + styleName.checkbox = checkbox; var editLink = e.querySelector(".style-edit-link"); editLink.setAttribute("href", editLink.getAttribute("href") + style.id); editLink.addEventListener("click", openLinkInTabOrWindow, false); - // the checkbox will not toggle itself after clicking the name, but calling enable will regenerate it - styleName.addEventListener("click", function() { enable(event, !event.target.previousSibling.checked); }, false); + styleName.addEventListener("click", function() { this.checkbox.click(); event.preventDefault(); }); // clicking the checkbox will toggle it, and this will run after that happens checkbox.addEventListener("click", function() { enable(event, event.target.checked); }, false); e.querySelector(".enable").addEventListener("click", function() { enable(event, true); }, false); From 0b821463c86cce7429616450a8bd26a616653fcf Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 8 May 2015 02:23:19 +0300 Subject: [PATCH 2/4] Popup regression fix: handle disableAll checkbox in active popup Apparently the original sender tab is excluded from chrome.extension.sendMessage broadcast as of Chrome 44. Even if it's a temporary bug the fixed method is okay. --- popup.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/popup.js b/popup.js index 98a5b6ec..e0c75f28 100644 --- a/popup.js +++ b/popup.js @@ -220,9 +220,11 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { case "styleDeleted": handleDelete(request.id); break; - case "styleDisableAll": - document.getElementById("disableAll").checked = request.disableAll; - handleDisableAll(request.disableAll); + case "prefChanged": + if (request.prefName == "disableAll") { + document.getElementById("disableAll").checked = request.value; + handleDisableAll(request.value); + } break; } } @@ -236,4 +238,5 @@ loadPrefs({"disableAll": false}); handleDisableAll(prefs.getPref("disableAll")); document.getElementById("disableAll").addEventListener("change", function(event) { notifyAllTabs({method: "styleDisableAll", disableAll: event.target.checked}); + handleDisableAll(event.target.checked); }); From 60381603dbbafe04820095c2002d88c861be39dc Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 8 May 2015 03:48:09 +0300 Subject: [PATCH 3/4] Popup: actually show newly installed styles fixup 5b0d8fb --- popup.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/popup.js b/popup.js index e0c75f28..f4f0cac1 100644 --- a/popup.js +++ b/popup.js @@ -193,10 +193,14 @@ function handleUpdate(style) { var styleElement = installed.querySelector("[style-id='" + style.id + "']"); if (styleElement) { installed.replaceChild(createStyleElement(style), styleElement); - } else if (chrome.extension.getBackgroundPage().getApplicableSections(style, location.href).length) { - // a new style for the current url is installed - document.getElementById("unavailable").style.display = "none"; - installed.appendChild(createStyleElement(style)); + } else { + chrome.tabs.query({currentWindow: true, active: true}, function(tabs) { + if (tabs.length && chrome.extension.getBackgroundPage().getApplicableSections(style, tabs[0].url).length) { + // a new style for the current url is installed + document.getElementById("unavailable").style.display = "none"; + installed.appendChild(createStyleElement(style)); + } + }); } } @@ -214,6 +218,7 @@ function handleDisableAll(disableAll) { chrome.extension.onMessage.addListener(function(request, sender, sendResponse) { if (request.method == "updatePopup") { switch (request.reason) { + case "styleAdded": case "styleUpdated": handleUpdate(request.style); break; From 4df61c4a21e12beead13220832ecebf9f7dc8cd3 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 10 May 2015 19:46:09 +0300 Subject: [PATCH 4/4] Popup: autoclose after click on 'Edit' link --- popup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/popup.js b/popup.js index f4f0cac1..39969c69 100644 --- a/popup.js +++ b/popup.js @@ -181,6 +181,7 @@ function openLinkInTabOrWindow(event) { } else { openLink(event); } + close(); } function openLink(event) {