fixed transparent background of popups

fixed popup border image location
fixed charset encoding issues
This commit is contained in:
lars 2011-03-09 00:01:15 +00:00
parent 38b7268e27
commit 039c5947a5
3 changed files with 41 additions and 38 deletions

View file

@ -31,3 +31,7 @@ div.event_map_info li {
font-size: x-small;
}
div.event_GroupDiv {
background-color: white;
}

View file

@ -20,6 +20,10 @@ var event_map_zoom_default_for_events = 13;
var event_map_zoom_default_for_marker = 15;
var event_map_zoom_default_for_edit = 12;
// location of the "cloud popup" mini images (e.g. "west-mini.png")
// checkout from: http://svn.openlayers.org/trunk/openlayers/img
var openlayers_images_url = "/event_map/html/external/openlayers-img/";
// names of fields to be manipulated in "edit" mode
var event_map_fieldname_lat = "edit-field-lat-0-value";
var event_map_fieldname_lon = "edit-field-long-0-value";
@ -117,8 +121,13 @@ function event_map_addCSSfile(cssfile, pos) {
}
event_map_addJavascript('http://www.openlayers.org/api/OpenLayers.js', 'head');
event_map_addJavascript('http://www.openstreetmap.org/openlayers/OpenStreetMap.js', 'head');
/* make sure, OpenLayers and OpenStreetMap js files are loaded in the correct order.
* We accomplish this by providing a combined download file for both.
*/
//event_map_addJavascript('http://www.openlayers.org/api/OpenLayers.js', 'head');
//event_map_addJavascript('http://www.openstreetmap.org/openlayers/OpenStreetMap.js', 'head');
event_map_addJavascript(event_map_base_url + 'html/external/combined.js', 'head')
// in case of problems of a browser with loading external ccs files, we could use the local copy
//event_map_addCSSfile(event_map_base_url + 'html/openlayers/style.css', 'head');
event_map_addCSSfile('http://openlayers.org/api/theme/default/style.css', 'head');
@ -126,6 +135,8 @@ event_map_addCSSfile(event_map_css_file, 'head');
function event_map_init() {
OpenLayers.ImgPath = openlayers_images_url;
OpenLayers.Lang.setCode("de");
event_map = new OpenLayers.Map('event_map', {
maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34),
numZoomLevels: 19,
@ -149,17 +160,19 @@ function event_map_init() {
});
var layerOePNV = new OpenLayers.Layer.OSM.OePNV("ÖPNV-Karte");
var layerCycle = new OpenLayers.Layer.OSM.CycleMap("Radweg-Karte");
var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
var layerTah = new OpenLayers.Layer.OSM.Osmarender("Osmarender");
var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Stadtplan");
var layerOePNV = new OpenLayers.Layer.OSM.OePNV("Nahverkehr");
var layerCycle = new OpenLayers.Layer.OSM.CycleMap("Radwege");
var layerTah = new OpenLayers.Layer.OSM.Osmarender("Detailliert");
event_map.addLayers([layerOePNV, layerCycle, layerMapnik, layerTah]);
event_map.addLayers([layerOePNV, layerCycle, layerMapnik]);
// choose default layer
event_map.setBaseLayer(layerMapnik);
if (event_map_display_type == 'marker') {
event_map_marker_layer = new OpenLayers.Layer.Markers("Markierung");
event_map.addLayer(event_map_marker_layer)
event_map.addLayer(event_map_marker_layer);
}
// allow to change the current layer (mapnik/tah/oepnv/cycle)
event_map.addControl(new OpenLayers.Control.LayerSwitcher());
@ -253,6 +266,7 @@ function event_map_show_marker(lonLat) {
function event_map_show_gml() {
OpenLayers.ImgPath = openlayers_images_url;
OpenLayers.Feature.prototype.popupClass = OpenLayers.Popup.FramedCloud;
var pois = new OpenLayers.Layer.GML("Veranstaltungen", event_map_gml_file, {
@ -292,6 +306,7 @@ function event_map_edit_clicked(evnt) {
function event_map_onFeatureSelect(feature) {
OpenLayers.ImgPath = openlayers_images_url;
selectedFeature = feature;
var content = '<div class="event_map_info">';
content += '<h1>' + feature.attributes.title + '</h1>';
@ -324,7 +339,9 @@ function event_map_onFeatureSelect(feature) {
feature.geometry.getBounds().getCenterLonLat(),
new OpenLayers.Size(300, 200),
content,
null, true, event_map_onPopupClose);
null,
true,
event_map_onPopupClose);
popup.maxSize = new OpenLayers.Size(350, 300);
feature.popup = popup;
event_map.addPopup(popup);

View file

@ -83,7 +83,6 @@ ICON_SIZES = {
}
# used for "html_escape" below
HTML_ESCAPE_TABLE = {
"&": "&amp;",
'"': "&quot;",
@ -104,17 +103,12 @@ TIME_OFFSET_HOURS = {
}
def htmlentitydecode(s):
# convert html enitities to unicode (taken from: http://wiki.python.org/moin/EscapingHtml)
return re.sub('&(%s);' % '|'.join(htmlentitydefs.name2codepoint),
lambda m: unichr(htmlentitydefs.name2codepoint[m.group(1)]), s)
def htmlentityencode(s):
# convert unicode to html enitities (taken from: http://wiki.python.org/moin/EscapingHtml)
def html_escape(s):
result = []
for char in s:
if ord(char) > 127:
if char in HTML_ESCAPE_TABLE:
result.append(HTML_ESCAPE_TABLE[char])
elif ord(char) > 127:
result.append("&#%d;" % ord(char))
else:
result.append(char)
@ -202,7 +196,7 @@ class EventParser(HTMLParser.HTMLParser, object):
pass
elif self.current_attribute == COLUMNS['title']:
# maybe the title is splitted by an ampersand entity
event['title'] = event.get('title', '') + htmlentityencode(data)
event['title'] = event.get('title', '') + html_escape(data)
elif self.current_attribute == COLUMNS['time']:
if event.has_key("time"):
# the first "time" field is the start
@ -223,13 +217,13 @@ class EventParser(HTMLParser.HTMLParser, object):
elif self.current_attribute == COLUMNS['category']:
event['category'] = data.strip()
elif self.current_attribute == COLUMNS['place']:
event['place'] = event.get('place', '') + htmlentityencode(data)
event['place'] = event.get('place', '') + html_escape(data)
elif self.current_attribute == COLUMNS['latitude']:
event['latitude'] = data.strip()
elif self.current_attribute == COLUMNS['longitude']:
event['longitude'] = data.strip()
elif self.current_attribute == COLUMNS['organizer']:
event['organizer'] = event.get('organizer', '') + htmlentityencode(data)
event['organizer'] = event.get('organizer', '') + html_escape(data)
else:
sys.stderr.write("UNKNOWN ATTRIBUTE: %d (%s)\n" % (self.current_attribute, data.encode(INPUT_ENCODING)))
@ -268,15 +262,7 @@ def get_date_string(timestamp):
sys.stderr.write("Locales (%s) not found: %s\n" % (LOCALE, err_msg) \
+ " Maybe you should run 'aptitude install locales-all' on debian.\n")
localtime = time.localtime(timestamp)
return htmlentityencode(time.strftime(locale.nl_langinfo(locale.D_T_FMT), localtime))
def html_escape(text):
"""Produce entities within text."""
chars = []
for c in text:
chars.append(HTML_ESCAPE_TABLE.get(c, c))
return "".join(chars)
return html_escape(time.strftime(locale.nl_langinfo(locale.D_T_FMT), localtime))
def get_data_from_html(html):
@ -353,10 +339,6 @@ def get_gml_from_data(data):
for place in group_sorted_events_by_location(data):
result.append([])
event = place[0]
# escape some html entities
for item in ["title", "place", "organizer"]:
if event.has_key(item):
event[item] = html_escape(event[item])
items = result[-1]
# the 'point'
items.append('%(latitude)s,%(longitude)s' % event)
@ -381,8 +363,8 @@ def get_gml_from_data(data):
description += '<li style="list-style-image:url(%s)">' \
% get_icon_url(other_event["category"], None)
description += '%s: <a href="%s" title="Details" target="_blank">%s</a></li>' \
% (html_escape(get_date_string(other_event["time"]).decode(DATE_ENCODING)),
other_event["event_url"], html_escape(other_event["title"]))
% (get_date_string(other_event["time"]).decode(DATE_ENCODING),
other_event["event_url"], other_event["title"])
description += '</ul></li>'
description += '</ul>'
items.append(description)