2015-04-25 20:58:39 +08:00
|
|
|
import ScrollListener from 'flarum/utils/scroll-listener';
|
|
|
|
import History from 'flarum/utils/history';
|
|
|
|
import Pane from 'flarum/utils/pane';
|
2015-06-24 10:14:53 +08:00
|
|
|
import Drawer from 'flarum/utils/drawer';
|
2015-04-25 20:58:39 +08:00
|
|
|
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';
|
2015-06-03 16:40:56 +08:00
|
|
|
import SearchBox from 'flarum/components/search-box';
|
2015-04-25 20:58:39 +08:00
|
|
|
|
|
|
|
export default function(app) {
|
|
|
|
var id = id => document.getElementById(id);
|
|
|
|
|
|
|
|
app.history = new History();
|
|
|
|
app.pane = new Pane(id('page'));
|
2015-06-18 16:11:37 +08:00
|
|
|
app.search = new SearchBox();
|
2015-06-24 10:14:53 +08:00
|
|
|
app.drawer = new Drawer();
|
2015-04-25 20:58:39 +08:00
|
|
|
app.cache = {};
|
|
|
|
|
2015-06-18 16:11:37 +08:00
|
|
|
m.startComputation();
|
|
|
|
|
2015-04-25 20:58:39 +08:00
|
|
|
m.mount(id('back-control'), BackButton.component({ className: 'back-control', drawer: true }));
|
|
|
|
m.mount(id('back-button'), BackButton.component());
|
|
|
|
|
2015-05-11 09:33:40 +08:00
|
|
|
$('.global-content').click(e => {
|
|
|
|
if ($('body').hasClass('drawer-open')) {
|
|
|
|
e.preventDefault();
|
|
|
|
$('body').removeClass('drawer-open');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-06-25 06:44:51 +08:00
|
|
|
$('#home-link').click(e => {
|
|
|
|
if (e.ctrlKey || e.metaKey || e.which === 2) return;
|
|
|
|
e.preventDefault();
|
|
|
|
app.history.home();
|
|
|
|
});
|
|
|
|
|
2015-04-25 20:58:39 +08:00
|
|
|
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());
|
|
|
|
|
2015-06-18 16:11:37 +08:00
|
|
|
m.route.mode = 'pathname';
|
2015-04-25 20:58:39 +08:00
|
|
|
m.route(id('content'), '/', mapRoutes(app.routes));
|
|
|
|
|
2015-06-18 16:11:37 +08:00
|
|
|
m.endComputation();
|
2015-06-03 16:40:56 +08:00
|
|
|
|
2015-04-25 20:58:39 +08:00
|
|
|
new ScrollListener(top => $('body').toggleClass('scrolled', top > 0)).start();
|
2015-06-18 16:11:37 +08:00
|
|
|
|
2015-06-24 10:14:53 +08:00
|
|
|
$(function() {
|
|
|
|
FastClick.attach(document.body);
|
|
|
|
});
|
|
|
|
|
2015-06-18 16:11:37 +08:00
|
|
|
app.booted = true;
|
2015-04-25 20:58:39 +08:00
|
|
|
}
|