2016-03-19 21:37:04 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const BaseView = require('./base_view.js');
|
|
|
|
|
|
|
|
class TopNavigationView extends BaseView {
|
2016-03-29 12:32:51 +02:00
|
|
|
constructor() {
|
|
|
|
super();
|
2016-03-27 21:10:41 +02:00
|
|
|
this.template = this.getTemplate('top-navigation-template');
|
2016-03-19 21:37:04 +01:00
|
|
|
this.navHolder = document.getElementById('top-nav-holder');
|
|
|
|
}
|
|
|
|
|
|
|
|
render(items) {
|
|
|
|
this.navHolder.innerHTML = this.template({items: items});
|
|
|
|
}
|
|
|
|
|
|
|
|
activate(itemName) {
|
|
|
|
const allItemsSelector = '#top-nav-holder [data-name]';
|
|
|
|
const currentItemSelector =
|
|
|
|
'#top-nav-holder [data-name="' + itemName + '"]';
|
|
|
|
for (let item of document.querySelectorAll(allItemsSelector)) {
|
|
|
|
item.className = '';
|
|
|
|
}
|
|
|
|
const currentItem = document.querySelectorAll(currentItemSelector);
|
|
|
|
if (currentItem.length > 0) {
|
|
|
|
currentItem[0].className = 'active';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = TopNavigationView;
|