2016-04-10 20:13:01 +00:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-12 21:49:46 +00:00
|
|
|
const events = require('../events.js');
|
2016-04-14 18:28:44 +00:00
|
|
|
const settings = require('../settings.js');
|
2016-04-12 21:49:46 +00:00
|
|
|
const EndlessPageView = require('../views/endless_page_view.js');
|
2016-04-10 20:13:01 +00:00
|
|
|
const ManualPageView = require('../views/manual_page_view.js');
|
|
|
|
|
|
|
|
class PageController {
|
|
|
|
constructor() {
|
2016-04-12 21:49:46 +00:00
|
|
|
events.listen(events.SettingsChange, () => {
|
|
|
|
this.update();
|
2016-05-11 19:29:57 +00:00
|
|
|
return true;
|
2016-04-12 21:49:46 +00:00
|
|
|
});
|
|
|
|
this.update();
|
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
2016-04-14 18:28:44 +00:00
|
|
|
if (settings.getSettings().endlessScroll) {
|
2016-04-12 21:49:46 +00:00
|
|
|
this.pageView = new EndlessPageView();
|
|
|
|
} else {
|
|
|
|
this.pageView = new ManualPageView();
|
|
|
|
}
|
2016-04-10 20:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run(ctx) {
|
2016-04-17 07:24:05 +00:00
|
|
|
this.pageView.unrender();
|
2016-04-10 20:13:01 +00:00
|
|
|
this.pageView.render(ctx);
|
|
|
|
}
|
2016-04-12 21:49:46 +00:00
|
|
|
|
|
|
|
stop() {
|
|
|
|
this.pageView.unrender();
|
|
|
|
}
|
2016-04-10 20:13:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = new PageController();
|