| 1 |
!function(){"use strict";jQuery(document).ready(function(a){function t(a,t,e){var l=new Date;l.setTime(l.getTime()+24*e*60*60*1e3);var i="expires="+l.toUTCString();document.cookie=a+"="+t+"; "+i}function e(a){for(var t=a+"=",e=document.cookie.split(";"),l=0;l<e.length;l++){for(var i=e[l];" "==i.charAt(0);)i=i.substring(1);if(0==i.indexOf(t))return i.substring(t.length,i.length)}return""}function l(l,i,n,s){var m=e("jltma_like_"+i),o=e("jltma_dislike_"+i);n.hasClass("jltma-like-trigger")&&(a(".jltma-dislike-trigger",n.closest(".jltma-like-dislike-wrapper")).removeClass("jltma-already-disliked"),n.addClass("jltma-already-liked")),n.hasClass("jltma-dislike-trigger")&&(a(".jltma-like-trigger",n.closest(".jltma-like-dislike-wrapper")).removeClass("jltma-already-liked"),n.addClass("jltma-already-disliked")),a.ajax({type:"post",url:jltma_localize_comments_data.ajax_url,data:{comment_id:i,jltma_like_cookie:m,jltma_dislike_cookie:o,action:"jltma_like_dislike",type:l,_wpnonce:jltma_localize_comments_data.ajax_nonce},beforeSend:function(a){},success:function(e){e=a.parseJSON(e);var n,m="jltma_"+l+"_"+i;n="jltma_"+s+"_"+i,document.cookie=n+"=; expires=Thu, 01 Jan 1970 00:00:01 GMT;",t(m,1,365);var o=e.latest_like_count,r=e.latest_dislike_count;a("#jltma-like-count-"+i).html(o),a("#jltma-dislike-count-"+i).html(r)}})}function i(a,t,e){var l="",i=a,n=jltma_localize_comments_data.page_number_loader;l+='<div class="jltma-comment-pagination-wrapper jltma-'+e+'"> <ul>',i>1&&(l+='<li class="jltma-previous-page-wrap"><a href="javascript:void(0);" class="jltma-previous-page" data-total-page="'+t+'" data-pagination-type="page-number"><i class="fa fa-angle-left"></i></a></li>');for(var s=t,m=i;m<=s;m++)l+='<li class="jltma-fa"><a href="javascript:void(0);" data-total-page="'+t+'" data-page-number="'+m+'" class="'+(i==m?"jltma-current-page jltma-page-link":"jltma-page-link")+'" data-pagination-type="page-number" >'+m;return i<t&&(l+='<li class="jltma-next-page-wrap"><a href="javascript:void(0);" data-total-page="'+t+'" class="jltma-next-page"" data-pagination-type="'+e+'"><i class="fa fa-angle-right"></i></a></li>'),l+='</ul> <img src="'+n+'" class="jltma-page-number-loader" style="display:none;"></div>'}a("body").on("click",".jltma-like-dislike-trigger",function(i){i.preventDefault();var n,s=a(this),m=a(this).data("comment-id"),o=a(this).data("trigger-type"),r=e("jltma_like_"+m),c=e("jltma_dislike_"+m),p=s.closest(".jltma-like-dislike-wrapper").find(".jltma-like-count-wrap").html(),d=s.closest(".jltma-like-dislike-wrapper").find(".jltma-dislike-count-wrap").html();if("like"==o&&""==r&&!s.hasClass("jltma-dislike-trigger")){if(t("jltma_"+o+"_"+m,1,365),""==c)if("K"==(n=p.slice(-1))||"M"==n||"B"==n||"T"==n)var j=parseInt(p),g=parseInt(d);else j=parseInt(p)+1,g=parseInt(d);""!=c&&("K"==(n=p.slice(-1))||"M"==n||"B"==n||"T"==n?(j=parseInt(p),g=parseInt(d)):((g=parseInt(d)-1)<0&&(g=0),j=parseInt(p)+1)),a("#jltma-like-count-"+m).html(j),a("#jltma-dislike-count-"+m).html(g),l(o,m,s,"dislike")}""!=c||"dislike"!=o||(t("jltma_"+o+"_"+m,1,365),s.hasClass("jltma-like-trigger"))||(""==r&&("K"==(n=d.slice(-1))||"M"==n||"B"==n||"T"==n?(j=parseInt(p),g=parseInt(d)):(g=parseInt(d)+1,j=parseInt(p))),""!=r&&("K"==(n=d.slice(-1))||"M"==n||"B"==n||"T"==n?(j=parseInt(p),g=parseInt(d)):((j=parseInt(p)-1)<0&&(j=0),g=parseInt(d)+1)),a("#jltma-like-count-"+m).html(j),a("#jltma-dislike-count-"+m).html(g),l(o,m,s,"like"))}),a(".jltma-comments-wrap").on("click",".jltma-page-link",function(t){a(this).closest(".jltma-comment-pagination-wrapper").find(".jltma-page-link").removeClass("jltma-current-page"),a(this).addClass("jltma-current-page");var e=a("#jltma-current-post-id").val(),l=a(this).data("page-number"),n=a(this).data("total-page"),s=a(this).data("pagination-type"),m=a(this).closest(".jltma-comments-wrap").data("jltma-comment-settings").template;a.ajax({type:"post",url:jltma_localize_comments_data.ajax_url,data:{page_number:l,template:m,post_id:e,action:"jltma_comment_pagination",_wpnonce:jltma_localize_comments_data.ajax_nonce},cache:!1,beforeSend:function(t){a(".jltma-page-number-loader").show()},success:function(t){a(".jltma-page-number-loader").hide();var e=i(l,n,s);a(".jltma-comment-list-inner").replaceWith(t),a(".jltma-comment-pagination-wrapper").replaceWith(e),a("html, body").animate({scrollTop:a(".jltma-comment-listing-wrap").offset().top},1e3)}})}),a("body").on("click",".jltma-next-page,.jltma-previous-page",function(){var t=a("#jltma-current-post-id").val(),e=a(this).data("total-page"),l=a(this).data("pagination-type"),n=a(this).closest(".jltma-comment-pagination-wrapper").find(".jltma-current-page").data("page-number"),s=parseInt(n)+1,m=parseInt(n)-1,o=a(this).closest(".jltma-comments-wrap").data("jltma-comment-settings").template;n=a(this).hasClass("jltma-previous-page")?m:s,a.ajax({type:"post",url:jltma_localize_comments_data.ajax_url,data:{page_number:n,template:o,post_id:t,action:"jltma_comment_pagination",_wpnonce:jltma_localize_comments_data.ajax_nonce},beforeSend:function(t){a(".jltma-page-number-loader").show()},success:function(t){a(".jltma-page-number-loader").hide();var s=i(n,e,l);a(".jltma-comment-list-inner").replaceWith(t),a(".jltma-comment-pagination-wrapper").replaceWith(s),a("html, body").animate({scrollTop:a(".jltma-comment-listing-wrap").offset().top},1e3)}})}),a("body").on("click",".jltma-show-replies-trigger",function(){var t=a(this).data("comment-id");a(this).closest(".jltma-comment-template").siblings("ul").slideDown(400,function(){}),a(".jltma-hide-reply-trigger-"+t).show(),a(".jltma-show-reply-trigger-"+t).hide()}),a("body").on("click",".jltma-hide-replies-trigger",function(){var t=a(this).data("comment-id");a(this).closest(".jltma-comment-template").siblings("ul").slideUp(400,function(){}),a(".jltma-hide-reply-trigger-"+t).hide(),a(".jltma-show-reply-trigger-"+t).show()}),a(".jltma_comment_loadmore").click(function(){var t=a(this);return jltma_localize_comments_data.jc_page--,a.ajax({url:jltma_localize_comments_data.ajax_url,data:{action:"jltma_loadmore_comments",post_id:jltma_localize_comments_data.parent_post_id,jc_page:jltma_localize_comments_data.jc_page},type:"POST",beforeSend:function(a){t.text("Loading...")},success:function(e){e?(a(".jltma-comment-list").append(e),t.text("More comments"),1==jltma_localize_comments_data.jc_page&&t.remove()):t.remove()}}),!1})})}(jQuery); |