Fix for heads.
[wolnelektury.git] / src / wolnelektury / static / js / book_text / references.js
index 4c72fe6..795c737 100644 (file)
         if (ref.location) {
             enable_map();
 
-            marker.setLatLng(ref.location);
+            let newLoc = [
+                ref.location[0],
+                ref.location[1] + Math.round(
+                    (map.getCenter().lng - ref.location[1]) / 360
+                ) * 360
+            ];
+
+            marker.setLatLng(newLoc);
             marker.bindTooltip(ref.label).openTooltip();
             map.addLayer(marker);
-            map.panTo(ref.location, {
+
+            map.panTo(newLoc, {
                 animate: true,
                 duration: 1,
             });
             $.each(ref.images, function(i, e) {
                 $i = $("<a target='_blank'><img></a>");
                 $i.attr('href', e.page);
-                $('img', $i).attr('src', e.url);
+                $('img', $i).attr('src', e.thumburl || e.url);
+                if (e.thumbresolution) {
+                    $('img', $i).attr('width', e.thumbresolution[0]).attr('height', e.thumbresolution[1]);
+                }
+
                 $("#reference-images").append($i);
             })
         }
 
         $("#reference-link").text(ref.label);
         $("#reference-link").attr('href', ref.wikipedia_link);
+
+        _paq.push(['trackEvent', 'html', 'reference']);
     });
 })})(jQuery);