Merge branch 'master' of https://github.com/Baegus/stylish-chrome
This commit is contained in:
commit
61c59af2ba
|
@ -10,13 +10,12 @@
|
|||
.disabled {
|
||||
color: #BBB;
|
||||
}
|
||||
.disabled .disable {
|
||||
display: none;
|
||||
}
|
||||
.enabled .enable {
|
||||
display: none;
|
||||
.checker {
|
||||
display: inline;
|
||||
}
|
||||
.style-name {
|
||||
cursor: default;
|
||||
display: inline;
|
||||
font-weight: bold;
|
||||
}
|
||||
.actions {
|
||||
|
|
22
popup.js
22
popup.js
|
@ -1,5 +1,5 @@
|
|||
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.extension.sendMessage({method: "getStyles", matchUrl: tab.url}, showStyles);
|
||||
|
@ -18,6 +18,14 @@ function showStyles(styles) {
|
|||
|
||||
function createStyleElement(style) {
|
||||
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("style-id", style.id);
|
||||
var styleName = e.querySelector(".style-name");
|
||||
|
@ -25,8 +33,15 @@ 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) {
|
||||
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);
|
||||
return e;
|
||||
}
|
||||
|
@ -86,4 +101,3 @@ tE("find-styles-link", "findStylesForSite");
|
|||
|
||||
document.getElementById("find-styles-link").addEventListener("click", openLink, false);
|
||||
document.getElementById("open-manage-link").addEventListener("click", openLink, false);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user