diff --git a/views/shared/css/geolocation-marker.css b/views/shared/css/geolocation-marker.css index c413414..a15e203 100644 --- a/views/shared/css/geolocation-marker.css +++ b/views/shared/css/geolocation-marker.css @@ -10,6 +10,13 @@ button#geolocation_find_location_by_address { float: none; } +#geolocation_metadata_select { + width: 80%; +} +#geolocation_metadata_select_label { + font-weight: bold; + margin-right: 5px; +} div#geolocation { clear: both; diff --git a/views/shared/map/input-partial.php b/views/shared/map/input-partial.php index 2f4b4a2..c82187b 100644 --- a/views/shared/map/input-partial.php +++ b/views/shared/map/input-partial.php @@ -8,6 +8,22 @@ +getAllElementTexts(); + + foreach ($texts as $textRecord) { + $element = $item->getElementById($textRecord->element_id); + // Build a label like "Title: My Item Title" and store it in the metadata array: + $metadata[] = sprintf('%s: %s', $element->name, substr($tmp = $textRecord->text, 0, 40) . (strlen($tmp) > 40 ? '...' : '')); + } + + $metadata = array_unique($metadata); +} +?> +
@@ -16,7 +32,22 @@
+ +
+ +
+
+ + +
+
@@ -57,5 +88,20 @@ jQuery('#geolocation_find_location_by_address').click(); } }); + + // Make the metadata load button set the hidden form fields the plugin uses. + jQuery('#geolocation_metadata_load_btn').on('click', function (event) { + event.preventDefault(); + + // Get the raw selected option text, e.g. "Title: My Awesome Place" + var selected = jQuery('#geolocation_metadata_select').val(); + if (!selected) return; + + // Split off the part after the first ": " + var parts = selected.split(': '); + var address = parts.slice(1).join(': '); + + jQuery('#geolocation_address').val(address).trigger('change'); + }); });