diff --git a/static/js/index.advanced-search-form.js b/static/js/index.advanced-search-form.js index 79deb8d..0746b9a 100644 --- a/static/js/index.advanced-search-form.js +++ b/static/js/index.advanced-search-form.js @@ -67,7 +67,7 @@ var searchGroups = $("div#search-groups"); }) }); - // Add an input field to the currently selected search group. + // Toggle the presence of an input field. $("div#sidebar input[type=checkbox]").click(function(){ var fieldId = $(this).prop("id"); if($(this).is(":checked")){ @@ -76,8 +76,12 @@ var searchGroups = $("div#search-groups"); if(fieldId.slice(0, 4) == "date") $(".search-group#selected ." + fieldId).datepicker(); } - else - $("div.search-group#selected #" + fieldId).remove() + else { + if($(".search-group#selected").children("div").length > 1) + $(".search-group#selected #" + fieldId).remove() + else + $(this).prop("checked", true); + } }); var previousAdvancedQuery = ""; @@ -140,8 +144,5 @@ function assembleQuery(){ function genFieldQueryString(field, hasRegex){ var terms = field.value.replace(/\\/g, "\\\\").replace(/\"/g, "\\\""); var query = field.getAttribute("name") + ":" + (hasRegex?"re:":"") + terms; - if(field.value.indexOf('"') >= 0){ - return '"' + query + '"'; - } - return query; + return '"' + query + '"'; } diff --git a/templates/index.html b/templates/index.html index 254508b..4bd72ea 100644 --- a/templates/index.html +++ b/templates/index.html @@ -89,31 +89,6 @@ Regex - -