Browse Source

Improve `footnote`

pull/60/head
alexdbondoc17 4 years ago
parent
commit
79f9b94ff7
  1. 16
      app/javascript/packs/application.js
  2. 1
      app/javascript/packs/application/footnotes.js

16
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"

1
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'

Loading…
Cancel
Save