summaryrefslogtreecommitdiff
path: root/chimere/static
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/static')
-rw-r--r--chimere/static/base.js2
-rw-r--r--chimere/static/main_map.js112
-rw-r--r--chimere/static/styles.css52
3 files changed, 133 insertions, 33 deletions
diff --git a/chimere/static/base.js b/chimere/static/base.js
index cabdf2a..3c7c575 100644
--- a/chimere/static/base.js
+++ b/chimere/static/base.js
@@ -60,4 +60,4 @@ function zoomToCurrentExtent(map){
else{
return;
}
-} \ No newline at end of file
+}
diff --git a/chimere/static/main_map.js b/chimere/static/main_map.js
index 1849713..ee742a2 100644
--- a/chimere/static/main_map.js
+++ b/chimere/static/main_map.js
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+/* Copyright (C) 2008-2010 É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
@@ -18,34 +18,88 @@ See the file COPYING for details.
/* main map */
-var current_cat;
+var current_cat = -1;
/* open a category section */
-function toggleCategory(id){
- old = document.getElementById('maincategory_' + current_cat)
+function toggleCategory(item){
+ var id = item.id.split('_').pop();
+ var old;
+ if (current_cat != -1){
+ old = document.getElementById('maincategory_' + current_cat);
+ } else {
+ img = document.getElementById('maincategory_img_' + id);
+ if (img.src.split('/').pop() == "minus.png"){
+ current_cat = id;
+ old = document.getElementById('maincategory_' + id);
+ }
+ }
if(old){
old.style.display = 'None';
old_img = document.getElementById('maincategory_img_' + current_cat);
- old_img.src = "/" + extra_url + "static/icons/plus.png";
+ old_img.src = media_path + "icons/plus.png";
}
if (id != current_cat){
current_cat = id;
document.getElementById('maincategory_' + current_cat).style.display = 'block';
img = document.getElementById('maincategory_img_' + current_cat);
- img.src = "/" + extra_url + "static/icons/minus.png";
+ img.src = media_path + "icons/minus.png";
} else {
current_cat = 0;
}
}
+/* reopen the current opened categories when a redraw occurs */
+function reOpenCurrent(){
+ if (current_cat){
+ document.getElementById('maincategory_' + current_cat).style.display = 'block';
+ img = document.getElementById('maincategory_img_' + current_cat);
+ img.src = media_path + "icons/minus.png";
+ }
+}
+
+function reCheckCategories(){
+ /* recheck categories when a redraw occurs */
+ if (!checked_categories){
+ return;
+ }
+ var checked_categories_ids = checked_categories.split('_');
+ inputs = window.document.forms["frm_categories"];
+ for (var i = 0; i < inputs.length; i++) {
+ input = inputs[i];
+ cat_id = input.name.split('_').pop();
+ if (checked_categories_ids.indexOf(cat_id) != -1){
+ input.checked = true;
+ }
+ if (input.id == 'display_submited' && display_submited == true){
+ input.checked = true;
+ }
+ }
+}
+
+/* get available subcategories for a designed category */
+function getSubcategories(category_id){
+ var ul = document.getElementById('maincategory_'+category_id);
+ var subcats = new Array();
+ for (i in ul.children){
+ var li = ul.children[i];
+ if (li.id){
+ subcats.push(li.id.split('_').pop());
+ }
+ }
+ return subcats;
+}
+
/* check all the categories if clicked, unckeck if unclick */
-function checkAll(item, ids){
+function checkAll(item){
check = false;
if(item.checked == true){
check = true;
}
- for (i in ids){
- document.getElementById('category_'+ids[i]).checked = check;
+ id = item.id.split('_').pop();
+ var subcats = getSubcategories(id);
+ for (i in subcats){
+ var checkbox = document.getElementById('category_'+subcats[i]);
+ checkbox.checked = check;
}
}
@@ -122,13 +176,19 @@ function loadLayersFromJSON(layer_markers, layer_vectors, geo_objects){
function zoomToArea(top, left, bottom, right){
var bounds = new OpenLayers.Bounds(left, bottom, right, top);
map.zoomToExtent(bounds, true);
+ loadCategories();
}
/* zoom to a desired category */
-function zoomToCategory(categorie_ids){
- updateCheckedCategories();
+function zoomToCategory(category_id){
+ var sub_cats = getSubcategories(category_id).join('_');
+ zoomToSubCategory(sub_cats);
+}
+
+/* zoom to desired sub categories */
+function zoomToSubCategory(subcategory_ids){
/* 0 stand for all categories */
- var uri = "/" + extra_url + "getGeoObjects/" + categorie_ids;
+ var uri = "/" + extra_url + "getGeoObjects/" + subcategory_ids;
if (display_submited) uri += "/A_S";
OpenLayers.loadURL(uri, '', this, zoomToCategoryExtent);
}
@@ -153,6 +213,28 @@ function zoomToCategoryExtent(response){
}
fakeLayerMarkers.destroy();
fakeLayerVectors.destroy();
+ loadCategories();
+}
+
+/* update the categories with an AJAX request */
+function loadCategories(){
+ var current_extent = map.getExtent().transform(map.getProjectionObject(),
+ epsg_display_projection);
+ current_extent = current_extent.toArray().join('_')
+ current_extent = current_extent.replace(/\./g, 'D');
+ current_extent = current_extent.replace(/-/g, 'M');
+ var uri = "/" + extra_url + "getAvailableCategories/" + current_extent;
+ if (display_submited) uri += "/A_S";
+ OpenLayers.loadURL(uri, '', this, updateCategories);
+}
+
+function updateCategories(response){
+ if (response.responseText.indexOf('no results') != -1) {
+ return;
+ }
+ document.getElementById('categories').innerHTML = response.responseText;
+ reCheckCategories();
+ reOpenCurrent();
}
/* load geo objects with an AJAX request */
@@ -282,6 +364,10 @@ var hidePopUp = function (evt) {
}
}
+var refreshMapItems = function (evt) {
+ loadCategories();
+}
+
/* update current detail panel with an AJAX request */
function updateDetail(pk){
var uri = "/" + extra_url + "getDetail/" + pk;
@@ -379,6 +465,7 @@ function init(){
map.addLayers([map_layer]);
map.events.register('click', map, hidePopUp);
+ map.events.register('moveend', map, refreshMapItems);
/* if from a permalink */
if (p_zoom) {
@@ -409,5 +496,6 @@ function init(){
/* if no extent in cookies zoom to default */
map.setCenter(centerLonLat, 13);
}
+ loadCategories();
loadGeoObjects();
}
diff --git a/chimere/static/styles.css b/chimere/static/styles.css
index 5e7e2cd..c6a0b97 100644
--- a/chimere/static/styles.css
+++ b/chimere/static/styles.css
@@ -13,11 +13,11 @@ border-radius: 10px;
legend{
font-weight:bold;
-color:#b400ff;
+color:#b400Ff;
}
a{
-color:#b400ff;
+color:#b400Ff;
}
h2{
@@ -28,7 +28,7 @@ margin-bottom:10px;
padding:0;
width:100%;
color:white;
-background-color:#b400ff;
+background-color:#b488ff;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
@@ -41,7 +41,7 @@ border-radius: 4px 4px 0 0;
}
h3{
-color:#b400ff;
+color:#b488ff;
}
h4{
@@ -88,8 +88,8 @@ background-color:#FFF;
}
#action li.selected{
-background-color:#b400ff;
-border-color:#b400ff;
+background-color:#b488ff;
+border-color:#b488ff;
color:white;
}
@@ -242,7 +242,7 @@ right:18px;
}
.detail_footer a{
-color:#b400ff;
+color:#b488ff;
padding:2px;
background-color:#FFF;
border:1px solid;
@@ -283,6 +283,7 @@ height:88%;
#map{
position:absolute;
+background-color:white;
border:1px solid #888;
margin:0px;
padding:0px;
@@ -310,31 +311,42 @@ padding:10px;
margin:0;
}
-ul#categories{
+#categories{
margin:0;
-padding:0 10px;
-overflow:auto;
+padding:0;
+width:290px;
height:160px;
-width:270px;
+overflow:auto;
+}
+
+#categories input {
+padding: 0;
+margin:0;
+vertical-align: bottom;
+}
+
+#categories ul{
+margin:0;
+padding:0 10px;
}
-ul#categories li{
+#categories li{
font-variant:small-caps;
list-style:none;
}
-ul#categories li li{
+#categories li li{
font-variant:normal;
margin-left:20px;
}
-ul#categories li li a{
+#categories li li a{
line-height:25px;
margin-left:0;
font-weight:bold;
}
-ul#categories ul{
+#categories ul ul{
margin:0;
padding:0;
}
@@ -343,9 +355,9 @@ ul.subcategories label img{
height:20px;
}
-ul#categories li#display_submited{
+#categories li#display_submited{
font-variant:normal;
-color:#b400ff;
+color:#b488ff;
}
.zoom_image{
@@ -358,7 +370,7 @@ vertical-align:text-bottom;
}
.errorlist{
-color:#b400ff;
+color:#b488ff;
font-weight:bold;
}
@@ -419,7 +431,7 @@ bottom:40px;
left:29px;
width:180px;
font-size:small;
-background-color:#b400ff;
+background-color:#b488ff;
text-align:center;
z-index:4;
}
@@ -439,7 +451,7 @@ bottom:12px;
left:20px;
width:180px;
font-size:small;
-background-color:#b400ff;
+background-color:#b488ff;
text-align:center;
}