summaryrefslogtreecommitdiff
path: root/chimere/templates/search/search.html
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/templates/search/search.html')
-rw-r--r--chimere/templates/search/search.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/chimere/templates/search/search.html b/chimere/templates/search/search.html
new file mode 100644
index 0000000..28b2b3a
--- /dev/null
+++ b/chimere/templates/search/search.html
@@ -0,0 +1,47 @@
+{% load url from future %}{% load i18n%}
+{% if query %}
+<script type='text/javascript'>
+var new_ids = [{% for result in page.object_list %}{{result.object.pk}}{% if not forloop.last %}, {% endif %}{% endfor %}];
+var geo_objects = [{% for result in page.object_list %}{{result.object.getGeoJSON|safe}}{% if not forloop.last %}, {% endif %}{% endfor %}];
+var geo_features = {};
+for (idx=0 ; idx < new_ids.length ; idx++){
+ if (search_result.indexOf(new_ids[idx]) == -1){
+ search_result.push(new_ids[idx]);
+ geo_features[new_ids[idx]] = $('#main-map').chimere('addMarker', geo_objects[idx]);
+ }
+}
+{% if page.object_list.count %}$("#main-map").chimere("zoomToMarkerExtent");{% endif %}
+</script>
+<div id='search-listing'>
+ <ul>
+{% for result in page.object_list %}
+ <li>
+ <a href="#" onclick="$('#main-map').chimere('showPopup', {{result.object.pk}});return false;">{{ result.object }}</a>
+ </li>
+{% empty %}
+ <li>{% trans "No results found." %}</li>
+{% endfor %}
+ </ul>
+</div>
+{% if page.has_previous or page.has_next %}
+ <div id='search-nav'>
+ {% if page.has_previous %}<a href="#" onclick="haystack_search(this, {{ page.previous_page_number }});">{% trans "Previous" %}</a>{% endif %}
+ {% if page.has_next %}<a href="#" onclick="haystack_search(this, {{ page.next_page_number }});">{% trans "More results..." %}</a>{% endif %}
+ </div>
+{% endif %}
+
+{% else %}
+<form id='search-form'>
+ {{ form.q }} <button name='haystack-search' id='haystack-search' type='button'>{% trans "Search" %}</button>
+</form>
+<div id='search-result'></div>
+<script type='text/javascript'>
+$(function(){
+ $('#haystack-search').click(
+ function(evt){
+ $("#main-map").chimere("razMap");
+ haystack_search(evt);
+ });
+});
+</script>
+{% endif %}