the-glorious-startpage/js/show-search-box.js
Gerome Matilla ae6e1254ea
Quality control (#27)
* fix paddings on screen

* fix  test Variable Assigned to Object Injection Sink

* fix parse int missing base

* fix security issues(regex not included)

* fix missing base

* fixes padding

* minor fixes

* regex

* cleanup

* minor cleanup in webmenu

* cleanups

* cleanups spaces to tab

* cleanups

* spacing tabs fixes test

* cleanup

* cleanup

* multitransition new line

* cleanup

* cleanup

* cleanup

* cleanup

* readme

* comments

* cleanup

* Avoid assignments in operands

* cleanup
2020-06-16 20:07:54 +08:00

70 lines
1.5 KiB
JavaScript

class SearchBoxShow {
constructor() {
this._searchBox = document.querySelector('#searchBox');
this._searchBoxContainer = document.querySelector('#searchBoxContainer');
this._centeredBoxOverlay = document.querySelector('#centeredBoxOverlay');
this._searchBoxVisility = false;
this.showSearchBox = this.showSearchBox.bind(this);
this.hideSearchBox = this.hideSearchBox.bind(this);
this.toggleSearchBox = this.toggleSearchBox.bind(this);
}
getSearchBoxVisibility = () => {
return this._searchBoxVisility;
}
showSearchBox = () => {
this._searchBoxContainer.classList.add('showSearchBox');
// Focus
this._searchBox.focus();
this._searchBoxVisility = !this._searchBoxVisility;
// Toggle overlay
this._centeredBoxOverlay.classList.toggle('showOverlay');
}
hideSearchBox = () => {
this._searchBoxContainer.classList.remove('showSearchBox');
// Toggle overlay
this._centeredBoxOverlay.classList.toggle('showOverlay');
this._searchBox.value = '';
// Hide suggestions
autoSuggestion.hideSuggestions();
this._searchBoxVisility = !this._searchBoxVisility;
}
toggleSearchBox = () => {
// If profile anim is still running,
// Return to avoid spam
if (profileImage.getProfileAnimationStatus()) return;
// Rotate profile
profileImage.rotateProfile();
if (this._searchBoxVisility) {
// Hide search box
this.hideSearchBox();
} else {
// Show search box
this.showSearchBox();
}
// console.log('toggle searchbox');
}
}