aboutsummaryrefslogtreecommitdiff
path: root/public/javascripts/search.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/javascripts/search.js')
-rw-r--r--public/javascripts/search.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/public/javascripts/search.js b/public/javascripts/search.js
index f0f905f..d1a49e2 100644
--- a/public/javascripts/search.js
+++ b/public/javascripts/search.js
@@ -53,9 +53,26 @@ self._handleTextUpdate = function () {
}
}
+self._handleFocus = function () {
+ self._nodes.input.select()
+}
+
+self._handleBlur = function () {
+ // this will removed the selection without drawing focus on it (safari)
+ // this will removed selection even when focusing an iframe (chrome)
+ const oldValue = self._nodes.value
+ self._nodes.value = ''
+ self._nodes.value = oldValue
+
+ // this will hide the keyboard (iOS safari)
+ document.activeElement.blur()
+}
+
autocomplete.on('select', self.submit)
self._nodes.search.addEventListener('submit', self._handleSubmit)
+self._nodes.input.addEventListener('focus', self._handleFocus)
+self._nodes.input.addEventListener('blur', self._handleBlur)
self._nodes.input.addEventListener('input', self._handleTextUpdate)
module.exports = self