function form_creator_datepicker_vista_datetime(id) {
MooTools.lang.setLanguage("pl-PL");
new DatePicker('form_creator_datepicker_vista_' + id, {
toggle : 'form_creator_calendar_bt_' + id,
draggable : false,
timePicker : true,
pickerClass : 'datepicker_vista',
format : "%Y-%m-%d %H:%M:00"
});
}
function form_creator_datepicker_vista_date(id) {
MooTools.lang.setLanguage("pl-PL");
new DatePicker('form_creator_datepicker_vista_' + id, {
toggle : 'form_creator_calendar_bt_' + id,
draggable : false,
timePicker : false,
pickerClass : 'datepicker_vista',
format : "%Y-%m-%d"
});
}
function form_creator_color_picker(id) {
new MooRainbow('form_creator_color_selector_' + id, {
id : 'formCreatorColorSelector_' + id,
wheel : true,
imgPath : "/panel/templates/t_0/images/mooRainbow/",
onComplete : function(color) {
$('form_creator_color_div_' + id).setStyle('background-color', color.hex);
$('form_creator_color_' + id).value = color.hex.replace('#', '');
}
});
}
function form_creator_generate_token(formCreatorId) {
var req = new Request({
method : 'post',
url:'/ajax/form_creator/generate_token/',
data: {
'formCreatorId': formCreatorId
},
onSuccess: function(data) {
$$('#form_creator_' + formCreatorId + ' #token').set('value', "2F569859A2590176CE92EC6D6AD38295");
}
}).send();
}
// -----------
function addSendToForms(idForm)
{
exV = new fValidator("form_creator_" + idForm, {
languageConfig : {
l : {required:"To pole jest obowiązkowe! ↑",alpha:"Pole zawiera nie prawidłowe znaki! ↑",alphanum:"Pole zawiera nie prawidłowe znaki! ↑",integer:"Nieprawidłowe dane! ↑",real:"Nieprawidłowy numer! ↑",date:"Prawidłowy format daty to (mm/dd/rrrr)! ↑",dateISO8601:"Prawidłowy format daty to (mm/dd/rrrr)! ↑",dateEU:"Prawidłowy format daty to (mm/dd/rrrr)!) ↑",email:"Nieprawidłowy adres e-mail! ↑",phone:"Nieprawidłowy numer telefonu! ↑",url:"Nieprawidłowy adres URL! ↑",zip:"Nieprawidłowy format kodu pocztowego! ↑",confirm:"Nieprawidłowe hasło! ↑"}
},
msgClass : "rc_div_alert",
msgContainerTag : "div",
//submitBt : "aaaa_" + idForm,
submitBt : "form_creator_submit_" + idForm,
fValidate_send : function() {
if(['27926', '9698', '23681'].includes(RC_SHOP_ID)) {
checkCaptcha().then(function (s) {
if (!s) {
return false;
}
salert("Formularz został wysłany!");
$('form_creator_' + idForm).submit();
});
} else if (RC_SHOP_ID === '38409' || RC_SHOP_ID === '9698') {
salert("Formularz został wysłany!");
$('form_creator_' + idForm).send();
} else {
salert("Formularz został wysłany!");
$('form_creator_' + idForm).submit();
}
}
});
}
window.addEvent('domready', function() {
$$('.form_creator_class').each(function(el, i) {
idForm = el.get('data-id_form');
addSendToForms(idForm);
});
$$('.form_creator_datepicker').each(function(el, i) {
id = el.get('data-id');
form_creator_datepicker_vista_date(id);
});
$$('.form_creator_datetimepicker').each(function(el, i) {
id = el.get('data-id');
form_creator_datepicker_vista_datetime(id);
});
$$('.form_creator_color_picker').each(function(el, i) {
id = el.get('data-id');
form_creator_color_picker(id);
});
});
function question_cms_mail(mail) { // m.g.
var rc_w=new rc_windows({
id:'rc_window3',
container: $(document.body),
useOverlay: true,
width:600,
height:300,
title: 'Formularz kontaktowy',
contentAJAX:'/ajax/question/cms/',
varAJAX:{"id":31337, "mail":mail},
onComplete: function() {
}
});
}
function question_cms_mail_send(mail) { // m.g.
var name = $('name_cms').get('value');
var phone = $('phone_cms').get('value');
var email = $('email_cms').get('value');
var text = $('text').get('value');
var myRequest = new Request({
url:'/ajax/question/cms/',
data: {
'name':name,
'phone':phone,
'email':email,
'text':text,
'mail':mail
},
onSuccess: function(responseText) {
// alert(responseText);
salert('Wiadomość wysłana');
close_window_out($('rc_window3'),1,5000);
}
}).send();
}
function formCreatorSectionShow(sectionName, isShow)
{
if(sectionName && (sectionName.length > 0))
{
if(isShow)
{
$$('.form_creator_class .form_creator_section_' + sectionName).show();
$$('.form_creator_class .form_creator_section_' + sectionName + ' .fValidate').each(function(el, i) {
el.removeAttribute('disabled');
});
}
else
{
$$('.form_creator_class .form_creator_section_' + sectionName).hide();
$$('.form_creator_class .form_creator_section_' + sectionName + ' .fValidate').each(function(el, i) {
el.setAttribute('disabled', 'disabled');
});
}
}
}
function formCreatorSectionSelect(formElement)
{
formElement.getElements('option').each(function(el, i) {
if(el.get('selected'))
formCreatorSectionShow(el.get('data-section'), true)
else
formCreatorSectionShow(el.get('data-section'), false)
});
}
function formCreatorSectionRadio(formElement)
{
groupName = formElement.get('name');
$$('.form_creator_class input[name="' + groupName + '"]').each(function(el, i) {
if(el.get('checked'))
formCreatorSectionShow(el.get('data-section'), true)
else
formCreatorSectionShow(el.get('data-section'), false);
});
}
function formCreatorSectionCheckbox(formElement)
{
if(formElement.get('checked'))
formCreatorSectionShow(formElement.get('data-section'), true);
else
formCreatorSectionShow(formElement.get('data-section'), false);
}
function formCreatorSectionInitialize()
{
$$('.form_creator_class input[type="radio"]').each(function(el, i) {
formCreatorSectionRadio(el);
});
$$('.form_creator_class input[type="checkbox"]').each(function(el, i) {
formCreatorSectionCheckbox(el);
});
$$('.form_creator_class select').each(function(el, i) {
formCreatorSectionSelect(el);
});
}
function checkCaptcha() {
return new Promise(function (resolve) {
var captcha = document.getElementById('g-recaptcha-response');
if (captcha) {
if (captcha.value.length > 5) {
var req = new Request.JSON({
url: '/ajax/form_creator/verifyRecaptcha/',
data: {'g-recaptcha-response': captcha.value},
onSuccess: function (data) {
if (data.error === 'false') {
return resolve(true);
}
return resolve(false);
}
}).send();
} else {
return resolve(false);
}
} else {
return resolve(true);
}
});
}