2016-04-11 22:38:59 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const views = require('../util/views.js');
|
|
|
|
|
|
|
|
class SettingsView {
|
|
|
|
constructor() {
|
|
|
|
this.template = views.getTemplate('settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
render(ctx) {
|
|
|
|
const target = document.getElementById('content-holder');
|
|
|
|
const source = this.template({browsingSettings: ctx.getSettings()});
|
|
|
|
|
|
|
|
const form = source.querySelector('form');
|
|
|
|
views.decorateValidator(form);
|
|
|
|
|
|
|
|
form.addEventListener('submit', e => {
|
|
|
|
e.preventDefault();
|
|
|
|
views.clearMessages(source);
|
|
|
|
ctx.saveSettings({
|
2016-04-14 21:01:33 +02:00
|
|
|
endlessScroll:
|
|
|
|
form.querySelector('#endless-scroll').checked,
|
|
|
|
keyboardShortcuts:
|
|
|
|
form.querySelector('#keyboard-shortcuts').checked,
|
2016-04-11 22:38:59 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
views.listenToMessages(target);
|
|
|
|
views.showView(target, source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = SettingsView;
|