2016-04-14 12:11:31 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const page = require('page');
|
2016-04-14 21:01:33 +02:00
|
|
|
const keyboard = require('../util/keyboard.js');
|
2016-04-14 12:11:31 +02:00
|
|
|
const misc = require('../util/misc.js');
|
|
|
|
const views = require('../util/views.js');
|
|
|
|
|
2016-05-11 12:17:40 +02:00
|
|
|
class UsersHeaderView {
|
2016-04-14 12:11:31 +02:00
|
|
|
constructor() {
|
2016-05-20 21:35:12 +02:00
|
|
|
this._template = views.getTemplate('users-header');
|
2016-04-14 12:11:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render(ctx) {
|
|
|
|
const target = ctx.target;
|
2016-05-20 21:35:12 +02:00
|
|
|
const source = this._template(ctx);
|
2016-04-14 12:11:31 +02:00
|
|
|
|
|
|
|
const form = source.querySelector('form');
|
|
|
|
|
2016-04-14 21:01:33 +02:00
|
|
|
keyboard.bind('q', () => {
|
|
|
|
form.querySelector('input').focus();
|
|
|
|
});
|
|
|
|
|
2016-04-14 12:11:31 +02:00
|
|
|
form.addEventListener('submit', e => {
|
|
|
|
e.preventDefault();
|
|
|
|
const searchTextInput = form.querySelector('[name=search-text]');
|
|
|
|
const text = searchTextInput.value;
|
|
|
|
searchTextInput.blur();
|
|
|
|
page('/users/' + misc.formatSearchQuery({text: text}));
|
|
|
|
});
|
|
|
|
|
|
|
|
views.showView(target, source);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-11 12:17:40 +02:00
|
|
|
module.exports = UsersHeaderView;
|