| ... |
... |
@@ -48,9 +48,12 @@ |
| 48 |
48 |
connectedCallback() { |
| 49 |
49 |
super.connectedCallback(); |
| 50 |
50 |
this.render(); |
|
51 |
+ const searchInput = this.$('input[type="text"]'); |
| 51 |
51 |
this.$('#search').addEventListener('click', this.handleSearch); |
| 52 |
52 |
this.$('#prev').addEventListener('click', this.handlePrevPage); |
| 53 |
53 |
this.$('#next').addEventListener('click', this.handleNextPage); |
|
55 |
+ searchInput.addEventListener('keypress', this.handleKeyPress); |
|
56 |
+ searchInput.focus(); |
| 54 |
54 |
} |
| 55 |
55 |
|
| 56 |
56 |
disconnectedCallback() { |
| ... |
... |
@@ -57,6 +57,7 @@ |
| 57 |
57 |
this.$('#search').removeEventListener('click', this.handleSearch); |
| 58 |
58 |
this.$('#prev').removeEventListener('click', this.handlePrevPage); |
| 59 |
59 |
this.$('#next').removeEventListener('click', this.handleNextPage); |
|
63 |
+ this.$('input[type="text"]').addEventListener('keypress', this.handleKeyPress); |
| 60 |
60 |
} |
| 61 |
61 |
|
| 62 |
62 |
get styles() { |
| ... |
... |
@@ -84,6 +84,11 @@ |
| 84 |
84 |
.then(this.renderResults); |
| 85 |
85 |
} |
| 86 |
86 |
|
|
91 |
+ handleKeyPress = (e) => { |
|
92 |
+ if(e.code === 'Enter') { |
|
93 |
+ this.handleSearch(); |
|
94 |
+ } |
|
95 |
+ } |
| 87 |
87 |
|
| 88 |
88 |
get html() { |
| 89 |
89 |
return ` |
| ... |
... |
@@ -103,7 +103,7 @@ |
| 103 |
103 |
const { title_, spaces, doccontent_en } = results[i]; |
| 104 |
104 |
const elt = document.createElement('clb-search-result'); |
| 105 |
105 |
elt.setAttribute('data-title', title_); |
| 106 |
|
- elt.setAttribute('data-href', spaces.join('/')); |
|
115 |
+ elt.setAttribute('data-breadcrumbs'); |
| 107 |
107 |
elt.innerHTML = doccontent_en; |
| 108 |
108 |
resultsContainer.appendChild(elt); |
| 109 |
109 |
} |
| ... |
... |
@@ -125,8 +125,8 @@ |
| 125 |
125 |
return this.getAttribute('data-title'); |
| 126 |
126 |
} |
| 127 |
127 |
|
| 128 |
|
- get hrefAttr() { |
| 129 |
|
- return this.getAttribute('data-href'); |
|
137 |
+ get breadcrumbsAttr() { |
|
138 |
+ return this.getAttribute('data-breadcrumbs'); |
| 130 |
130 |
} |
| 131 |
131 |
|
| 132 |
132 |
get styles() { |
| ... |
... |
@@ -139,7 +139,7 @@ |
| 139 |
139 |
get html() { |
| 140 |
140 |
return ` |
| 141 |
141 |
<div> |
| 142 |
|
- <a href=${this.hrefAttr}>${this.titleAttr}</a> |
|
151 |
+ <a href="/bin/view/${this.breadcrumbsAttr.join("/")}>${this.titleAttr}</a> |
| 143 |
143 |
<div> |
| 144 |
144 |
<slot></slot> |
| 145 |
145 |
</div> |