(()=>{var o;o=jQuery,dokan.login_form_popup={form_html:"",form_title:"",init:function(){o("body").on("dokan:login_form_popup:show",this.get_form),o("body").on("submit","#dokan-login-form-popup-form",this.submit_form),o("body").on("dokan:login_form_popup:working",this.working),o("body").on("dokan:login_form_popup:done_working",this.done_working)},get_form:function(n,a){dokan.login_form_popup.form_html?dokan.login_form_popup.show_popup():(a=o.extend(!0,{nonce:dokan.nonce,action:"dokan_get_login_form"},a),o("body").trigger("dokan:login_form_popup:fetching_form"),o.ajax({url:dokan.ajaxurl,method:"get",dataType:"json",data:{_wpnonce:a.nonce,action:a.action}}).done(function(n){dokan.login_form_popup.form_html=n.data.html,dokan.login_form_popup.form_title=n.data.title,dokan.login_form_popup.show_popup(),o("body").trigger("dokan:login_form_popup:fetched_form")}))},show_popup:function(){o("body").append('<div id="dokan-modal-login-form-popup"></div>');const n=o("#dokan-modal-login-form-popup").iziModal({headerColor:dokan.modal_header_color,overlayColor:"rgba(0, 0, 0, 0.8)",width:690,onOpened:()=>{o("body").trigger("dokan:login_form_popup:opened")}});n.iziModal("setTitle",dokan.login_form_popup.form_title),n.iziModal("setContent",dokan.login_form_popup.form_html),n.iziModal("open")},submit_form:function(n){n.preventDefault();var a=o(this).serialize(),i=o(".dokan-login-form-error","#dokan-login-form-popup-form");i.removeClass("has-error").text(""),o("body").trigger("dokan:login_form_popup:working"),o.ajax({url:dokan.ajaxurl,method:"post",dataType:"json",data:{_wpnonce:dokan.nonce,action:"dokan_login_user",form_data:a}}).done(function(n){o("body").trigger("dokan:login_form_popup:logged_in",n),o("#dokan-modal-login-form-popup").iziModal("close")}).always(function(){o("body").trigger("dokan:login_form_popup:done_working")}).fail(function(o){o.responseJSON&&o.responseJSON.data&&o.responseJSON.data.message&&i.addClass("has-error").text(o.responseJSON.data.message)})},working:function(){o("fieldset","#dokan-login-form-popup-form").prop("disabled",!0),o("#dokan-login-form-submit-btn").addClass("dokan-hide"),o("#dokan-login-form-working-btn").removeClass("dokan-hide")},done_working:function(){o("fieldset","#dokan-login-form-popup-form").prop("disabled",!1),o("#dokan-login-form-submit-btn").removeClass("dokan-hide"),o("#dokan-login-form-working-btn").addClass("dokan-hide")}},dokan.login_form_popup.init()})();
(()=>{"use strict";var o={n:e=>{var a=e&&e.__esModule?()=>e.default:()=>e;return o.d(a,{a}),a},d:(e,a)=>{for(var s in a)o.o(a,s)&&!o.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:a[s]})},o:(o,e)=>Object.prototype.hasOwnProperty.call(o,e)};const e=window.jQuery;var a=o.n(e);dokan.reportAbuse={button:null,form_html:"",form_title:"",flashMessage:"",init(){const o=this;a()(".dokan-report-abuse-button").on("click",function(e){if(e.preventDefault(),o.button=this,"on"===dokanReportAbuse.reported_by_logged_in_users_only&&!dokanReportAbuse.is_user_logged_in)return a()("body").trigger("dokan:login_form_popup:show");o.getForm()}),a()("body").on("dokan:login_form_popup:fetching_form",()=>{o.showLoadingAnim()}),a()("body").on("dokan:login_form_popup:fetched_form",()=>{o.stopLoadingAnim()}),a()("body").on("dokan:login_form_popup:logged_in",(e,a)=>{dokanReportAbuse.is_user_logged_in=!0,dokanReportAbuse.nonce=a.data.dokan_report_abuse_nonce,o.getForm()}),a()("body").on("submit","#dokan-report-abuse-form-popup form",function(e){e.preventDefault(),o.submitForm(this)})},showLoadingAnim(){a()(this.button).addClass("working").children("i").removeClass("fa-flag").addClass("fa-spin fa-refresh")},stopLoadingAnim(){a()(this.button).removeClass("working").children("i").removeClass("fa-spin fa-refresh").addClass("fa-flag")},submittingForm(){a()("#dokan-report-abuse-form-popup fieldset").prop("disabled",!0),a()("#dokan-report-abuse-form-submit-btn").addClass("dokan-hide"),a()("#dokan-report-abuse-form-working-btn").removeClass("dokan-hide")},submittedForm(){a()("#dokan-report-abuse-form-popup fieldset").prop("disabled",!1),a()("#dokan-report-abuse-form-submit-btn").removeClass("dokan-hide"),a()("#dokan-report-abuse-form-working-btn").addClass("dokan-hide")},getForm(){const o=this;o.form_html?o.showPopup():(o.showLoadingAnim(),a().ajax({url:dokan.ajaxurl,method:"get",dataType:"json",data:{_wpnonce:dokanReportAbuse.nonce,action:"dokan_report_abuse_get_form"}}).done(e=>{o.form_html=e.data.html,o.form_title=e.data.title,o.showPopup()}).always(()=>{o.stopLoadingAnim()}))},showPopup(){const o=this;a()("body").append('<div id="dokan-modal-report-abuse-popup"></div>');const e=a()("#dokan-modal-report-abuse-popup").iziModal({headerColor:dokan.modal_header_color,width:690,onClosed:()=>{o.afterPopupClose()}});e.iziModal("setTitle",o.form_title),e.iziModal("setContent",o.form_html),e.iziModal("open")},afterPopupClose(){this.flashMessage&&(dokan_sweetalert(this.flashMessage,{icon:"success"}),this.flashMessage="")},submitForm(o){const e=this,s=(a()(o).serialize(),a()(".dokan-popup-error","#dokan-report-abuse-form-popup"));s.removeClass("has-error").text(""),e.submittingForm(),a().ajax({url:dokan.ajaxurl,method:"post",dataType:"json",data:{_wpnonce:dokanReportAbuse.nonce,action:"dokan_report_abuse_submit_form",form_data:{reason:a()(o).find('[name="reason"]:checked').val(),product_id:dokanReportAbuse.product_id,customer_name:a()(o).find('[name="customer_name"]').val(),customer_email:a()(o).find('[name="customer_email"]').val(),description:a()(o).find('[name="description"]').val()}}}).done(o=>{e.flashMessage=o.data.message,a()("#dokan-modal-report-abuse-popup").iziModal("close")}).always(()=>{e.submittedForm()}).fail(o=>{o.responseJSON&&o.responseJSON.data&&o.responseJSON.data.message&&s.addClass("has-error").text(o.responseJSON.data.message)})}},dokan.reportAbuse.init()})();
(function($){
const wrapper=$('.dokan-store-tabs');
const support_btn=$('.dokan-store-support-btn');
let support_btn_text=$('.dokan-store-support-btn').html();
const custom_support_btn=support_btn.html();
let storeSuppportModal=null;
var Dokan_Store_Support={
init(){
$('.dokan-store-support-btn').on('click', this.popUp.show);
$('body').on('submit',
'#dokan-support-login',
this.popUp.submitLogin
);
$('body').on('submit',
'#dokan-support-form',
this.popUp.submitSupportMsg
);
if(! $('.dokan-store-support-modals').length){
const $div=$('<div />').appendTo('body');
$div.attr('class', 'dokan-store-support-modals');
}
storeSuppportModal=$('.dokan-store-support-modals').iziModal({
width: 430,
closeButton: true,
appendTo: 'body',
title: '',
headerColor: dokan.modal_header_color,
onClosed(){
$('.dokan-store-support-btn').html(support_btn_text);
},
});
},
popUp: {
show(e){
e.preventDefault();
support_btn_text=$('.dokan-store-support-btn').html();
support_btn.html(dokan_store_support_i18n.wait);
if(support_btn.hasClass('user_logged_out') ){
Dokan_Store_Support.popUp.getForm('login_form');
setTimeout(function (){
if(typeof turnstile==='undefined'){
return;
}
const widgetId=turnstile.render('#dokan-captcha-field',
{
sitekey: $('.cf-turnstile').data('sitekey'),
execution: 'execute',
callback(token){
$('.dokan_recaptcha_token').val(token);
},
}
);
turnstile.execute('#dokan-captcha-field');
}, 1000);
}else{
Dokan_Store_Support.popUp.getForm('get_support_form');
}},
getForm(data){
const s_data={
action: 'dokan_support_ajax_handler',
data,
store_id: support_btn.data('store_id'),
order_id: support_btn.data('order_id'),
};
$.post(dokan.ajaxurl, s_data, function(resp){
if(resp.success==true){
const template =
'<div class="white-popup dokan-support-login-wrapper dokan-izimodal-wraper" style="position: relative;">' +
'<div class="dokan-izimodal-close-btn" style="position: absolute; top: 0; right: 0;"><button data-iziModal-close class="icon-close" style="background: white; padding: 0.2em 0.5em 0 0;"><i class="fa fa-times" aria-hidden="true"></i></button></div>' +
'<div id="ds-error-msg" ></div>' +
resp.data +
'</div>';
storeSuppportModal.iziModal('setContent',
template.trim()
);
storeSuppportModal.iziModal('open');
}else{
alert('failed');
support_btn.html(custom_support_btn);
}});
},
async submitLogin(e){
e.preventDefault();
storeSuppportModal.iziModal('startLoading');
const self=$(this);
if(typeof window.dokan_execute_recaptcha==='function'){
try {
await window.dokan_execute_recaptcha('form#dokan-support-login .dokan_recaptcha_token',
'dokan_store_support_login_recaptcha'
);
} catch(err){
}}
const s_data={
action: 'dokan_support_ajax_handler',
data: 'login_data_submit',
form_data: self.serialize(),
};
const $e_msg=$('#ds-error-msg');
$e_msg.addClass('dokan-hide');
$.post(dokan.ajaxurl, s_data, function(resp){
storeSuppportModal.iziModal('stopLoading');
self.find('input[name="dokan_recaptcha_token"]').val(''
);
if(resp.success==true){
Dokan_Store_Support.popUp.getForm('get_support_form');
support_btn.html(custom_support_btn);
}else if(resp.success==false){
$e_msg.removeClass('dokan-hide');
$e_msg.html(resp.msg);
$e_msg.addClass('dokan-alert dokan-alert-danger');
}else{
alert('failed');
support_btn.html(custom_support_btn);
}});
},
submitSupportMsg(e){
e.preventDefault();
$('#support-submit-btn').prop('disabled', true);
storeSuppportModal.iziModal('startLoading');
const self=$(this);
const s_data={
action: 'dokan_support_ajax_handler',
data: 'support_msg_submit',
form_data: self.serialize(),
};
const $e_msg=$('#ds-error-msg');
$.post(dokan.ajaxurl, s_data, function(resp){
storeSuppportModal.iziModal('stopLoading');
if(resp.success==true){
self.trigger('reset');
const template =
'<div class="white-popup dokan-support-login-wrapper dokan-alert dokan-alert-success dokan-izimodal-wraper"><div class="dokan-izimodal-close-btn"><button data-iziModal-close class="icon-close"><i class="fa fa-times" aria-hidden="true"></i></button></div>' +
resp.msg +
'</div>';
storeSuppportModal.iziModal('setContent',
template.trim()
);
}else if(resp.success==false){
$e_msg.removeClass('dokan-hide');
$e_msg.html(resp.msg);
$e_msg.addClass('dokan-alert dokan-alert-danger');
}else{
alert('failed');
$('#support-submit-btn').prop('disabled', false);
}
support_btn.html(custom_support_btn);
});
},
},
};
$(function (){
Dokan_Store_Support.init();
});
})(jQuery);
(function($){
const wrapper=$('.dokan-support-topic-wrapper');
var Dokan_support_comment={
init(){
$('body').on('submit',
'#dokan-support-commentform',
this.submitComment
);
Dokan_support_comment.scroolTOBottomList();
},
submitComment(e){
e.preventDefault();
const self=$(this);
const s_data={
action: 'dokan_support_ajax_handler',
data: 'support_msg_submit',
form_data: self.serialize(),
};
if($('#comment').val().trim().length===0){
dokan_sweetalert(dokan_store_support_i18n.empty_comment_msg, {
confirmButtonColor: '#f54242',
icon: 'error',
});
return;
}
const formurl=self.attr('action');
$('.dokan-support-topic-wrapper').block({
message: null,
overlayCSS: {
background:
'#fff url(' + dokan.ajax_loader + ') no-repeat center',
opacity: 0.6,
},
});
$.post(formurl, s_data.form_data, function(resp){
if(resp){
$('.dokan-support-topic-wrapper').unblock();
$('.dokan-support-topic-wrapper').html($(resp).find('.dokan-support-topic-wrapper').html()
);
Dokan_support_comment.scroolTOBottomList();
}});
},
scroolTOBottomList(){
const comments=$('.dokan-dss-chat-box');
$.each(comments, function(i, val){
val.scrollIntoView();
});
},
};
$(function (){
Dokan_support_comment.init();
});
})(jQuery);
(function($){
const Dokan_support_settings={
init(){
$('body').on('change',
'#support_checkbox',
this.toggle_name_input
);
$('body').on('change',
'#support_checkbox_product',
this.toggle_name_input
);
},
toggle_name_input(){
if($('#support_checkbox').is(':checked') ||
$('#support_checkbox_product').is(':checked')
){
$('.support-enable-check').show();
}else{
$('.support-enable-check').hide();
}},
};
$(function (){
Dokan_support_settings.init();
Dokan_support_settings.toggle_name_input();
});
})(jQuery);