From a060686f519faea39faffb351d39a1cfb2c7f5d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20MI?= Date: Fri, 8 May 2015 00:11:16 -0300 Subject: [PATCH] Fixes bug to make site work even if there's an ad block-like plugin --- app/assets/js/SendMessage.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/app/assets/js/SendMessage.js b/app/assets/js/SendMessage.js index 5dcae6f..21cde79 100644 --- a/app/assets/js/SendMessage.js +++ b/app/assets/js/SendMessage.js @@ -153,19 +153,21 @@ ppar.SendMessage = function (container, legislatives, options) { } }); - twttr.events.bind('click', function (event) { - var id; - if (event) { - id = jQuery(event.target).attr("id"); - currentLegislativeId = parseInt(id.substr(id.indexOf("-") + 1), 10); - } - }); + if (window.twttr) { + twttr.events.bind('click', function (event) { + var id; + if (event) { + id = jQuery(event.target).attr("id"); + currentLegislativeId = parseInt(id.substr(id.indexOf("-") + 1), 10); + } + }); - twttr.events.bind('tweet', function (event) { - if (event) { - registerActivity("tweet"); - } - }); + twttr.events.bind('tweet', function (event) { + if (event) { + registerActivity("tweet"); + } + }); + } container.find(".js-fb-feed").click(function (event) { var link = jQuery(event.target);