lemonmade / bigfoot

A jQuery plugin for creating exceptional footnotes.
http://www.bigfootjs.com
MIT License
935 stars 77 forks source link

Request: Reference markup placeholder for .text() #6

Closed marcoarment closed 10 years ago

marcoarment commented 10 years ago

In my buttonMarkup, I'd like access to the original footnote link's inner text, e.g.:

{{SUP:text()}}

Currently, these placeholders can only be used to access attributes.

Why: I'm redesigning my footnote buttons to include the original footnote numbers generated by Markdown Extra, and there's no data-attribute containing the footnote number. I can't just use {{FOOTNOTENUM}} because it's wrong on multi-post pages (like index/archive pages) — it increments globally throughout the whole page rather than resetting to 1 at the beginning of each new post.

lemonmade commented 10 years ago

I was working on this issue from a different angle. There's now an option (numberResetSelector) that allows you to pass in an element that, when that element changes, a new property on the footnote popover (data-footnote-number) will reset to 1. After looking at your index page, it looks like each post is contained in an article tag, so this should reset the numbering for each post:

var bigfoot = $.bigfoot({numberResetSelector: "article"}); // add additional options as appropriate

You can then access the footnote's number within a containing block by checking .footnote-content's data-footnote-number attribute, or by adding {{FOOTNOTENUM}} in the button/ footnote template strings (the data-footnote-identifier is still around as well (though its now represented as {{FOOTNOTEID}} as this is how the footnotes are uniquely identified when being activated/ closed).

Does that work for what you had in mind?

marcoarment commented 10 years ago

Perfect, thanks.