54e3099c56
- Controller lifetime is bound to route lifetime - View lifetime is bound to controller lifetime - Control lifetime is bound to view lifetime - Enhanced event dispatching - Enhanced responsiveness in some places - Views communicate user input to controllers via new event system
24 lines
592 B
JavaScript
24 lines
592 B
JavaScript
'use strict';
|
|
|
|
const views = require('../util/views.js');
|
|
|
|
const template = views.getTemplate('top-navigation');
|
|
|
|
class TopNavigationView {
|
|
constructor() {
|
|
this._hostNode = document.getElementById('top-navigation-holder');
|
|
}
|
|
|
|
render(ctx) {
|
|
views.replaceContent(this._hostNode, template(ctx));
|
|
}
|
|
|
|
activate(key) {
|
|
for (let itemNode of this._hostNode.querySelectorAll('[data-name]')) {
|
|
itemNode.classList.toggle(
|
|
'active', itemNode.getAttribute('data-name') === key);
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = TopNavigationView;
|