From b5e8ab9895759b9d5f8b78cd4d50c54b0ceb61df Mon Sep 17 00:00:00 2001 From: Curtis Mitchell Date: Mon, 25 Nov 2013 12:10:24 -0500 Subject: [PATCH 1/2] Inserting an up-arrow to the TOC when the TOC is at the top of the page --- js/basic_skeleton.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/js/basic_skeleton.js b/js/basic_skeleton.js index 74c90ac6..89509057 100644 --- a/js/basic_skeleton.js +++ b/js/basic_skeleton.js @@ -191,6 +191,18 @@ $pilcrow.appendTo($heading); } + // adds a link to the navigation at the top of the page + function addJumpLinkToTOC($heading) { + var $jumpLink = $('[⬆]'); + $jumpLink.click(function(ev) { + ev.preventDefault(); + + $('body').scrollTop($('#md-page-menu').position().top); + }); + + $jumpLink.insertAfter($heading); + } + // adds a page inline anchor to each h1,h2,h3,h4,h5,h6 element // which can be accessed by the headings text $('h1,h2,h3,h4,h5,h6').not('#md-title h1').each (function () { @@ -199,6 +211,10 @@ var text = $heading.clone().children('.anchor-highlight').remove().end().text(); var href = $.md.util.getInpageAnchorHref(text); addPilcrow($heading, href); + + //add jumplink to table of contents + addJumpLinkToTOC($heading); + }); } From d2bc3649838e0fc38b6ad2fc3aaed802f413a433 Mon Sep 17 00:00:00 2001 From: Curtis Mitchell Date: Sun, 1 Dec 2013 13:49:23 -0500 Subject: [PATCH 2/2] added config.json entry and default for toc --- js/basic_skeleton.js | 3 ++- js/init.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/js/basic_skeleton.js b/js/basic_skeleton.js index 89509057..0aa36a67 100644 --- a/js/basic_skeleton.js +++ b/js/basic_skeleton.js @@ -193,7 +193,8 @@ // adds a link to the navigation at the top of the page function addJumpLinkToTOC($heading) { - var $jumpLink = $('[⬆]'); + var c = $.md.config.tocAnchor; + var $jumpLink = $('' + c + ''); $jumpLink.click(function(ev) { ev.preventDefault(); diff --git a/js/init.js b/js/init.js index 23b6e608..05bcb99b 100644 --- a/js/init.js +++ b/js/init.js @@ -21,7 +21,8 @@ useSideMenu: true, lineBreaks: 'gfm', additionalFooterText: '', - anchorCharacter: '¶' + anchorCharacter: '¶', + tocAnchor: '[⬆]' };