From 0f8066d0ffc3cb785c41605a603343da6ba5e91b Mon Sep 17 00:00:00 2001 From: plutonik Date: Wed, 29 Nov 2017 15:07:29 +0100 Subject: [PATCH] fix(search): Show date only if a certain input is selected #288 Check, if only Historical Documents is checked and only then expand the date widget. --- resources/scripts/app.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/resources/scripts/app.js b/resources/scripts/app.js index 8c4ae0eb5..a0732b34c 100644 --- a/resources/scripts/app.js +++ b/resources/scripts/app.js @@ -179,6 +179,11 @@ $(document).ready(function() { return sections.filter(':checked').size() === sections.size(); } + // Return all filters unchecked except for input "Historical Documents" + function allSelectedButDocuments() { + return sections.not(documentsInput).filter(':checked').size() === 0; + } + /** * Toggle visibility of date component, if sections input "Historical Documents" is checked or not */ @@ -191,10 +196,11 @@ $(document).ready(function() { }); function toggleDateComponent () { - if ( $( documentsInput ).is( ":checked" )) { + if (documentsInput.is( ":checked" ) && allSelectedButDocuments()) { dateComponent.removeClass("hsg-hidden"); dateComponent.addClass("hsg-active"); s } + else { dateComponent.addClass("hsg-hidden"); dateComponent.removeClass("hsg-active");