]> git.openstreetmap.org Git - nominatim.git/blobdiff - website/js/nominatim-ui.js
search UI: hide unused query parameters
[nominatim.git] / website / js / nominatim-ui.js
index d631e7aa4861db4a63f54fa5715287f52e4e4686..72c1b3b054d6fd5236e7cedeac9f0dd8396408ee 100644 (file)
@@ -20,11 +20,37 @@ function parse_and_normalize_geojson_string(raw_string){
 jQuery(document).ready(function(){
 
     if ( !$('#search-page,#reverse-page').length ){ return; }
-    
+
     var is_reverse_search = !!( $('#reverse-page').length );
 
     $('#q').focus();
 
+        $(document).ready(function() {
+                $("input[name='query-selector']").click(function(){
+                var query_val = $("input[name='query-selector']:checked").val() ;
+                if (query_val == "simple") {
+                    $("div.form-group-structured").hide();
+                    $("div.form-group-simple").show();
+                    $("div.form-group-structured .form-control").prop('disabled', true);
+                    $("div.form-group-simple .form-control").prop('disabled', false);
+                    $('.form-group-structured').find('input:text').val('');
+                }
+                else if (query_val == "structured") {
+                    $("div.form-group-simple").hide();
+                    $("div.form-group-structured").show();
+                    $("div.form-group-structured .form-control").prop('disabled', false);
+                    $("div.form-group-simple .form-control").prop('disabled', true);
+                    $('.form-group-simple').find('input:text').val('');
+                }
+        });
+
+        if (nominatim_structured_query) {
+            $('input#structured').prop('checked', true).trigger('click');
+        } else {
+            $('input#simple').prop('checked', true).trigger('click');
+        }
+    });
+
     map = new L.map('map', {
                 attributionControl: (nominatim_map_init.tile_attribution && nominatim_map_init.tile_attribution.length),
                 scrollWheelZoom:    true, // !L.Browser.touch,
@@ -185,7 +211,7 @@ jQuery(document).ready(function(){
             circle.on('click', function(){
                 highlight_result(position);
             });
-            layerGroup.addLayer(circle);            
+            layerGroup.addLayer(circle);
         }
         if (result.aBoundingBox){