Problem/Motivation
When Shariff is used on page that has Twitter integration (fe. module: Media entity Twitter [media_entity_twitter]) and when we click on twitter Shariff button, two pup-up windows appear.
Problem comes from twitter widget.js (//platform.twitter.com/widgets.js) script, it simply handles click on link and in case of tweet link, it will pop-up window with tweet (here is link to example). Here is twitter documentation for integration and looks like, it's not possible to mark link to be ignored by twitter widget.
Proposed resolution
Possible solution is to stop click event propagation outside Shariff Block and then twitter widget click even handler will not be executed.
Remaining tasks
- Add behaviour that will register click handler to stop propagation outside Shariff Block.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | interdiff_2845000_4_2.txt | 1.9 KB | mtodor |
| #4 | 2845000_4.patch | 3.28 KB | mtodor |
| #2 | 2845000_2.patch | 3.15 KB | mtodor |
Comments
Comment #2
mtodor commentedHere is proposed solution.
Comment #3
nebel54Thanks for the patch, but I would prefer to get this problem handled directly in the Shariff library directly, as it is not a drupal specific problem. I added a pull request here: https://github.com/heiseonline/shariff/pull/201.
Let's see if we can find a solution over there, otherwise we should apply your patch and extend it to make it work outside of the shariff block.
Comment #4
mtodor commentedSince Shariff library is released (1.25.1) -> shariff.complete.js file does not exist anymore. So this patch has to be adjusted to use shariff.min.js instead of shariff.complete.js.
@Nebel54 In my opinion this issue is related to integration of Shariff library, that's why I'm not sure it should be handled in library itself. In short: if someone integrates shariff lib and twitter lib on same page, they have to take care of it. If we argue that shariff lib should handle it, then we can also argue that twitter lib should handle it. ;)
Comment #6
nebel54Agreed. Thanks for the patch! Its commited.
Comment #7
mtodor commentedThere is one problem, there is not new release of Shariff library. :(
Here is issue on Shariff library github: https://github.com/heiseonline/shariff/issues/217
But asset packagist displays it (both bower and npm):
https://asset-packagist.org/package/search?query=npm-asset%2Fshariff
Comment #8
nebel54Urgs... But it seems like they are working on a release. Maybe my pull request will become part of the next version :)