}
var map_enabled = false;
- var marker = L.circleMarker([0,0]);
+ var marker = null;
var map = null;
- function enable_map() {
- $("#reference-map").show('slow');
+ function enable_map(callback) {
+ if (!$("#reference-map").length) return;
- if (map_enabled) return;
-
- map = L.map('reference-map').setView([0, 0], 11);
- L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=a8a97f0ae5134403ac38c1a075b03e15', {
- attribution: 'Maps © <a href="http://www.thunderforest.com">Thunderforest</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'
- }).addTo(map);
-
- map_enabled = true;
+ if (!map_enabled) {
+ map = L.map('reference-map').setView([0, 0], 11);
+ L.tileLayer('https://tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png?apikey=a8a97f0ae5134403ac38c1a075b03e15', {
+ attribution: 'Maps © <a href="http://www.thunderforest.com">Thunderforest</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'
+ }).addTo(map);
+ marker = L.circleMarker([0,0]);
+ map_enabled = true;
+ }
+ $("#reference-map").show('slow', () => {
+ map.invalidateSize();
+ callback();
+ });
}
function disable_map() {
$("#reference-map").hide('slow');
$this.addClass('interesting');
ref = interestingReferences[uri];
- $this.attr('href', ref.wikipedia_link);
- $this.attr('target', '_blank');
+ if (ref.wikipedia_link) {
+ $this.attr('href', ref.wikipedia_link);
+ $this.attr('target', '_blank');
+ } else {
+ $this.removeAttr('href')
+ }
}
});
ref = interestingReferences[uri];
if (ref.location) {
- enable_map();
+ enable_map(() => {
let newLoc = [
ref.location[0],
animate: true,
duration: 1,
});
+ });
} else {
disable_map();
if (map) {
}
$("#reference-link").text(ref.label);
- $("#reference-link").attr('href', ref.wikipedia_link);
+ if (ref.wikipedia_link) {
+ $("#reference-link").attr('href', ref.wikipedia_link);
+ } else {
+ $('#reference-link').removeAttr('href');
+ }
+ $("#reference-print").attr('href', '/mapa/ulotka/' + ref.id);
+
_paq.push(['trackEvent', 'html', 'reference']);
});
$('a.anchor').on('click', function(e) {
// Workaround for bad TOC markers.
- if (($this).closest('#toc').length) return;
+ if ($(this).closest('#toc').length) return;
+ if ($(this).closest('.toc').length) return;
+ if ($(this).closest('#wltoc').length) return;
e.preventDefault();
let sel = window.getSelection();
let range = document.createRange();
let $p = $(this).nextAll('.paragraph').first()
- range.selectNode($p[0]);
+ range.selectNodeContents($p[0]);
sel.addRange(range);
qbox.showForSelection(sel);
history.pushState({}, '', anchor);
},
});
+ return true;
}
}
}
scrollToAnchor(window.location.hash)
- $('#toc, #themes, #book-text, #annotation').on('click', 'a', function(event) {
- event.preventDefault();
- scrollToAnchor($(this).attr('href'));
+ $('#toc, #themes, #book-text, #annotation, .scroll').on('click', 'a', function(event) {
+ if (scrollToAnchor($(this).attr('href'))) {
+ event.preventDefault();
+ }
});
-
})})(jQuery);