heiseonline / shariff

👮 Shariff enables website users to share their favorite content without compromising their privacy.
http://ct.de/-2467514
MIT License
1.4k stars 177 forks source link

infoUrl cannot be set by data-* attribute #44

Closed neffets closed 9 years ago

neffets commented 9 years ago

In current Firefox, its not possible to add an own infoUrl per data-attribute

$('.shariff').attr('data-infoUrl', 'http://www.berlin.de/wir-ueber-uns-be/agb/pp/20150101/#socialplugins');

The browser will add the data-attribute, BUT it will become a "data-infourl" (all lowercase).

There are three ways to solve it:

pmb0 commented 9 years ago

Hi!

First, jQuery does an automatic conversion of data key names. Example:

> jQuery("body").data("foo-bar", "baz").data()
< Object {fooBar: "baz"}

So, if you want to set the info url, you would have to use something like $("shariff").data("info-url", "blah") (also notice data() instead of attr()). Since Object.observe() is not supported by most browsers, Shariff can't detect changes made on the data list. And there is no update() method on the shariff object yet.

I just pushed a (not released) change, that renames _Shariff to Shariff and that exports the class to the global window object. I also pushed an example that shows how to pass own options to the Shariff constructor method.

Summary:

a) use data-info-url instead of data-infourl/data-infoUrl b) there is no reason to change it c) Custom options could always be passed to the constructor. The change, that sets the Shariff class in the global window object, will be released soon.

pmb0 commented 9 years ago

See v1.9.1