Noosfero/noosfero

View on GitHub
plugins/social_share_privacy/public/socialshareprivacy/demo/events.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>Social Share Privacy: Events</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://panzi.github.com/SocialSharePrivacy/javascripts/jquery.cookies.js"></script>
<script type="text/javascript" src="../javascripts/socialshareprivacy.js"></script>
<script type="text/javascript" src="../javascripts/modules/facebook.js"></script>
<script type="text/javascript" src="../javascripts/modules/twitter.js"></script>
<script type="text/javascript" src="../javascripts/modules/gplus.js"></script>
<script type="text/javascript" src="../javascripts/modules/reddit.js"></script>
<script type="text/javascript">
// <![CDATA[
$.fn.socialSharePrivacy.settings.path_prefix = '../';

$(document).ready(function () {
    // I simply call enable/disable on ALL share elements. This does not result in
    // an endless-loops because enabling/disabling an already enabled/disabled
    // service does nothing and thus doesn't trigger the event recursively.
    $('.share').socialSharePrivacy().
    on('socialshareprivacy:enable', function (event) {
        $('.share').socialSharePrivacy('enable',event.serviceName);
    }).
    on('socialshareprivacy:disable', function (event) {
        $('.share').socialSharePrivacy('disable',event.serviceName);
    });
});
// ]]>
</script>
</head>
<body>

<h1>Social Share Privacy: Events</h1>

<div class="share"></div>

<p>
This demo demonstrates how multiple social share privacy widgets can be synchronized using events.
</p>

<div class="share"></div>

</body>
</html>