From a2e541e51776aec16d3a3523e71519ea42ed0937 Mon Sep 17 00:00:00 2001 From: Benjamin Lupton Date: Tue, 4 Feb 2014 15:30:05 +1100 Subject: [PATCH] Updated the bevry script to the latest --- package.json | 2 +- site/src/documents/scripts/bevry.js.coffee | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 0292652..2f97076 100755 --- a/package.json +++ b/package.json @@ -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", diff --git a/site/src/documents/scripts/bevry.js.coffee b/site/src/documents/scripts/bevry.js.coffee index 0d45d6b..795f5cc 100644 --- a/site/src/documents/scripts/bevry.js.coffee +++ b/site/src/documents/scripts/bevry.js.coffee @@ -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) @@ -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,'') @@ -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)) @@ -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)