mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
Moved book cover image input into collapsible section
Prevent extra friction when creating a new book and makes it easier to skip if grid view is not in use
This commit is contained in:
37
resources/assets/js/components/collapsible.js
Normal file
37
resources/assets/js/components/collapsible.js
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Collapsible
|
||||
* Provides some simple logic to allow collapsible sections.
|
||||
*/
|
||||
class Collapsible {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.trigger = elem.querySelector('[collapsible-trigger]');
|
||||
this.content = elem.querySelector('[collapsible-content]');
|
||||
|
||||
if (!this.trigger) return;
|
||||
|
||||
this.trigger.addEventListener('click', this.toggle.bind(this));
|
||||
}
|
||||
|
||||
open() {
|
||||
this.elem.classList.add('open');
|
||||
$(this.content).slideDown(400);
|
||||
}
|
||||
|
||||
close() {
|
||||
this.elem.classList.remove('open');
|
||||
$(this.content).slideUp(400);
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if (this.elem.classList.contains('open')) {
|
||||
this.close();
|
||||
} else {
|
||||
this.open();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Collapsible;
|
@ -15,6 +15,7 @@ let componentMapping = {
|
||||
'markdown-editor': require('./markdown-editor'),
|
||||
'editor-toolbox': require('./editor-toolbox'),
|
||||
'image-picker': require('./image-picker'),
|
||||
'collapsible': require('./collapsible'),
|
||||
};
|
||||
|
||||
window.components = {};
|
||||
|
Reference in New Issue
Block a user