X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f7d8acded4a58d423035c5759f6dee9a34396959..b17486a9270334855c3b908b8250e3a020803875:/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 146067523..ef6c51c94 100644 --- a/src/wolnelektury/static/js/book_text/references.js +++ b/src/wolnelektury/static/js/book_text/references.js @@ -139,10 +139,11 @@ leftoffset = x - margin; } else { right = ''; - - // default position. - leftoffset = 40; + leftoffset = $elem.data('default-leftoffset'); + if (leftoffset === undefined) { + leftoffset = $elem.width() / 2; + } nx = x - leftoffset; @@ -157,12 +158,8 @@ // Do we need to move away from the right? if (nx + boxwidth > maxx) { - // ACTUALLY CALCULATE STUFF - // if maxx - minx < 470 px -- daj z lewej do prawej i już! - right = ''; let d = nx + boxwidth - maxx; - //if (leftoffset + d > $elem.width() - 10) d = $elem.width() - leftoffset - 10; nx -= d; leftoffset += d; } @@ -171,6 +168,9 @@ left: nx, right: right }); + $elem.css({ + display: "block" + }); if (!$elem.data('attach-bottom')) { ny = y - $elem.height() - 10; } else { @@ -183,9 +183,6 @@ left: leftoffset - 6 }); - $elem.css({ - display: "block" - }); } function closeNoteBox() { @@ -219,23 +216,12 @@ if ($(this).parents('#footnotes').length) return; event.preventDefault(); - - - let x = $(this).width() / 2, y = 0; - let elem = $(this); - while (elem.attr('id') != 'book-text') { - let p = $(elem).position(); - x += p.left; - y += p.top; - elem = elem.parent(); - } href = $(this).attr('href').substr(1); content = $("[name='" + href + "']").next().next().html(); if (!content) return; $("#annotation-content").html(content); $("#footnote-link").attr('href', '#' + href) - putNoteAt($('#annotation-box'), this); event.stopPropagation(); }); @@ -474,7 +460,7 @@ let text = window.location.protocol + '//' + window.location.host + window.location.pathname; - if (anchor) text += anchor; + if (anchor) text += '#' + anchor; navigator.clipboard.writeText(text); this.hideCopied(); @@ -619,6 +605,9 @@ }); $('a.anchor').on('click', function(e) { + // Workaround for bad TOC markers. + if ($(this).closest('#toc').length) return; + if ($(this).closest('#wltoc').length) return; e.preventDefault(); let sel = window.getSelection();