szurubooru/client/js/controllers/page_controller.js

34 lines
779 B
JavaScript
Raw Normal View History

2016-04-10 22:13:01 +02:00
'use strict';
2016-04-12 23:49:46 +02:00
const events = require('../events.js');
const settingsController = require('./settings_controller.js');
const EndlessPageView = require('../views/endless_page_view.js');
2016-04-10 22:13:01 +02:00
const ManualPageView = require('../views/manual_page_view.js');
class PageController {
constructor() {
2016-04-12 23:49:46 +02:00
events.listen(events.SettingsChange, () => {
this.update();
});
this.update();
}
update() {
if (settingsController.getSettings().endlessScroll) {
this.pageView = new EndlessPageView();
} else {
this.pageView = new ManualPageView();
}
2016-04-10 22:13:01 +02:00
}
run(ctx) {
this.pageView.render(ctx);
}
2016-04-12 23:49:46 +02:00
stop() {
this.pageView.unrender();
}
2016-04-10 22:13:01 +02:00
}
module.exports = new PageController();