X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tpl%2Fdefault%2Fjs%2Fshaarli.js;fp=tpl%2Fdefault%2Fjs%2Fshaarli.js;h=24d11cdb23465105a23570b6cb53a5fa42f098f0;hb=0d46b90b44b52bb9c511b18d51752dc16eb5e61b;hp=3afec7f32babcad4d0eef6984636b7bf221dd461;hpb=e722fde6e3ab4145e7d48bfc8b78627dd424833f;p=github%2Fshaarli%2FShaarli.git diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index 3afec7f3..24d11cdb 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js @@ -53,20 +53,6 @@ function getParentByClass(el, className) { window.addEventListener(WINDOW_CHANGE_EVENT, closeMenu); })(this, this.document); - -/** - * Expend search fields on focus. - */ -var searchInputs = document.querySelectorAll('#search input[type="text"]'); -[].forEach.call(searchInputs, function(searchInput) { - searchInput.addEventListener('focus', function(event) { - event.target.style.width = '250px'; - }); - searchInput.addEventListener('blur', function(event) { - event.target.style.width = '140px'; - }); -}); - /** * Fold/Expand shaares description and thumbnail. */ @@ -184,4 +170,18 @@ if (hiddenReturnurl != null) { var autofocusElements = document.querySelector('.autofocus'); if (autofocusElements != null) { autofocusElements.focus(); -} \ No newline at end of file +} + +/** + * Hide search bar, and display it on search click. + */ +var searchBar = document.getElementById('search'); +var searchButton = document.getElementById('search-button'); +if (searchBar != null && searchButton != null) { + searchBar.classList.toggle('closed'); + searchButton.addEventListener('click', function(event) { + event.preventDefault(); + searchBar.classList.toggle('closed'); + searchBar.classList.toggle('open'); + }); +}