szurubooru/client/js/controllers/page_controller.js
rr- 69fe8ec31a client/general: refactor all the things
- Move controls to the "controls/" directory
- Make controls interface look similar to each other
- Prefix "private" methods and attributes with underscore
2016-05-21 00:08:43 +02:00

35 lines
816 B
JavaScript

'use strict';
const events = require('../events.js');
const settings = require('../settings.js');
const EndlessPageView = require('../views/endless_page_view.js');
const ManualPageView = require('../views/manual_page_view.js');
class PageController {
constructor() {
events.listen(events.SettingsChange, () => {
this._update();
return true;
});
this._update();
}
_update() {
if (settings.getSettings().endlessScroll) {
this._pageView = new EndlessPageView();
} else {
this._pageView = new ManualPageView();
}
}
run(ctx) {
this._pageView.unrender();
this._pageView.render(ctx);
}
stop() {
this._pageView.unrender();
}
}
module.exports = new PageController();