diff options
Diffstat (limited to 'chimere/static')
| -rw-r--r-- | chimere/static/base.js | 63 | ||||
| -rw-r--r-- | chimere/static/edit_area.js | 51 | ||||
| -rw-r--r-- | chimere/static/edit_map.js | 146 | ||||
| -rw-r--r-- | chimere/static/edit_route_map.js | 121 | ||||
| -rw-r--r-- | chimere/static/forms.css | 49 | ||||
| -rw-r--r-- | chimere/static/icons/minus.png | bin | 0 -> 259 bytes | |||
| -rw-r--r-- | chimere/static/icons/plus.png | bin | 0 -> 275 bytes | |||
| -rw-r--r-- | chimere/static/icons/zoom.png | bin | 0 -> 655 bytes | |||
| -rw-r--r-- | chimere/static/main_map.js | 413 | ||||
| -rw-r--r-- | chimere/static/styles.css | 456 | ||||
| -rw-r--r-- | chimere/static/textareas.js | 27 |
11 files changed, 1326 insertions, 0 deletions
diff --git a/chimere/static/base.js b/chimere/static/base.js new file mode 100644 index 0000000..cabdf2a --- /dev/null +++ b/chimere/static/base.js @@ -0,0 +1,63 @@ +/* base function shared by some pages */ +/* Copyright (C) 2009 É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 +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +/* show a block panel */ +function show(id){ + document.getElementById(id).style.display = 'block'; +} + +/* hide a panel */ +function hide(id){ + document.getElementById(id).style.display = 'None'; +} + +function saveExtent() { + /* save the current extent in a cookie */ + if(!map) return; + document.cookie = "MAP_EXTENT=" + map.getExtent().toArray().join('_') + + ';path="/"'; +} + +function getExtent() { + /* get the current extent from a cookie */ + var cookies = document.cookie.split(';'); + var map_extent; + for (i in cookies){ + var items = cookies[i].split('='); + key = items[0].split(' ').join(''); + if (key == 'MAP_EXTENT'){ + map_extent = items[1].split('_'); + } + } + return map_extent; +} + +function zoomToCurrentExtent(map){ + /* zoom to current extent */ + var current_extent = getExtent(); + if (OpenLayers && current_extent && current_extent.length == 4){ + extent = new OpenLayers.Bounds(current_extent[0], current_extent[1], + current_extent[2], current_extent[3]); + map.zoomToExtent(extent, true); + return true; + } + else{ + return; + } +}
\ No newline at end of file diff --git a/chimere/static/edit_area.js b/chimere/static/edit_area.js new file mode 100644 index 0000000..4daccf3 --- /dev/null +++ b/chimere/static/edit_area.js @@ -0,0 +1,51 @@ +/* Copyright (C) 2008 É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 +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +/* area edit */ + +var map; + +/* update form fields on zoom action */ +function updateForm(){ + var bounds = map.getExtent(); + document.getElementById('upper_left_lat').value = bounds.top; + document.getElementById('upper_left_lon').value = bounds.left; + document.getElementById('lower_right_lat').value = bounds.bottom; + document.getElementById('lower_right_lon').value = bounds.right; +} + +/* main initialisation function */ +function init(){ + map = new OpenLayers.Map ('map_edit', { + controls:[new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PanPanel(), + new OpenLayers.Control.ZoomPanel(), + new OpenLayers.Control.Attribution()], + maxResolution: 156543.0399, + units: 'm', + projection: epsg_projection, + displayProjection: epsg_display_projection + } ); + map.addLayers([map_layer]); + map.events.register('zoomend', map, updateForm); + map.events.register('moveend', map, updateForm); + /* zoom to the appropriate extent */ + if (!zoomToCurrentExtent(map)){ + map.setCenter(centerLonLat, 12); + } +} diff --git a/chimere/static/edit_map.js b/chimere/static/edit_map.js new file mode 100644 index 0000000..8f37f6b --- /dev/null +++ b/chimere/static/edit_map.js @@ -0,0 +1,146 @@ +/* Copyright (C) 2008 É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 +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +/* map edit */ + +var map; + +/* availaible map layers */ +var layerMarkers = new OpenLayers.Layer.Markers('POIs'); + +/* default size and offset for icon */ +var size = new OpenLayers.Size(21, 25); +var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); +var icon = new OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png', size, offset); + +/* set a marker with a click on the map */ +var setMarker = function (event){ + event = event || window.event; + var lonlat = layerMarkers.getLonLatFromViewPortPx(event.xy); + putMarker(lonlat, false); + OpenLayers.Event.stop(event); +} + +/* put the marker on the map and update latitude and longitude fields */ +var putMarker = function (lonlat, zoom){ + if (marker) { + layerMarkers.removeMarker(marker); + } + var marker = new OpenLayers.Marker(lonlat.clone(), icon); + layerMarkers.addMarker(marker); + lonlat = lonlat.clone().transform(map.getProjectionObject(), + epsg_display_projection); + document.getElementById('id_point').value = 'POINT(' + lonlat.lon + + ' ' + lonlat.lat + ')'; + document.getElementById('live_latitude').value = lonlat.lon; + document.getElementById('live_longitude').value = lonlat.lat; + /*zoom to the point*/ + if (zoom){ + var bounds = layerMarkers.getDataExtent(); + if (bounds) map.zoomToExtent(bounds); + } + return; +} + +/* main initialisation function */ +function init(){ + var options = { + controls:[new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PanPanel(), + new OpenLayers.Control.ZoomPanel(), + new OpenLayers.Control.Attribution()], + maxResolution: 156543.0399, + units: 'm', + projection: epsg_projection, + displayProjection: epsg_display_projection + }; + if (restricted_extent){options['restrictedExtent'] = restricted_extent;} + map = new OpenLayers.Map ('map_edit', options); + layerMarkers.setOpacity(0.5); + map.addLayers([map_layer, layerMarkers]); + map.events.register('click', map, setMarker); + /* zoom to the appropriate extent */ + if (!zoomToCurrentExtent(map)){ + map.setCenter(centerLonLat, 12); + } +} + + +/* code for drag'n drop : delayed for further version of openlayers */ + +/* +function init_b(){ + init(); + + marker.events.register('mouseup', marker, releaseMarker); + marker.events.register('mousedown', marker, catchMarker); + marker.events.register('mouseover', marker, markerOver); + marker.events.register('mouseout', marker, markerOut); + + map.events.register('mousemove', map, onMouseMove); + map.events.register('moveend', map, onMoveEnd); +} + +var marker_catched = false; + +function catchMarker(event){ + marker_catched = true; + event = event || window.event; + OpenLayers.Event.stop(event); +} + +function releaseMarker(event){ + event = event || window.event; + if(marker_catched) { + marker_catched = false; + lonlat = layerMarkers.getLonLatFromViewPortPx(marker.icon.px); + marker.lonlat = lonlat; + document.getElementById('latitude').value = marker.lonlat.lat; + document.getElementById('longitude').value = marker.lonlat.lon; + } + OpenLayers.Event.stop(event); +} + +function onMouseMove(event) { + event = event || window.event; + if (!marker_catched) {return;} + marker.icon.px = null; + marker.icon.moveTo(new OpenLayers.Pixel(event.xy.x + delta_x, + event.xy.y + delta_y + 20)); + defLiveLatLon(); + lonlat = layerMarkers.getLonLatFromViewPortPx(marker.icon.px).transform(epsg_projection, epsg_display_projection); + live_longitude.value = lonlat.lon; + live_latitude.value = lonlat.lat; + OpenLayers.Event.stop(event); +} + +function onMoveEnd(event) { + event = event || window.event; + marker.icon.px = map.getPixelFromLonLat(marker.lonlat); + OpenLayers.Event.stop(event); +} + +var markerOver = function (evt) { + document.body.style.cursor='pointer'; + OpenLayers.Event.stop(evt); +}; +var markerOut = function (evt) { + document.body.style.cursor='auto'; + OpenLayers.Event.stop(evt); +}; +*/ diff --git a/chimere/static/edit_route_map.js b/chimere/static/edit_route_map.js new file mode 100644 index 0000000..dcf7c84 --- /dev/null +++ b/chimere/static/edit_route_map.js @@ -0,0 +1,121 @@ +/* Copyright (C) 2008 É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 +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +/* map edit */ + +var map; +var currentControl; + +/* availaible map layers */ +var vectors = new OpenLayers.Layer.Vector("Vector Layer"); + +vectors.events.on({ + "featuremodified": updateForm, + "featureadded": featureCreated +}); + +var currentFeature; +function featureCreated(event) { + /* toggle to edition mode */ + pathCreate.deactivate(); + currentControl = pathModify; + var help_route_create = document.getElementById('help-route-create'); + if (help_route_create){ + help_route_create.style.display = 'None'; + } + document.getElementById('help-route-modify').style.display = 'block'; + + pathModify.activate(); + updateForm(event); + pathModify.selectControl.select(event.feature); + +} + +function initFeature(json_geometry){ + var json = new OpenLayers.Format.JSON(); + var polyline = json.read(json_geometry); + var point_array = new Array(); + for (i=0; i<polyline.coordinates.length; i++){ + var point = new OpenLayers.Geometry.Point(polyline.coordinates[i][0], + polyline.coordinates[i][1]); + point_array.push(point); + } + var linestring = new OpenLayers.Geometry.LineString(point_array); + currentFeature = new OpenLayers.Feature.Vector(); + currentFeature.geometry = linestring; + vectors.addFeatures([currentFeature]); + currentControl = pathModify; + /*zoom to the route*/ + var bounds = vectors.getDataExtent(); + if (bounds) map.zoomToExtent(bounds); +} + +function updateForm(event) { + /* update the form */ + currentFeature = event.feature; + document.getElementById('id_route').value = currentFeature.geometry; +} + + +/* path control */ +var pathCreate = new OpenLayers.Control.DrawFeature(vectors, + OpenLayers.Handler.Path); +var currentControl = pathCreate; + +var pathModify = new OpenLayers.Control.ModifyFeature(vectors, + {clickout:false, toggle:false}); + +/* main initialisation function */ +function init(){ + var options = { + controls:[new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PanPanel(), + new OpenLayers.Control.ZoomPanel(), + new OpenLayers.Control.Attribution(), + pathCreate, + pathModify], + maxResolution: 156543.0399, + units: 'm', + projection: epsg_projection, + displayProjection: epsg_display_projection, + }; + if (restricted_extent){options['restrictedExtent'] = restricted_extent;} + map = new OpenLayers.Map('map_edit', options); + + vectors.setOpacity(0.5); + map.addLayers([map_layer, vectors]); + /* zoom to the appropriate extent */ + if (!zoomToCurrentExtent(map)){ + map.setCenter(centerLonLat, 12); + } +} + +function toggleDrawOn() { + currentControl.activate(); + document.getElementById('draw-toggle-off').style.display = 'None'; + document.getElementById('draw-toggle-on').style.display = 'block'; + if (currentFeature){ + pathModify.selectControl.select(currentFeature); + } +} + +function toggleDrawOff() { + currentControl.deactivate(); + document.getElementById('draw-toggle-on').style.display = 'None'; + document.getElementById('draw-toggle-off').style.display = 'block'; +} diff --git a/chimere/static/forms.css b/chimere/static/forms.css new file mode 100644 index 0000000..c8e4939 --- /dev/null +++ b/chimere/static/forms.css @@ -0,0 +1,49 @@ +#map_edit{ +border: 1px solid black; +width:700px; +height:400px; +float:left; +} + +#live_lonlat{ +margin:1em; +float:left; +} + +.toggle-button{ +float:left; +padding:4px; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +border:1px solid grey; +} + +#draw-toggle-off{ +color:black; +} + +#draw-toggle-on{ +background-color:lightgrey; +display:None; +} + +.help-route{ +width:700px; +background-color:#EEF;; +margin: 10px 0px; +float:left; +padding:0 4px; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +border:1px solid grey; +} + +#help-route-create{ +} + +#help-route-modify{ +display:None +} + diff --git a/chimere/static/icons/minus.png b/chimere/static/icons/minus.png Binary files differnew file mode 100644 index 0000000..a95822f --- /dev/null +++ b/chimere/static/icons/minus.png diff --git a/chimere/static/icons/plus.png b/chimere/static/icons/plus.png Binary files differnew file mode 100644 index 0000000..404a24a --- /dev/null +++ b/chimere/static/icons/plus.png diff --git a/chimere/static/icons/zoom.png b/chimere/static/icons/zoom.png Binary files differnew file mode 100644 index 0000000..3a53680 --- /dev/null +++ b/chimere/static/icons/zoom.png diff --git a/chimere/static/main_map.js b/chimere/static/main_map.js new file mode 100644 index 0000000..1849713 --- /dev/null +++ b/chimere/static/main_map.js @@ -0,0 +1,413 @@ +/* Copyright (C) 2008 É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 +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +/* main map */ + +var current_cat; + +/* open a category section */ +function toggleCategory(id){ + old = document.getElementById('maincategory_' + current_cat) + if(old){ + old.style.display = 'None'; + old_img = document.getElementById('maincategory_img_' + current_cat); + old_img.src = "/" + extra_url + "static/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"; + } else { + current_cat = 0; + } +} + +/* check all the categories if clicked, unckeck if unclick */ +function checkAll(item, ids){ + check = false; + if(item.checked == true){ + check = true; + } + for (i in ids){ + document.getElementById('category_'+ids[i]).checked = check; + } +} + +var map; +var permalink; + +/* default size and offset for icon */ +var size = new OpenLayers.Size(21, 25); +var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); + +/* define global variable */ +var markers = new Array(); +var layerMarkers; +var layerVectors; + +var currentPopup; +var currentFeature; +var clicked = false; + +/* show a popup */ +function showPop(feature) { + if (currentPopup != null) { + currentPopup.hide(); + } + if (feature.popup == null) { + feature.popup = feature.createPopup(); + map.addPopup(feature.popup); + } else { + feature.popup.toggle(); + } + currentPopup = feature.popup; + /* hide on click on the cloud */ + currentPopup.groupDiv.onclick = hidePopUp; +} + +/* check checked categories */ +var checked_categories; +var display_submited = false; + +function updateCheckedCategories(){ + /* get checked categories */ + inputs = window.document.forms["frm_categories"]; + checked_categories = ''; + display_submited = false; + for (var i = 0; i < inputs.length; i++) { + input = inputs[i]; + // 'category_'.length : 9 + if (input.checked + && input.name.substring(9, 0) == 'category_'){ + id = input.name.substring(9, input.name.length); + if(checked_categories) checked_categories += '_'; + checked_categories += id; + } + if (input.checked && input.name == 'display_submited'){ + display_submited = true; + } + } + permalink.updateLink(); +} + +/* load marker and route layer from a JSON feature string */ +function loadLayersFromJSON(layer_markers, layer_vectors, geo_objects){ + for (var i = 0; i < geo_objects.features.length; i++) { + var feature = geo_objects.features[i]; + if (feature.geometry.type == 'Point'){ + putMarker(layer_markers, feature); + } else if (feature.geometry.type == 'LineString') { + putRoute(layer_vectors, feature); + } + } +} + +/* zoom to an area */ +function zoomToArea(top, left, bottom, right){ + var bounds = new OpenLayers.Bounds(left, bottom, right, top); + map.zoomToExtent(bounds, true); +} + +/* zoom to a desired category */ +function zoomToCategory(categorie_ids){ + updateCheckedCategories(); + /* 0 stand for all categories */ + var uri = "/" + extra_url + "getGeoObjects/" + categorie_ids; + if (display_submited) uri += "/A_S"; + OpenLayers.loadURL(uri, '', this, zoomToCategoryExtent); +} + +/* zoom to a selected category from an http response GeoJSON */ +function zoomToCategoryExtent(response){ + if (response.responseText.indexOf('no results') != -1) return; + var fakeLayerVectors = new OpenLayers.Layer.Vector("Fake vector layer"); + var fakeLayerMarkers = new OpenLayers.Layer.Markers('Fake POIs layer'); + var json = new OpenLayers.Format.JSON(); + var geo_objects = json.read(response.responseText); + /* load every geo object */ + loadLayersFromJSON(fakeLayerMarkers, fakeLayerVectors, geo_objects); + var bounds = fakeLayerMarkers.getDataExtent(); + if (bounds){ + bounds.extend(fakeLayerVectors.getDataExtent()); + } else { + bounds = fakeLayerVectors.getDataExtent(); + } + if(bounds){ + map.zoomToExtent(bounds); + } + fakeLayerMarkers.destroy(); + fakeLayerVectors.destroy(); +} + +/* load geo objects with an AJAX request */ +function loadGeoObjects(){ + updateCheckedCategories(); + /* 0 stand for all categories */ + if (!checked_categories) checked_categories = '0'; + var uri = "/" + extra_url + "getGeoObjects/" + checked_categories; + if (display_submited) uri += "/A_S"; + OpenLayers.loadURL(uri, '', this, setGeoObjects); +} + +/* update the marker and vector layers from an http response GeoJSON */ +function setGeoObjects(response){ + if(layerMarkers) layerMarkers.destroy(); + if(layerVectors) layerVectors.destroy(); + if (response.responseText.indexOf('no results') == -1) { + /* clean the marker layer */ + if (currentPopup) { + currentPopup.hide(); + hide('detail'); + } + layerVectors = new OpenLayers.Layer.Vector("Vector Layer"); + map.addLayer(layerVectors); + layerVectors.setOpacity(0.8); + layerMarkers = new OpenLayers.Layer.Markers('POIs'); + map.addLayer(layerMarkers); + layerMarkers.setOpacity(0.8); + + var json = new OpenLayers.Format.JSON(); + var geo_objects = json.read(response.responseText); + /* load every geo object */ + loadLayersFromJSON(layerMarkers, layerVectors, geo_objects); + /* + var geojson = new OpenLayers.Format.GeoJSON(); + var markers_pt = geojson.read(response.responseText); + for (var i = 0; i < markers_pt.length; i++) { + putMarker2(markers_pt[i]); + }*/ + } +} + +/* put a route on the map */ +function putRoute(layer, route) { + var polyline = route.geometry; + var point_array = new Array(); + for (i=0; i<polyline.coordinates.length; i++){ + var point = new OpenLayers.Geometry.Point(polyline.coordinates[i][0], + polyline.coordinates[i][1]); + point_array.push(point); + } + var linestring = new OpenLayers.Geometry.LineString(point_array); + currentFeature = new OpenLayers.Feature.Vector(); + + var style = OpenLayers.Util.extend({}, + OpenLayers.Feature.Vector.style['default']); + style.strokeColor = route.properties.color; + style.strokeWidth = 3; + currentFeature.style = style; + currentFeature.geometry = linestring; + layer.addFeatures([currentFeature]); +} + + +/* put a marker on the map */ +function putMarker(layer, mark) { + /* initialise a new marker with appropriate attribute for setting a + marker */ + lat = mark.geometry.coordinates[1]; + lon = mark.geometry.coordinates[0]; + var size = new OpenLayers.Size(mark.properties.icon_width, + mark.properties.icon_height); + iconclone = new OpenLayers.Icon(media_path + mark.properties.icon_path, + size, offset); + var feature = new OpenLayers.Feature(markers, + new OpenLayers.LonLat(lon, lat).transform(epsg_display_projection, + epsg_projection), + {icon:iconclone}); + /*feature.closeBox = false;*/ + feature.pk = mark.properties.pk; + feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud); + feature.data.popupContentHTML = "<div class='cloud'>"; + feature.data.popupContentHTML += mark.properties.name; + feature.data.popupContentHTML += "</div>"; + feature.data.overflow = 'hidden'; + var marker = feature.createMarker(); + /* manage markers events */ + var markerClick = function (evt) { + currentFeature = this; + if (clicked) { + if (currentPopup == this.popup) { + this.popup.hide(); + clicked = false; + hide('detail'); + } else { + currentPopup.hide(); + showPop(this); + updateDetail(this.pk); + } + } else { + showPop(this); + clicked = true; + updateDetail(this.pk); + } + OpenLayers.Event.stop(evt); + }; + var markerOver = function (evt) { + document.body.style.cursor='pointer'; + OpenLayers.Event.stop(evt); + }; + var markerOut = function (evt) { + document.body.style.cursor='auto'; + OpenLayers.Event.stop(evt); + }; + marker.events.register('click', feature, markerClick); + marker.events.register('mouseover', feature, markerOver); + marker.events.register('mouseout', feature, markerOut); + layer.addMarker(marker); + return feature; +} + +var hidePopUp = function (evt) { + if (clicked) { + currentPopup.hide(); + clicked = false; + hide('detail'); + } +} + +/* update current detail panel with an AJAX request */ +function updateDetail(pk){ + var uri = "/" + extra_url + "getDetail/" + pk; + OpenLayers.loadURL(uri, '', this, setDetail); +} + +/* update the detail panel from an http response */ +function setDetail(response){ + if (response.responseText.indexOf('no results') == -1) { + document.getElementById('detail').innerHTML = response.responseText; + show('detail'); + } +} + +/* show the detail of a category */ +function displayCategoryDetail(category_id) { + var uri = "/" + extra_url + "getDescriptionDetail/" + category_id; + OpenLayers.loadURL(uri, '', this, setCategoryDetail); +} + +/* update the category detail panel from an http response */ +function setCategoryDetail(response){ + if (response.responseText.indexOf('no results') == -1) { + document.getElementById('category_detail').innerHTML = + response.responseText; + show('category_detail'); + } +} + +/* new permalink createParams method - update when facilities are given to +personalize the permalink */ +function createParams(center, zoom, layers) { + center = center || this.map.getCenter(); + var params = OpenLayers.Util.getParameters(this.base); + // If there's still no center, map is not initialized yet. + // Break out of this function, and simply return the params from the + // base link. + if (center) { + //zoom + params.zoom = zoom || this.map.getZoom(); + //lon,lat + var lat = center.lat; + var lon = center.lon; + if (this.displayProjection) { + var mapPosition = OpenLayers.Projection.transform( + { x: lon, y: lat }, + this.map.getProjectionObject(), + this.displayProjection ); + lon = mapPosition.x; + lat = mapPosition.y; + } + params.lat = Math.round(lat*100000)/100000; + params.lon = Math.round(lon*100000)/100000; + //layers + layers = layers || this.map.layers; + params.layers = ''; + for (var i=0, len=layers.length; i<len; i++) { + var layer = layers[i]; + + if (layer.isBaseLayer) { + params.layers += (layer == this.map.baseLayer) ? "B" : "0"; + } else { + params.layers += (layer.getVisibility()) ? "T" : "F"; + } + } + /* only piece of code added */ + params.checked_categories = checked_categories; + params.display_submited = display_submited; + } + return params; +} + +/* main initialisation function */ +function init(){ + /* set the main map */ + var options = { + controls:[new OpenLayers.Control.Navigation(), + new OpenLayers.Control.PanPanel(), + new OpenLayers.Control.ZoomPanel(), + new OpenLayers.Control.ScaleLine()], + maxResolution: 156543.0399, + units: 'm', + projection: new OpenLayers.Projection('EPSG:4326'), + theme:null, + }; + if (restricted_extent){options['restrictedExtent'] = restricted_extent;} + map = new OpenLayers.Map('map', options); + permalink = new OpenLayers.Control.Permalink("permalink"); + permalink.createParams = createParams; + map.addControl(permalink); + // update with the translated permalink label + if(permalink_label && permalink.div && permalink.div.childNodes.length > 0){ + permalink.div.childNodes[0].textContent = permalink_label; + } + map.addLayers([map_layer]); + + map.events.register('click', map, hidePopUp); + + /* if from a permalink */ + if (p_zoom) { + var p_centerLonLat = new OpenLayers.LonLat(p_lon, p_lat); + map.setCenter(p_centerLonLat, p_zoom); + if (p_display_submited) { + document.getElementById('display_submited_check').checked = true; + } + if (p_checked_categories){ + /* ckeck selected categories and uncheck others */ + inputs = window.document.forms["frm_categories"]; + for (var i = 0; i < inputs.length; i++) { + input = inputs[i]; + if (input.name.substring(9, 0) == 'category_'){ + id = input.name.substring(9, input.name.length); + input.checked = false; + for (var cc=0; cc < p_checked_categories.length; cc++){ + if (p_checked_categories[cc] == id){ + input.checked = true; + } + } + } + } + } + } + /* if not zoom to the extent in cookies */ + else if (!zoomToCurrentExtent(map)){ + /* if no extent in cookies zoom to default */ + map.setCenter(centerLonLat, 13); + } + loadGeoObjects(); +} diff --git a/chimere/static/styles.css b/chimere/static/styles.css new file mode 100644 index 0000000..5e7e2cd --- /dev/null +++ b/chimere/static/styles.css @@ -0,0 +1,456 @@ +body{ +background-color:#b488ff; +font-family:arial; +font-size:80%; +} + +fieldset{ +background-color:#FFF; +-moz-border-radius: 10px; +-webkit-border-radius: 10px; +border-radius: 10px; +} + +legend{ +font-weight:bold; +color:#b400ff; +} + +a{ +color:#b400ff; +} + +h2{ +font-size:16px; +text-align:center; +margin:0; +margin-bottom:10px; +padding:0; +width:100%; +color:white; +background-color:#b400ff; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +} + +#areas h2, #panel h2{ +-moz-border-radius: 4px 4px 0 0; +-webkit-border-radius: 4px 4px 0 0; +border-radius: 4px 4px 0 0; +} + +h3{ +color:#b400ff; +} + +h4{ +color:#5e1e68; +font-weight:normal; +font-style:italic; +} + +hr.spacer{ +clear:both; +border:None; +visibility: hidden; +} + +fieldset{ +margin-top:8px; +} + +.edit label{ +display:block; +} + +ul#action{ +position:absolute; +z-index:5; +list-style-type:none; +top:20px; +left:80px; +margin:0; +padding:3px; +padding-left:0; +} + +#action li{ +font-size:15px; +display:inline; +padding:1px 5px; +margin-right:6px; +border:1px solid #888; +-moz-border-radius: 4px; +-webkit-border-radius: 4px; +border-radius: 4px; +background-color:#FFF; +} + +#action li.selected{ +background-color:#b400ff; +border-color:#b400ff; +color:white; +} + +#action a{ +text-decoration:None; +color:black; +} + +#action li ul{ +margin:8px 6px; +position:absolute; +width:600px; +} + +#action li.selected a{ +color:white; +} + +#action li.selected li a{ +color:black; +} + +#action li.selected li.selected a{ +color:white; +} + +#content{ +margin:4px; +margin-top:14px; +padding:20px; +padding-top:46px; +background-color:white; +-moz-border-radius: 10px; +-webkit-border-radius: 10px; +border-radius: 10px; +border:1px solid #888; +} + +#footer{ +text-align:center; +} + +#map-footer{ +position:absolute; +z-index:5; +background-color:white; +bottom:5px; +right:5px; +border:1px solid #888; +padding:2px; +} + +#panel{ +padding:0; +border:1px solid #888; +height:200px; +position:absolute; +z-index:5; +top:50px; +bottom:20px; +right:18px; +width:300px; +background-color:#FFF; +opacity:0.8; +-moz-border-radius:10px; +-webkit-border-radius:10px; +border-radius:10px; +} + +#areas{ +padding:0; +border:1px solid #888; +height:115px; +position:absolute; +z-index:5; +bottom:105px; +left:18px; +width:200px; +background-color:#FFF; +opacity:0.8; +-moz-border-radius:10px; +-webkit-border-radius:10px; +border-radius:10px; +overflow:auto; +} + +#areas ul{ +margin:0; +padding:0 10px; +} + +#areas li{ +list-style:none; +} + +#popup_link{ +text-align:center; +} + +#welcome{ +padding:6px 10px; +border:1px solid #888; +position:absolute; +z-index:5; +top:50px; +bottom:102px; +left:80px; +margin-right:360px; +background-color:#FFF; +opacity:0.9; +-moz-border-radius:10px; +-webkit-border-radius:10px; +border-radius:10px; +} + +#detail{ +display:None; +padding:6px 10px; +border:1px solid #888; +position:absolute; +z-index:5; +top:274px; +bottom:38px; +right:18px; +width:300px; +background-color:#FFF; +-moz-border-radius:10px; +-webkit-border-radius:10px; +border-radius:10px; +} + +#detail_content{ +overflow:auto; +height:90%; +} + +#detail_content img{ +width:280px; +} + +#welcome h2{ +padding:10px 0; +} + +.detail_footer{ +text-align:center; +position:absolute; +top:15px; +right:18px; +} + +.detail_footer a{ +color:#b400ff; +padding:2px; +background-color:#FFF; +border:1px solid; +display:block; +text-decoration:None; +-moz-border-radius:4px; +-webkit-border-radius:4px; +border-radius:4px; +} + +#category_detail{ +display:None; +padding:6px 10px; +border:1px solid #888; +position:absolute; +z-index:5; +top:120px; +bottom:180px; +left:100px; +right:50px; +margin-right:360px; +background-color:#FFF; +opacity:0.9; +-moz-border-radius:10px; +-webkit-border-radius:10px; +border-radius:10px; +} + +#category_detail h2{ +padding:10px 0; +} + + +#category_desc_content{ +overflow:auto; +height:88%; +} + +#map{ +position:absolute; +border:1px solid #888; +margin:0px; +padding:0px; +height:98%; +margin:0; +padding:0; +top:8px; +bottom:8px; +left:8px; +right:8px; +z-index:0; +} + +.news{ +} + +.news h3{ +padding:0px; +margin:0; +} + +.info{ +border-top:1px dashed; +padding:10px; +margin:0; +} + +ul#categories{ +margin:0; +padding:0 10px; +overflow:auto; +height:160px; +width:270px; +} + +ul#categories li{ +font-variant:small-caps; +list-style:none; +} + +ul#categories li li{ +font-variant:normal; +margin-left:20px; +} + +ul#categories li li a{ +line-height:25px; +margin-left:0; +font-weight:bold; +} + +ul#categories ul{ +margin:0; +padding:0; +} + +ul.subcategories label img{ +height:20px; +} + +ul#categories li#display_submited{ +font-variant:normal; +color:#b400ff; +} + +.zoom_image{ +cursor:pointer; +} + +.control_image{ +cursor:pointer; +vertical-align:text-bottom; +} + +.errorlist{ +color:#b400ff; +font-weight:bold; +} + +.fieldWrapper{ +padding:6px; +} + +div.warning{ +margin-top:18px; +padding:0 10px; +border:1px solid #888; +-moz-border-radius: 10px; +-webkit-border-radius: 10px; +border-radius: 10px; +background-color:#ffdbdb; +} + +#logos{ +text-align:center; +z-index:5; +position: absolute; +bottom:46px; +left:18px; +} + +#logos ul{ +margin:0; +margin-right:20px; +padding:4px; +border:1px solid #888; +-moz-border-radius: 10px; +-webkit-border-radius: 10px; +border-radius: 10px; +background-color:white; +height:40px; +float:left; +} + +#logos li{ +display:inline; +} + +#logos img{ +height:40px; +text-decoration:None; +border-width:0; +} + +#logos li a{ +text-decoration:None; +border-width:0; +} + +#welcome_button { +display: block; +position: absolute; +bottom:40px; +left:29px; +width:180px; +font-size:small; +background-color:#b400ff; +text-align:center; +z-index:4; +} + +#welcome_button a{ +color:white; +font-size:14px; +text-align:center; +text-decoration:none; +} + +/* openlayer customisation */ +.olControlPermalink { +display: block; +position: absolute; +bottom:12px; +left:20px; +width:180px; +font-size:small; +background-color:#b400ff; +text-align:center; +} + +.olControlPermalink a{ +color:white; +font-size:14px; +text-align:center; +text-decoration:none; +} + +.olControlScaleLine { +bottom:12px; +left:220px; +} diff --git a/chimere/static/textareas.js b/chimere/static/textareas.js new file mode 100644 index 0000000..fec83b8 --- /dev/null +++ b/chimere/static/textareas.js @@ -0,0 +1,27 @@ +/* base function shared by some pages */ +/* Copyright (C) 2009 É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 +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +See the file COPYING for details. +*/ + +tinyMCE.init({ + mode : "textareas", + theme : "advanced", + relative_urls : false, + theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,bullist,numlist,separator,hr,separator,link", + theme_advanced_buttons2 : "", + theme_advanced_buttons3 : "" +}); |
