2019-08-30 15:30:12 +03:00
|
|
|
|
|
|
|
const state = {
|
|
|
|
query: ""
|
2019-09-01 13:06:47 +03:00
|
|
|
};
|
2019-08-30 15:30:12 +03:00
|
|
|
|
|
|
|
function doSearch(){
|
|
|
|
m.route.set(`/search/${state.query}`);
|
|
|
|
}
|
2019-06-11 16:01:16 +03:00
|
|
|
|
2019-06-11 15:16:41 +03:00
|
|
|
export default {
|
2019-04-14 20:17:43 +03:00
|
|
|
view: function(){
|
2019-08-30 15:30:12 +03:00
|
|
|
|
2019-04-14 20:17:43 +03:00
|
|
|
function handleInput(e){
|
2019-08-30 15:30:12 +03:00
|
|
|
state.query = e.target.value;
|
2019-04-21 22:51:43 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function handleKeyDown(e){
|
|
|
|
if (e.keyCode == 13){
|
2019-08-30 15:30:12 +03:00
|
|
|
doSearch();
|
2019-04-21 22:51:43 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-14 20:51:31 +03:00
|
|
|
return m("div", { class: "input-group mb-3" }, [
|
2019-04-15 08:54:11 +03:00
|
|
|
m("input[type=text]", {
|
|
|
|
placeholder: "Search",
|
|
|
|
class: "form-control",
|
|
|
|
oninput: handleInput,
|
2019-04-21 22:51:43 +03:00
|
|
|
onkeydown: handleKeyDown,
|
2019-08-30 15:30:12 +03:00
|
|
|
value: state.query
|
2019-04-21 22:51:43 +03:00
|
|
|
}),
|
2019-08-30 15:30:12 +03:00
|
|
|
m("div", { class: "input-group-append", onclick: doSearch }, [
|
2019-04-21 22:51:43 +03:00
|
|
|
m("span", { class: "input-group-text" }, [
|
|
|
|
m("i", { class: "fa fa-search"})
|
|
|
|
])
|
|
|
|
])
|
2019-04-14 20:51:31 +03:00
|
|
|
]);
|
2019-04-14 20:17:43 +03:00
|
|
|
}
|
2019-04-15 08:54:11 +03:00
|
|
|
};
|