/* Do not modify this file directly. It is compiled from other files. */ /* global pm, wpcom_reblog, JSON */ var jetpackLikesWidgetBatch=[],jetpackLikesMasterReady=!1,jetpackLikesLookAhead=2e3,jetpackCommentLikesLoadedWidgets=[];function JetpackLikesPostMessage(e,t){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){return}pm({target:t,type:"likesMessage",data:e,origin:"*"})}function JetpackLikesBatchHandler(){var e=[];jQuery("div.jetpack-likes-widget-unloaded").each(function(){if(!(jetpackLikesWidgetBatch.indexOf(this.id)>-1)&&jetpackIsScrolledIntoView(this)){jetpackLikesWidgetBatch.push(this.id);var t,i=/like-(post|comment)-wrapper-(\d+)-(\d+)-(\w+)/.exec(this.id);i&&5===i.length&&(t={blog_id:i[2],width:this.width},"post"===i[1]?t.post_id=i[3]:"comment"===i[1]&&(t.comment_id=i[3]),t.obj_id=i[4],e.push(t))}}),e.length>0&&JetpackLikesPostMessage({event:"initialBatch",requests:e},window.frames["likes-master"])}function JetpackLikesMessageListener(e,t){var i,a,s,d,o,r;if(void 0!==e.event&&("https://widgets.wp.com","https://widgets.wp.com"===t.origin))switch(e.event){case"masterReady":jQuery(document).ready(function(){jetpackLikesMasterReady=!0;var e={event:"injectStyles"},t=jQuery(".sd-text-color"),i=jQuery(".sd-link-color");jQuery("iframe.admin-bar-likes-widget").length>0&&(JetpackLikesPostMessage({event:"adminBarEnabled"},window.frames["likes-master"]),e.adminBarStyles={background:jQuery("#wpadminbar .quicklinks li#wp-admin-bar-wpl-like > a").css("background"),isRtl:"rtl"===jQuery("#wpadminbar").css("direction")}),window.addEventListener||jQuery("#wp-admin-bar-admin-bar-likes-widget").hide(),e.textStyles={color:t.css("color"),fontFamily:t.css("font-family"),fontSize:t.css("font-size"),direction:t.css("direction"),fontWeight:t.css("font-weight"),fontStyle:t.css("font-style"),textDecoration:t.css("text-decoration")},e.linkStyles={color:i.css("color"),fontFamily:i.css("font-family"),fontSize:i.css("font-size"),textDecoration:i.css("text-decoration"),fontWeight:i.css("font-weight"),fontStyle:i.css("font-style")},JetpackLikesPostMessage(e,window.frames["likes-master"]),JetpackLikesBatchHandler()});break;case"showLikeWidget":case"showCommentLikeWidget":jQuery("#"+e.id+" .likes-widget-placeholder").fadeOut("fast");break;case"killCommentLikes":jQuery(".jetpack-comment-likes-widget-wrapper").remove();break;case"clickReblogFlair":wpcom_reblog.toggle_reblog_box_flair(e.obj_id);break;case"showOtherGravatars":i=jQuery("#likes-other-gravatars"),a=i.find("ul"),i.hide(),a.html(""),i.find(".likes-text span").text(e.total),jQuery.each(e.likers,function(e,t){var i;"http"===t.profile_URL.substr(0,4)&&((i=jQuery("
  • ")).addClass(t.css_class),i.find("a").attr({href:t.profile_URL,rel:"nofollow",target:"_parent"}).addClass("wpl-liker"),i.find("img").attr({src:t.avatar_URL,alt:t.name}).css({width:"30px",height:"30px",paddingRight:"3px"}),a.append(i))}),s=jQuery("[name='"+e.parent+"']").offset(),i.css("left",s.left+e.position.left-10+"px"),i.css("top",s.top+e.position.top-33+"px"),d=Math.floor(e.width/37),(o=37*Math.ceil(e.likers.length/d)+13)>204&&(o=204),i.css("height",o+"px"),i.css("width",37*d-7+"px"),a.css("width",37*d+"px"),i.fadeIn("slow"),(r=a[0].offsetWidth-a[0].clientWidth)>0&&(i.width(i.width()+r),a.width(a.width()+r))}}function JetpackLikesWidgetQueueHandler(){var e;if(jetpackLikesMasterReady){jetpackUnloadScrolledOutWidgets();var t=jetpackGetUnloadedWidgetsInView();t.length>0&&JetpackLikesBatchHandler();for(var i=0,a=t.length;i<=a-1;i++)(e=t[i].id)&&jetpackLoadLikeWidgetIframe(e)}else setTimeout(JetpackLikesWidgetQueueHandler,500)}function jetpackLoadLikeWidgetIframe(e){var t;if(void 0!==e){(t=jQuery("#"+e)).find("iframe").remove();var i=t.find(".likes-widget-placeholder");if(i.hasClass("post-likes-widget-placeholder")){var a=document.createElement("iframe");a.class="post-likes-widget jetpack-likes-widget",a.name=t.data("name"),a.src=t.data("src"),a.height="18px",a.width="200px",a.frameBorder="0",a.scrolling="no",t.hasClass("slim-likes-widget")?(a.height="22px",a.width="68px",a.scrolling="no"):(a.height="55px",a.width="100%"),i.after(a)}if(i.hasClass("comment-likes-widget-placeholder")){var s=document.createElement("iframe");s.class="comment-likes-widget-frame jetpack-likes-widget-frame",s.name=t.data("name"),s.src=t.data("src"),s.height="18px",s.width="100%",s.frameBorder="0",s.scrolling="no",t.find(".comment-like-feedback").after(s),jetpackCommentLikesLoadedWidgets.push(s)}t.removeClass("jetpack-likes-widget-unloaded").addClass("jetpack-likes-widget-loading"),t.find("iframe").load(function(e){var i=jQuery(e.target);JetpackLikesPostMessage({event:"loadLikeWidget",name:i.attr("name"),width:i.width()},window.frames["likes-master"]),t.removeClass("jetpack-likes-widget-loading").addClass("jetpack-likes-widget-loaded"),t.hasClass("slim-likes-widget")&&t.find("iframe").Jetpack("resizeable")})}}function jetpackGetUnloadedWidgetsInView(){return jQuery("div.jetpack-likes-widget-unloaded").filter(function(){return jetpackIsScrolledIntoView(this)})}function jetpackIsScrolledIntoView(e){var t=e.getBoundingClientRect().top,i=e.getBoundingClientRect().bottom;return t+jetpackLikesLookAhead>=0&&i<=window.innerHeight+jetpackLikesLookAhead}function jetpackUnloadScrolledOutWidgets(){for(var e=jetpackCommentLikesLoadedWidgets.length-1;e>=0;e--){var t=jetpackCommentLikesLoadedWidgets[e];if(!jetpackIsScrolledIntoView(t)){var i=jQuery(t).parent().parent();i.removeClass("jetpack-likes-widget-loaded jetpack-likes-widget-loading").addClass("jetpack-likes-widget-unloaded"),i.children(".comment-likes-widget-placeholder").fadeIn(),jetpackCommentLikesLoadedWidgets.splice(e,1),jQuery(t).remove()}}}pm.bind("likesMessage",JetpackLikesMessageListener),jQuery(document).click(function(e){var t=jQuery("#likes-other-gravatars");0===t.has(e.target).length&&t.fadeOut("slow")});var jetpackWidgetsDelayedExec=function(e,t){var i;return function(){i&&clearTimeout(i),i=setTimeout(t,e)}},jetpackOnScrollStopped=jetpackWidgetsDelayedExec(250,JetpackLikesWidgetQueueHandler);JetpackLikesWidgetQueueHandler(),window.addEventListener("scroll",jetpackOnScrollStopped,!0);