mirror of
https://github.com/flarum/core.git
synced 2025-10-14 08:24:28 +02:00
Massive JavaScript cleanup
- Use JSX for templates - Docblock/comment everything - Mostly passes ESLint (still some work to do) - Lots of renaming, refactoring, etc. CSS hasn't been updated yet.
This commit is contained in:
@@ -1,12 +1,53 @@
|
||||
/**
|
||||
* The `Drawer` class controls the page's drawer. The drawer is the area the
|
||||
* slides out from the left on mobile devices; it contains the header and the
|
||||
* footer.
|
||||
*/
|
||||
export default class Drawer {
|
||||
constructor() {
|
||||
// Set up an event handler so that whenever the content area is tapped,
|
||||
// the drawer will close.
|
||||
$('.global-content').click(e => {
|
||||
if (this.isOpen()) {
|
||||
e.preventDefault();
|
||||
this.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether or not the drawer is currently open.
|
||||
*
|
||||
* @return {Boolean}
|
||||
* @public
|
||||
*/
|
||||
isOpen() {
|
||||
return $('body').hasClass('drawer-open');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the drawer.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
hide() {
|
||||
$('body').removeClass('drawer-open');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the drawer.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
show() {
|
||||
$('body').addClass('drawer-open');
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the drawer.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
toggle() {
|
||||
$('body').toggleClass('drawer-open');
|
||||
}
|
||||
|
Reference in New Issue
Block a user