Improved options page
This commit is contained in:
parent
d222b70f7d
commit
9bd8141b17
12
options.css
12
options.css
@ -14,8 +14,6 @@ body {
|
|||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
body > div {
|
body > div {
|
||||||
border: 1px solid #ddd;
|
|
||||||
padding: 30px 15px 15px 15px;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
body > div + div {
|
body > div + div {
|
||||||
@ -24,15 +22,14 @@ body > div + div {
|
|||||||
h1 {
|
h1 {
|
||||||
border-bottom: 1px solid #ddd;
|
border-bottom: 1px solid #ddd;
|
||||||
margin: 0.5em 0;
|
margin: 0.5em 0;
|
||||||
|
font-size: 2rem;
|
||||||
}
|
}
|
||||||
h2 {
|
h2 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding: 10px 15px;
|
border-bottom: 1px solid #ddd;
|
||||||
position: absolute;
|
font-size: 1.625rem;
|
||||||
top: calc(-1 * (0.625em + 10px));
|
padding: 0 0 2px 0;
|
||||||
left: 10px;
|
|
||||||
border: inherit;
|
|
||||||
}
|
}
|
||||||
textarea {
|
textarea {
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
@ -40,6 +37,7 @@ textarea {
|
|||||||
font-size: 1.125rem;
|
font-size: 1.125rem;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: block;
|
display: block;
|
||||||
|
max-height: calc(100vh - 275px);
|
||||||
}
|
}
|
||||||
#matchingPatterns textarea {
|
#matchingPatterns textarea {
|
||||||
min-height: 300px;
|
min-height: 300px;
|
||||||
|
|||||||
21
options.js
21
options.js
@ -47,6 +47,11 @@ function resetChanges() {
|
|||||||
|
|
||||||
toggleModeSelectorState(window.currentMode);
|
toggleModeSelectorState(window.currentMode);
|
||||||
setButtonsActive(false);
|
setButtonsActive(false);
|
||||||
|
|
||||||
|
// Expand all textareas.
|
||||||
|
document.querySelectorAll("textarea").forEach(textarea => {
|
||||||
|
expandTextarea(textarea);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,6 +61,15 @@ function setButtonsActive(active) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expandTextarea(textarea) {
|
||||||
|
let totalBorderHeight = 2;
|
||||||
|
if (textarea.clientHeight == textarea.scrollHeight + totalBorderHeight) return;
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
textarea.style.height = 'auto';
|
||||||
|
textarea.style.height = textarea.scrollHeight + totalBorderHeight + 'px';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/******************/
|
/******************/
|
||||||
/* INITIALIZATION */
|
/* INITIALIZATION */
|
||||||
/******************/
|
/******************/
|
||||||
@ -86,6 +100,13 @@ function initialize() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listeners to auto-expand textareas on input.
|
||||||
|
document.querySelectorAll("textarea").forEach(textarea => {
|
||||||
|
textarea.addEventListener("input", (event) => {
|
||||||
|
expandTextarea(textarea);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Listeners for mode select switch.
|
// Listeners for mode select switch.
|
||||||
document.querySelector("input[type='checkbox']").addEventListener("change", (event) => {
|
document.querySelector("input[type='checkbox']").addEventListener("change", (event) => {
|
||||||
modeSelectorInputReceived();
|
modeSelectorInputReceived();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user