Sha256: c8dfc2021f9b42abb7d1c096e966cc9521e0aee211b7e895579017391479c34f

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

{%- include snippets/get-sources.html -%}
{%- assign _sources = __return -%}
<script>
  (function() {
    function scrollAnimateTo(destination, duration, callback) {
      var $body = $('html, body'), bodyScrollTop = $body.scrollTop();
      if(bodyScrollTop === destination) { return; }
      $body.animate({ scrollTop: destination }, duration, callback);
    }
    window.scrollTopAnchor = function(anchor, callback) {
      scrollAnimateTo($(anchor).offset().top, 400, function() {
        window.history.replaceState(null, '', window.location.href.split('#')[0] + anchor);
        callback && callback();
      });
    }
  })();
  window.Lazyload.js('{{ _sources.jquery }}', function() {
    var $articleContent = $('.m-post, .m-page').find('.m-article-content'), $this;
    $articleContent.children('.highlight').each(function() {
      $this = $(this);
      $this.attr('data-lang', $this.find('code').attr('data-lang'));
    });

    $articleContent.children('h1, h2, h3, h4, h5, h6').each(function() {
      $this = $(this);
      $this.append($('<a class="anchor" aria-hidden="true"></a>').html('{%- include icon/link.svg -%}'));
    });
    $articleContent.on('click', '.anchor', function() {
      window.scrollTopAnchor('#' + $(this).parent().attr('id'));
    });
  });
</script>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-text-theme-1.5.0 _includes/scripts/page-post.html