minor fix
[wolnelektury.git] / src / wolnelektury / static / js / book_text / references.js
index 6abd103..1a284a0 100644 (file)
             left: nx,
             right: right
         });
             left: nx,
             right: right
         });
+        $elem.css({
+            display: "block"
+        });
         if (!$elem.data('attach-bottom')) {
             ny = y - $elem.height() - 10;
         } else {
         if (!$elem.data('attach-bottom')) {
             ny = y - $elem.height() - 10;
         } else {
             left: leftoffset - 6
         });
 
             left: leftoffset - 6
         });
 
-        $elem.css({
-            display: "block"
-        });
     }
 
     function closeNoteBox() {
     }
 
     function closeNoteBox() {
         if ($(this).parents('#footnotes').length) return;
         event.preventDefault();
 
         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)
 
         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();
     });
         putNoteAt($('#annotation-box'), this);
         event.stopPropagation();
     });
     });
 
     $('a.anchor').on('click', function(e) {
     });
 
     $('a.anchor').on('click', function(e) {
+        // Workaround for bad TOC markers.
+        if (($this).closest('#toc').length) return;
         e.preventDefault();
 
         let sel = window.getSelection();
         e.preventDefault();
 
         let sel = window.getSelection();