mirror of
https://github.com/flarum/framework.git
synced 2024-12-23 14:23:43 +08:00
e466dcc626
Most of #137 done. - Use FastClick to make everything feel more responsive - Use transforms for animations to make them silky smooth - Style the drawer the same as the header to keep things simple - Revert to fixed composer, but allow it to be minimised - Add a separate notifications page for mobile so it’s easy to go back - Add indicator to the menu button when there are unread notifications - Close the drawer when navigating away - Make dropdowns/modals scrollable - Many other mobile tweaks and bug fixes Didn’t take much care to keep CSS clean, due to #103
60 lines
2.0 KiB
JavaScript
60 lines
2.0 KiB
JavaScript
import ScrollListener from 'flarum/utils/scroll-listener';
|
|
import History from 'flarum/utils/history';
|
|
import Pane from 'flarum/utils/pane';
|
|
import Drawer from 'flarum/utils/drawer';
|
|
import mapRoutes from 'flarum/utils/map-routes';
|
|
|
|
import BackButton from 'flarum/components/back-button';
|
|
import HeaderPrimary from 'flarum/components/header-primary';
|
|
import HeaderSecondary from 'flarum/components/header-secondary';
|
|
import FooterPrimary from 'flarum/components/footer-primary';
|
|
import FooterSecondary from 'flarum/components/footer-secondary';
|
|
import Composer from 'flarum/components/composer';
|
|
import Modal from 'flarum/components/modal';
|
|
import Alerts from 'flarum/components/alerts';
|
|
import SearchBox from 'flarum/components/search-box';
|
|
|
|
export default function(app) {
|
|
var id = id => document.getElementById(id);
|
|
|
|
app.history = new History();
|
|
app.pane = new Pane(id('page'));
|
|
app.search = new SearchBox();
|
|
app.drawer = new Drawer();
|
|
app.cache = {};
|
|
|
|
m.startComputation();
|
|
|
|
m.mount(id('back-control'), BackButton.component({ className: 'back-control', drawer: true }));
|
|
m.mount(id('back-button'), BackButton.component());
|
|
|
|
$('.global-content').click(e => {
|
|
if ($('body').hasClass('drawer-open')) {
|
|
e.preventDefault();
|
|
$('body').removeClass('drawer-open');
|
|
}
|
|
});
|
|
|
|
m.mount(id('header-primary'), HeaderPrimary.component());
|
|
m.mount(id('header-secondary'), HeaderSecondary.component());
|
|
m.mount(id('footer-primary'), FooterPrimary.component());
|
|
m.mount(id('footer-secondary'), FooterSecondary.component());
|
|
|
|
app.composer = m.mount(id('composer'), Composer.component());
|
|
app.modal = m.mount(id('modal'), Modal.component());
|
|
app.alerts = m.mount(id('alerts'), Alerts.component());
|
|
|
|
m.route.mode = 'pathname';
|
|
m.route(id('content'), '/', mapRoutes(app.routes));
|
|
|
|
m.endComputation();
|
|
|
|
new ScrollListener(top => $('body').toggleClass('scrolled', top > 0)).start();
|
|
|
|
$(function() {
|
|
FastClick.attach(document.body);
|
|
});
|
|
|
|
app.booted = true;
|
|
}
|