!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}var t;(t=jQuery).fn.emulateTransitionEnd=function(e){var o=!1,i=this;return t(this).one("wpcomTransitionEnd",(function(){o=!0})),setTimeout((function(){o||t(i).trigger(t.__transition.end)}),e),this},t((function(){t.__transition=function(){var e=document.createElement("wpcom"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var o in t)if(void 0!==e.style[o])return{end:t[o]};return!1}(),t.__transition&&(t.event.special.wpcomTransitionEnd={bindType:t.__transition.end,delegateType:t.__transition.end,handle:function(e){if(t(e.target).is(this))return e.handleObj.handler.apply(this,arguments)}})})),function(t){var o=function(e,o){this.options=o,this.$body=t(document.body),this.$element=t(e),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.fixedContent=".navbar-fixed-top, .navbar-fixed-bottom",this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,t.proxy((function(){this.$element.trigger("loaded.wpcom.modal")}),this))};function i(i,s){return this.each((function(){var a=t(this),n=a.data("wpcom.modal"),r=t.extend({},o.DEFAULTS,a.data(),"object"==e(i)&&i);n||a.data("wpcom.modal",n=new o(this,r)),"string"==typeof i?n[i](s):r.show&&n.show(s)}))}if(o.TRANSITION_DURATION=250,o.BACKDROP_TRANSITION_DURATION=120,o.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},o.prototype.toggle=function(e){return this.isShown?this.hide():this.show(e)},o.prototype.show=function(e){var i=this,s=t.Event("show.wpcom.modal",{relatedTarget:e});this.$element.trigger(s),this.isShown||s.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.wpcom.modal",'[data-wpcom-dismiss="modal"], [data-dismiss="modal"]',t.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.wpcom.modal",(function(){i.$element.one("mouseup.dismiss.wpcom.modal",(function(e){t(e.target).is(i.$element)&&(i.ignoreBackdropClick=!0)}))})),this.backdrop((function(){var s=t.__transition&&i.$element.hasClass("fade");i.$element.parent().length||i.$element.appendTo(i.$body),i.$element.show().scrollTop(0),i.adjustDialog(),s&&i.$element[0].offsetWidth,i.$element.addClass("in"),i.enforceFocus();var a=t.Event("shown.wpcom.modal",{relatedTarget:e});s?i.$dialog.one("wpcomTransitionEnd",(function(){i.$element.trigger("focus").trigger(a)})).emulateTransitionEnd(o.TRANSITION_DURATION):i.$element.trigger("focus").trigger(a)})))},o.prototype.hide=function(e){e&&e.preventDefault(),e=t.Event("hide.wpcom.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),t(document).off("focusin.wpcom.modal"),this.$element.removeClass("in").off("click.dismiss.wpcom.modal").off("mouseup.dismiss.wpcom.modal"),this.$dialog.off("mousedown.dismiss.wpcom.modal"),t.__transition&&this.$element.hasClass("fade")?this.$element.one("wpcomTransitionEnd",t.proxy(this.hideModal,this)).emulateTransitionEnd(o.TRANSITION_DURATION):this.hideModal())},o.prototype.enforceFocus=function(){t(document).off("focusin.wpcom.modal").on("focusin.wpcom.modal",t.proxy((function(e){document===e.target||this.$element[0]===e.target||this.$element.has(e.target).length||this.$element.trigger("focus")}),this))},o.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.wpcom.modal",t.proxy((function(e){27==e.which&&this.hide()}),this)):this.isShown||this.$element.off("keydown.dismiss.wpcom.modal")},o.prototype.resize=function(){this.isShown?t(window).on("resize.wpcom.modal",t.proxy(this.handleUpdate,this)):t(window).off("resize.wpcom.modal")},o.prototype.hideModal=function(){var e=this;this.$element.hide(),this.backdrop((function(){e.$body.removeClass("modal-open"),e.resetAdjustments(),e.resetScrollbar(),e.$element.trigger("hidden.wpcom.modal")}))},o.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},o.prototype.backdrop=function(e){var i=this,s=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var a=t.__transition&&s;if(this.$backdrop=t(document.createElement("div")).addClass("wpcom-modal-backdrop "+s).appendTo(this.$body),this.$element.on("click.dismiss.wpcom.modal",t.proxy((function(e){this.ignoreBackdropClick?this.ignoreBackdropClick=!1:e.target===e.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide())}),this)),a&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!e)return;a?this.$backdrop.one("wpcomTransitionEnd",e).emulateTransitionEnd(o.BACKDROP_TRANSITION_DURATION):e()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var n=function(){i.removeBackdrop(),e&&e()};t.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("wpcomTransitionEnd",n).emulateTransitionEnd(o.BACKDROP_TRANSITION_DURATION):n()}else e&&e()},o.prototype.handleUpdate=function(){this.adjustDialog()},o.prototype.adjustDialog=function(){var e=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&e?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!e?this.scrollbarWidth:""})},o.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},o.prototype.checkScrollbar=function(){var e=window.innerWidth;if(!e){var t=document.documentElement.getBoundingClientRect();e=t.right-Math.abs(t.left)}this.bodyIsOverflowing=document.body.clientWidthn)return wpcom_alert(_wpmx_js.cropper.alert_size),!1;this.files[0].type.match(/image.*/)?(i=window.URL.createObjectURL(this.files[0]),e(".crop-img-wrap").append('').show(),e(".crop-img-btn").hide(),o=new Cropper(document.getElementById("crop-img"),{aspectRatio:s?2.7:1,minContainerHeight:300,viewMode:s?3:1,ready:function(){var e={width:300,height:300};s&&(e={width:810,height:300,left:44}),o.setCropBoxData(e)}}),e(this).val("")):wpcom_alert(_wpmx_js.cropper.alert_filetype)})).on("click",".j-crop-close",(function(){o&&o.destroy(),o=null,e(".crop-img-wrap").hide(),e(".crop-img-btn").show(),e("#crop-img").remove()})).on("click",".j-crop-apply",(function(){var t=e(this);if(t.loading(1),o)if(o.crop().cropped){var n=o.getData();console.log(n,"cropData");var r=new FormData;r.append("action","wpcom_cropped_upload"),r.append("nonce",e("#wpcom_cropper_nonce").val()),r.append("file",a),r.append("x",n.x),r.append("y",n.y),r.append("width",n.width),r.append("height",n.height),r.append("type",s),i&&r.append("user",i),e.ajax(_wpmx_js.ajaxurl,{type:"POST",data:r,dataType:"json",processData:!1,contentType:!1,success:function(o){"1"==o.result?(s?e(".wpcom-profile-head .wpcom-ph-bg img").attr("src",o.url):e(".member-account-avatar img.avatar,.wpcom-ph-avatar img.avatar,#j-user-wrap img.avatar").replaceWith(''),e("#crop-modal")._modal("hide")):"-1"==o.result?wpcom_notice({message:_wpmx_js.cropper.err_nonce,show:2e3,type:"warning"}):"-2"==o.result?wpcom_notice({message:_wpmx_js.cropper.err_fail,show:2e3,type:"error"}):"-3"==o.result?wpcom_notice({message:_wpmx_js.cropper.err_login,show:2e3,type:"warning"}):"-4"==o.result&&wpcom_notice({message:_wpmx_js.cropper.alert_filetype,show:2e3,type:"error"}),t.loading(0)},error:function(){wpcom_notice({message:_wpmx_js.cropper.ajaxerr,show:2e3,type:"error"}),t.loading(0)}})}else t.loading(0);else wpcom_notice({message:_wpmx_js.cropper.err_empty,show:2e3,type:"warning"}),t.loading(0)})).on("click",".j-social-unbind",(function(){var t=e(this);if(t.hasClass("disabled"))return!1;var o=t.data("name");t.addClass("disabled").text("\u5904\u7406\u4e2d..."),confirm("\u662f\u5426\u786e\u5b9a\u89e3\u9664\u7ed1\u5b9a\uff1f")?e.ajax({type:"POST",url:_wpmx_js.ajaxurl,data:{action:"wpcom_social_unbind",name:o},dataType:"json",success:function(e){t.removeClass("disabled").text("\u89e3\u9664\u7ed1\u5b9a"),1==e.result?(wpcom_alert("\u89e3\u7ed1\u6210\u529f\uff01"),t.parent().html(e.error)):e.error&&wpcom_alert(e.error)},error:function(){t.removeClass("disabled").text("\u89e3\u9664\u7ed1\u5b9a")}}):t.removeClass("disabled").text("\u89e3\u9664\u7ed1\u5b9a")})).on("click","a",(function(o){var i=e(this).attr("href"),s=i?i.match(/(\?|&)modal-type=(login|register)/i):null;if(s&&s[2]){if(e("body.navbar-on").length)return;o.preventDefault(),o.stopPropagation();var a=e("#login-form-modal");0===a.length&&(jQuery(document.body).append(''),a=jQuery("#login-form-modal")),e("#login-modal").length&&e("#login-modal")._modal("hide");var n=a.find(".modal-body");n.html(''),e("body").hasClass("modal-open")?setTimeout((function(){a._modal("show")}),200):a._modal("show");var r=t(i,"approve"),l={action:"wpcom_login_modal",type:s[2]};return r&&(l.approve=r,l.login=t(i,"login")),e.ajax({type:"POST",url:_wpmx_js.ajaxurl,data:l,dataType:"html",success:function(t){"undefined"==typeof is_load_login?e.getScript(_wpmx_js.plugin_url+"js/login.js",(function(){n.html(t),e(document).trigger("init_captcha")})):(n.html(t),e(document).trigger("init_captcha")),setTimeout((function(){e.fn.tooltip&&n.find('[data-toggle="tooltip"]').tooltip()}),1e3)},error:function(){}}),!1}})).on("click",".member-form-tab a",(function(t){t.preventDefault();var o=e(this);if(o.closest("li").hasClass("active"))return!1;var i=o.closest("ul"),s=i.closest(".member-form-inner"),a=o.data("type"),n=e("#j-tpl-login"+("2"==a?"2":"")).html();n&&(s.find(".member-form-items").html(n),i.find("li").removeClass("active"),o.closest("li").addClass("active"),a=a?0:1,e(document).trigger("init_captcha"))})).on("click",".show-password",(function(){var t=e(this);t.hasClass("active")?(t.html('').removeClass("active"),t.parent().find("input").attr("type","password")):(t.html('').addClass("active"),t.parent().find("input").attr("type","text"))})).on("wpcom_not_login",(function(){!function(){if(0===jQuery("#login-modal").length){var e=_wpmx_js.login_url,t=_wpmx_js.register_url,o='
\n \n
";jQuery("body").append(o)}}()}));var n=e("#j-user-wrap");e.ajax({type:"POST",url:_wpmx_js.ajaxurl,data:{action:"wpcom_is_login"},dataType:"json",success:function(t){if(0==t.result){if(n.length){var o=0;t.messages&&(o=Number(t.messages)),t.notifications&&(o+=Number(t.notifications));var i='",n.html(i)}window.is_login=!0,e(document).trigger("wpcom_login",t)}else n.length&&n.find(".login").addClass("cur"),window.is_login=!1,e(document).trigger("wpcom_not_login");n.length&&t.wc&&(t.wc.fragments&&t.wc.fragments["a.cart-contents"]&&e("header .shopping-cart").html(t.wc.fragments["a.cart-contents"]),setTimeout((function(){t.wc.fragments&&t.wc.fragments["div.widget_shopping_cart_content"]&&e("header .shopping-cart").append(t.wc.fragments["div.widget_shopping_cart_content"])}),100)),e(document).trigger("wpcom_login_checked")}}),e(".social-login-wrap").on("submit","#sl-form-create",(function(){var t=e(this);if(t.find(".sl-input-submit.disabled").length)return!1;t.find(".sl-input-submit").addClass("disabled");for(var o=0,i=t.find(".sl-input input.require"),s=0;s'):o.removeClass("loading").find(".wi-loader").remove()}}),window.wpcom_alert||(window.wpcom_alert=function(e,o){o=o||"\u63d0\u793a\u4fe1\u606f";var i=t("#wpcom-alert");if(i.length)i.find(".modal-title").html(o),i.find(".modal-body").html(e),i._modal("show");else{var s='';t("body").append(s)}t("#wpcom-alert")._modal("show")}),window.wpcom_notice||(window.wpcom_notice=function(t){if(!arguments.length||1===arguments.length&&"object"===e(arguments[0])||(t={},void 0!==arguments[0]&&(t.message=arguments[0]),void 0!==arguments[1]&&(t.type=arguments[1]),void 0!==arguments[2]&&"loading"!==t.type&&(t.show=arguments[2]),void 0!==arguments[2]&&"loading"===t.type&&(t.callback=arguments[2])),t&&t.message){t.type=t.type?t.type:"success";var o='
';"success"===t.type?o+='':"warning"===t.type||"error"===t.type?o+='':"loading"===t.type&&(o+=''),o+=t.message+"
";var i=jQuery(o),s=jQuery(".notice-message-wrapper");return 0===s.length&&(jQuery(document.body).append('
'),s=jQuery(".notice-message-wrapper")),s.append(i),i.one("hide.notice",(function(){var e=jQuery(this);e.removeClass("notice-message-active").addClass("notice-message-up"),setTimeout((function(){e.remove(),0===s.find(".notice-message").length&&s.remove()}),320)})),setTimeout((function(){i.addClass("notice-message-active"),"loading"===t.type&&void 0!==t.callback?t.callback(i):setTimeout((function(){i.trigger("hide.notice")}),t.show?t.show:3e3)}),50),i}}),t(document.body).on("click",".profile-tab .profile-tab-item",(function(){var e=t(this),o=e.closest(".wpcom-profile-main"),i=e.index();o.find(".profile-tab-item, .profile-tab-content").removeClass("active"),e.addClass("active"),o.find(".profile-tab-content").eq(i).addClass("active").trigger("profile_tab_show")})).on("click",".j-user-posts, .j-user-comments, .j-user-favorites, .j-user-follows, .j-user-followers",(function(){var e=t(this);if(!e.hasClass("disabled")&&!e.hasClass("loading")){var o=null,i=e.data("page");if(i=void 0!==i?i+1:2,e.hasClass("j-user-posts")){var s=t(".profile-posts-list").data("user");o={action:"wpcom_user_posts",user:s||0,page:i}}else if(e.hasClass("j-user-comments")){var a=t(".profile-comments-list").data("user");o={action:"wpcom_user_comments",user:a||0,page:i}}else if(e.hasClass("j-user-favorites")){var n=t(".profile-favorites-list").data("user");o={action:"wpcom_user_favorites",user:n||0,page:i}}else if(e.hasClass("j-user-follows")){var r=t(".profile-tab").data("user");o={action:"wpcom_user_follows",user:r||0,page:i}}else if(e.hasClass("j-user-followers")){var l=t(".profile-tab").data("user");o={action:"wpcom_user_followers",user:l||0,page:i}}return e.loading(1),t.ajax({type:"POST",url:_wpmx_js.ajaxurl,data:o,dataType:"html",success:function(o,s,a){if("0"==o){if(e.addClass("disabled").text(_wpmx_js.js_lang.page_loaded),e.hasClass("j-user-followers")){var n=e.closest(".profile-tab-content");n.find(".follow-items-loading").length&&(n.find(".follow-items-loading").remove(),n.find(".profile-no-content").show())}}else{var r=t(o);if(e.parent().prev().append(r),e.hasClass("j-user-follows"))t(document).trigger("check_follow");else if(e.hasClass("j-user-followers")){var l=e.closest(".profile-tab-content");l.find(".follow-items-loading").remove(),l.find(".follow-items").show(),"0"!==a.getResponseHeader("Next-page")&&l.find(".load-more-wrap").show(),t(document).trigger("check_follow")}"undefined"!=typeof _wpcom_js&&t.fn.lazyload&&function(e){if(e.length){var t=void 0!==_wpcom_js.webp&&_wpcom_js.webp?_wpcom_js.webp:null;if(e.eq(0).is("img"))e.eq(0).one("load",(function(){e.lazyload({webp:t})}));else{var o=document.createElement("img"),i=window.getComputedStyle(e[0]).getPropertyValue("background-image");i?(o.src=i.slice(4,-1).replace(/['"]/g,""),o.onload=function(){e.lazyload({webp:t})}):setTimeout((function(){o.onload=function(){e.lazyload({webp:t})}}),300)}}}(r.find(".j-lazy")),e.data("page",i),t(window).trigger("scroll")}e.loading(0)},error:function(){e.loading(0)}}),!1}}))}))}));