diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 3578f1b..46b038c 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -42,6 +42,22 @@ $(document).on("ready turbolinks:load", function () { if ($.fn.footnotes) { $('#documentTabContent').footnotes() } + + $(document).on('click', 'a[href="#footnotes"]', function(event){ + $(this).each(function(){ + var a, b, c, d; + a = $(this), b = a.attr('href'), c = a.text(), d = '#footnote' + c + a.attr('href', d), a.attr('id', 'fn' + c) + a.trigger('click') + }) + event.preventDefault(); + }).on('click', 'a[href^="#footnote"], a[href^="#fn"]', function(event){ + var a, b; + a = $(this), b = $(a.attr('href')) + if(b.length<=0)return + event.preventDefault() + $('html, body, .tab-content').animate({ scrollTop: b.offset().top }, 700, 'linear') + }) }); import "channels" diff --git a/app/javascript/packs/application/footnotes.js b/app/javascript/packs/application/footnotes.js index 9801bb3..849babd 100644 --- a/app/javascript/packs/application/footnotes.js +++ b/app/javascript/packs/application/footnotes.js @@ -9,7 +9,6 @@ b.each(function(){ var $this = $(this); - console.log($this) if($this.anchor_check()){ if(!$this.parent('span.footnote-x').length){ // Wrap the anchor with 'footnote-x'