X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..53a66f70e4a8f9585b3d1a459542fb2e44f310f2:/src/wolnelektury/static/js/book_text/menu.js diff --git a/src/wolnelektury/static/js/book_text/menu.js b/src/wolnelektury/static/js/book_text/menu.js index 5bbc1a8d8..dde96edf9 100644 --- a/src/wolnelektury/static/js/book_text/menu.js +++ b/src/wolnelektury/static/js/book_text/menu.js @@ -30,6 +30,7 @@ $('#menu-toggle-on').click(function(e) { if (!$("#menu").is(":visible")) { body.addClass("menu-showed"); } + _paq.push(['trackEvent', 'html', 'menu-on']); }); /* Hide menu */ @@ -42,6 +43,7 @@ $('#menu-toggle-off').click(function(e) { if ($("#menu").is(":visible")) { $("body").addClass("menu-hidden"); } + _paq.push(['trackEvent', 'html', 'menu-off']); }); @@ -53,7 +55,7 @@ $("#box-underlay").click(release_menu); $("#menu a").each(function() { var boxid = $(this).attr("data-box"); if (boxid) { - $("#" + $(this).attr("data-box")).hide(); + $("#" + boxid).hide(); $(this).click(function(e) { e.preventDefault(); @@ -63,9 +65,10 @@ $("#menu a").each(function() { $("body").addClass("menu-showed"); $(this).addClass("active"); $("#box-underlay").show(); - $("#" + $(this).attr("data-box")).show(); + $("#" + boxid).show(); } }); + _paq.push(['trackEvent', 'html', boxid]); } else if ($(this).hasClass('dropdown')) { $(this).click(function(e) { @@ -91,37 +94,94 @@ $("#menu a").each(function() { $("#menu-other").show(); + function insertOtherText(text) { + let tree = $(text); + let lang = tree.attr('lang') || 'pl'; + + // toc? + // themes? + + let cursor = $(".main-text-body #book-text").children().first(); + // wstawiamy przed kursorem + lastTarget = ''; + tree.children().each((i, e) => { + let $e = $(e); + + if ($e.hasClass('anchor')) return; + if ($e.hasClass('numeracja')) return; + if ($e.attr('id') == 'toc') return; + if ($e.attr('id') == 'nota_red') return; + if ($e.attr('id') == 'themes') return; + if ($e.attr('name') && $e.attr('name').startsWith('sec')) return; + + if ($e.hasClass('target')) { + let target = $e.attr('name'); + + while (lastTarget != target) { + let nc = cursor.next(); + if (!nc.length) { + break; + } + cursor = nc; + lastTarget = cursor.attr('name'); + } + + while (true) { + let nc = cursor.next(); + if (!nc.length) { + break; + } + cursor = nc; + lastTarget = cursor.attr('name'); + if (lastTarget) break; + } + + } else { + let d = $('