From 40da07846be517c1049a52da0e47a22583bbca79 Mon Sep 17 00:00:00 2001 From: Baegus Date: Wed, 1 Oct 2014 21:51:25 +0200 Subject: [PATCH 1/7] Checkbox for enabling/disabling styles This fixes #17 --- popup.html | 10 ++++------ popup.js | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/popup.html b/popup.html index 9ab450d7..5bd8225c 100644 --- a/popup.html +++ b/popup.html @@ -10,13 +10,11 @@ .disabled { color: #BBB; } - .disabled .disable { - display: none; - } - .enabled .enable { - display: none; + .checker { + display: inline; } .style-name { + display: inline; font-weight: bold; } .actions { @@ -53,4 +51,4 @@ - + \ No newline at end of file diff --git a/popup.js b/popup.js index 1abc467f..44af1a81 100644 --- a/popup.js +++ b/popup.js @@ -1,5 +1,5 @@ var styleTemplate = document.createElement("div"); -styleTemplate.innerHTML = "
" + t('editStyleLabel') + " " + t('enableStyleLabel') + " " + t('disableStyleLabel') + " " + t('deleteStyleLabel') + "
"; +styleTemplate.innerHTML = "
" + t('editStyleLabel') + " " + t('deleteStyleLabel') + "
"; chrome.tabs.getSelected(null, function(tab) { chrome.extension.sendMessage({method: "getStyles", matchUrl: tab.url}, showStyles); @@ -18,6 +18,16 @@ function showStyles(styles) { function createStyleElement(style) { var e = styleTemplate.cloneNode(true); + var checkbox = e.querySelector(".checker"); + checkbox.setAttribute("type","checkbox"); + checkbox.setAttribute("class","checker") + if (style.enabled == "true") { + checkbox.checked = true; + } + else { + checkbox.checked = false; + } + e.setAttribute("class", "entry " + (style.enabled == "true" ? "enabled" : "disabled")); e.setAttribute("style-id", style.id); var styleName = e.querySelector(".style-name"); @@ -25,8 +35,13 @@ function createStyleElement(style) { var editLink = e.querySelector(".style-edit-link"); editLink.setAttribute("href", editLink.getAttribute("href") + style.id); editLink.addEventListener("click", openLink, false); - e.querySelector(".enable").addEventListener("click", function() { enable(event, true); }, false); - e.querySelector(".disable").addEventListener("click", function() { enable(event, false); }, false); + + if (checkbox.checked == true) { + (checkbox).addEventListener("click", function() { enable(event, false); }, false); + } + else { + (checkbox).addEventListener("click", function() { enable(event, true); }, false); + } e.querySelector(".delete").addEventListener("click", function() { doDelete(event, false); }, false); return e; } From eed410663b1d8c8307fb8f0c82860ae3d0f26dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Petrnou=C5=A1ek?= Date: Fri, 3 Oct 2014 07:50:40 +0200 Subject: [PATCH 2/7] Update popup.js --- popup.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/popup.js b/popup.js index 44af1a81..cbd7667a 100644 --- a/popup.js +++ b/popup.js @@ -19,8 +19,6 @@ function showStyles(styles) { function createStyleElement(style) { var e = styleTemplate.cloneNode(true); var checkbox = e.querySelector(".checker"); - checkbox.setAttribute("type","checkbox"); - checkbox.setAttribute("class","checker") if (style.enabled == "true") { checkbox.checked = true; } From 01e705aef0fdc6cfe7543f6ab13eea48a2b6a0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Petrnou=C5=A1ek?= Date: Fri, 3 Oct 2014 22:31:25 +0200 Subject: [PATCH 3/7] Arrow cursor on style name --- popup.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/popup.html b/popup.html index 5bd8225c..22601961 100644 --- a/popup.html +++ b/popup.html @@ -14,6 +14,7 @@ display: inline; } .style-name { + cursor: default; display: inline; font-weight: bold; } @@ -51,4 +52,4 @@ - \ No newline at end of file + From 9574adeaebc3171fa6623ca8fddda11ef813819a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Petrnou=C5=A1ek?= Date: Fri, 3 Oct 2014 22:32:49 +0200 Subject: [PATCH 4/7] Clicking the style name now toggles it as well --- popup.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/popup.js b/popup.js index cbd7667a..6569ada0 100644 --- a/popup.js +++ b/popup.js @@ -35,10 +35,10 @@ function createStyleElement(style) { editLink.addEventListener("click", openLink, false); if (checkbox.checked == true) { - (checkbox).addEventListener("click", function() { enable(event, false); }, false); + (checkbox, styleName).addEventListener("click", function() { enable(event, false); }, false); } else { - (checkbox).addEventListener("click", function() { enable(event, true); }, false); + (checkbox, styleName).addEventListener("click", function() { enable(event, true); }, false); } e.querySelector(".delete").addEventListener("click", function() { doDelete(event, false); }, false); return e; @@ -99,4 +99,3 @@ tE("find-styles-link", "findStylesForSite"); document.getElementById("find-styles-link").addEventListener("click", openLink, false); document.getElementById("open-manage-link").addEventListener("click", openLink, false); - From 1705ab33272aa7391a7ae888ca72151e32efd456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Petrnou=C5=A1ek?= Date: Fri, 3 Oct 2014 23:04:04 +0200 Subject: [PATCH 5/7] Fixed the checkbox There, now everything should work. It's not ideal though, I need to figure out how to shorten it. --- popup.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/popup.js b/popup.js index 6569ada0..a4f8d13c 100644 --- a/popup.js +++ b/popup.js @@ -34,11 +34,13 @@ function createStyleElement(style) { editLink.setAttribute("href", editLink.getAttribute("href") + style.id); editLink.addEventListener("click", openLink, false); - if (checkbox.checked == true) { - (checkbox, styleName).addEventListener("click", function() { enable(event, false); }, false); + if (checkbox.checked) { + styleName.addEventListener("click", function() { enable(event, false); }, false); + checkbox.addEventListener("click", function() { enable(event, false); }, false); } else { - (checkbox, styleName).addEventListener("click", function() { enable(event, true); }, false); + styleName.addEventListener("click", function() { enable(event, true); }, false); + checkbox.addEventListener("click", function() { enable(event, true); }, false); } e.querySelector(".delete").addEventListener("click", function() { doDelete(event, false); }, false); return e; From 3835a69770e2980e5bd6f4bb7f2526dce9a3d7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Petrnou=C5=A1ek?= Date: Sat, 4 Oct 2014 18:57:37 +0200 Subject: [PATCH 6/7] Update compress --- codemirror/bin/compress | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/codemirror/bin/compress b/codemirror/bin/compress index 925eee2c..809fbe83 100755 --- a/codemirror/bin/compress +++ b/codemirror/bin/compress @@ -6,7 +6,7 @@ // // bin/compress codemirror runmode javascript xml // -// Will take lib/codemirror.js, lib/util/runmode.js, +// Will take lib/codemirror.js, addon/runmode/runmode.js, // mode/javascript/javascript.js, and mode/xml/xml.js, run them though // the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit // out the result. @@ -29,14 +29,15 @@ function help(ok) { process.exit(ok ? 0 : 1); } -var local = null, args = null, files = [], blob = ""; +var local = null, args = [], extraArgs = null, files = [], blob = ""; for (var i = 2; i < process.argv.length; ++i) { var arg = process.argv[i]; if (arg == "--local" && i + 1 < process.argv.length) { var parts = process.argv[++i].split(/\s+/); local = parts[0]; - args = parts.slice(1); + extraArgs = parts.slice(1); + if (!extraArgs.length) extraArgs = ["-c", "-m"]; } else if (arg == "--help") { help(true); } else if (arg[0] != "-") { @@ -61,8 +62,11 @@ function walk(dir) { } walk("lib/"); +walk("addon/"); walk("mode/"); +if (!local && !blob) help(false); + if (files.length) { console.log("Some speficied files were not found: " + files.map(function(a){return a.name;}).join(", ")); @@ -70,7 +74,7 @@ if (files.length) { } if (local) { - require("child_process").spawn(local, args, {stdio: ["ignore", process.stdout, process.stderr]}); + require("child_process").spawn(local, args.concat(extraArgs), {stdio: ["ignore", process.stdout, process.stderr]}); } else { var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8"); var req = require("http").request({ From 8d622e6262d253eea871cccba59fd36415b1dd05 Mon Sep 17 00:00:00 2001 From: Baegus Date: Sat, 4 Oct 2014 20:09:43 +0200 Subject: [PATCH 7/7] Revert "Update compress" This reverts commit 3835a69770e2980e5bd6f4bb7f2526dce9a3d7e7. --- codemirror/bin/compress | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/codemirror/bin/compress b/codemirror/bin/compress index 809fbe83..925eee2c 100755 --- a/codemirror/bin/compress +++ b/codemirror/bin/compress @@ -6,7 +6,7 @@ // // bin/compress codemirror runmode javascript xml // -// Will take lib/codemirror.js, addon/runmode/runmode.js, +// Will take lib/codemirror.js, lib/util/runmode.js, // mode/javascript/javascript.js, and mode/xml/xml.js, run them though // the online minifier at http://marijnhaverbeke.nl/uglifyjs, and spit // out the result. @@ -29,15 +29,14 @@ function help(ok) { process.exit(ok ? 0 : 1); } -var local = null, args = [], extraArgs = null, files = [], blob = ""; +var local = null, args = null, files = [], blob = ""; for (var i = 2; i < process.argv.length; ++i) { var arg = process.argv[i]; if (arg == "--local" && i + 1 < process.argv.length) { var parts = process.argv[++i].split(/\s+/); local = parts[0]; - extraArgs = parts.slice(1); - if (!extraArgs.length) extraArgs = ["-c", "-m"]; + args = parts.slice(1); } else if (arg == "--help") { help(true); } else if (arg[0] != "-") { @@ -62,11 +61,8 @@ function walk(dir) { } walk("lib/"); -walk("addon/"); walk("mode/"); -if (!local && !blob) help(false); - if (files.length) { console.log("Some speficied files were not found: " + files.map(function(a){return a.name;}).join(", ")); @@ -74,7 +70,7 @@ if (files.length) { } if (local) { - require("child_process").spawn(local, args.concat(extraArgs), {stdio: ["ignore", process.stdout, process.stderr]}); + require("child_process").spawn(local, args, {stdio: ["ignore", process.stdout, process.stderr]}); } else { var data = new Buffer("js_code=" + require("querystring").escape(blob), "utf8"); var req = require("http").request({