Now the thumbnail image is shown for foto entries.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 3 Nov 2013 20:42:21 +0000 (20:42 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sun, 3 Nov 2013 20:42:21 +0000 (20:42 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1786 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.body.php
wrmap.js

index 73fdf3b64df3d109be62df0be60c89c9b25104f4..2245d6e0b8fdf3ec6b5eb2d38c32220aef8ce205 100644 (file)
@@ -154,7 +154,7 @@ class WrBaseMap {
                                        if ($property == 'wiki') {
                                                $title = Title::newFromText($propval);
                                                $propval = $title->getLocalUrl();
-                                               $file_url = WrBaseMap::wikipage_to_image($title, 300);
+                                               $file_url = WrBaseMap::wikipage_to_image($title, 200);
                                                if (!is_null($file_url)) $properties['thumb_url'] = $file_url;
                                        }
                                        $properties[$property] = $propval;
index aca6cc0c2d6880178bf083dae3e9e0627133cf36..e7142c5fc71fb395d1d4fad0bdd68d95838e80da 100644 (file)
--- a/wrmap.js
+++ b/wrmap.js
@@ -228,29 +228,42 @@ function init_wrmap(i, jq_map) {
                autoActivate: true,
                toggle: true,
                onSelect: function(feature) {
+                       var attr = feature.attributes;
                        var popup_div = createElement('div');
-                       if (feature.attributes.type == 'sledrun') {
-                               popup_div.append(createElement('h2').text(feature.attributes.name));
+
+                       // name
+                       if (attr.name !== undefined && (attr.wiki !== undefined || attr.thumb_url !== undefined))
+                               popup_div.append(createElement('h2').text(attr.name));
+
+                       // sledrun information
+                       if (attr.type == 'sledrun') {
                                var ul = appendElement(popup_div, 'ul');
-                               ul.append(createElement('li').append(createElement('a', {'href': feature.attributes.wiki}).text('Details zur Rodelbahn')));
+                               ul.append(createElement('li').append(createElement('a', {'href': attr.wiki}).text('Details zur Rodelbahn')));
                                var li = appendElement(ul, 'li').text('Rodelbahnzustand').append(createElement('br'));
-                               if (feature.attributes.condition !== undefined) {
+                               if (attr.condition !== undefined) {
                                        var condition_text = {1: 'Sehr gut', 2: 'Gut', 3: 'Mittelmäßig', 4: 'Schlecht', 5: 'Geht nicht'};
-                                       var year_month_day = feature.attributes.date_report.split('-');
-                                       li.append(createElement('a', {'href': feature.attributes.wiki + '#Eintr.C3.A4ge'}).text(condition_text[feature.attributes.condition]), ' ');
+                                       var year_month_day = attr.date_report.split('-');
+                                       li.append(createElement('a', {'href': attr.wiki + '#Eintr.C3.A4ge'}).text(condition_text[attr.condition]), ' ');
                                        li.append(createElement('small').text(year_month_day[2] + '.' + year_month_day[1] + '.'), ' ');
-                                       li.append(createElement('em').append(createElement('a', {'href': feature.attributes.wiki + '#Eintragen'}).text('Neu')));
+                                       li.append(createElement('em').append(createElement('a', {'href': attr.wiki + '#Eintragen'}).text('Neu')));
                                } else {
-                                       li.append(createElement('em').append(createElement('a', {'href': feature.attributes.wiki + '#Eintragen'}).text('Bitte eintragen')));
+                                       li.append(createElement('em').append(createElement('a', {'href': attr.wiki + '#Eintragen'}).text('Bitte eintragen')));
                                }
-                       } else if (feature.attributes.wiki !== undefined) {
-                               if (feature.attributes.name != undefined) popup_div.append(createElement('h2').text(feature.attributes.name));
-                               popup_div.append(createElement('p').append(createElement('a', {'href': feature.attributes.wiki}).text('Details')));
-                       } else return;
+                       }
+
+                       // wiki link
+                       if (attr.wiki !== undefined) {
+                               var a = appendElement(appendElement(popup_div, 'p'), 'a', {'href': attr.wiki});
+                               if (attr.thumb_url === undefined) a.text('Details');
+                               else a.append(createElement('img', {'src': attr.thumb_url, 'alt': 'Details'}));
+                       }
+
+                       // no popup if we don't have anything to say
+                       if (popup_div.children().length == 0) return;
 
                        // Open popup
                        var selectFeatureControl = this;
-                       var popup = new OpenLayers.Popup.FramedCloud('sledruninfopopup_' + feature.attributes.wiki, 
+                       var popup = new OpenLayers.Popup.FramedCloud('sledruninfopopup_' + attr.wiki,
                        feature.geometry.getBounds().getCenterLonLat(),
                        null,
                        popup_div.html(),