2016-03-29 10:34:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const config = require('../config.js');
|
|
|
|
const BaseView = require('./base_view.js');
|
|
|
|
|
|
|
|
class HelpView extends BaseView {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.template = this.getTemplate('help-template');
|
|
|
|
this.sectionTemplates = {};
|
|
|
|
const sectionKeys = ['about', 'keyboard', 'search', 'comments', 'tos'];
|
|
|
|
for (let section of sectionKeys) {
|
|
|
|
const templateName = 'help-' + section + '-template';
|
|
|
|
this.sectionTemplates[section] = this.getTemplate(templateName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
render(section) {
|
|
|
|
if (!section) {
|
|
|
|
section = 'about';
|
|
|
|
}
|
|
|
|
if (!(section in this.sectionTemplates)) {
|
|
|
|
this.showView('');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const content = this.sectionTemplates[section]({
|
2016-04-06 19:49:26 +00:00
|
|
|
name: config.name,
|
2016-03-29 10:34:10 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
this.showView(this.template({'content': content}));
|
|
|
|
|
|
|
|
const allItemsSelector = '#content-holder [data-name]';
|
|
|
|
for (let item of document.querySelectorAll(allItemsSelector)) {
|
|
|
|
if (item.getAttribute('data-name') === section) {
|
|
|
|
item.className = 'active';
|
|
|
|
} else {
|
|
|
|
item.className = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = HelpView;
|