Skip to content

Commit

Permalink
Merge pull request #8 from knalli/master
Browse files Browse the repository at this point in the history
New plugin option "headerText: Function" to change the default header text retrieval.
  • Loading branch information
Greg committed Jul 6, 2012
2 parents 5aa25e2 + a4c174e commit 47635a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dist/jquery.toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $.fn.toc = function(options) {

//build TOC item
var a = $('<a/>')
.text($h.text())
.text(opts.headerText(i, heading, $h))
.attr('href', '#' + opts.anchorName(i, heading, opts.prefix))
.bind('click', scrollTo);

Expand All @@ -108,6 +108,9 @@ jQuery.fn.toc.defaults = {
highlightOffset: 100,
anchorName: function(i, heading, prefix) {
return prefix+i;
},
headerText: function(i, heading, $h) {
return $h.text();
}
};

Expand Down
3 changes: 3 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Defaults shown below
'highlightOffset': 100, //offset to trigger the next headline
'anchorName': function(i, heading, prefix) { //custom function for anchor name
return prefix+i;
},
'headerText': function(i, heading, $heading) { // custom function building the header-item text
return $heading.text();
}
});

Expand Down

0 comments on commit 47635a6

Please sign in to comment.