szurubooru/client/js/views/users_header_view.js

36 lines
942 B
JavaScript
Raw Normal View History

2016-04-14 12:11:31 +02:00
'use strict';
const page = require('page');
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() {
this._template = views.getTemplate('users-header');
2016-04-14 12:11:31 +02:00
}
render(ctx) {
const target = ctx.target;
const source = this._template(ctx);
2016-04-14 12:11:31 +02:00
const form = source.querySelector('form');
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;