Skip to content

Commit

Permalink
Updated the bevry script to the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Feb 4, 2014
1 parent 8c74fe4 commit a2e541e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docpad-website",
"version": "0.1.27",
"version": "0.1.28",
"private": true,
"description": "The Docpad Website",
"homepage": "https://github.com/bevry/docpad-website",
Expand Down
14 changes: 8 additions & 6 deletions site/src/documents/scripts/bevry.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class BevryApp
return unless hash
el = document.getElementById(hash)
return unless el
if el.tagName.toLowerCase() is 'h2'
if el.className.indexOf('anchor-link') isnt -1
$(el).trigger('select')
else
$(el).ScrollTo(@config.sectionScrollOpts)
Expand All @@ -198,8 +198,8 @@ class BevryApp
# Special handling for long docs
@$article = $article = $('#content article:first')

# Documentation
if $article.is('.block.doc')
# Anchors
if $article.is('.block.doc, .block.page')
$article.find('h1,h2,h3,h4,h5,h6').each ->
return if @id
id = (@textContent or @innerText or '').toLowerCase().replace(/\s+/g,' ').replace(/[^a-zA-Z0-9]+/g,'-').replace(/--+/g,'-').replace(/^-|-$/g,'')
Expand All @@ -208,12 +208,14 @@ class BevryApp
@setAttribute('data-href', '#'+@id) unless @getAttribute('data-href')
@className += 'hover-link' unless @className.indexOf('hover-link') isnt -1

# Documentation
if $article.is('.block.doc')
@$docHeaders = $docHeaders = $article.find('h2')

# Compact
if $article.is('.compact')
$docHeaders
.addClass('hover-link')
.addClass('hover-link anchor-link')
.each (index) ->
$header = $(this)
$header.nextUntil('h2').wrapAll($docSectionWrapper.clone().attr('id','h2-'+index))
Expand All @@ -230,12 +232,12 @@ class BevryApp
.end()
$header.ScrollTo(config.sectionScrollOpts) if !opts or opts.scroll isnt false
.first()
.trigger('select',{scroll:false})
.trigger('select', {scroll:false})

# Non-Compact
else
$docHeaders
.addClass('hover-link')
.addClass('hover-link anchor-link')
.on 'select', (event,opts) ->
$docHeaders.filter('.current').removeClass('current')
$header = $(this)
Expand Down

0 comments on commit a2e541e

Please sign in to comment.