Manager: styleAdded event bugfix and code dedup
styleAdded event handler was trying to use 'installed' variable that wasn't defined in the scope
This commit is contained in:
parent
3817246da2
commit
8a407fc0f4
|
@ -15,6 +15,7 @@ var styleTemplate = tHTML('\
|
||||||
');
|
');
|
||||||
|
|
||||||
var lastUpdatedStyleId = null;
|
var lastUpdatedStyleId = null;
|
||||||
|
var installed = document.getElementById("installed");
|
||||||
|
|
||||||
var appliesToExtraTemplate = document.createElement("span");
|
var appliesToExtraTemplate = document.createElement("span");
|
||||||
appliesToExtraTemplate.className = "applies-to-extra";
|
appliesToExtraTemplate.className = "applies-to-extra";
|
||||||
|
@ -33,7 +34,6 @@ function showStyles(styles) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
styles.sort(function(a, b) { return a.name.localeCompare(b.name)});
|
styles.sort(function(a, b) { return a.name.localeCompare(b.name)});
|
||||||
var installed = document.getElementById("installed");
|
|
||||||
styles.map(createStyleElement).forEach(function(e) {
|
styles.map(createStyleElement).forEach(function(e) {
|
||||||
installed.appendChild(e);
|
installed.appendChild(e);
|
||||||
});
|
});
|
||||||
|
@ -186,7 +186,6 @@ chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleUpdate(style) {
|
function handleUpdate(style) {
|
||||||
var installed = document.getElementById("installed");
|
|
||||||
var element = createStyleElement(style);
|
var element = createStyleElement(style);
|
||||||
installed.replaceChild(element, installed.querySelector("[style-id='" + style.id + "']"));
|
installed.replaceChild(element, installed.querySelector("[style-id='" + style.id + "']"));
|
||||||
if (style.id == lastUpdatedStyleId) {
|
if (style.id == lastUpdatedStyleId) {
|
||||||
|
@ -197,7 +196,6 @@ function handleUpdate(style) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDelete(id) {
|
function handleDelete(id) {
|
||||||
var installed = document.getElementById("installed");
|
|
||||||
installed.removeChild(installed.querySelector("[style-id='" + id + "']"));
|
installed.removeChild(installed.querySelector("[style-id='" + id + "']"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,10 +434,7 @@ document.getElementById("check-all-updates").addEventListener("click", checkUpda
|
||||||
document.getElementById("apply-all-updates").addEventListener("click", applyUpdateAll, false);
|
document.getElementById("apply-all-updates").addEventListener("click", applyUpdateAll, false);
|
||||||
|
|
||||||
function onFilterChange (className, event) {
|
function onFilterChange (className, event) {
|
||||||
var container = document.getElementById("installed"),
|
installed.classList.toggle(className, event.target.checked);
|
||||||
control = event.target;
|
|
||||||
if (control.checked) container.classList.add(className);
|
|
||||||
else container.classList.remove(className);
|
|
||||||
}
|
}
|
||||||
function initFilter(className, node) {
|
function initFilter(className, node) {
|
||||||
node.addEventListener("change", onFilterChange.bind(undefined, className), false);
|
node.addEventListener("change", onFilterChange.bind(undefined, className), false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user