document.write(''); var affectedElement = null; jQuery(function () { jQuery(".dropdown-toggle").hover(function () { var $el = jQuery(this); var $container = $el.parent().find("div"); affectedElement = $container; if($container.find("div").length == 0){ var category = jQuery(this).html(); var id = jQuery(this).attr("data-id"); var tipo = jQuery(this).attr("data-tipo"); jQuery.ajax({ url: "https://www.publico.pt/Areas/Menu/" + id + "/" + tipo, type: "GET", dataType: 'jsonp', jsonp: 'callback', cache: true, jsonpCallback: "pwCallbackMenu", success: function (data) { }, error: function (xhr, status, error) { errorLog(xhr, status, error); } }); }else{ console.log("SKIPPED"); } }, function () { //$(this).parent().removeClass("open"); //console.log("CLOSE"); }); }); function pwCallbackMenu(data) { if(affectedElement.find("div").length == 0){ affectedElement.append(data); } } function errorLog(xhr, status, error) { console.log(xhr); } function trackEventSatelites(category, action, label) { try { _gaq.push(['_trackEvent', category, action, label]); } catch (e) { } if(typeof ga != "undefined") { ga('send', 'event', category, action, label); } }