This commit is contained in:
Jason Barnabe 2014-10-06 10:51:53 -05:00
commit 61c59af2ba
2 changed files with 22 additions and 9 deletions

View File

@ -10,13 +10,12 @@
.disabled { .disabled {
color: #BBB; color: #BBB;
} }
.disabled .disable { .checker {
display: none; display: inline;
}
.enabled .enable {
display: none;
} }
.style-name { .style-name {
cursor: default;
display: inline;
font-weight: bold; font-weight: bold;
} }
.actions { .actions {

View File

@ -1,5 +1,5 @@
var styleTemplate = document.createElement("div"); var styleTemplate = document.createElement("div");
styleTemplate.innerHTML = "<div class='style-name'></div><div class='actions'><a class='style-edit-link' href='edit.html?id='>" + t('editStyleLabel') + "</a> <a href='#' class='enable'>" + t('enableStyleLabel') + "</a> <a href='#' class='disable'>" + t('disableStyleLabel') + "</a> <a href='#' class='delete'>" + t('deleteStyleLabel') + "</a></div>"; styleTemplate.innerHTML = "<input class='checker' type='checkbox'></input><div class='style-name'></div><div class='actions'><a class='style-edit-link' href='edit.html?id='>" + t('editStyleLabel') + "</a> <a href='#' class='delete'>" + t('deleteStyleLabel') + "</a></div>";
chrome.tabs.getSelected(null, function(tab) { chrome.tabs.getSelected(null, function(tab) {
chrome.extension.sendMessage({method: "getStyles", matchUrl: tab.url}, showStyles); chrome.extension.sendMessage({method: "getStyles", matchUrl: tab.url}, showStyles);
@ -18,6 +18,14 @@ function showStyles(styles) {
function createStyleElement(style) { function createStyleElement(style) {
var e = styleTemplate.cloneNode(true); var e = styleTemplate.cloneNode(true);
var checkbox = e.querySelector(".checker");
if (style.enabled == "true") {
checkbox.checked = true;
}
else {
checkbox.checked = false;
}
e.setAttribute("class", "entry " + (style.enabled == "true" ? "enabled" : "disabled")); e.setAttribute("class", "entry " + (style.enabled == "true" ? "enabled" : "disabled"));
e.setAttribute("style-id", style.id); e.setAttribute("style-id", style.id);
var styleName = e.querySelector(".style-name"); var styleName = e.querySelector(".style-name");
@ -25,8 +33,15 @@ function createStyleElement(style) {
var editLink = e.querySelector(".style-edit-link"); var editLink = e.querySelector(".style-edit-link");
editLink.setAttribute("href", editLink.getAttribute("href") + style.id); editLink.setAttribute("href", editLink.getAttribute("href") + style.id);
editLink.addEventListener("click", openLink, false); 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) {
styleName.addEventListener("click", function() { enable(event, false); }, false);
checkbox.addEventListener("click", function() { enable(event, false); }, false);
}
else {
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); e.querySelector(".delete").addEventListener("click", function() { doDelete(event, false); }, false);
return e; return e;
} }
@ -86,4 +101,3 @@ tE("find-styles-link", "findStylesForSite");
document.getElementById("find-styles-link").addEventListener("click", openLink, false); document.getElementById("find-styles-link").addEventListener("click", openLink, false);
document.getElementById("open-manage-link").addEventListener("click", openLink, false); document.getElementById("open-manage-link").addEventListener("click", openLink, false);