gallery.accords-library.com/client/js/controllers/page_controller.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2016-04-10 20:13:01 +00:00
'use strict';
2016-04-12 21:49:46 +00:00
const events = require('../events.js');
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();
return true;
2016-04-12 21:49:46 +00:00
});
this._update();
2016-04-12 21:49:46 +00:00
}
_update() {
if (settings.getSettings().endlessScroll) {
this._pageView = new EndlessPageView();
2016-04-12 21:49:46 +00:00
} else {
this._pageView = new ManualPageView();
2016-04-12 21:49:46 +00:00
}
2016-04-10 20:13:01 +00:00
}
run(ctx) {
this._pageView.unrender();
2016-06-11 07:59:29 +00:00
ctx.headerContext = ctx.headerContext || {};
Object.assign(ctx.headerContext, {
searchQuery: ctx.searchQuery,
});
ctx.pageContext = ctx.pageContext || {};
Object.assign(ctx.pageContext, {
searchQuery: ctx.searchQuery,
});
this._pageView.render(ctx);
2016-04-10 20:13:01 +00:00
}
2016-04-12 21:49:46 +00:00
stop() {
this._pageView.unrender();
2016-04-12 21:49:46 +00:00
}
2016-04-10 20:13:01 +00:00
}
module.exports = new PageController();