Sha256: ab451bd86dfe96018c4a96c9df89214d4f6d8b1dcf4eb48e727d2c11b39998ff
Contents?: true
Size: 1.08 KB
Versions: 8
Compression:
Stored size: 1.08 KB
Contents
# Finds all header attributes which have a name and adds a HREF attribute to itself # Used so that users can link to a particular part of the page by hovering over the header # https://css-tricks.com/hash-tag-links-padding/#article-header-id-1 class this.HeaderAnchors @init: -> # Add self links to h2, h3 & h4 anchors # This allows users to click the anchor to link to $('.wysiwyg-content h2 a[name], .wysiwyg-content h3 a[name], .wysiwyg-content h4 a[name]').each -> @dataset.turbolinks = false @href = '#' + @name # TL currently has a bug in which it reloads pages when an anchor link for the same page is clicked. # Workaround: As long as that link has data-turbolinks=false we don't need to preventDefault $('a[href*="#"]:not([href="#"])').each -> currentUrl = window.location.origin + window.location.pathname # Check if anchor link is linking to the same page if /^#/.test(@href) == true or currentUrl == @href.split('#')[0] @dataset.turbolinks = false # Prevent possible return false which would cause a loop break true
Version data entries
8 entries across 8 versions & 1 rubygems