summaryrefslogtreecommitdiff
path: root/chimere/static
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@proxience.com>2015-02-22 21:04:43 +0100
committerÉtienne Loks <etienne.loks@proxience.com>2015-02-22 21:04:43 +0100
commit906a299b4c07d4e6f0a31cd6504926cf7ff7cc66 (patch)
tree6f05955d3b12933817813d02a1c7aaa856e3efe7 /chimere/static
parent49a981c28c1c47ee548859f0490fa157acf9b1ba (diff)
parented6c1559c44bdc3214cd2dffb377359601b28a33 (diff)
downloadChimère-906a299b4c07d4e6f0a31cd6504926cf7ff7cc66.tar.bz2
Chimère-906a299b4c07d4e6f0a31cd6504926cf7ff7cc66.zip
Merge branch 'v2.2'
Conflicts: chimere/admin.py chimere/models.py chimere/static/chimere/css/styles.css chimere/urls.py chimere/views.py
Diffstat (limited to 'chimere/static')
-rw-r--r--chimere/static/chimere/css/styles.css36
-rw-r--r--chimere/static/chimere/js/base.js6
-rw-r--r--chimere/static/chimere/js/jquery.chimere-ol.js48
-rw-r--r--chimere/static/chimere/js/search-autocomplete.js58
4 files changed, 113 insertions, 35 deletions
diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css
index c41442e..98bc7ab 100644
--- a/chimere/static/chimere/css/styles.css
+++ b/chimere/static/chimere/css/styles.css
@@ -69,7 +69,7 @@ fieldset, .action li, #content,
background-color:#FFF;
}
-div.warning, .errorlist{
+div.warning, .errorlist, .errorlist legend{
background-color:#ffca64;
}
@@ -81,24 +81,6 @@ div.warning, .errorlist{
border:1px solid #54c200;
}
-#no-content .alert,
-#layer_selection h4,
-#layer_selection #layer_list,
-#maps, #detail, #main-map,
-div.warning,
-#content,
-.action li.selected,
-#content .olControlLayerSwitcher .layersDiv,
-#panel, #map-footer, #chimere_itinerary_panel,
-#search-box, #utils-div{
- border:1px solid #327e04;
-}
-
-
-.errorlist{
- border:1px solid #ff3f3f;
-}
-
/* rounded */
/* entête */
@@ -201,6 +183,12 @@ fieldset{
display:block;
}
+a[disabled] {
+ pointer-events: none;
+ cursor: default;
+ color: gray;
+}
+
#page_title{
position:absolute;
top:6px;
@@ -815,6 +803,10 @@ table.inline-table td input[type=file]{
margin-right: auto;
}
+#haystack-search .action-label{
+ display:none;
+}
+
#search-box{
position:absolute;
z-index:200;
@@ -1016,6 +1008,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;
diff --git a/chimere/static/chimere/js/base.js b/chimere/static/chimere/js/base.js
index 641f94a..b26d9f3 100644
--- a/chimere/static/chimere/js/base.js
+++ b/chimere/static/chimere/js/base.js
@@ -141,3 +141,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-ol.js b/chimere/static/chimere/js/jquery.chimere-ol.js
index 251c09c..ae3e340 100644
--- a/chimere/static/chimere/js/jquery.chimere-ol.js
+++ b/chimere/static/chimere/js/jquery.chimere-ol.js
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2014 É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
@@ -461,8 +461,36 @@ if (typeof(OpenLayers) != 'undefined'){
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;
@@ -601,6 +629,15 @@ if (typeof(OpenLayers) != 'undefined'){
$('#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
*/
@@ -646,6 +683,7 @@ if (typeof(OpenLayers) != 'undefined'){
},
complete: function () {
if($('#waiting').length){$('#waiting').hide();}
+ methods.update_permalink_activation();
}
});
},
@@ -725,6 +763,7 @@ if (typeof(OpenLayers) != 'undefined'){
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')){
@@ -875,6 +914,7 @@ if (typeof(OpenLayers) != 'undefined'){
settings.current_popup.groupDiv.onclick = methods.hidePopup;
}
settings.permalink.updateLink();
+ methods.update_permalink_activation();
}
var _repan_popup = function(){
/* re-pan manually */
@@ -1598,9 +1638,10 @@ if (typeof(OpenLayers) != 'undefined'){
var c_marker = settings.layerMarkers.markers[j];
if(c_marker.pk == feature_pk){
c_marker.events.triggerEvent('click');
- return
+ return true
}
}
+ return false;
//feature.markerClick();
//OpenLayers.Popup.popupSelect.clickFeature(feature);
/*
@@ -1618,6 +1659,7 @@ if (typeof(OpenLayers) != 'undefined'){
else { // Default behaviour
if (settings.current_popup)
{
+ settings.current_feature = null;
if (!settings.simple){
$('#detail').fadeOut();
}
@@ -1625,10 +1667,12 @@ if (typeof(OpenLayers) != 'undefined'){
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(){
diff --git a/chimere/static/chimere/js/search-autocomplete.js b/chimere/static/chimere/js/search-autocomplete.js
index cd1b0e1..5e8a85e 100644
--- a/chimere/static/chimere/js/search-autocomplete.js
+++ b/chimere/static/chimere/js/search-autocomplete.js
@@ -1,5 +1,6 @@
-var no_result_message = "No exact match.";
+var do_you_mean = "Do you mean: ";
+var end_do_you_mean = "?";
var Autocomplete = function(options) {
this.form_selector = options.form_selector;
@@ -30,14 +31,23 @@ Autocomplete.prototype.setup = function() {
}
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) {
@@ -47,11 +57,38 @@ Autocomplete.prototype.fetch = function(query) {
url: this.url,
data: { 'q': query },
success: function(data) {
- self.show_results(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();
@@ -60,17 +97,10 @@ Autocomplete.prototype.show_results = function(data) {
var results_wrapper = $('<div class="ac-results"></div>');
var base_elem = $('<div class="result-wrapper"><a href="#" class="ac-result"></a></div>');
- if(results.length > 0) {
- 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);
- }
- }
- else {
+ for(var res_offset in results) {
var elem = base_elem.clone();
- elem.text(no_result_message);
+ // don't use .html(...) here, as it opens to XSS.
+ elem.find('.ac-result').text(results[res_offset]);
results_wrapper.append(elem);
}