Fold unused categories

This commit is contained in:
the1812 2018-10-28 00:23:29 +08:00
parent 49df9167da
commit 5a63e9713f
6 changed files with 37 additions and 21 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -60,6 +60,17 @@
return settings.blurBackgroundOpacity; return settings.blurBackgroundOpacity;
} }
}; };
function getCategoriyItems(category)
{
let element = category.nextElementSibling;
const elements = [];
while (element !== null && !element.classList.contains("category"))
{
elements.push(element);
element = element.nextElementSibling;
}
return elements;
}
function darkScheduleValidate(text, defaultValue) function darkScheduleValidate(text, defaultValue)
{ {
const match = text.match(/^([\d]{1,2}):([\d]{1,2})$/); const match = text.match(/^([\d]{1,2}):([\d]{1,2})$/);
@ -109,6 +120,16 @@
{ {
settingsChange(key, undefined, settings[key]); settingsChange(key, undefined, settings[key]);
} }
$(".gui-settings-content ul li.category").each((_, e) =>
{
const items = getCategoriyItems(e);
if (items
.filter(it => !it.classList.contains("disabled"))
.every(it => $(it).has("input:checked").length === 0))
{
$(e).click();
}
});
} }
function setupEvents() function setupEvents()
{ {
@ -133,12 +154,7 @@
$(".gui-settings-content ul li.category").on("click", e => $(".gui-settings-content ul li.category").on("click", e =>
{ {
e.currentTarget.classList.toggle("folded"); e.currentTarget.classList.toggle("folded");
let element = e.currentTarget.nextElementSibling; getCategoriyItems(e).forEach(it => it.classList.toggle("folded"));
while (element !== null && !element.classList.contains("category"))
{
element.classList.toggle("folded");
element = element.nextElementSibling;
}
}); });
onSettingsChange(settingsChange); onSettingsChange(settingsChange);
} }
@ -249,6 +265,11 @@
$("body").append(settingsBox); $("body").append(settingsBox);
setupEvents(); setupEvents();
fillSvgData(); fillSvgData();
if (typeof offlineData !== "undefined")
{
$("li:has(input[key=useCache])").addClass("disabled");
$("input[key=useCache]").prop("disabled", true);
}
syncGui(); syncGui();
listenDependencies(); listenDependencies();
addPredefinedColors(); addPredefinedColors();
@ -261,11 +282,6 @@
{ {
$(".gui-settings-panel").addClass("animation"); $(".gui-settings-panel").addClass("animation");
} }
if (typeof offlineData !== "undefined")
{
$("li:has(input[key=useCache])").addClass("disabled");
$("input[key=useCache]").prop("disabled", true);
}
} }
new SpinQuery( new SpinQuery(

View File

@ -487,14 +487,14 @@ i.settings-category-arrow
{ {
transform-origin: center; transform-origin: center;
transition: all .2s ease-out; transition: all .2s ease-out;
transform: translateY(-2.828427px) rotate(45deg); transform: translateY(2.828427px) rotate(-135deg);
height: 100%; height: 100%;
display: inline-block; display: inline-block;
margin-left: 12px; margin-left: 12px;
} }
li.category.folded i.settings-category-arrow li.category.folded i.settings-category-arrow
{ {
transform: translateY(2.828427px) rotate(-135deg); transform: translateY(-2.828427px) rotate(45deg);
} }
i.settings-category-arrow::after i.settings-category-arrow::after
{ {