瀏覽代碼

Improved options page

master
Said Achmiz 6 年之前
父節點
當前提交
9bd8141b17
共有 2 個文件被更改,包括 26 次插入7 次删除
  1. 5
    7
      options.css
  2. 21
    0
      options.js

+ 5
- 7
options.css 查看文件

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 {
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;
position: absolute;
top: calc(-1 * (0.625em + 10px));
left: 10px;
border: inherit;
border-bottom: 1px solid #ddd;
font-size: 1.625rem;
padding: 0 0 2px 0;
} }
textarea { textarea {
border: 1px solid #aaa; border: 1px solid #aaa;
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
- 0
options.js 查看文件



toggleModeSelectorState(window.currentMode); toggleModeSelectorState(window.currentMode);
setButtonsActive(false); setButtonsActive(false);

// Expand all textareas.
document.querySelectorAll("textarea").forEach(textarea => {
expandTextarea(textarea);
});
}); });
} }


}); });
} }


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 */
/******************/ /******************/
}); });
}); });


// 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…
取消
儲存