summaryrefslogtreecommitdiff
path: root/chimere/static
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/static')
-rw-r--r--chimere/static/chimere/css/styles.css96
-rw-r--r--chimere/static/chimere/js/base.js9
-rw-r--r--chimere/static/chimere/js/jquery.chimere.js88
-rw-r--r--chimere/static/chimere/js/search-autocomplete.js108
-rw-r--r--chimere/static/chimere/js/search.js32
5 files changed, 302 insertions, 31 deletions
diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css
index ab68d68..fd39b79 100644
--- a/chimere/static/chimere/css/styles.css
+++ b/chimere/static/chimere/css/styles.css
@@ -21,6 +21,7 @@ h2, h3, th, .action li, .action li a,
color:#fff;
}
+#search-listing ul li a,
.action li.ui-state-active a,
#content .olControlLayerSwitcher,
.action li li.ui-state-active a{
@@ -62,7 +63,7 @@ fieldset, .action li, #content,
background-color:#FFF;
}
-div.warning, .errorlist{
+div.warning, .errorlist, .errorlist legend{
background-color:#ffca64;
}
@@ -74,23 +75,6 @@ div.warning, .errorlist{
border:1px solid #54c200;
}
-#layer_selection h4,
-#layer_selection #layer_list,
-#areas, #detail, #main-map,
-div.warning,
-#content,
-.action li.selected,
-#content .olControlLayerSwitcher .layersDiv,
-#panel, #map-footer, #chimere_itinerary_panel,
-#utils-div{
- border:1px solid #327e04;
-}
-
-
-.errorlist{
- border:1px solid #ff3f3f;
-}
-
/* rounded */
/* entête */
@@ -193,6 +177,13 @@ fieldset{
display:block;
}
+a:link[disabled],
+a[disabled] {
+ pointer-events: none;
+ cursor: default;
+ color: #ccc;
+}
+
#page_title{
position:absolute;
top:6px;
@@ -275,6 +266,11 @@ ul#action-2 {
padding:0.3em;
}
+#areas-div label{
+ color: #777;
+ font-variant:small-caps;
+}
+
#areas{
position:absolute;
z-index:5;
@@ -317,6 +313,16 @@ ul#action-2 {
margin:4px 8px;
}
+#close-detail{
+ position: absolute;
+ right: 10px;
+ font-weight:bold;
+}
+
+#close-detail:hover{
+ cursor:pointer;
+}
+
#news_content{
overflow:auto;
}
@@ -340,8 +346,10 @@ ul#action-2 {
ul.share{
list-style-type:none;
margin:0;
- padding:0;
- display:inline;
+ padding:0 1em;
+ display:block;
+ text-align:right;
+ font-style:italic;
}
ul.share li{
@@ -772,6 +780,46 @@ table.inline-table td input[type=file]{
margin-right: auto;
}
+#haystack-search .action-label{
+ display:none;
+}
+
+#search-box{
+ position:absolute;
+ z-index:200;
+ left:70px;
+ top:50px;
+ padding:0.3em;
+ padding-right:1.4em;
+ width:auto;
+ background-color:white;
+}
+
+#search-listing{
+ overflow:auto;
+}
+
+#search-listing ul{
+ list-style-type:none;
+ margin:0;
+ padding:4px;
+}
+
+#search-listing ul li{
+ padding:4px;
+}
+
+#search-listing a{
+ padding: 0.2em 0.5em;
+ border-radius:5px;
+}
+
+#search-listing a:hover{
+ text-decoration:none;
+ background-color:rgb(175, 231, 175);
+}
+
+
.alert-box .ui-dialog-titlebar {
display:none;
}
@@ -937,6 +985,12 @@ ul#multimedia_list_content li.multimedia{
min-height:50px;
}
+.errorlist legend{
+ margin:0;
+ padding:0 10px;
+ border:none;
+}
+
p.legend{
padding:0;
margin:0;
@@ -1051,7 +1105,7 @@ div.pp_default .pp_expand{
}
.olControlSimplePanZoom {
- top: 10px;
+ top: 20px;
right: 10px;
}
diff --git a/chimere/static/chimere/js/base.js b/chimere/static/chimere/js/base.js
index fe8d954..d7a9695 100644
--- a/chimere/static/chimere/js/base.js
+++ b/chimere/static/chimere/js/base.js
@@ -1,5 +1,5 @@
/* base function shared by some pages */
-/* Copyright (C) 2009-2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+/* Copyright (C) 2009-2014 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -60,7 +60,6 @@ function open_window(url){
return false;
}
-
function saveExtent() {
/* save the current extent in a cookie */
if(!map) return;
@@ -141,3 +140,9 @@ function share_link_update(){
return false;
});
}
+
+$("a").on("click", function(event){
+ if ($(this).is("[disabled]")) {
+ event.preventDefault();
+ }
+});
diff --git a/chimere/static/chimere/js/jquery.chimere.js b/chimere/static/chimere/js/jquery.chimere.js
index c9f02af..d85490f 100644
--- a/chimere/static/chimere/js/jquery.chimere.js
+++ b/chimere/static/chimere/js/jquery.chimere.js
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2012 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+/* Copyright (C) 2008-2015 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -167,8 +167,7 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
new OpenLayers.Control.Zoom()];
} else {
settings.controls = [new OpenLayers.Control.Navigation(),
- new OpenLayers.Control.PanPanel(),
- new OpenLayers.Control.ZoomPanel(),
+ new OpenLayers.Control.SimplePanZoom(),
new OpenLayers.Control.ScaleLine()];
}
}
@@ -441,8 +440,36 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
methods.routingAddStep();
}
}
+
+ // verify that the initial display_feature is displayed
+ if (settings.display_feature){
+ var is_displayed = false;
+ for(j=0; j<settings.layerMarkers.markers.length;j++){
+ var c_marker = settings.layerMarkers.markers[j];
+ if(c_marker.pk == settings.display_feature){
+ is_displayed = true;
+ }
+ }
+ if (!is_displayed){
+ methods.loadMarker(settings.display_feature);
+ }
+ }
+ methods.update_permalink_activation();
+
methods.preload_images();
}, // end of init
+ update_permalink_activation:function(){
+ if (settings.checked_categories.length ||
+ settings.current_feature ||
+ settings.routing_speed ||
+ settings.routing_transport ||
+ settings.routing_start ||
+ settings.routing_end){
+ $("#permalink a").removeAttr("disabled");
+ } else {
+ $("#permalink a").attr("disabled", "disabled");
+ }
+ },
/* Preload icons */
preload_images: function(){
if (typeof extra_url == 'undefined') return;
@@ -581,6 +608,15 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
$('#chimere_map_menu').css('left', offsetX);
}
},
+ loadMarker: function(object_id) {
+ var uri = extra_url + "get-marker/" + object_id;
+ $.ajax({url: uri,
+ dataType: "json",
+ success: function (data) {
+ for (idx in data) methods.addMarker(data[idx]);
+ }
+ });
+ },
/*
* Load markers and route from DB
*/
@@ -626,9 +662,14 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
},
complete: function () {
if($('#waiting').length){$('#waiting').hide();}
+ methods.update_permalink_activation();
}
});
},
+ razMap: function() {
+ settings.layerMarkers.clearMarkers();
+ settings.layerVectors.removeAllFeatures();
+ },
/*
* Update the categories div in ajax
*/
@@ -701,6 +742,7 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
settings.permalink.updateLink();
});
$('.subcategories li input').bind("click", function (e) {
+ $('#search-result').html('');
var c_name = $(this).attr('name');
c_name = c_name.substr(c_name.lastIndexOf("_")+1);
if($(this).is(':checked')){
@@ -734,8 +776,8 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
var id = this.id.substr(this.id.lastIndexOf("_")+1);
helpers.zoom_to_subcategories([id]);
});
- $(".toggle_category").parent().bind("click", function (e) {
- var item = $(this).children('.toggle_category');
+ $(".toggle_category").bind("click", function (e) {
+ var item = $(this);
var id = item.attr('id').substr(item.attr('id').lastIndexOf("_")+1);
methods.toggle_category(id);
});
@@ -851,6 +893,7 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
settings.current_popup.groupDiv.onclick = methods.hidePopup;
}
settings.permalink.updateLink();
+ methods.update_permalink_activation();
}
var _repan_popup = function(){
/* re-pan manually */
@@ -882,7 +925,7 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
if (settings.current_popup == feature.popup) {
feature.popup.hide();
if (!settings.simple){
- $('#detail').hide();
+ $('#detail').fadeOut();
}
} else {
settings.current_popup.hide();
@@ -1332,7 +1375,7 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
}
else {
if (!settings.popupContentFull) {
- $('#detail').html(data).show();
+ $('#detail').html(data).fadeIn();
}
else {
settings.current_popup.setContentHTML("<div class='cloud'>" + data + "</div>");
@@ -1451,6 +1494,10 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
settings.map.zoomToExtent(extent, true);
return true;
},
+ zoomToMarkerExtent: function(){
+ settings.map.zoomToExtent(
+ settings.layerMarkers.getDataExtent());
+ },
// methods for edition
setMarker: function (event){
event = event || window.event;
@@ -1567,6 +1614,24 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
var bounds = settings.layerVectors.getDataExtent();
if (bounds) settings.map.zoomToExtent(bounds);
},
+ showPopup: function (feature_pk) {
+ for(j=0; j<settings.layerMarkers.markers.length;j++){
+ var c_marker = settings.layerMarkers.markers[j];
+ if(c_marker.pk == feature_pk){
+ c_marker.events.triggerEvent('click');
+ return true
+ }
+ }
+ return false;
+ //feature.markerClick();
+ //OpenLayers.Popup.popupSelect.clickFeature(feature);
+ /*
+ settings.current_popup = feature.marker._popup();
+ if (!settings.current_popup.visible()){
+ settings.current_popup.show();
+ methods.display_feature_detail(feature.pk);
+ }*/
+ },
hidePopup: function (evt) {
$('#'+settings.marker_hover_id).hide();
if (settings.hide_popup_fx) {
@@ -1575,17 +1640,20 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
else { // Default behaviour
if (settings.current_popup)
{
+ settings.current_feature = null;
if (!settings.simple){
- $('#detail').hide();
+ $('#detail').fadeOut();
}
if (settings.current_popup.visible()){
settings.current_popup.hide();
if(evt)
settings.map.events.triggerEvent('click', evt);
+ methods.update_permalink_activation();
return true;
}
}
}
+ methods.update_permalink_activation();
return false;
},
saveExtent: function(){
@@ -1681,6 +1749,10 @@ OpenLayers.Layer.MapQuestOSM = OpenLayers.Class(OpenLayers.Layer.XYZ, {
methods.loadCategories();
}
},
+ zoom_to_latlon: function (){
+ var lonlat = new OpenLayers.LonLat(lon, lat);
+ settings.map.setCenter(f.lonlat);
+ },
getSavedExtent: function() {
/* get the current extent from a cookie */
var cookies = document.cookie.split(';');
diff --git a/chimere/static/chimere/js/search-autocomplete.js b/chimere/static/chimere/js/search-autocomplete.js
new file mode 100644
index 0000000..5e8a85e
--- /dev/null
+++ b/chimere/static/chimere/js/search-autocomplete.js
@@ -0,0 +1,108 @@
+
+var do_you_mean = "Do you mean: ";
+var end_do_you_mean = "?";
+
+var Autocomplete = function(options) {
+ this.form_selector = options.form_selector;
+ this.url = options.url || '/search/autocomplete/';
+ this.delay = parseInt(options.delay || 300);
+ this.minimum_length = parseInt(options.minimum_length || 3);
+ this.form_elem = null;
+ this.query_box = null;
+}
+
+Autocomplete.prototype.setup = function() {
+ var self = this;
+
+ this.form_elem = $(this.form_selector);
+ this.query_box = this.form_elem.find('input[name=q]');
+
+ // watch the input box.
+ this.query_box.on('keyup', function() {
+ var query = self.query_box.val();
+ if (query){
+ $('#haystack-search').removeAttr("disabled");
+ } else {
+ $('#haystack-search').attr('disabled', 'disabled');
+ }
+
+ if(query.length < self.minimum_length) {
+ return false;
+ }
+
+ self.fetch(query);
+ });
+
+ // on selecting a result, populate the search field.
+ this.form_elem.on('click', '.ac-result', function(ev) {
+ self.query_box.val($(this).text());
+ $('.ac-results').remove();
+ $('#spelling').fadeOut();
+ return false;
+ });
+
+ // on selecting a suggestion, populate the search field.
+ $('#search-box').on('click', '.spelling-item', function(ev) {
+ self.query_box.val($(this).text());
+ $('.ac-results').remove();
+ $('#spelling').fadeOut();
+ return false;
+ });
+}
+
+Autocomplete.prototype.fetch = function(query) {
+ var self = this ;
+
+ $.ajax({
+ url: this.url,
+ data: { 'q': query },
+ success: function(data) {
+ if(data.results.length){
+ self.show_results(data);
+ } else {
+ $('.ac-results').remove();
+ }
+ if(data.spelling.length){
+ self.show_spelling(data.spelling)
+ } else {
+ $("#spelling").fadeOut();
+ }
+ return true;
+ }
+ })
+}
+
+Autocomplete.prototype.show_spelling = function(spelling) {
+ var text = do_you_mean;
+ var base_elem = '<a href="#" class="spelling-item">'
+ var end_base_elem = '</a>';
+ for(var offset in spelling) {
+ if (offset > 0){
+ text += ", ";
+ }
+ text += base_elem;
+ text += spelling[offset];
+ text += end_base_elem;
+ }
+ text += end_do_you_mean;
+ $("#spelling").html(text);
+ $("#spelling").fadeIn();
+}
+
+Autocomplete.prototype.show_results = function(data) {
+ // Remove any existing results.
+ $('.ac-results').remove();
+
+ var results = data.results || []
+ var results_wrapper = $('<div class="ac-results"></div>');
+ var base_elem = $('<div class="result-wrapper"><a href="#" class="ac-result"></a></div>');
+
+ for(var res_offset in results) {
+ var elem = base_elem.clone();
+ // don't use .html(...) here, as it opens to XSS.
+ elem.find('.ac-result').text(results[res_offset]);
+ results_wrapper.append(elem);
+ }
+
+ this.query_box.after(results_wrapper)
+}
diff --git a/chimere/static/chimere/js/search.js b/chimere/static/chimere/js/search.js
new file mode 100644
index 0000000..6f46f3f
--- /dev/null
+++ b/chimere/static/chimere/js/search.js
@@ -0,0 +1,32 @@
+function load_search_box(){
+ if (!search_url) return;
+ $.ajax({url: search_url}).done(function( data ) {
+ $("#search-box").html(data);
+ });
+}
+
+function haystack_search(evt, page){
+ search_result = new Array();
+ $('#categories').find('#ul_categories > li > input').attr("checked", false);
+ if (!$('#id_q').val()) return false;
+
+ var c_url = search_url + "?q=" + $('#id_q').val();
+ if (page){
+ c_url += '&page=' + page;
+ }
+ $.get(c_url).done(function( data ) {
+ $('.ac-results').remove();
+ $('#search-result').html(data).show('slow');
+ });
+ return false;
+}
+
+// disable enter
+$(window).keydown(function(event){
+ if ($("#haystack-search").length && event.keyCode == 13) {
+ event.preventDefault();
+ $("#haystack-search").click();
+ return false;
+ }
+});
+