Browse Source

Merge pull request #60 from lexintegritastech/improve-main-ui

Improve `footnote`
pull/61/head
Alexander D. Bondoc 4 years ago committed by GitHub
parent
commit
8c0ad7d874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  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) { if ($.fn.footnotes) {
$('#documentTabContent').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" import "channels"

1
app/javascript/packs/application/footnotes.js

@ -9,7 +9,6 @@
b.each(function(){ b.each(function(){
var $this = $(this); var $this = $(this);
console.log($this)
if($this.anchor_check()){ if($this.anchor_check()){
if(!$this.parent('span.footnote-x').length){ if(!$this.parent('span.footnote-x').length){
// Wrap the anchor with 'footnote-x' // Wrap the anchor with 'footnote-x'

Loading…
Cancel
Save