PinterestPlus icon indicating copy to clipboard operation
PinterestPlus copied to clipboard

Smart(er) defaults

Open nikcorg opened this issue 11 years ago • 4 comments

This PR allows using functions as default values to properties, enabling smart attempts at finding the intended value. There are two examples included, one for data-url and one for data-image.

For data-url the href of an a-tag or a nested a-tag is used. When none is found the document.location.href.

For data-image the src of an img-tag or a nested img-tag is used. When none is found an error is generated.

For now, I've only added the functionality to pinterest-plus-html5.js. If you like the idea, I can extend it everywhere and add demos to the examples.

As a rudimentary example, with the markup below the PinIt-button would get the value of http://foo.com/bar for data-url and http://foo.com/baz.jpg for data-media.

<div class="pin-it-button">
    <a href="http://foo.com/bar"><img src="http://foo.com/baz.jpg"></a>
</div>

nikcorg avatar Jan 14 '14 15:01 nikcorg

Hello Niklas, I like the ideas behind this pull request, and I plan to merge this work. However, I probably wont' have time to get to it until this upcoming weekend.

Cheers, Mike

skibblenybbles avatar Jan 15 '14 14:01 skibblenybbles

Cool! Let me know if there's something that you feel is missing. I will gladly patch any shortcomings.

nikcorg avatar Jan 16 '14 09:01 nikcorg

I'm guessing maybe safe to just close and delete this one?

nikcorg avatar Feb 08 '17 16:02 nikcorg

@nikcorg I haven't had to deal with Pinterest APIs for years, so I have no idea whether this library is still useful. If you still use it, I'd be happy to transfer ownership of this repo to you. Otherwise, I'm just going to let it remain "as-is" just in case some old project depends on it.

skibblenybbles avatar Feb 08 '17 16:02 skibblenybbles