szurubooru/client/js/views/user_view.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-04-06 22:34:21 +02:00
'use strict';
const BaseView = require('./base_view.js');
const UserSummaryView = require('./user_summary_view.js');
const UserEditView = require('./user_edit_view.js');
class UserView extends BaseView {
constructor() {
super();
this.template = this.getTemplate('user-template');
this.summaryView = new UserSummaryView();
this.editView = new UserEditView();
}
render(options) {
let section = options.section;
if (!section) {
section = 'summary';
}
let view = null;
if (section == 'edit') {
view = this.editView;
} else {
view = this.summaryView;
}
this.showView(this.template(options));
2016-04-06 22:34:21 +02:00
options.target = this.contentHolder.querySelector(
'#user-content-holder');
view.render(options);
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 = UserView;