From 91f5992423bb69d518f9f4ed17cab36a765fcd13 Mon Sep 17 00:00:00 2001 From: Simounet Date: Thu, 28 Dec 2017 23:27:45 +0100 Subject: Close add entry and search nav JS action improved --- app/Resources/static/themes/material/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'app/Resources/static') diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js index bdccc534..96310d81 100755 --- a/app/Resources/static/themes/material/index.js +++ b/app/Resources/static/themes/material/index.js @@ -35,6 +35,13 @@ $(document).ready(() => { initFilters(); initExport(); + const toggleNav = (toShow, toFocus) => { + $('.nav-panel-actions').hide(100); + $(toShow).show(100); + $('.nav-panels').css('background', 'white'); + $(toFocus).focus(); + }; + $('#nav-btn-add-tag').on('click', () => { $('.nav-panel-add-tag').toggle(100); $('.nav-panel-menu').addClass('hidden'); @@ -42,10 +49,7 @@ $(document).ready(() => { return false; }); $('#nav-btn-add').on('click', () => { - $('.nav-panel-actions').hide(100); - $('.nav-panel-add').show(100); - $('.nav-panels').css('background', 'white'); - $('#entry_url').focus(); + toggleNav('.nav-panel-add', '#entry_url'); return false; }); const materialAddForm = $('.nav-panel-add'); @@ -54,15 +58,11 @@ $(document).ready(() => { $('input#entry_url', materialAddForm).prop('readonly', true).trigger('blur'); }); $('#nav-btn-search').on('click', () => { - $('.nav-panel-actions').hide(100); - $('.nav-panel-search').show(100); - $('.nav-panels').css('background', 'white'); - $('#search_entry_term').focus(); + toggleNav('.nav-panel-search', '#search_entry_term'); return false; }); - $('.close').on('click', () => { - $('.nav-panel-add').hide(100); - $('.nav-panel-search').hide(100); + $('.close').on('click', (e) => { + $(e.target).parent('.nav-panel-item').hide(100); $('.nav-panel-actions').show(100); $('.nav-panels').css('background', 'transparent'); return false; -- cgit v1.2.3