X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/b89f3aa7efdc44a9b59b26384862df0f06803a7b..e64c6b6dfe83cc2de8065807553bc5fe488edc36:/src/wolnelektury/static/js/book_text/references.js diff --git a/src/wolnelektury/static/js/book_text/references.js b/src/wolnelektury/static/js/book_text/references.js index 3f5b7e37f..cd782c894 100644 --- a/src/wolnelektury/static/js/book_text/references.js +++ b/src/wolnelektury/static/js/book_text/references.js @@ -49,8 +49,12 @@ $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') + } } }); @@ -104,8 +108,14 @@ } $("#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']); }); @@ -610,6 +620,7 @@ $('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('#wltoc').length) return; e.preventDefault(); @@ -662,14 +673,15 @@ 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);