szurubooru/static/js/views/top_navigation_view.js
rr- 797ace982f start
Done so far

Basic backend skeleton

- technology choices
- database migration outline
- basic self hosting facade
- basic REST outline
- proof of concept for auth and privileges

Basic frontend skeleton

- technology choices
- pretty robust frontend compilation
- top navigation
- proof of concept for registration form
2016-03-27 23:05:10 +02:00

30 lines
910 B
JavaScript

'use strict';
const BaseView = require('./base_view.js');
class TopNavigationView extends BaseView {
constructor(handlebars) {
super(handlebars);
this.template = this.getTemplate('top-nav-template');
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;