$(document).ready((function(){var t=$("#comments"),e=t.data("content-id"),o=t.data("content-table"),n=!1,i=$("#new_comment");if(bindBbcodeEvents(i),bindSmiliesEvents(i),$("#new_comment form").ajaxForm({afterSubmit:function(e){if(1==e.success){dataLayer.push({event:"GAEvent",category:"Comment",action:"New"}),t.html(e.html),m(t),$("#follow-container").hide();var o=$("#c"+e.commentId);$(document).scrollTop(o.offset().top-67)}}}),window.location.hash){var c=window.location.hash.match(/#comment([0-9]+)/);if(null!=c){var a=c[1],r=$("#c"+a);0==r.length?(n=!0,$.ajax({url:"/index.php?controller=comment&action=get_content_comments&comment_id="+a,type:"GET",dataType:"json",success:function(e){1==e.success&&(t.html(e.html),m(t),r=$("#c"+a),$(document).scrollTop(r.offset().top-67))}})):$(document).scrollTop(r.offset().top-67)}}function s(e,o,n){$.ajax({url:"/index.php?controller=comment&action=get_content_comments&content_table="+e+"&content_id="+o+"&page="+n,type:"GET",dataType:"json",success:function(i){1==i.success&&(dataLayer.push({event:"GAEvent",category:"Comment",action:"Pagination-"+e,label:o,value:n}),t.html(i.html),m(t))}})}function m(t){refreshLazyLoading(),youtubelazy(),function(n){var i=n('<div id="tooltip" class="text-window"></div>'),c=n(".cite",t);function a(t,c){i.html("Cargando..."),n("body").append(i);var a=t.x+10,r=t.y+10;n(window).width()-(a+i.outerWidth())<0&&(a-=i.outerWidth()),n(window).height()-(r+i.outerHeight())<0&&(r-=i.outerHeight());var s={top:r+"px",left:a+"px"};n(window).width()<=420&&(s={bottom:"0px",left:"0px",right:"0px",width:"auto",position:"fixed"}),i.css(s),i.show();var m=c.attr("id").match(/^relative\-id\-([0-9]+)$/)[1];i.load("/index.php?controller=comment&action=get_comment_text&content_id="+e+"&content_table="+o+"&relative_id="+m)}function r(){i.detach()}isTouchDevice()?c.on("touchstart",(function(t){t.stopPropagation();var e=n(this),o=(t=t.originalEvent).touches[0];a({x:o.pageX,y:o.pageY},e),n(document).on("touchstart.cite",(function(t){r(),n(document).off("touchstart.cite")}))})):c.on("mouseenter",(function(t){var e=n(this);a({x:t.pageX,y:t.pageY},e)})).on("mouseleave",(function(t){r()}))}(jQuery),isTouchDevice()?$(".advanced-buttons",t).show():($(".user-info",t).userInfo(),function(t){var e=t('<div id="jtip" class="tooltip"></div>');t(".tooltip-trigger").mouseenter((function(o){var n=t(this);t("body").append(e),e.html(n.data("tooltip"));var i=n.offset(),c=i.left+n.outerWidth()/2-e.outerWidth()/2,a=i.top-e.outerHeight()-5;e.css({left:c,top:a,position:"absolute"}),e.show()})).mouseleave((function(t){e.remove()}))}(jQuery)),$(".miniicon-like",t).on("click",(function(t){t.preventDefault();var e=$(this),o=e.parents(".comment").data("comment-id");$.ajax({type:"GET",url:"/index.php?controller=comment&action=vote_comment_up&comment_id="+o,dataType:"json",success:function(t){1==t.success?(e.html(t.votes.up),e.removeClass("enabled")):0==t.success&&$.lightbox.error(t.reason)}})})),$(".warn-user",t).on("click",(function(t){t.preventDefault();var e=$(this).data("user-id"),o=$(this).parents(".comment").data("comment-id");$.lightbox.warnUser(e,o,"comments")})),$(".miniicon-report",t).on("click",(function(t){t.preventDefault();var e=$(this).parents(".comment").data("comment-id");$.lightbox.addReport(e,"comments")})),$(".delete-comment",t).on("click",(function(t){t.preventDefault();var e=$(this).parents(".comment"),o=e.data("comment-id");o>0&&$.lightbox.confirmation("¿Estás seguro de que quieres eliminar este comentario?",(function(){$.ajax({url:"/index.php?controller=comment&action=delete_comment&comment_id="+o+"&csrf="+Hispasonic.User.csrf,type:"GET",dataType:"json",error:function(){$.lightbox.error("Se produjo un error")},success:function(t){!0===t.success?$(".richtext",e).html("Comentario eliminado"):!1===t.success?$.lightbox.error(t.reason):$.lightbox.error("Se produjo un error")}})}))})),$(".pagination .page",t).on("click",(function(){var n=$(this),i=n.data("page");$(".pagination div",t).removeClass("selected"),n.addClass("selected"),s(o,e,i)}))}n||s(o,e,1)}));