szurubooru/client/js/controllers/page_controller.js

36 lines
816 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 settings = require('../settings.js');
2016-04-12 23:49:46 +02:00
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();
return true;
2016-04-12 23:49:46 +02:00
});
this._update();
2016-04-12 23:49:46 +02:00
}
_update() {
if (settings.getSettings().endlessScroll) {
this._pageView = new EndlessPageView();
2016-04-12 23:49:46 +02:00
} else {
this._pageView = new ManualPageView();
2016-04-12 23:49:46 +02:00
}
2016-04-10 22:13:01 +02:00
}
run(ctx) {
this._pageView.unrender();
this._pageView.render(ctx);
2016-04-10 22:13:01 +02:00
}
2016-04-12 23:49:46 +02:00
stop() {
this._pageView.unrender();
2016-04-12 23:49:46 +02:00
}
2016-04-10 22:13:01 +02:00
}
module.exports = new PageController();