-
diff --git a/public/js/components/searchbar/searchbar.js b/public/js/components/searchbar/searchbar.js
index 3626df32a..2a3f11982 100644
--- a/public/js/components/searchbar/searchbar.js
+++ b/public/js/components/searchbar/searchbar.js
@@ -8,6 +8,7 @@ export default {
data: function() {
return {
searchtimer: null,
+ hidetimer: null,
showsettings: false,
searchsettings: {
searchstr: '',
@@ -26,37 +27,44 @@ export default {
organisationunit: organisationunit
},
template: `
-
-
-
-
-
-
{{ this.error }}
-
Es wurden keine Ergebnisse gefunden.
-
-
-
-
-
- Unbekannter Ergebnistyp: '{{ res.type }}'.
-
-
-
-
-
-
-
+
+
+
+
+
+
{{ this.error }}
+
Es wurden keine Ergebnisse gefunden.
+
+
+
+
+
+ Unbekannter Ergebnistyp: '{{ res.type }}'.
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
`,
beforeMount: function() {
this.updateSearchOptions();
@@ -68,17 +76,20 @@ export default {
this.searchsettings.types.push(this.searchoptions.types[idx]);
}
},
+ calcSearchResultExtent: function() {
+ var rect = this.$refs.searchbox.getBoundingClientRect();
+ //console.log(window.innerWidth + ' ' + window.innerHeight + ' ' + JSON.stringify(rect));
+ this.$refs.result.style.top = Math.floor(rect.bottom + 3) + 'px';
+ this.$refs.result.style.right = Math.floor(window.innerWidth - rect.right) + 'px';
+ this.$refs.result.style.width = Math.floor(window.innerWidth * 0.75) + 'px';
+ this.$refs.result.style.height = Math.floor(window.innerHeight * 0.75) + 'px';
+ },
search: function() {
if( this.searchtimer !== null ) {
clearTimeout(this.searchtimer);
}
if( this.searchsettings.searchstr.length >= 3 ) {
- var rect = this.$refs.searchbox.getBoundingClientRect();
- //console.log(window.innerWidth + ' ' + window.innerHeight + ' ' + JSON.stringify(rect));
- this.$refs.result.style.top = Math.floor(rect.bottom + 3) + 'px';
- this.$refs.result.style.right = Math.floor(window.innerWidth - rect.right) + 'px';
- this.$refs.result.style.width = Math.floor(window.innerWidth * 0.75) + 'px';
- this.$refs.result.style.height = Math.floor(window.innerHeight * 0.75) + 'px';
+ this.calcSearchResultExtent();
this.searchtimer = setTimeout(
this.callsearchapi,
500
@@ -109,24 +120,42 @@ export default {
this.search();
this.togglesettings();
},
- togglesettings: function() {
- this.showsettings = !this.showsettings;
+ calcSearchSettingsExtent: function() {
var rect = this.$refs.settingsbutton.getBoundingClientRect();
//console.log(window.innerWidth + ' ' + window.innerHeight + ' ' + JSON.stringify(rect));
this.$refs.settings.style.top = Math.floor(rect.bottom + 3) + 'px';
this.$refs.settings.style.right = Math.floor(window.innerWidth - rect.right) + 'px';
this.$refs.settings.style.width = Math.floor(window.innerWidth * 0.5) + 'px';
- //this.$refs.settings.style.height = Math.floor(window.innerHeight * 0.5) + 'px';
+ //this.$refs.settings.style.height = Math.floor(window.innerHeight * 0.5) + 'px';
},
- hideresult: function(e) {
- //window.removeEventListener('click', this.hideresult);
+ togglesettings: function() {
+ this.showsettings = !this.showsettings;
+ this.calcSearchSettingsExtent();
+ },
+ hideresult: function() {
this.showresult = false;
+ window.removeEventListener('resize', this.calcSearchResultExtent);
},
showsearchresult: function() {
if( this.searchsettings.searchstr.length >= 3 ) {
this.showresult = true;
- //window.addEventListener('click', this.hideresult);
+ window.addEventListener('resize', this.calcSearchResultExtent);
}
+ },
+ searchfocusin: function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ if( this.hidetimer !== null ) {
+ clearTimeout(this.hidetimer);
+ }
+ },
+ searchfocusout: function(e) {
+ e.preventDefault();
+ e.stopPropagation();
+ this.hidetimer = setTimeout(
+ this.hideresult,
+ 100
+ );
}
}
};