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

Shariff not working w/o Backend? #65

Closed CenkJaxon closed 9 years ago

CenkJaxon commented 9 years ago

Hi, I try to use Shariff w/o Backend which works with <div class="shariff clear"></div>. But as soon as I add the data-services tag to customize the buttons it disappears at the front-end. What might be the reason? Btw. I'm using shariff.min.js and shariff.complete.css.

pmb0 commented 9 years ago

What exactly are you using as data-services value?

CenkJaxon commented 9 years ago

data-services="["facebook","twitter","googleplus","mail","info"]"

CenkJaxon commented 9 years ago
data-services="[&quot;facebook&quot;,&quot;twitter&quot;,&quot;googleplus&quot;,&quot;mail&quot;,&quot;info&quot;]"
pmb0 commented 9 years ago

This works for me:

<div class="shariff" data-services="[&quot;facebook&quot;,&quot;twitter&quot;,&quot;googleplus&quot;,&quot;mail&quot;,&quot;info&quot;]"></div>
CenkJaxon commented 9 years ago

Still same. When I view the source-code, I can see the entities not printed as &quot; but as " for example. May this be the reason?

CenkJaxon commented 9 years ago

2015-05-13 16_08_17-view-source_www zugeschnuert-shop de_gutscheintest

pmb0 commented 9 years ago

I assume the JS exception Uncaught TypeError: undefined is not a function in your structured_autocomplete.js:496 causes JS execution to stop.

pmb0 commented 9 years ago

No, I was wrong. I inspected your html markup. Your shariff element doesn't contain the data-services value as described above:

<h4>Weitersagen</h4>
<div class="shariff" data-services="[\/facebook,twitter,googleplus,mail,info]"></div>

versus

<h4>Weitersagen</h4>
<div class="shariff" data-services="[&quot;facebook&quot;,&quot;twitter&quot;,&quot;googleplus&quot;,&quot;mail&quot;,&quot;info&quot;]"></div>
CenkJaxon commented 9 years ago

Yeah, like I asked before: You caught me trying to use escapes to get these entities work correctly. Somehow the template engine seems to interprete them :-/ 2015-05-13 16_32_12-remote desktop manager free plentymarkets

pmb0 commented 9 years ago

If you cannot fix this behavior, you can initialize Shariff in your own JS code.

var $shariff = $("<div>");
new Shariff($shariff, {services: ["twitter", "googleplus"]});
$shariff.appendTo("#share");

This code needs to run after your <script src="shariff.min.js"> line.

CenkJaxon commented 9 years ago

This worked. Thanks a lot Philipp.

pmb0 commented 9 years ago

👍

liayn commented 9 years ago

Don't know which template engine you're using, but with TYPO3 Fluid you have to use this syntax:

<rx:shariff data="{url: 'http://example.com/', services: '[\"whatsapp\",\"facebook\"]'}" />

(The example is using the viewhelper of the rx_shariff extension for TYPO3 CMS)

CenkJaxon commented 9 years ago

Thx. Didn't know there is an extension for typo3.

liayn commented 9 years ago

;-) Yep, comes with full shariff-backend integration. http://typo3.org/extensions/repository/view/rx_shariff