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 : "https://trends-shop.pl/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:'https://trends-shop.pl/ajax/form_creator/generate_token/', data: { 'formCreatorId': formCreatorId }, onSuccess: function(data) { $$('#form_creator_' + formCreatorId + ' #token').set('value', data); } }).send(); } // disabled elementy nie są sprawdzane przez fValidator 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 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 : "form_creator_submit_" + idForm, fValidate_send : function() { 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); }); if('36576' === '7922' || '36576' === '9595' || '36576' === '12319') { if($('mstar2')) { var rating2 = new rc_ratings({ moostarwidth:$('mstar2').getSize().x, moostarnum:5, inpercent:false, isFractional:false, moostar:$('mstar2'), moostartval:$('mstarval2'), moostartval2:$('mstarval22'), msid:$('msid2'), sid:'36576', cookie:'redcart_blog_', url: '/ajax/blog/rating/', url1: '/ajax/blog/rating_get/' }); } } formCreatorSectionInitialize(); });