mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-24 07:39:59 +08:00
Cleaned some form styling
Removed uppercasing of labels to make a little friendlier. Extracted out toggleswitch JS into own component. Improved basic code input for html-head-input area.
This commit is contained in:
@ -16,6 +16,7 @@ let componentMapping = {
|
||||
'editor-toolbox': require('./editor-toolbox'),
|
||||
'image-picker': require('./image-picker'),
|
||||
'collapsible': require('./collapsible'),
|
||||
'toggle-switch': require('./toggle-switch'),
|
||||
};
|
||||
|
||||
window.components = {};
|
||||
|
19
resources/assets/js/components/toggle-switch.js
Normal file
19
resources/assets/js/components/toggle-switch.js
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
class ToggleSwitch {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.input = elem.querySelector('input');
|
||||
|
||||
this.elem.onclick = this.onClick.bind(this);
|
||||
}
|
||||
|
||||
onClick(event) {
|
||||
let checked = this.input.value !== 'true';
|
||||
this.input.value = checked ? 'true' : 'false';
|
||||
checked ? this.elem.classList.add('active') : this.elem.classList.remove('active');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ToggleSwitch;
|
Reference in New Issue
Block a user