"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},ThriveComments=ThriveComments||{};ThriveComments.util=ThriveComments.util||{},_.templateSettings={evaluate:/<#([\s\S]+?)#>/g,interpolate:/<#=([\s\S]+?)#>/g,escape:/<#-([\s\S]+?)#>/g},function(a){ThriveComments.util.tpl=function(b,c){var d=a("script#"+b.replace(/\//g,"-")).html()||"";return c?_.template(d)(c):_.template(d)},ThriveComments.util.nested=function(a,b){var c=this;return a instanceof Backbone.Model?this.nested(a.attributes,b):_.each(b,function(b){b.children&&(a[b.name]=c.nested(a[b.name],b.children)),_.isArray(a)?_.each(a,function(a){a[b.name]=new b.obj(a[b.name])}):a[b.name]=new b.obj(a[b.name])}),a},ThriveComments.util.validateInput=function(a,b,c){var d=a instanceof jQuery?a.val():a,e=!0;return d=d.trim(),""==d?(b||(b=ThriveComments.util.render_label("isRequired")),e=!1,a instanceof jQuery&&(a.removeClass("tcm-valid"),a.addClass("tcm-invalid"),a.prev(".tcm-error-message").show().html(b))):(a.removeClass("tcm-invalid"),a.prev(".tcm-error-message").hide(b)),e},ThriveComments.util.validateInputUrl=function(a,b,c){var d=a instanceof jQuery?a.val():a,e=!0;return void 0!=d&&0==this.isValidUrl(this.addHttp(d))?(b||(b=ThriveComments.util.render_label("isRequired")),e=!1,a instanceof jQuery&&(a.removeClass("tcm-valid"),a.addClass("tcm-invalid"),a.prev(".tcm-error-message").show().html(b))):(a.removeClass("tcm-invalid"),a.prev(".tcm-error-message").hide(b)),e},ThriveComments.util.validateStoringConsent=function(a,b){var c=a instanceof jQuery?a.is(":checked"):a,d=a.siblings(".tcm-consent-text"),e=ThriveComments.util.get_cookie("tcm_cookie_user_name"),f=!0;return""===ThriveComments.settings.storing_consent||0===ThriveComments.settings.storing_consent?f:(c||""!==e?(d.removeClass("tcm-not-selected"),a.prev(".tcm-error-message").hide(b)):(b||(b=ThriveComments.util.render_label("isRequired")),f=!1,a instanceof jQuery&&(d.removeClass("tcm-not-selected"),d.addClass("tcm-not-selected"),a.prev(".tcm-error-message").show().html(b))),f)},ThriveComments.util.validateEmail=function(a,b){var c=a.length?a.val():a;return/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(c)?(a instanceof jQuery&&(a.removeClass("tcm-invalid"),a.prev(".tcm-error-message").hide()),!0):(a instanceof jQuery&&(a.removeClass("tcm-valid"),a.addClass("tcm-invalid"),a.prev(".tcm-error-message").show().html(b)),!1)},ThriveComments.util.valuesToArray=function(a){return Object.keys(a).map(function(b){return a[b]})},ThriveComments.util.set_avatar_url=function(b){var c=this;if(this.set_avatar_url.images||(this.set_avatar_url.images={}),b.length){var d=b.data("comment-id"),e=b.data("email-hash");if(void 0!==this.set_avatar_url.images[e])return b.css("background-image","url("+this.set_avatar_url.images[e]+")"),!0;a.ajax({url:ThriveComments.routes.gravatar,type:"GET",dataType:"json",data:{comment_id:d}}).success(function(a){b.css("background-image","url("+a.gravatar_url+")"),c.set_avatar_url.images[e]=a.gravatar_url}).always(function(a){})}},ThriveComments.util.previousUser=function(){return""!==ThriveComments.util.get_cookie("social-login")||!!ThriveComments.current_user.ID||void 0},ThriveComments.util.set_cookie=function(a,b,c,d){d=d||"/",c=c||2592e3;var e,f=new Date;c=parseInt(c),f.setTime(f.getTime()+1e3*c),e=f.toUTCString(),"object"===(void 0===b?"undefined":_typeof(b))&&(b=JSON.stringify(b)),document.cookie=encodeURIComponent(a)+"="+b+";expires="+e+";path="+d},ThriveComments.util.get_cookie=function(a){for(var b=a+"=",c=document.cookie.split(";"),d=0;d<c.length;d++){for(var e=c[d];" "==e.charAt(0);)e=e.substring(1);if(0==e.indexOf(b))return e.substring(b.length,e.length)}return""},ThriveComments.util.search_comment=function(a,b){return void 0!==a.models&&this.search_recursive(a.models,b)},ThriveComments.util.search_recursive=function(a,b){for(var c=0,d=0;!c&&d<a.length;d++)a[d].get("comment_ID")==b?c=a[d]:a[d].get("children")&&a[d].get("children").length&&(c=c||this.search_recursive(a[d].get("children"),b));return c},ThriveComments.util.elem_viewport=function(b){var c=b.offset().top,d=c+b.outerHeight(),e=a(window).scrollTop(),f=e+a(window).height();return d>e&&c<f},ThriveComments.util.focusElement=function(b){var c=b.offset().top,d=b.height(),e=a(window).height(),f=void 0;f=d<e?c-(e/2-d/2):c,a("html, body").animate({scrollTop:f},300,"easeOutQuint")},ThriveComments.util.save_setting_model=function(a,b,c,d){if(!a)return!1;d=d||{},d.success||(d.success=ThriveComments.translations.settings_saved_success_toast),d.fail||(d.fail=ThriveComments.translations.settings_saved_fail_toast),new ThriveComments.models.Settings({name:a,value:b}).save().success(function(e){"NoMessage"!==d.success&&TVE_Dash.success(d.success),-1!==ThriveComments.tcm_sync_settings.indexOf(a)&&c.where({name:a}).shift().set("value",b)}).error(function(a){TVE_Dash.err(d.fail)})},ThriveComments.util.render_label=function(a,b,c){var d,e,f,g,h,i;if(b||(b=""),!(d=window.parent.ThriveComments?void 0===window.parent.ThriveComments.objects.Settings?ThriveComments.tcm_customize_labels:window.parent.ThriveComments.objects.Settings.get(ThriveComments.tcm_labels_key).get("value"):ThriveComments.tcm_customize_labels)||!d.hasOwnProperty(a))return"";if(h=d[a].text,-1===h.indexOf("{"))return h;switch(f=h.indexOf("{"),g=h.indexOf("}"),c){case"before":i=h.substr(0,f);break;case"after":i=h.substr(g+1,h.length-1);break;default:e=h.substring(f,g+1),i=h.replace(e,b)}return i},ThriveComments.util.showCommentsNumber=function(b){var c=a(".tcm-comments-number");c.length&&c.html(c.html().replace("comment_count",b)).show()},ThriveComments.util.tcm_show_loader=function(){a(".tcm-dot-loader").show()},ThriveComments.util.tcm_hide_loader=function(){a(".tcm-dot-loader").hide(),a(".thrive-comments-content").show()},ThriveComments.util.tcm_hide_textareas=function(b){var c=a(b.currentTarget).closest(".tcm-reply-container").find(".tcm-reply-btn").attr("data-id");a("textarea[name=tcm-post-content]").each(function(){var b=a(this).closest(".tcm-comment-wrapper"),d=a(this).closest(".tcm-reply-container").find(".tcm-reply-btn").attr("data-id"),e=b.find(".tcm-create-post-container").attr("data-position");void 0!==c&&a(this).closest(".comment-id-0").find(".tcm-comment-additional-fields").hide(),""!=e&&"top"===e||c==d||(a(this).closest(".tcm-comment-wrapper").slideUp(),a(this).closest(".tcm-reply-container").find(".tcm-reply-btn").attr("data-clicked",0))})},ThriveComments.util.after_ajax_login_actions=function(){a(".tcm-lazy-comments").empty(),a.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},cache:!1,url:ThriveComments.routes.generate_nonce,dataType:"JSON",data:{action:"refresh_nonce"},type:"GET"}).done(function(b){var c=window.parent.ThriveComments.util.commentId,d=c?"comments/"+c:"";ThriveComments.current_user=b.current_user,ThriveComments.nonce=b.nonce,Backbone.history.loadUrl(d),a(".tcm-comment-item").each(function(){var b=a(this);b.find(".tcm-comment-wrapper").hide(),b.find(".tcm-error-heading").hide()})})},ThriveComments.util.focusAfterLogin=function(){if(this.commentId&&parseInt(this.commentId)===this.commentId){var b=a("div[data-comment-id="+this.commentId+"]");b.find(".tcm-reply-btn").click(),b.find("#tcm-post-content").val(this.content).focus()}if("bottom"===this.position){var c=a(".add-comment");c.click(),c.closest(".tcm-lazy-comments").find("textarea#tcm-post-content").val(this.content).focus()}"top"===this.position&&a("textarea#tcm-post-content").focus(),this.position=null},ThriveComments.util.scrollToElement=function(b){b.length&&a("body, html").animate({scrollTop:b.offset().top-a(window).height()/2+30},{duration:500,complete:function(){var a=b.parent();a.addClass("tcm-highlight-item"),setTimeout(function(){return a.removeClass("tcm-highlight-item")},800)}})},ThriveComments.util.showCommentConversion=function(a){var b=new ThriveComments.views.CommentConversion({commentView:a});b.handleAfterShowAction(),a.$el.prepend(b.$el)},ThriveComments.util.isValidUrl=function(a){return!(null===a.match(/(http(s)?:\/\/.)(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/g))},ThriveComments.util.addHttp=function(b){return b=a.trim(b),b&&!/^(?:f|ht)tps?\:\/\//.test(b)&&(b="http://"+b),b},ThriveComments.util.err=function(b,c,d){a(".tvd-toast").remove(),Toasts.init(b,c||3e3,"tvd-toast tvd-red",d,"bottom"),a(".tvd-toast").parent().addClass("tcm-frontend-toast")},ThriveComments.util.getDropDownItems=function(a){var b=void 0;if(a.meta_query.tcm_delegate)b={approve:1,unapprove:1,no_reply_needed:1,featured:1,delegate:1,spam:1,trash:1};else if(a.meta_query.tcm_featured)b={stop_featured:1,no_reply_needed:1,delegate:1};else switch(a.status){case"all":case"hold":case"tcm_unreplied":b={approve:1,unapprove:1,no_reply_needed:1,featured:1,delegate:1,spam:1,trash:1};break;case"featured":b={no_reply_needed:1,stop_featured:1,delegate:1};break;case"spam":b={not_spam:1,delete:1};break;case"trash":b={spam:1,restore:1,delete:1}}return b},ThriveComments.util.dynamicSortByProperty=function(a){var b=1;return"-"===a[0]&&(b=-1,a=a.substr(1)),function(c,d){return(c[a]<d[a]?-1:c[a]>d[a]?1:0)*b}},ThriveComments.util.insertAtCaret=function(a,b){if(a.length){var c=a[0],d=c.scrollTop,e=0,f=c.selectionStart||"0"==c.selectionStart?"ff":!!document.selection&&"ie";if("ie"==f){c.focus();var g=document.selection.createRange();g.moveStart("character",-c.value.length),e=g.text.length}else"ff"==f&&(e=c.selectionStart);var h=c.value.substring(0,e),i=c.value.substring(e,c.value.length);if(c.value=h+b+i,e+=b.length,"ie"==f){c.focus();var j=document.selection.createRange();j.moveStart("character",-c.value.length),j.moveStart("character",e),j.moveEnd("character",0),j.select()}else"ff"==f&&(c.selectionStart=e,c.selectionEnd=e,c.focus());c.scrollTop=d}},ThriveComments.util.ajaxurl=function(a){var b=-1!==ajaxurl.indexOf("?")?"&":"?";return a&&a.length?(a=a.replace(/^(\?|&)/,""),a+="&_nonce="+ThriveComments.admin_nonce,ajaxurl+b+a):ajaxurl+b+"_nonce="+ThriveComments.admin_nonce},ThriveComments.util.toCamelCase=function(a){return a=a.replace(/_/g," "),a.toLowerCase().replace(/(?:(^.))/g,function(a){return a.charAt(a.length-1).toUpperCase()})},ThriveComments.util.formatSelection=function(a){var b=a,c=document.getElementById(b),d=void 0,e=void 0,f=void 0;if(void 0!==document.selection){c.focus();d=document.selection.createRange().text}else void 0!==c.selectionStart&&(e=c.selectionStart,f=c.selectionEnd,d=c.value.substring(e,f));return{selectedText:d,startPos:e,endPos:f}},ThriveComments.util.set_subscriber_cookies=function(a){var b=ThriveComments.util.get_cookie("subscribed_posts");if(""!==b&&(b=JSON.parse(b)),0===a){var c=b.indexOf(ThriveComments.post.ID);c>-1&&(b.splice(c,1),ThriveComments.util.set_cookie("subscribed_posts",JSON.stringify(b),31104e3))}else""===b?b=[ThriveComments.post.ID]:b.push(ThriveComments.post.ID),ThriveComments.util.set_cookie("subscribed_posts",JSON.stringify(b),31104e3)}}(jQuery);var ThriveComments=ThriveComments||{};ThriveComments.models=ThriveComments.models||{},ThriveComments.collections=ThriveComments.collections||{},function(a){ThriveComments.models.Base=Backbone.Model.extend({idAttribute:"comment_ID",sync:function(a,b,c){var d;return c=c||{},c.cache=!1,_.isUndefined(ThriveComments.nonce)||_.isNull(ThriveComments.nonce)||(d=c.beforeSend,c.beforeSend=function(a){if(a.setRequestHeader("X-WP-Nonce",ThriveComments.nonce),d)return d.apply(this,arguments)}),Backbone.sync(a,b,c)}}),ThriveComments.collections.Base=Backbone.Collection.extend({sync:function(a,b,c){var d;return c=c||{},c.cache=!1,c.url=this.url(),_.isUndefined(ThriveComments.nonce)||_.isNull(ThriveComments.nonce)||(d=c.beforeSend,c.beforeSend=function(a){if(a.setRequestHeader("X-WP-Nonce",ThriveComments.nonce),d)return d.apply(this,arguments)}),Backbone.sync(a,b,c)}}),ThriveComments.models.Comment=ThriveComments.models.Base.extend({getCommentStatus:function(){var a="";switch(1===parseInt(this.get("tcm_featured"))&&(a="featured"),this.get("comment_approved").toString()){case"1":case"approved":a="approved";break;case"0":case"hold":a="unapproved";break;case"spam":a="spam";break;case"trash":a="trash";break;default:0===parseInt(this.get("tcm_featured"))&&(a="stop_featuring")}return a},setCommentApproved:function(){if(void 0!==this.get("status")){var a=this.get("status")===ThriveComments.const.moderation.unapprove?0:1;this.set("comment_approved",a)}},url:function(){return ThriveComments.routes.comments+"/"+ThriveComments.post.ID},isPostAuthor:function(){return this.attributes.user_id===ThriveComments.post.post_author},parse:function(a){return delete a.author,void 0===a.replace_keyword||!1===a.replace_keyword?a:(ThriveComments.settings.tcm_keywords&&ThriveComments.settings.tcm_keywords.sort(ThriveComments.util.dynamicSortByProperty("-name")),_.each(ThriveComments.settings.tcm_keywords,function(b){var c=b.name.split(", ");_.each(c,function(c){var d,e='<a href="'+b.value+'"';b.new_tab&&(e+=' target="_blank"'),b.no_follow&&(e+=' rel="nofollow"'),c=c.trim(),e+=">"+c+"</a>";var f=new RegExp("\\b"+c+"\\b(?![^<]*?<\\/a>)","gi"),g=c.length;d=a.comment_content;var h=d.match(f);_.each(h,function(a){var b=d.search(f),h=e,i=e.search(">"+c+"<")+1;h=[h.slice(0,i),a,h.slice(i+g)].join(""),d=[d.slice(0,b),h,d.slice(b+g)].join("")}),a.comment_content=d})}),a)}}),ThriveComments.collections.Comments=ThriveComments.collections.Base.extend({model:ThriveComments.models.Comment,compField:ThriveComments.sorting.sort_field,compOrder:ThriveComments.sorting.order,tcm_secret:"",commentCount:0,awaiting_moderation:0,userCommentCount:0,minCompField:null,url:function(){return ThriveComments.routes.comments+"/"+ThriveComments.post.ID},comparator:function(a){return 1===parseInt(a.get("tcm_featured"))?-1*Number.MAX_SAFE_INTEGER+this.compOrder*a.get(this.compField):this.compOrder*a.get(this.compField)},nested:function(a){var b=this;return a.children&&_.each(a.children,function(c,d){b.nested(c),a.children[d]=new ThriveComments.models.Comment(c,{parse:!0})}),a},parse:function(a){var b=this;return this.commentCount=a.count,this.userCommentCount=a.user_comment_count,a=a.comments,_.each(a,function(c,d){c.children&&c.children.length&&(a[d]=b.nested(c))}),a},insertComment:function(a,b){var c=this;_.each(a,function(d,e){if(d.get("comment_ID")===parseInt(b.get("comment_parent"))){var f=a[e].get("children");f||(f=[]),f.push(b),a[e].set("children",f)}else d.get("children")&&d.get("children").length&&c.insertComment(d.get("children"),b)})},push:function(a){this.commentCount++,0==a.get("comment_parent")?(this.models.push(a),this.length=this.length+1):this.insertComment(this.models,a)}})}(jQuery);var ThriveComments=ThriveComments||{};ThriveComments.views=ThriveComments.views||{},ThriveComments.objects=ThriveComments.objects||{},function(a){ThriveComments.views.CreateComment=Backbone.View.extend({template:ThriveComments.util.tpl("comments/create"),events:{"focus #tcm-post-content":"showMainCreateFields","click .tcm-save-btn":"saveComment","click .tcm-show-login":"showLogin","keydown .form-input":"keyAction","input textarea":"textareaSizing","click #tcm-fb-logo":"facebookLogin","click #tcm-gp-logo":"googleLogin","click .tcm-logout-label":"logout"},keyAction:function(a){13===a.keyCode&&(this.saveComment(a),a.stopPropagation())},initialize:function(a){a&&(this.viewList=a.viewList),this.comments_media_query()},comments_media_query:function(){var a=this.$el.parents("#comments");a.width()<600&&a.addClass("tcm-small")},textareaSizing:function(b){var c=b.currentTarget;a(c).css("height",1).css("height",c.scrollHeight+2)},showMainCreateFields:function(a){if(ThriveComments.util.tcm_hide_textareas(a),this.viewList.showPreviousClickedReplys(),this.$(".tcm-comment-additional-fields").slideDown(),!ThriveComments.current_user.ID){var b=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_name")).slice(1,-1).replace(/\+/g," "),c=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email")).slice(1,-1),d=JSON.parse('{ "link": "'+decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_website")).slice(1,-1)+'" }');b&&""===this.$("#tcm-guest-name").val()&&(this.$("#tcm-guest-name").val(b),this.$("#tcm-guest-email").val(c),this.$("#tcm-author-url").val(d.link),this.$("span.checkmark").click())}},render:function(b){var c=this.$("#tcm-post-content").val(),d=ThriveComments.util.get_cookie("social-login");return""!==d&&(ThriveComments.social_user=JSON.parse(d)),b=a.extend({},b,{gravatarActive:ThriveComments.settings.gravatar_active,share_individual_comments:ThriveComments.settings.share_individual_comments,comment_registration:ThriveComments.settings.comment_registration,current_user_id:void 0!==ThriveComments.current_user.ID?ThriveComments.current_user.ID:0,comment_content:void 0!==c?c:"",close_comments:ThriveComments.close_comments}),this.$el.html(this.template(b)),this.afterRender(),this},afterRender:function(){new Clipboard("#tcm-click-to-copy").on("success",function(b){var c=a(b.trigger).text(),d=a(b.trigger);d.text(ThriveComments.translations.copy_input),setTimeout(function(){d.text(c)},1e3),b.clearSelection()})},saveComment:function(b){var c=this;if(!this.validateComment())return!1;this.$("#tcm-submit-comment").text(ThriveComments.translations.comment_sending);var d=this.prepareCommentForSave();d=new ThriveComments.models.Comment(d),d.save().done(function(d){var e=new ThriveComments.models.Comment(d),f=c.$("textarea");a(".tcm-post-input-container textarea").val(""),c.$("#tcm-submit-comment").text(ThriveComments.util.render_label("submit_comment")),"trash"!==e.get("comment_approved")&&c.addNewCommentToList(b.currentTarget,e,0),c.removeCreateForm(),f.css("height",1),c.replyAndApprove(d,e),a(".tcm-reply-btn").attr("data-clicked",0),c.viewList.showPreviousClickedReplys()}).error(function(a){var b=c.handleError(a);ThriveComments.util.err(b)}).always(function(){c.$("#tcm-submit-comment").text(ThriveComments.util.render_label("submit_comment"))})},prepareCommentForSave:function(){var a=null,b=null,c=null,d="",e=ThriveComments.util.get_cookie("social-login"),f=this.$("#tcm-author-url").val();return""!==e?(a=JSON.parse(e),b=a.name,c=a.email,d=a.picture):(b=ThriveComments.util.previousUser()?ThriveComments.current_user.display_name:this.$("input[name='name']").val(),c=ThriveComments.util.previousUser()?ThriveComments.current_user.user_email:this.$("input[name='email']").val()),{children:[],comment_content:this.$("#tcm-post-content").val().trim(),comment_author:b,comment_author_email:c,comment_author_url:void 0!==f&&ThriveComments.util.isValidUrl(ThriveComments.util.addHttp(f))?f:"",comment_author_picture:d,comment_parent:this.$(".tcm-save-btn").attr("data-parent"),level:this.$(".tcm-save-btn").attr("data-parent")>0?Math.min(parseInt(this.$(".tcm-save-btn").attr("data-level"))+1,3):0,secret_spam:ThriveComments.secret_spam,comment_post_ID:ThriveComments.post.ID,tva_term:void 0!==ThriveComments.tva_term&&ThriveComments.tva_term,tcm_receive_notifications:this.$("#tcm_receive_notifications").prop("checked"),tcm_remember_me:this.$("#tcm_remember_me").prop("checked"),tcm_storing_consent:this.$("#tcm_storing_consent").prop("checked")}},handleError:function(a){var b="";switch(a.status){case 409:b=ThriveComments.util.render_label("comment_duplicate");break;case 429:b=ThriveComments.util.render_label("comment_flood");break;default:b=ThriveComments.util.render_label(a.responseJSON.code),""===b&&(b=a.responseJSON.code+". "+a.responseJSON.message)}return b},replyAndApprove:function(a,b){var c=b.get("comment_parent"),d=null;if(c&&b.get("is_moderator")&&(d=ThriveComments.util.search_comment(ThriveComments.objects.Comments,c))){var e={id:d.get("comment_ID")};d.set("comment_approved",1),d.set("status",1),d.save(e,{error:this.handleError})}},removeCreateForm:function(){var a=this.$(".mainInput");a.parents("div.tcm-lazy-comments").length&&this.$(".tcm-create-post-container").hide(),a.length?(a.val(""),this.$(".tcm-comment-additional-fields").hide()):this.$el.remove()},addNewCommentToList:function(b,c,d){var e=jQuery(b).closest(".tcm-comment-item"),f=this.$el.siblings(".tcm-comments-list"),g="";return!!f.first().find("div[data-comment-id="+c.get("comment_ID")+"]").length||(ThriveComments.objects.Comments.push(c),this.updateCommentCountLabel(c),g=this.insertCommentIntoPosition(b,c,e,d),g&&ThriveComments.util.showCommentConversion(g),a(window).trigger("scroll"),this)},insertCommentIntoPosition:function(b,c,d,e){var f,g=new ThriveComments.views.CommentsItem({model:c,commentsList:this.viewList});if(f=g.render().$el,!d.length){var h=a(b).closest(".tcm-create-post-container").attr("data-position");return f.addClass("tcm-main-parent"),"top"===h&&-1===ThriveComments.objects.Comments.compOrder?(this.$el.next().prepend(f),g):"bottom"!==h||1!==ThriveComments.objects.Comments.compOrder||jQuery(".tcm-loader").is(":visible")?e?(jQuery(".tcm-loader").is(":visible")&&-1!==ThriveComments.objects.Comments.compOrder||this.$el.next().prepend(f),g):(this.viewList.close(),this.viewList.pushCommentsCreated({comment_id:c.get("comment_ID"),comment_after_save:c.get("show_after_save")}),this.viewList.initDisplayComments(c.get("comment_ID")),!1):(this.$el.parent().prev().append(f),g)}return c.get("level")>2&&f.addClass("stop-nesting"),d.append(f),g},updateCommentCountLabel:function(b){"1"===b.get("comment_approved")&&a(".tcm-comments-number").text(function(a,b){return b.replace(/(\d+)/,ThriveComments.objects.Comments.commentCount)})},validateComment:function(){var a=!0;ThriveComments.util.get_cookie("social-login");return ThriveComments.util.previousUser()||(ThriveComments.util.validateInput(this.$("input[name='name']"),ThriveComments.util.render_label("author_name_required"),!0)||(a=!1),ThriveComments.util.validateEmail(this.$("input[name='email']"),ThriveComments.util.render_label("isRequired"),!0)||(a=!1),""!==this.$("#tcm-author-url").val()&&(ThriveComments.util.validateInputUrl(this.$("#tcm-author-url"),ThriveComments.translations.invalid_website_url,!0)||(a=!1)),ThriveComments.util.validateStoringConsent(this.$("#tcm_storing_consent"),ThriveComments.translations.accept_privacy_checkbox)||(a=!1)),ThriveComments.util.validateInput(this.$("#tcm-post-content"),ThriveComments.util.render_label("comment_content_missing"),!0)||(a=!1),a},showLogin:function(b){var c,d=a("#wp-auth-check"),e=a("#wp-auth-check-form"),f=a("#wp-auth-check-wrap"),g=f.find(".wp-auth-fallback-expired"),h=this,i=!1,j=jQuery(b.currentTarget).closest(".tcm-create-post-container");ThriveComments.util.position=j.data("position"),ThriveComments.util.content=j.find("textarea#tcm-post-content").val(),ThriveComments.util.afterLogin=1,ThriveComments.util.commentId=j.data("comment-id"),e.length&&(a(window).on("beforeunload.wp-auth-check",function(a){a.originalEvent.returnValue=window.authcheckL10n.beforeunload}),e.attr("data-src",e.attr("data-src").replace("members/login/","wp-login.php")),c=a('<iframe id="wp-auth-check-frame" frameborder="0">').attr("title",g.text()),c.on("load",function(){var b,c;i=!0,e.removeClass("loading");try{c=a(this).contents().find("body"),b=c.height()}catch(a){return f.addClass("fallback"),d.css("max-height",""),e.remove(),void g.focus()}b?c&&c.hasClass("interim-login-success")?h.hideLogin():d.css("max-height",b+40+"px"):c&&c.length||(f.addClass("fallback"),d.css("max-height",""),e.remove(),g.focus())}).attr("src",e.data("src")).ready(function(){f.find(".wp-auth-check-close").on("click",function(){h.hideLogin()})}),e.append(c)),a("body").addClass("modal-open"),f.removeClass("hidden"),c?(c.focus(),setTimeout(function(){i||(f.addClass("fallback"),e.remove(),g.focus())},1e4)):g.focus()},hideLogin:function(){var b=a("#wp-auth-check-wrap");a(window).off("beforeunload.wp-auth-check"),"undefined"==typeof adminpage||"post-php"!==adminpage&&"post-new-php"!==adminpage||"undefined"==typeof wp||!wp.heartbeat||(a(document).off("heartbeat-tick.wp-auth-check"),wp.heartbeat.connectNow()),b.fadeOut(200,function(){b.addClass("hidden").css("display",""),a("#wp-auth-check-frame").remove(),a("body").removeClass("modal-open")})},checkConversion:function(a){var b=this;("first_time"==a.show_after_save&&"tcm_redirect"==ThriveComments.settings.tcm_conversion.first_time.active||"second_time"==a.show_after_save&&"tcm_redirect"==ThriveComments.settings.tcm_conversion.second_time.active)&&b.redirectURL(a)},redirectURL:function(a){"first_time"==a.show_after_save?window.location.replace(ThriveComments.settings.tcm_conversion.tcm_redirect.first_time.redirect_url):"second_time"==a.show_after_save&&window.location.replace(ThriveComments.settings.tcm_conversion.tcm_redirect.second_time.redirect_url)},facebookLogin:function(a){var b=this;FB.login(function(c){if(c.authResponse){FB.api("/me?fields=name,email",function(c){var d={name:c.name,email:c.email,picture:location.protocol+"//graph.facebook.com/"+c.id+"/picture?width=200"};ThriveComments.util.set_cookie("social-login",d),ThriveComments.social_user=d,b.reloadView(a)})}},{scope:"email"})},googleLogin:function(a){var b,c=null,d=this;"undefined"!=typeof gapi&&gapi.load("auth2",function(){b=gapi.auth2.init({client_id:ThriveComments.tcm_social_apis.google.client_id,scope:"profile"}),b.signIn().then(function(){c=b.currentUser.get().getBasicProfile();var e={name:c.getName(),email:c.getEmail(),picture:c.getImageUrl()};ThriveComments.util.set_cookie("social-login",e),ThriveComments.social_user=e,d.reloadView(a)})})},logout:function(a){ThriveComments.util.set_cookie("social-login","",-1),delete ThriveComments.social_user,this.reloadView(a)},reloadView:function(b){var c=a(b.currentTarget).closest(".tcm-create-post-container"),d=c.data("comment-id"),e=d?"comments/"+d:"";ThriveComments.util.position=c.data("position"),ThriveComments.util.content=c.find("textarea#tcm-post-content").val(),ThriveComments.util.afterLogin=1,ThriveComments.util.commentId=d,Backbone.history.loadUrl(e),a(".tcm-comment-item").each(function(){var b=a(this);b.find(".tcm-comment-wrapper").hide(),b.find(".tcm-error-heading").hide()})}}),ThriveComments.views.SortComments=Backbone.View.extend({template:ThriveComments.util.tpl("comments/sort"),sortBy:ThriveComments.sorting.sort_name,events:{"click #tcm-sort-by":"mouseEnterShare","click .tcm-dropdown-element":"sortComments","mouseenter #tcm-sort-by":"mouseEnterShare","mouseleave #tcm-sort-by":"mouseLeaveShare"},initialize:function(a){this.viewList=a.viewList,this.render()},render:function(){this.$el.empty(),this.$el.append(this.template({sortBy:this.sortBy}))},sortComments:function(a){var b=a.currentTarget.getAttribute("data-value");jQuery(a.currentTarget).parent().siblings(".current-sorting").html(a.currentTarget.innerHTML.trim()),this.sortBy=b,this.viewList.sortComments(b),jQuery("#tcm-sort-by").removeClass("tcm-share-dropdown-hover")},mouseEnterShare:function(a){return"click"===a.type&&a.stopPropagation(),!a.target.classList.contains("tcm-sort-by")&&a.currentTarget.classList.add("tcm-share-dropdown-hover"),!1},mouseLeaveShare:function(a){return jQuery(a.currentTarget).removeClass("tcm-share-dropdown-hover"),!1}}),ThriveComments.views.Comments=Backbone.View.extend({template:ThriveComments.util.tpl("comments/list"),events:{"change #tcm-sort-by":"sortComments"},viewLazy:null,viewSort:null,comments_rendered:0,commentsCreated:[],lazyFlag:1,clickedRplyButtons:[],initialize:function(a){this.viewLazy=a.viewLazy,this.viewSort=a.viewSort,"undefined"==typeof FB&&1===ThriveComments.settings.tcm_api_status.facebook&&ThriveComments.settings.tcm_enable_social_signin&&(window.fbAsyncInit=function(){FB.init({appId:ThriveComments.tcm_social_apis.facebook.app_id,autoLogAppEvents:!0,status:!0,xfbml:!0,version:"v2.9"})},function(a,b,c){var d,e=a.getElementsByTagName(b)[0];a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src="//connect.facebook.net/en_US/sdk.js",e.parentNode.insertBefore(d,e))}(document,"script","facebook-jssdk")),"undefined"==typeof gapi&&1===ThriveComments.settings.tcm_api_status.google_api&&ThriveComments.settings.tcm_enable_social_signin&&function(a,b,c){var d,e=a.getElementsByTagName(b)[0];a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src="https://apis.google.com/js/platform.js",e.parentNode.insertBefore(d,e))}(document,"script","google-api")},close:function(){this.$el.empty(),this.unbind()},startLazy:function(a){var b=this;if(!a&&ThriveComments.settings.lazy_load){var c=jQuery("#thrive-comments");(this.lazyFlag&&ThriveComments.util.elem_viewport(c)||ThriveComments.util.elem_viewport(this.viewLazy.$el)||ThriveComments.util.afterLogin)&&(b.initDisplayComments(a),b.lazyFlag=0),jQuery(window).scroll(function(){b.lazyFlag&&ThriveComments.util.elem_viewport(c)&&(b.initDisplayComments(a),b.lazyFlag=0)})}else b.initDisplayComments(a);this.lazy_avatar()},initDisplayComments:function(b){var c=this;if(ThriveComments.util.tcm_show_loader(),"static"===this.viewLazy.type){var d={};ThriveComments.tva_term&&void 0!==ThriveComments.tva_term&&(d.tva_term=ThriveComments.tva_term),this.collection.fetch({data:a.param(d),success:function(){c.displayComments(b)},error:function(a,b){ThriveComments.util.err(ThriveComments.translations.tcm_get_comments_error)}})}else this.displayComments(b)},lazy_avatar:function(){var b=this;a(window).on("scroll",function(){b.show_images()})},show_images:function(){a("div.no-image").each(function(){var b=a(this);if(!0===b.data("social-avatar"))return b.removeClass("no-image"),!1;ThriveComments.util.elem_viewport(b)&&(ThriveComments.util.set_avatar_url(b),b.removeClass("no-image"))})},displayComments:function(a){this.viewLazy.view=this,this.viewLazy.changePage(null,{id:a,page:1,sortBy:ThriveComments.sorting.sort_field})},sortComments:function(a){switch(a){case"desc":this.collection.compField="comment_ID",this.collection.compOrder=-1;break;case"asc":this.collection.compField="comment_ID",this.collection.compOrder=1;break;case"top-rated":this.collection.compField="comment_karma",this.collection.compOrder=-1}var b=1==this.collection.compOrder?"ASC":"DESC";this.comments_rendered=0,this.viewLazy.changePage(null,{page:1,resetContent:1,sortBy:this.collection.compField,order:b})},render:function(a){var b=this;return ThriveComments.util.showCommentsNumber(this.collection.commentCount),a.forEach(function(a){var c,d=new ThriveComments.views.CommentsItem({model:a,commentsList:b}),e=d.render().$el;e.addClass("tcm-main-parent"),b.$el.append(e),(c=b.searchInCommentsCreated(a.get("comment_ID")))&&(d.model.set("show_after_save",c.comment_after_save),ThriveComments.util.showCommentConversion(d))}),ThriveComments.util.tcm_hide_loader(),this},pushCommentsCreated:function(a){this.commentsCreated.push(a)},searchInCommentsCreated:function(b){if(!this.commentsCreated.length)return!1;var c=a.grep(this.commentsCreated,function(a){return parseInt(a.comment_id)===b});return 0!==c.length&&c[0]},addClickedReplyButton:function(a){return this.clickedRplyButtons.push(a),this},showPreviousClickedReplys:function(){return this.clickedRplyButtons.forEach(function(a){1!==parseInt(a.getAttribute("data-clicked"))&&(a.style.display="block")}),this}}),ThriveComments.views.FrontendModeration=Backbone.View.extend({template:ThriveComments.util.tpl("comments/moderation"),actions:{},events:{"click .tcm-dropdown-moderate-element":"updateComment"},initialize:function(a){this.commentView=a.commentView?a.commentView:null,this.setActions(),this.render(),this.initClipboard()},render:function(){var a=this.model.getCommentStatus(),b=this.getActions(a);this.$el.html(this.template({actions:b}))},initClipboard:function(){var b=this.$("[data-value=copyLink]");if(b.length){var c=new Clipboard(b[0]),d=ThriveComments.const.post_url+"#comments/"+this.$el.closest(".tcm-comment-content").attr("data-comment-id")
;b.attr("data-clipboard-text",d),c.on("success",function(b){var c=a(b.trigger),d=c.text();c.text(ThriveComments.translations.copy_input),setTimeout(function(){c.text(d)},1e3),b.clearSelection()})}},updateComment:function(a){var b=a.currentTarget.getAttribute("data-fn"),c=a.currentTarget.getAttribute("data-value");"function"==typeof this[b]&&this[b](c)},changeApprove:function(a){var b={id:this.model.get("comment_ID")};ThriveComments.const.moderation.unapprove===a&&"0"!==this.model.get("tcm_featured")&&(this.model.set("tcm_featured",0),b.update_meta="tcm_featured"),this.model.set("comment_approved",a),this.model.set("status",a),this.model.save(b,{error:this.errorAtSave})},changeFeature:function(a){var b={id:this.model.get("comment_ID"),update_meta:"tcm_featured"};return ThriveComments.const.moderation.featured===parseInt(a)&&this.model.get("comment_approved")!==ThriveComments.const.moderation.approve&&(this.model.set("status",ThriveComments.const.moderation.approve),this.model.set("comment_approved",1)),this.model.set("tcm_featured",parseInt(a)),this.model.save(b,{error:this.errorAtSave}),this},changeSpam:function(a){var b={id:this.model.get("comment_ID")};this.model.set("comment_approved",a),this.model.set("status",a).save(b,{error:this.errorAtSave})},changeTrash:function(a){var b={id:this.model.get("comment_ID")};this.model.set("status",a).save(b,{error:this.errorAtSave})},undoDelete:function(){var a="trash"===this.model.get("status")?"untrash":"unspam",b={id:this.model.get("comment_ID")};return this.model.set("status",a),this.model.save(b,{error:this.errorAtSave}),!1},errorAtSave:function(a,b,c){var d="";if(b.responseJSON.message)d=b.responseJSON.message;else if(b.responseText)try{if("parsererror"===c)d="Could not parse response: "+b.responseText;else{var e=JSON.parse(b.responseText);d=e.message}}catch(a){}d||(d=(b.statusText||c)+(b.status?" ("+b.status+")":"")),ThriveComments.util.err(d)},setActions:function(){var a={unapproved:{approve:{text:ThriveComments.translations.approve_text,fn:"changeApprove",value:1},feature:{text:ThriveComments.translations.feature_text,fn:"changeFeature",value:ThriveComments.const.moderation.featured},copy:{text:ThriveComments.util.render_label("copy_url"),value:"copyLink"},spam:{text:ThriveComments.translations.spam_text,fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.translations.trash_text,fn:"changeTrash",value:ThriveComments.const.moderation.trash}},approved:{unapprove:{text:ThriveComments.translations.unapprove_text,fn:"changeApprove",value:ThriveComments.const.moderation.unapprove},feature:{text:ThriveComments.translations.feature_text,fn:"changeFeature",value:ThriveComments.const.moderation.featured},copy:{text:ThriveComments.util.render_label("copy_url"),value:"copyLink"},spam:{text:ThriveComments.translations.spam_text,fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.translations.trash_text,fn:"changeTrash",value:ThriveComments.const.moderation.trash}},featured:{unapprove:{text:ThriveComments.translations.unapprove_text,fn:"changeApprove",value:ThriveComments.const.moderation.unapprove},stop_featuring:{text:ThriveComments.translations.stop_feature_text,fn:"changeFeature",value:ThriveComments.const.moderation.not_featured},spam:{text:ThriveComments.translations.spam_text,fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.translations.trash_text,fn:"changeTrash",value:ThriveComments.const.moderation.trash}},stop_featuring:{unapprove:{text:ThriveComments.translations.unapprove_text,fn:"changeApprove",value:ThriveComments.const.moderation.unapprove},feature:{text:ThriveComments.translations.feature_text,fn:"changeFeature",value:ThriveComments.const.moderation.featured},spam:{text:ThriveComments.translations.spam_text,fn:"changeSpam",value:ThriveComments.const.moderation.spam},trash:{text:ThriveComments.translations.trash_text,fn:"changeTrash",value:ThriveComments.const.moderation.trash}}},b={approved:{copy:{text:ThriveComments.util.render_label("copy_url"),value:"copyLink"}}};this.actions=ThriveComments.current_user.is_moderator?a:b},getActions:function(a){return""!==a?this.actions[a]:{}}}),ThriveComments.views.DeletedItem=Backbone.View.extend({template:ThriveComments.util.tpl("comments/deleted"),events:{"click .undo-action":"undoAction"},initialize:function(a){this.commentView=a.commentView?a.commentView:null,this.moderationView=a.moderationView?a.moderationView:null},render:function(){return this.$el.html(this.template({comment:this.model})),this.commentView.$(".tcm-comment-content").hide(),this.commentView.$(".tcm-comment-item").hide(),this.commentView.$el.removeClass("tcm-featured-class"),this},undoAction:function(){return this.moderationView.undoDelete(),!1}}),ThriveComments.views.CommentsItem=Backbone.View.extend({className:"tcm-comment-item",template:ThriveComments.util.tpl("comments/item"),voteRoute:ThriveComments.routes.comments+"/vote",events:{"click .tcm-reply-btn":"showCreateFields","click .tcm-share-btn":"showShareButtons","mouseenter .tcm-share-dropdown":"mouseEnterShare","mouseleave .tcm-share-dropdown":"mouseLeaveShare","click .tcm-share-twitter":"shareTwitter","click .tcm-share-facebook":"shareFacebook","click .tcm-voting-input":"vote"},initialize:function(a){this.commentsList=a.commentsList?a.commentsList:null,this.listenTo(this.model,"sync",this.commentSync)},showCreateFields:function(b){var c=new ThriveComments.views.CreateComment({viewList:this.commentsList}),d=b.currentTarget,e=d.getAttribute("data-id"),f=d.getAttribute("data-level");"1"!==d.getAttribute("data-clicked")&&(ThriveComments.util.tcm_hide_textareas(b),this.commentsList.showPreviousClickedReplys(),a(".add-comment").show(),jQuery(d).siblings(".tcm-create-comment-fields").html("").append(c.render({mainInput:0,id:e,level:f,photo_src:ThriveComments.current_user.photo_url,previousUser:ThriveComments.util.previousUser(),position:"",close_comments:ThriveComments.close_comments}).$el).css("display","none").slideDown(),d.setAttribute("data-clicked",1),d.style.display="none",this.commentsList.addClickedReplyButton(d),b.stopPropagation(),jQuery(window).trigger("scroll"))},commentSync:function(){return this.render(),"spam"!==this.model.get("status")&&"trash"!==this.model.get("status")||this.deletedState(),jQuery(window).trigger("scroll"),this},render:function(){var a=ThriveComments.util.get_cookie("vote-comment-"+this.model.id);return this.model.setCommentApproved(),this.$el.html(this.template({comment:this.model,gravatarActive:ThriveComments.settings.gravatar_active,close_comments:ThriveComments.close_comments,share_individual_comments:ThriveComments.settings.share_individual_comments,lazy_load_avatar:ThriveComments.settings.lazy_load_avatar,last_vote:a})),this.afterRender(),this.initCommentModeration(),this.model.get("children")&&this.model.get("children").length&&(this.$el.addClass("tcm-has-children"),this.renderChildren(this.model.get("comment_ID"),this.model.get("children"),this.$el)),this.commentsList.comments_rendered++,this},renderChildren:function(a,b,c){var d=this;b&&b.forEach(function(b){if(0!==parseInt(b.get("comment_parent"))&&parseInt(b.get("comment_parent"))===a){var e=new ThriveComments.views.CommentsItem({model:b,commentsList:d.commentsList}),f=e.render().$el,g=[];c.append(f),(g=d.commentsList.searchInCommentsCreated(b.get("comment_ID")))&&(e.model.set("show_after_save",g.comment_after_save),ThriveComments.util.showCommentConversion(e),e.handleAfterShowAction())}})},afterRender:function(){return this.model.get("user_id")===ThriveComments.post.post_author&&(this.$el.addClass("tcm-post-author"),this.$("strong").addClass("tcm-color-ac")),this.model.get("level")>=3&&this.$el.addClass("stop-nesting"),this.model.get("children")&&this.model.get("children").length&&this.$el.addClass("tcm-has-children"),1===parseInt(this.model.get("tcm_featured"))?this.$el.addClass("tcm-featured-class"):this.$el.removeClass("tcm-featured-class"),this},initCommentModeration:function(){this.moderationView=new ThriveComments.views.FrontendModeration({el:this.$("#tcm-moderate-front"),model:this.model,commentView:this})},showShareButtons:function(){this.$(".tcm-share-btns-container").show()},mouseEnterShare:function(a){return jQuery(a.currentTarget).addClass("tcm-share-dropdown-hover"),!1},mouseLeaveShare:function(a){var b=jQuery(a.currentTarget);return b.removeClass("tcm-share-dropdown-hover"),b.find(".tcm-copy-input-content").removeClass("hover"),!1},shareTwitter:function(a){var b,c=this.$(".tcm-comment-text-content").html().trim(),d=a.currentTarget.getAttribute("data-url"),e=this.$(".tcm-comment-author-name strong").text().replace(/\s\s+/g," ");for(c=c.replace(/<(?:.|\n)*?>/gm,"");e.length>20;)e=e.split(" ").slice(0,-1).join(" ");return c=c.replace(/<br\s*[\/]?>/gi," "),c.length>90&&(c=c.substring(0,90),c=c.split(" ").slice(0,-1).join(" ")),c=c+"... -"+e+" "+d,b=this.$("a.tcm-share-twitter").attr("href")+"?text="+encodeURIComponent(c),window.open(b,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=500"),!1},shareFacebook:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c=this.$(".tcm-comment-author-img").css("background-image").replace("url(","").replace(")","").replace(/\"/gi,""),d=this.$(".tcm-comment-text-content").html().trim(),e=encodeURIComponent(a.currentTarget.getAttribute("data-url")),f="";return d=d.replace(/<(?:.|\n)*?>/gm,""),d=d.replace(/<br\s*[\/]?>/gi,""),f=this.$("a.tcm-share-facebook").attr("href")+"?u="+e+"&title="+b+"&description="+d+"&picture="+encodeURIComponent(c),window.open(f,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=500"),!1},vote:function(a){var b=this,c=this.model.id,d=a.currentTarget.dataset.type,e=this.$(".tcm-comment-content:first .tcm-voting-input"),f=e.filter(".tcm-upvote").find(".tcm-votes-count").text(),g=e.filter(".tcm-downvote").find(".tcm-votes-count").text();return!this.doingVote&&(this.doingVote=!0,a.currentTarget.classList.contains("active")?(a.currentTarget.classList.remove("active"),a.currentTarget.classList.contains("tcm-upvote")?e.filter(".tcm-upvote").find(".tcm-votes-count").text(parseInt(f)-1):e.filter(".tcm-downvote").find(".tcm-votes-count").text(parseInt(g)-1)):(a.currentTarget.classList.contains("tcm-upvote")?(e.filter(".tcm-upvote").find(".tcm-votes-count").text(parseInt(f)+1),e.filter(".tcm-downvote").hasClass("active")&&e.filter(".tcm-downvote").find(".tcm-votes-count").text(parseInt(g)-1)):(e.filter(".tcm-downvote").find(".tcm-votes-count").text(parseInt(g)+1),e.filter(".tcm-upvote").hasClass("active")&&e.filter(".tcm-upvote").find(".tcm-votes-count").text(parseInt(f)-1)),e.removeClass("active"),a.currentTarget.classList.add("active")),jQuery.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},url:this.voteRoute,type:"POST",data:{comment_id:c,vote_type:d,secret_spam:ThriveComments.secret_spam}}).done(function(a){b.doingVote=!1}).error(function(a){ThriveComments.util.err(a.responseJSON.message)}).always(function(){}),!1)},deletedState:function(){this.childView=new ThriveComments.views.DeletedItem({el:this.$(".deleted-state").first(),model:this.model,commentView:this,moderationView:this.moderationView}),this.childView.render(),a(window).trigger("scroll")}}),ThriveComments.views.LazyLoad=Backbone.View.extend({template:ThriveComments.util.tpl("comments/lazy-loading"),events:{"click .tcm-loader":"changePage","click .add-comment":"addCommentBottom","click .tcm-link-subscribe":"showSubscribeForm","click .tcm-link-unsubscribe":"unSubscribe","click .submit-subscribe-post":"subscribePost","click .submit-unsubscribe-post":"unSubscribePost"},currentPage:1,itemsPerPage:ThriveComments.settings.comments_per_page,collection:null,params:null,type:"",view:null,order:"",sortBy:"",initialize:function(a){this.collection=a.collection,this.view=a.view,this.type=a.type,this.order=1===ThriveComments.sorting.order?"ASC":"DESC"},changePage:function(b,c){a(".tcm-lazy-comments .tcm-dot-loader").removeClass("done"),this.$(".add-comment").hide();var d=this,e={itemsPerPage:this.itemsPerPage};if(c&&void 0!==c.page?e.page=parseInt(c.page):e.page=this.currentPage,e.page<1&&(e.page=1),c&&void 0!==c.resetContent&&this.view.$el.empty(),c&&c.id&&(e.go_to_id=c.id),"dynamic"==this.type)c&&void 0!==c.sortBy?e.sortBy=c.sortBy:e.sortBy=this.sortBy,c&&void 0!==c.order?e.order=c.order:e.order=this.order,ThriveComments.tva_term&&void 0!==ThriveComments.tva_term&&(e.tva_term=ThriveComments.tva_term),this.collection.fetch({reset:!0,data:a.param(e),success:function(a,b){d.$el.show(),null!=b.nextPage?d.updateParams(b.nextPage,e.sortBy,e.order):d.updateParams(e.page+1,e.sortBy,e.order),d.view.render(a),d.render(),ThriveComments.util.scrollToElement(d.view.$("div[data-comment-id="+e.go_to_id+"]"))}});else if("static"===this.type&&void 0!==this.view&&null!==this.view){var f,g=(e.page-1)*this.itemsPerPage,h=e.page,i=0,j=this.collection.sort();if(ThriveComments.settings.page_comments){if(c&&c.id){do{f=j.chain().rest(g).first(this.itemsPerPage).value(),i=ThriveComments.util.search_recursive(f,c.id),this.view.render(f),h+=1,g=(h-1)*this.itemsPerPage,this.updateParams(h,"","")}while(!i&&0!==f.length);ThriveComments.util.scrollToElement(this.view.$("div[data-comment-id="+c.id+"]")),i?ThriveComments.util.scrollToElement(this.view.$("div[data-comment-id="+c.id+"]")):(g=(e.page-1)*this.itemsPerPage,this.view.$el.empty(),this.updateParams(e.page+1,"",""),f=j.chain().rest(g).first(this.itemsPerPage).value(),this.view.render(f))}else this.updateParams(e.page+1,"",""),f=j.chain().rest(g).first(this.itemsPerPage).value(),this.view.render(f);if(0===f.length)return ThriveComments.util.showCommentsNumber(0),ThriveComments.util.tcm_hide_loader(),void this.$(".tcm-loader").hide()}else this.view.render(j),ThriveComments.util.scrollToElement(this.view.$("div[data-comment-id="+c.id+"]"));d.render()}return!1},updateParams:function(a,b,c){this.currentPage=a,this.sortBy=b,this.order=c},render:function(){this.$el.html(this.template({commentsLength:this.collection.commentCount,comments_rendered:this.view.comments_rendered,showPoweredBy:ThriveComments.settings.powered_by,pageComments:ThriveComments.settings.page_comments,type:this.type})),a(".level-0").length>=parseInt(this.collection.userCommentCount)?this.$(".tcm-loader").hide():this.$(".tcm-loader").show(),ThriveComments.util.focusAfterLogin(),jQuery(window).trigger("scroll");var b=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email"));return""!==ThriveComments.util.get_cookie("subscribed_posts")&&b&&-1!==JSON.parse(ThriveComments.util.get_cookie("subscribed_posts")).indexOf(ThriveComments.post.ID)&&void 0!==ThriveComments.current_user.ID?(this.$(".tcm-link-subscribe").hide(),this.$(".tcm-link-unsubscribe").show(),!1):this},addCommentBottom:function(b){ThriveComments.util.tcm_hide_textareas(b);var c=new ThriveComments.views.CreateComment({viewList:this.viewList}),d=this.$(".tcm-powered-by"),e=c.render({mainInput:1,id:0,level:0,photo_src:ThriveComments.current_user.photo_url,previousUser:ThriveComments.util.previousUser(),position:"bottom",close_comments:ThriveComments.close_comments}).$el;a(b.currentTarget).hide(),d.length?d.before(e):this.$el.append(e)},showSubscribeForm:function(){return ThriveComments.current_user.ID?this.addPostSubscriber(ThriveComments.current_user.user_email,1):(this.$(".tcm-link-subscribe").hide(),this.$("#tcm-subscribe-form").show()),!1},unSubscribe:function(a){var b=ThriveComments.current_user.user_email;this.$(".tcm-link-unsubscribe").hide(),this.$("#tcm-unsubscribe-form").hide(),this.$(".tcm-link-subscribe").show(),a.stopPropagation(),void 0===ThriveComments.current_user.user_email&&(b=decodeURIComponent(ThriveComments.util.get_cookie("tcm_cookie_user_email"))),this.addPostSubscriber(b,0)},subscribePost:function(){var a=this.$(".tcm-subscriber-email");if(ThriveComments.util.validateEmail(a,ThriveComments.util.render_label("isRequired"))){if(""!==ThriveComments.util.get_cookie("subscribed_posts")&&-1!==JSON.parse(ThriveComments.util.get_cookie("subscribed_posts")).indexOf(ThriveComments.post.ID)&&ThriveComments.util.validateEmail(a,ThriveComments.util.render_label("isRequired")))return this.$("#tcm-subscribe-form").hide(),this.$(".tcm-already-subscribed").show(),!1;this.addPostSubscriber(a.val(),1)}},unSubscribePost:function(){var a=this.$(".tcm-unsubscriber-email");return""!==ThriveComments.util.get_cookie("subscribed_posts")&&-1!==JSON.parse(ThriveComments.util.get_cookie("subscribed_posts")).indexOf(ThriveComments.post.ID)&&ThriveComments.util.validateEmail(a,ThriveComments.util.render_label("isRequired"))&&this.addPostSubscriber(a.val(),0),!1},addPostSubscriber:function(b,c){var d=this.$(".tcm-link-subscribe"),e=ThriveComments.util.render_label("subscribe"),f=this.$("#tcm-subscribe-form"),g=this.$(".tcm-link-unsubscribe"),h=this.$("#tcm-unsubscribe-form"),i={email:b,post_id:ThriveComments.post.ID,subscribe:c};ThriveComments.tva_term&&void 0!==ThriveComments.tva_term&&(i.tva_term=ThriveComments.tva_term),d.text(ThriveComments.translations.comment_pending),f.hide(),ThriveComments.current_user.ID?d.show():d.hide(),a.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},type:"POST",url:ThriveComments.routes.update_post_subscriber,data:i}).done(function(){ThriveComments.util.set_subscriber_cookies(c),0===c?(d.text(e),ThriveComments.current_user.ID?d.show():(d.hide(),h.hide(),f.show())):1===c&&ThriveComments.current_user.ID?(d.hide(),g.show()):(f.hide(),d.hide(),h.show())}).error(function(a){h.show(),d.text(e),ThriveComments.util.err(a.responseJSON.message)})}}),ThriveComments.views.CommentConversion=Backbone.View.extend({className:"tcm-conversion-container",template:ThriveComments.util.tpl("comments-conversion"),events:{"click .fb-button":"conv_facebook","click .tw-button":"conv_twitter","click .in-button":"conv_linkedin","click .pt-button":"conv_pinterest","click .gm-button":"conv_google","click .xi-button":"conv_xing"},commentView:null,initialize:function(a){this.commentView=a.commentView,this.conversionSettings=this.commentView.model.get("conversion_settings")},render:function(a){return this.$el.html(this.template(a)),this},handleAfterShowAction:function(a){var b=this.commentView.model.get("show_after_save"),c=this.commentView.model.get("commenter_first");if(!b)return!1;if("live_update"===b)return this.handleLiveUpdate(b,c,"tcm_live_update"),!0;switch(this.conversionSettings[b].active){case"tcm_redirect":this.redirectURL(b);break;case"tcm_live_update":this.handleLiveUpdate(b,c,"tcm_live_update");break;case"tcm_related_posts":this.handleRelatedPosts(b,"tcm_related_posts");break;case"tcm_thrivebox":this.handleThrivebox(b);break;case"tcm_social_share":this.handleSocialShare(b,"tcm_social_share")}},handleSocialShare:function(a,b){var c="live_update"===a?this.conversionSettings.tcm_live_update[a]:this.conversionSettings.tcm_social_share[a],d="";d=c.custom_message.replace("{commenter_name}",this.commentView.model.get("comment_author")),this.render({html_switch:b,custom_message:d,share_btns:c.social_sharing_buttons})},handleRelatedPosts:function(a,b){var c="live_update"===a?this.conversionSettings.tcm_live_update[a]:this.conversionSettings.tcm_related_posts[a],d="",e=0;""!==c.custom_message&&(d=c.custom_message.replace("{commenter_name}",this.commentView.model.get("comment_author")),e=c.show_featured_image,this.render({html_switch:b,custom_message:d,show_featured_image:e}))},redirectURL:function(a){""==ThriveComments.settings.tcm_conversion.tcm_redirect[a].redirect_url||ThriveComments.settings.tcm_conversion.tcm_redirect[a].flag||window.location.replace(ThriveComments.settings.tcm_conversion.tcm_redirect[a].redirect_url)},handleLiveUpdate:function(a,b,c){var d=1===parseInt(b)?"first_time":"second_time",e="live_update"===a?this.conversionSettings.tcm_live_update[d]:this.conversionSettings.tcm_live_update[a],f="";""!==e.custom_message&&(f=e.custom_message.replace("{commenter_name}",this.commentView.model.get("comment_author")),this.render({html_switch:c,custom_message:f}))},handleThrivebox:function(b){var c=this.conversionSettings.tcm_thrivebox[b].thrivebox_id,d=void 0,e=this;if(!c||"undefined"==typeof TL_Const||"0"===c)return d="first_time"===b?1:2,this.handleLiveUpdate(b,d,"tcm_live_update"),!1;var f={tcb_js:"undefined"!=typeof TCB_Front?1:0,two_step_ids:[c.toString()],action:"tve_leads_ajax_load_forms",security:TL_Const.security,display_options:TL_Const.display_options,current_screen:TL_Const.current_screen,tve_flat_included:a("#tve_style_family_tve_flt-css").length};ThriveGlobal.$j.each(TL_Const.custom_post_data,function(a,b){f[a]=b}),window.TVE_Dash&&!TVE_Dash.ajax_sent?ThriveGlobal.$j(document).on("tve-dash.load",function(a){TVE_Dash.add_load_item("tl_lazy_load",f,TL_Front.ajax_load_callback)}):ThriveGlobal.$j.ajax({url:TL_Const.ajax_url,type:"post",dataType:"json",data:f,xhrFields:{withCredentials:!0}}).done(function(a){TL_Front.ajax_load_callback(a);var b=jQuery(".tl-2step-trigger-"+c);if(b.length){var d=jQuery('[data-tl-type="two_step_'+c+'"]'),f=void 0;d.length&&(f=jQuery(d[0]),f.find('input[name="email"]').val(e.commentView.model.get("comment_author_email")),f.find('input[name="name"]').val(e.commentView.model.get("comment_author"))),b.click()}})},conv_facebook:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c=ThriveComments.post.featured_image?ThriveComments.post.featured_image:"",d=encodeURIComponent(ThriveComments.post.permalink),e="";return e=a.currentTarget.getAttribute("data-href")+"?u="+d+"&title="+b+"&image_url="+encodeURIComponent(c),window.open(e,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=350,width=500"),!1},conv_twitter:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c="";return b.length>90&&(b=b.substring(0,90),b=b.split(" ").slice(0,-1).join(" ")),b=b+" "+ThriveComments.post.permalink,c=a.currentTarget.getAttribute("data-href")+"?text="+b,window.open(c,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_linkedin:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c="";return c=a.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&summary="+b+"&title="+b,window.open(c,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_pinterest:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c=ThriveComments.post.featured_image?ThriveComments.post.featured_image:"",d="";return d=a.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&description="+b+"&media="+c,window.open(d,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_google:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c="";return c=a.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&text="+b,window.open(c,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1},conv_xing:function(a){var b=ThriveComments.post?ThriveComments.post.post_title:"",c="";return c=a.currentTarget.getAttribute("data-href")+"?url="+encodeURIComponent(ThriveComments.post.permalink)+"&title="+b,window.open(c,"","menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=483,width=672"),!1}}),ThriveComments.views.LiveUpdate=Backbone.View.extend({template:"",events:"",initialize:function(a){this.commentsView=a.commentsView,this.viewCreate=a.viewCreate,this.collection=a.collection,this.updateInterval=1e3*parseInt(ThriveComments.settings.tcm_live_update_refresh_rate),this.updateComments()},updateComments:function(){var a=this;ThriveComments.settings.tcm_live_update&&setTimeout(function(){a.startTimeout(jQuery(".tcm-comments-list")),a.updateComments()},this.updateInterval)},startTimeout:function(b){var c=this;a.ajax({headers:{"X-WP-Nonce":ThriveComments.nonce},cache:!1,url:ThriveComments.routes.live_update,dataType:"JSON",type:"GET",data:{post_id:ThriveComments.post.ID,update_interval:this.updateInterval}}).done(function(a){a.comment_found?(_.each(a.comments,function(a){var d=null,e=null,f=null;b&&(e=b.find("button[data-id="+a.top_parent_id+"]"),d=b.find("button[data-id="+a.comment_parent+"]"),f=new ThriveComments.models.Comment(a,{parse:!0}),0==a.comment_parent||d.length&&e.length?c.viewCreate.addNewCommentToList(d,f,1):ThriveComments.util.search_comment(c.collection,a.comment_ID)||ThriveComments.objects.Comments.push(f))}),c.updateInterval=1e3*parseInt(ThriveComments.settings.tcm_live_update_refresh_rate)):c.updateInterval=c.updateInterval+100})}})}(jQuery);var ThriveComments=ThriveComments||{};ThriveComments.objects=ThriveComments.objects||{},function(a){ThriveComments.objects.TCRouter=Backbone.Router.extend({view:null,routes:{"":"comments",comments:"comments","comments/:id":"comments","comments-:id":"comments","*n":"comments"},params:{},initialize:function(b){a.extend(!0,this,b),window.TVE_Dash&&!TVE_Dash.ajax_sent&&TVE_Dash.add_load_item("tcm_dash_data",ThriveComments.const.ajax_dash,this.dashResponse),this.facebook_init()},dashResponse:function(a){ThriveComments.secret_spam=a.secret,ThriveComments.has_plugin_cache&&(ThriveComments.nonce=a.nonce,Backbone.history.start({hashchange:!0}),Backbone.history.fragment||ThriveComments.router.navigate("",{trigger:!0}))},route:function(a,b,c){var d=this;c||(c=this[b]);var e=function(){c.apply(d,arguments)};return Backbone.Router.prototype.route.call(this,a,b,e)},comments:function(b){var c,d,e;b=a.isNumeric(b)?b:null,ThriveComments.objects.Comments||(ThriveComments.objects.Comments=new ThriveComments.collections.Comments),d=this.get_me_a_view("LazyLoad",{collection:ThriveComments.objects.Comments,el:this.$el.find(".tcm-lazy-comments"),type:ThriveComments.settings.is_dynamic?"dynamic":"static"}),e=this.get_me_a_view("Comments",{collection:ThriveComments.objects.Comments,el:this.$el.find(".tcm-comments-list"),viewLazy:d}),d.viewList=e,this.get_me_a_view("SortComments",{el:this.$el.find(".tcm-comments-filter"),viewList:e}),e.close(),e.startLazy(b),c=this.get_me_a_view("CreateComment",{el:this.$el.find(".tcm-comments-create"),viewList:e}),c.render({mainInput:1,id:0,level:0,photo_src:ThriveComments.current_user.photo_url,previousUser:ThriveComments.util.previousUser(),position:"top",close_comments:ThriveComments.close_comments}),this.get_me_a_view("LiveUpdate",{commentsView:e,id:b,viewCreate:c,collection:ThriveComments.objects.Comments})},get_me_a_view:function(a,b){var c="view"+a;return this[c]||(this[c]=new ThriveComments.views[a](b)),this[c]},facebook_init:function(){"undefined"==typeof FB&&1===ThriveComments.settings.tcm_api_status.facebook&&ThriveComments.settings.tcm_enable_social_signin&&(window.fbAsyncInit=function(){FB.init({appId:ThriveComments.tcm_social_apis.facebook.app_id,autoLogAppEvents:!0,status:!0,xfbml:!0,version:"v2.9"})},function(a,b,c){var d,e=a.getElementsByTagName(b)[0];a.getElementById(c)||(d=a.createElement(b),d.id=c,d.src="//connect.facebook.net/en_US/sdk.js",e.parentNode.insertBefore(d,e))}(document,"script","facebook-jssdk"))}}),a(function(){0!==a("#thrive-comments").length&&(ThriveComments.router=new ThriveComments.objects.TCRouter({$el:a("#thrive-comments")}),ThriveComments.has_plugin_cache||(Backbone.history.start({hashchange:!0}),Backbone.history.fragment||ThriveComments.router.navigate("",{trigger:!0})))})}(jQuery);