2279 lines
71 KiB
JavaScript
2279 lines
71 KiB
JavaScript
var
|
||
_factor = 1,
|
||
_max_amount = 460,
|
||
_unit = 360/_max_amount ,
|
||
_flag = false,
|
||
_angle = {'x': 0, 'y': 0};
|
||
_anglelast = {'x': 0, 'y': 0};
|
||
;
|
||
|
||
var _root_path = "http://chocolatdemariage.com";
|
||
|
||
|
||
var _custom =
|
||
{
|
||
'face_custom' :
|
||
{
|
||
'image' : null,
|
||
'text' : '',
|
||
'is_initials' : false
|
||
},
|
||
'faces_dc_exclu' :
|
||
{
|
||
|
||
},
|
||
'faces_chocos_exclu' :
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
var face_exclu =
|
||
{
|
||
'index' : 0,
|
||
'image' : null,
|
||
'color' : '',
|
||
'color_text' : '',
|
||
'text' : '',
|
||
'font' : '',
|
||
'is_initials' : false,
|
||
'is_custom' : false
|
||
}
|
||
|
||
// add DC faces to object
|
||
for( var i=1; i<=12; i++)
|
||
{
|
||
// Deep copy
|
||
_custom.faces_dc_exclu['face_'+i] = jQuery.extend(true, {}, face_exclu);
|
||
_custom.faces_dc_exclu['face_'+i].index = (i-1);
|
||
}
|
||
|
||
// add chocos faces to object
|
||
for( var i=1; i<=5; i++)
|
||
{
|
||
var face_num = (11 + parseInt(i*2));
|
||
_custom.faces_chocos_exclu['face_'+face_num] = jQuery.extend(true, {}, face_exclu);
|
||
_custom.faces_chocos_exclu['face_'+face_num].index = (i-1);
|
||
}
|
||
|
||
|
||
|
||
|
||
/*log(_custom.faces_dc_exclu.face_1.image)
|
||
log(_custom.faces_dc_exclu.face_2.image)
|
||
log(_custom.faces_chocos_exclu.face_13.image)*/
|
||
|
||
//EXCLU
|
||
var _color_3,_color_3_id,_color_3_text;
|
||
var _choco_exclu_id = 1;
|
||
var _face_exclu_id = 1;
|
||
|
||
var _errors = "";
|
||
|
||
|
||
//==================================================================
|
||
//
|
||
//==================================================================
|
||
$(document).ready(function()
|
||
{
|
||
//logSimu()
|
||
getXML_tarifs();
|
||
//initCanvas();
|
||
});
|
||
|
||
function logSimu()
|
||
{
|
||
log('---------------SIMU--------------')
|
||
$.each(_simu,function(index,value)
|
||
{
|
||
log(index,value)
|
||
});
|
||
log('---------------------------------')
|
||
}
|
||
|
||
//==================================================================
|
||
// MOVE BOX
|
||
//==================================================================
|
||
//document.addEventListener('touchmove', function(e) { e.preventDefault(); }, false);
|
||
|
||
function initDrag()
|
||
{
|
||
$('#simu-box').on(events.start, function(e) {
|
||
|
||
if(hasTouchSupport)
|
||
{
|
||
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
||
p0 = { 'x': touch.pageX, 'y': touch.pageY };
|
||
}
|
||
else
|
||
{
|
||
p0 = { 'x': e.clientX, 'y': e.clientY };
|
||
}
|
||
|
||
_flag = true;
|
||
$(document).on(events.move, drag);
|
||
$('.container').removeClass('animated');
|
||
e.preventDefault();
|
||
});
|
||
|
||
$(document).on(events.end, function(e) {
|
||
|
||
var p1;
|
||
|
||
if(hasTouchSupport)
|
||
{
|
||
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
||
p1 = { 'x': touch.pageX, 'y': touch.pageY };
|
||
}
|
||
else
|
||
{
|
||
p1 = { 'x': e.clientX, 'y': e.clientY };
|
||
}
|
||
|
||
_flag = false;
|
||
$(document).off(events.move, drag);
|
||
_angle = {'x': _anglelast.x, 'y': _anglelast.y}
|
||
});
|
||
}
|
||
|
||
function drag(e) {
|
||
/* distance and angle values since starting to drag */
|
||
|
||
var p1;
|
||
|
||
if(hasTouchSupport)
|
||
{
|
||
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
|
||
p1 = { 'x': touch.pageX - p0.x, 'y': touch.pageY - p0.y }
|
||
}
|
||
else
|
||
{
|
||
p1 = { 'x': e.clientX - p0.x, 'y': e.clientY - p0.y }
|
||
}
|
||
|
||
|
||
var angle = {'x': -p1.y*_unit, 'y': p1.x*_unit};
|
||
tmp = 'rotateX(' + (_angle.x + angle.x) + 'deg)' + 'rotateY(' + (_angle.y + angle.y) + 'deg) scale(.92)';
|
||
$('.container').css({'-webkit-transform' : tmp , 'transform' : tmp});
|
||
_anglelast = {'x': (_angle.x + angle.x), 'y': (_angle.y + angle.y)}
|
||
|
||
};
|
||
|
||
function rotateDC(rX,rY)
|
||
{
|
||
$('.container').addClass('animated');
|
||
|
||
tmp = 'rotateX(' + rX + 'deg)' + 'rotateY(' + rY + 'deg)';
|
||
$('.container').css({'transform' : tmp});
|
||
_angle = {'x': rX, 'y': rY}
|
||
_anglelast = {'x': rX, 'y': rY}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// TOOLS
|
||
//==================================================================
|
||
|
||
|
||
function initTools()
|
||
{
|
||
initToolsInfos()
|
||
initToolsContenant()
|
||
initToolsNiveau()
|
||
initToolsCustom()
|
||
initToolsFinit();
|
||
initToolsCommande();
|
||
|
||
// base DB
|
||
/*$(".container-db").html($('#temp-base .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-base .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-base .pochettes').contents().clone());
|
||
$('.container-db .cubeface').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.chocos-holder .flipper .front').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.chocos-holder .flipper .back').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.container-pochette .pochette .front').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.container-pochette .pochette .back').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})*/
|
||
|
||
$('#email_sauvegarde').val(_simu.email_sauvegarde);
|
||
|
||
//init contenant dc, chocos...
|
||
$('#tool-contenant a#btn-'+_simu.offre).click();
|
||
|
||
//init niveau exclu, bicolore, thematique
|
||
$('#tool-niveau a#btn-'+_simu.custom).click();
|
||
|
||
// init modele ivoire, damier...
|
||
if(_simu.custom != "exclu" && _simu.modele != "") $('#cycle-modele-'+_simu.custom+' .cycle').cycle(_modeles[_simu.custom].indexOf(_simu.modele))
|
||
//init quantite
|
||
//cf. updateSelectQuantite()
|
||
//init type chocos
|
||
if(_simu.offre=="doublecube")
|
||
{
|
||
$('input[value="'+_simu.typeChoco_1+'"]').prop('checked', true);
|
||
_lastChocoChecked = $('input[value="'+_simu.typeChoco_2+'"]')
|
||
_lastChocoChecked.prop('checked', true)
|
||
}
|
||
else
|
||
{
|
||
_lastChocoChecked = $('input[value="'+_simu.typeChoco_1+'"]')
|
||
_lastChocoChecked.prop('checked', true);
|
||
}
|
||
|
||
_is_quantite_init = true;
|
||
|
||
setTimeout(checkFacesSave, 500);
|
||
}
|
||
|
||
function checkFacesSave()
|
||
{
|
||
//SAVED CUSTOM FACES
|
||
if(face_custom_save)
|
||
{
|
||
log(face_custom_save)
|
||
|
||
_custom.face_custom = face_custom_save;
|
||
|
||
if(_custom.face_custom.image)
|
||
{
|
||
var img_path = _root_path+'/uploads/'+_simu.dossier+'/face_3.jpg';
|
||
$('.face-custom-img').html('<div class="image-holder"></div>')
|
||
$('.image-holder').css('background-image', 'url('+img_path+')');
|
||
log($('.image-holder').length);
|
||
setTimeout(function(){log($('.image-holder').length);},500)
|
||
}
|
||
else if(_custom.face_custom.text != "")
|
||
{
|
||
$('.freetext').val((_custom.face_custom.text).replace(/<br>/g, "\n"))
|
||
addFreeTxt();
|
||
}
|
||
else if(_custom.face_custom.is_initials)
|
||
{
|
||
addInitials();
|
||
}
|
||
}
|
||
|
||
if(faces_dc_exclu_save)
|
||
{
|
||
log(faces_dc_exclu_save)
|
||
_custom.faces_dc_exclu = faces_dc_exclu_save;
|
||
var faceX = $('.exclu .container-db .cubeface')
|
||
setFacesExclu(_custom.faces_dc_exclu,faceX)
|
||
}
|
||
|
||
if(faces_chocos_exclu_save)
|
||
{
|
||
log(faces_chocos_exclu_save)
|
||
_custom.faces_chocos_exclu = faces_chocos_exclu_save;
|
||
var faceX = $('.exclu .chocos-holder .flipper .front')
|
||
setFacesExclu(_custom.faces_chocos_exclu,faceX)
|
||
}
|
||
}
|
||
|
||
|
||
function setFacesExclu(faces,faceX)
|
||
{
|
||
$.each(faces, function(index,face){
|
||
|
||
$_face_exclu = faceX.eq(face.index)
|
||
|
||
if(face.image != null)
|
||
{
|
||
var img_path;
|
||
|
||
if(face.image == true)
|
||
{
|
||
img_path = _root_path+'/uploads/'+_simu.dossier+'/'+index+'.jpg' ;
|
||
$_face_exclu.find('.imgface').css('background-image', 'url('+img_path+')');
|
||
}
|
||
else
|
||
{
|
||
var face_exclu = $_face_exclu;
|
||
var reader = new FileReader();
|
||
reader.onload = function (e) {
|
||
|
||
face_exclu.find('.imgface').css('background-image', 'url('+e.target.result+')');
|
||
}
|
||
reader.readAsDataURL(face.image);
|
||
}
|
||
|
||
}
|
||
else if(face.text != "")
|
||
{
|
||
_color_3 = face.color;
|
||
$('#custom-exclu .freetext').val((face.text).replace(/<br \/>/g, "\n"))
|
||
$_face_exclu.find('.txtface').addClass(face.font);
|
||
addFreeTxt();
|
||
}
|
||
else if(face.is_initials)
|
||
{
|
||
_color_3 = face.color;
|
||
$_face_exclu.find('.txtface').addClass(face.font);
|
||
addInitials();
|
||
}
|
||
});
|
||
|
||
$_face_exclu = $('.exclu .chocos-holder .flipper').eq(0).find('.front')
|
||
$('#colorpicker3').simplecolorpicker('selectColor', _color_3);
|
||
}
|
||
|
||
|
||
//==================================================================
|
||
// INFOS
|
||
//==================================================================
|
||
|
||
var monthR = ["","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"]
|
||
|
||
function initToolsInfos()
|
||
{
|
||
$('#name_1').val(_simu.name_1)
|
||
$('#name_2').val(_simu.name_2)
|
||
$('.nom_1').html(_simu.name_1)
|
||
$('.nom_2').html(_simu.name_2)
|
||
$('.initiale_1').html($('#name_1').val().substring(0,1));
|
||
$('.initiale_2').html($('#name_2').val().substring(0,1));
|
||
|
||
// name lui
|
||
$('#name_1').on('keyup',function(){
|
||
|
||
$('.nom_1').html($('#name_1').val())
|
||
$('.initiale_1').html($('#name_1').val().substring(0,1));
|
||
_simu.name_1 = $('#name_1').val();
|
||
});
|
||
|
||
// name elle
|
||
$('#name_2').on('keyup',function(){
|
||
|
||
$('.nom_2').html($('#name_2').val())
|
||
$('.initiale_2').html($('#name_2').val().substring(0,1));
|
||
_simu.name_2 = $('#name_2').val();
|
||
});
|
||
|
||
// nb invités
|
||
$('#nb_invites').val(_simu.nb_invites)
|
||
$('#nb_invites').on('keyup',onNbInvitesChange);
|
||
$('#nb_invites').on('change',onNbInvitesChange);
|
||
|
||
|
||
// date mariage
|
||
$('#date_mariage').val((_simu.date_mariage != "") ? formatDateInput(_simu.date_mariage) : formatDateInput(todaySimu()) );
|
||
$('#date_mariage').on('change',onDateChange);
|
||
onDateChange();
|
||
}
|
||
|
||
var _refs =
|
||
{
|
||
'doublecube':{'qte':0,'ref':'','prix':''},
|
||
'chocos':{'qte':0,'ref':'','prix':''},
|
||
'sachet':{'qte':0,'ref':'','prix':''},
|
||
'pochette':{'qte':0,'ref':'','prix':''}
|
||
}
|
||
|
||
function onNbInvitesChange()
|
||
{
|
||
_simu.nb_invites = $('#nb_invites').val();
|
||
$('.nb_invites').html(_simu.nb_invites)
|
||
|
||
if(_simu.nb_invites > 0)
|
||
{
|
||
$('.suggestion').show();
|
||
$('#suggestions-holder').show();
|
||
}
|
||
else
|
||
{
|
||
$('.suggestion').hide();
|
||
$('#suggestions-holder').hide();
|
||
}
|
||
|
||
//DC
|
||
_refs.doublecube.qte = Math.max(30,Math.min(600,Math.ceil(_simu.nb_invites/10)*10))
|
||
if(_refs.doublecube.qte > 500) _refs.doublecube.qte = 600;
|
||
else if(_refs.doublecube.qte > 450) _refs.doublecube.qte = 500;
|
||
else if(_refs.doublecube.qte > 400) _refs.doublecube.qte = 450;
|
||
else if(_refs.doublecube.qte > 350) _refs.doublecube.qte = 400;
|
||
else if(_refs.doublecube.qte > 300) _refs.doublecube.qte = 350;
|
||
else if(_refs.doublecube.qte > 250) _refs.doublecube.qte = 300;
|
||
_refs.doublecube.ref = _refs.doublecube.qte+'DB';
|
||
_refs.doublecube.prix = $(_xmlTarifs).find('tarif[ref="'+_refs.doublecube.ref+'"]').text()
|
||
$('#sugg-doublecube').find('.qte').html(_refs.doublecube.qte)
|
||
$('#sugg-doublecube').find('.px').html(_refs.doublecube.prix)
|
||
|
||
//CHOCOS
|
||
_refs.chocos.qte = Math.max(200,Math.min(2000,Math.ceil((_simu.nb_invites * 5)/100)*100));
|
||
if(_refs.chocos.qte > 1600) _refs.chocos.qte = 2000;
|
||
_refs.chocos.ref = (_refs.chocos.qte/100)+'QP';
|
||
_refs.chocos.prix = $(_xmlTarifs).find('tarif[ref="'+_refs.chocos.ref+'"]').text()
|
||
$('#sugg-chocos').find('.qte').html(_refs.chocos.qte)
|
||
$('#sugg-chocos').find('.px').html(_refs.chocos.prix)
|
||
|
||
//POCHETTE
|
||
_refs.pochette.qte = Math.max(50,Math.min(600,Math.ceil((_simu.nb_invites)/10)*10));
|
||
if(_refs.pochette.qte > 500) _refs.pochette.qte = 600;
|
||
else if(_refs.pochette.qte > 450) _refs.pochette.qte = 500;
|
||
else if(_refs.pochette.qte > 400) _refs.pochette.qte = 450;
|
||
else if(_refs.pochette.qte > 350) _refs.pochette.qte = 400;
|
||
else if(_refs.pochette.qte > 300) _refs.pochette.qte = 350;
|
||
else if(_refs.pochette.qte > 250) _refs.pochette.qte = 300;
|
||
_refs.pochette.ref = _refs.pochette.qte+'P4';
|
||
_refs.pochette.prix = $(_xmlTarifs).find('tarif[ref="'+_refs.pochette.ref+'"]').text()
|
||
$('#sugg-pochette').find('.qte').html(_refs.pochette.qte)
|
||
$('#sugg-pochette').find('.px').html(_refs.pochette.prix)
|
||
|
||
//SACHET
|
||
_refs.sachet.qte = Math.max(40,Math.min(600,Math.ceil((_simu.nb_invites)/10)*10));
|
||
if(_refs.sachet.qte > 500) _refs.sachet.qte = 600;
|
||
else if(_refs.sachet.qte > 450) _refs.sachet.qte = 500;
|
||
else if(_refs.sachet.qte > 400) _refs.sachet.qte = 450;
|
||
else if(_refs.sachet.qte > 350) _refs.sachet.qte = 400;
|
||
else if(_refs.sachet.qte > 300) _refs.sachet.qte = 350;
|
||
else if(_refs.sachet.qte > 250) _refs.sachet.qte = 300;
|
||
_refs.sachet.ref = _refs.sachet.qte+'SACH';
|
||
_refs.sachet.prix = $(_xmlTarifs).find('tarif[ref="'+_refs.sachet.ref+'"]').text()
|
||
$('#sugg-sachet').find('.qte').html(_refs.sachet.qte)
|
||
$('#sugg-sachet').find('.px').html(_refs.sachet.prix)
|
||
|
||
$('#sugg-'+_simu.offre).hide();
|
||
_simu.ref_base = _refs[_simu.offre].ref;
|
||
//log('nb_invites',_simu.offre, _refs[_simu.offre].qte, _simu.ref_base );
|
||
log(_refs)
|
||
$('#select-quantite').val(_simu.ref_base);
|
||
onQuantiteChange()
|
||
}
|
||
|
||
function onDateChange()
|
||
{
|
||
var day = $('#date_mariage').val().substring(8,10);
|
||
var month = $('#date_mariage').val().substring(5,7)
|
||
var year = $('#date_mariage').val().substring(0,4)
|
||
|
||
$('.day').html(day)
|
||
$('.month').html(monthR[parseInt(month)])
|
||
$('.year').html(year)
|
||
_simu.date_mariage = year+month+day
|
||
log(_simu.date_mariage)
|
||
}
|
||
|
||
function formatDateInput(date)
|
||
{
|
||
var day = date.substring(6,8);
|
||
var month = date.substring(4,6)
|
||
var year = date.substring(0,4)
|
||
|
||
log(year+'-'+month+'-'+day)
|
||
|
||
return year+'-'+month+'-'+day;
|
||
}
|
||
|
||
function todaySimu()
|
||
{
|
||
var today = new Date();
|
||
var dd = (today.getDate()).toString();
|
||
var mm = (today.getMonth()+1).toString(); //January is 0!
|
||
var yyyy = (today.getFullYear()).toString();
|
||
|
||
if(dd<10) dd='0'+dd;
|
||
if(mm<10) mm='0'+mm;
|
||
|
||
log("today : " + yyyy+mm+dd);
|
||
|
||
return yyyy+mm+dd;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// CONTENANT
|
||
//==================================================================
|
||
|
||
function initToolsContenant()
|
||
{
|
||
|
||
$('#tool-contenant a').on('click',function(){
|
||
|
||
$('#tool-contenant a').removeClass('actif')
|
||
$(this).addClass('actif')
|
||
|
||
_simu.offre = $(this).attr('data-offre');
|
||
$('.box-holder').hide();
|
||
|
||
$('.chocos-holder .flip-container').eq(4).show();
|
||
$('#tool-finit').hide();
|
||
$('#custom-freeface').hide()
|
||
|
||
updateSelectQuantite();
|
||
|
||
if(_is_quantite_init) updateFaces();
|
||
|
||
$('.legende-move').hide();
|
||
$('.legende2').hide();
|
||
$('.legende-'+_simu.offre).show();
|
||
|
||
log(_simu.offre);
|
||
|
||
$('#nb_varietes_max').html('1 variété maximum')
|
||
|
||
|
||
if(_simu.offre == "chocos")
|
||
{
|
||
$('.chocos-box-holder').show();
|
||
|
||
//chocos choice
|
||
$('input[name=typeChoco]:checked').eq(1).attr('checked', false);
|
||
_lastChocoChecked = $('input[name=typeChoco]:checked').eq(0)
|
||
}
|
||
else if(_simu.offre == "doublecube")
|
||
{
|
||
$('.doublecube-holder').show();
|
||
$('#tool-finit').show();
|
||
if(_simu.custom != 'exclu') $('#custom-freeface').show()
|
||
$('.legende-move').show();
|
||
$('#nb_varietes_max').html('2 variétés maximum')
|
||
|
||
}
|
||
else if(_simu.offre == "pochette")
|
||
{
|
||
$('.pochette-holder').show();
|
||
$('.chocos-holder .flip-container').eq(4).hide();
|
||
|
||
//chocos choice
|
||
$('input[name=typeChoco]:checked').eq(1).attr('checked', false);
|
||
_lastChocoChecked = $('input[name=typeChoco]:checked').eq(0)
|
||
$('.legende-move').show();
|
||
}
|
||
else if(_simu.offre == "sachet")
|
||
{
|
||
$('.sachet-holder').show();
|
||
|
||
//chocos choice
|
||
$('input[name=typeChoco]:checked').eq(1).attr('checked', false);
|
||
_lastChocoChecked = $('input[name=typeChoco]:checked').eq(0)
|
||
}
|
||
|
||
updateSlider();
|
||
|
||
|
||
return false;
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// NIVEAU
|
||
//==================================================================
|
||
|
||
var _is_modele_init = false;
|
||
|
||
function initToolsNiveau()
|
||
{
|
||
$('#tool-niveau a').on('click',function(){
|
||
|
||
$('#tool-niveau a').removeClass('actif')
|
||
$(this).addClass('actif');
|
||
|
||
_simu.custom = $(this).attr('data-custom');
|
||
|
||
$('#tool-custom').removeClass('locked')
|
||
$('#tool-custom .tool-part').hide()
|
||
$("#simus-holder").removeClass('exclu')
|
||
|
||
if(_simu.custom == 'thematique')
|
||
{
|
||
$('#custom-thematique').show()
|
||
if(_simu.offre == "doublecube") $('#custom-freeface').show()
|
||
|
||
if( _is_modele_init)
|
||
{
|
||
$('.container').removeClass(_simu.modele);
|
||
$('.chocos-holder').removeClass(_simu.modele);
|
||
_simu.modele = "ivoire";
|
||
}
|
||
|
||
$('.container').addClass(_simu.modele );
|
||
$('.chocos-holder').addClass(_simu.modele);
|
||
|
||
updateSlider();
|
||
|
||
}
|
||
else if(_simu.custom == 'bicolore')
|
||
{
|
||
$('#colorpicker1').simplecolorpicker('selectColor', _simu.color_1);
|
||
$('#colorpicker2').simplecolorpicker('selectColor', _simu.color_2);
|
||
_simu.color_1 = $('#colorpicker1').val()
|
||
_simu.color_1_text = $('#colorpicker1 option:selected').text()
|
||
_simu.color_1_id = $('#colorpicker1 option:selected').attr('data-id')
|
||
_simu.color_2 = $('#colorpicker2').val()
|
||
_simu.color_2_text = $('#colorpicker2 option:selected').text()
|
||
_simu.color_2_id = $('#colorpicker2 option:selected').attr('data-id');
|
||
$('.color1text').html(_simu.color_1_text);
|
||
$('.color2text').html(_simu.color_2_text);
|
||
|
||
$('#custom-bicolore').show()
|
||
log(_simu.offre)
|
||
if(_simu.offre == "doublecube") $('#custom-freeface').show()
|
||
|
||
if( _is_modele_init)
|
||
{
|
||
$('.container').removeClass(_simu.modele);
|
||
$('.chocos-holder').removeClass(_simu.modele);
|
||
_simu.modele = "damier";
|
||
}
|
||
|
||
$('.container').addClass(_simu.modele );
|
||
$('.chocos-holder').addClass(_simu.modele);
|
||
|
||
}
|
||
else if(_simu.custom == 'exclu')
|
||
{
|
||
_color_3 = $('#colorpicker3').val()
|
||
_color_3_text = $('#colorpicker3 option:selected').text()
|
||
_color_3_id = $('#colorpicker3 option:selected').attr('data-id')
|
||
$('.color3text').html(_color_3_text);
|
||
|
||
$('.container').removeClass(_simu.modele);
|
||
$('.chocos-holder').removeClass(_simu.modele)
|
||
_simu.modele = "";
|
||
$("#simus-holder").addClass('exclu')
|
||
$('#custom-exclu').show()
|
||
$('#custom-freeface').hide()
|
||
}
|
||
|
||
_is_modele_init = true;
|
||
|
||
updateFaces()
|
||
updateSelectQuantite();
|
||
|
||
if(_simu.offre == "pochette") $('.chocos-holder .flip-container').eq(4).hide();
|
||
|
||
$('#cycle-modele-'+_simu.custom+' .cycle').cycle(0)
|
||
updateSlider();
|
||
|
||
return false;
|
||
});
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// CUSTOMIZE
|
||
//==================================================================
|
||
var _modeles =
|
||
{
|
||
'thematique' : ['ivoire','fleurs','voyage','tendance','oriental','vintage','uv','gourmandise','chocolate','cinema','champetre'],
|
||
'bicolore' : ['damier','ruban','bayadere','liseres']
|
||
}
|
||
|
||
var _fontExcluOn = "Aladdin";
|
||
|
||
var rotateR =
|
||
[
|
||
null,
|
||
[-90,0],
|
||
[90,0],
|
||
[0,180],
|
||
[0,0],
|
||
[0,100],
|
||
[0,-20],
|
||
[-90,0],
|
||
[90,0],
|
||
[0,180],
|
||
[0,0],
|
||
[0,20],
|
||
[0,-100]
|
||
]
|
||
|
||
|
||
function updateSlider()
|
||
{
|
||
if(_simu.custom == "bicolore" || _simu.custom == "thematique")
|
||
{
|
||
$.each(_modeles[_simu.custom],function(index, value) {
|
||
|
||
log(index,value)
|
||
|
||
$('#slide-'+value).css({'background-image':'url(img/simulation/slides/'+_simu.offre+'/'+_simu.custom+'/'+value+'.png)'})
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
function initToolsCustom()
|
||
{
|
||
$('#cycle-modele-thematique .cycle').cycle({
|
||
slides:".item",
|
||
speed: 300,
|
||
manualSpeed: 300,
|
||
timeout:0,
|
||
//easing:'easeInOutExpo',
|
||
fx:"scrollHorz"
|
||
,prev : "#prev-modele-thematique",
|
||
next : "#next-modele-thematique"
|
||
});
|
||
|
||
$('#cycle-modele-thematique .cycle').on( 'cycle-after', function( event, opts )
|
||
{
|
||
//remove class active
|
||
$('.container').removeClass(_simu.modele);
|
||
$('.chocos-holder').removeClass(_simu.modele)
|
||
|
||
var index = opts.slideNum - 1;
|
||
_simu.modele = _modeles.thematique[index];
|
||
|
||
$('.container').addClass(_simu.modele);
|
||
$('.chocos-holder').addClass(_simu.modele)
|
||
//log(_simu.modele);
|
||
|
||
updateFaces();
|
||
});
|
||
|
||
|
||
$('#cycle-modele-bicolore .cycle').cycle({
|
||
slides:".item",
|
||
speed: 300,
|
||
manualSpeed: 300,
|
||
timeout:0,
|
||
//easing:'easeInOutExpo',
|
||
fx:"scrollHorz"
|
||
,prev : "#prev-modele-bicolore",
|
||
next : "#next-modele-bicolore"
|
||
});
|
||
|
||
$('#cycle-modele-bicolore .cycle').on( 'cycle-after', function( event, opts )
|
||
{
|
||
//remove class active
|
||
$('.container').removeClass(_simu.modele);
|
||
$('.chocos-holder').removeClass(_simu.modele)
|
||
|
||
var index = opts.slideNum - 1;
|
||
_simu.modele = _modeles.bicolore[index];
|
||
|
||
$('.container').addClass(_simu.modele);
|
||
$('.chocos-holder').addClass(_simu.modele)
|
||
//log(_simu.modele);
|
||
|
||
updateFaces();
|
||
|
||
//checkForFinit()
|
||
});
|
||
|
||
|
||
|
||
|
||
|
||
//IMAGE
|
||
$('.input-image').on('change',function(){
|
||
|
||
addImage(this);
|
||
rotateDC(0,180)
|
||
})
|
||
|
||
//IMAGE
|
||
$('.input-image-exclu').on('change',function(){
|
||
|
||
addImageExclu(this);
|
||
})
|
||
|
||
//FREETEXT
|
||
$('.freetext').on('keyup',function(){
|
||
|
||
if(_simu.custom=="exclu")
|
||
{
|
||
if(_faceSelected == "dc") rotateDC(rotateR[_face_exclu_id][0],rotateR[_face_exclu_id][1])
|
||
}
|
||
else
|
||
{
|
||
rotateDC(0,180)
|
||
}
|
||
addFreeTxt();
|
||
|
||
})
|
||
$('.freetext').on('focus',function(){
|
||
|
||
if(_simu.custom=="exclu")
|
||
{
|
||
if(_faceSelected == "dc") rotateDC(rotateR[_face_exclu_id][0],rotateR[_face_exclu_id][1])
|
||
}
|
||
else
|
||
{
|
||
rotateDC(0,180)
|
||
}
|
||
addFreeTxt();
|
||
})
|
||
|
||
|
||
//INITIALES
|
||
$('.btn-initiales').on('click',function(){
|
||
|
||
if(_simu.custom=="exclu")
|
||
{
|
||
if(_faceSelected == "dc") rotateDC(rotateR[_face_exclu_id][0],rotateR[_face_exclu_id][1])
|
||
}
|
||
else
|
||
{
|
||
rotateDC(0,180)
|
||
}
|
||
addInitials();
|
||
})
|
||
|
||
|
||
//BI COLORS
|
||
$('#colorpicker1').simplecolorpicker({
|
||
picker: true
|
||
}).on('change', function() {
|
||
_simu.color_1 = $('#colorpicker1').val()
|
||
_simu.color_1_text = $('#colorpicker1 option:selected').text()
|
||
_simu.color_1_id = $('#colorpicker1 option:selected').attr('data-id')
|
||
$('.color1text').html(_simu.color_1_text)
|
||
|
||
updateFaces();
|
||
});
|
||
|
||
$('#colorpicker2').simplecolorpicker({
|
||
picker: true
|
||
}).on('change', function() {
|
||
_simu.color_2 = $('#colorpicker2').val()
|
||
_simu.color_2_text = $('#colorpicker2 option:selected').text()
|
||
_simu.color_2_id = $('#colorpicker2 option:selected').attr('data-id');
|
||
$('.color2text').html(_simu.color_2_text)
|
||
|
||
updateFaces();
|
||
});
|
||
|
||
|
||
//EXCLU COLOR
|
||
$('#colorpicker3').simplecolorpicker({
|
||
picker: true
|
||
}).on('change', function() {
|
||
_color_3 = $('#colorpicker3').val()
|
||
_color_3_text = $('#colorpicker3 option:selected').text()
|
||
_color_3_id = $('#colorpicker3 option:selected').attr('data-id');
|
||
$('.color3text').html(_color_3_text)
|
||
|
||
_face_exclu.image = null;
|
||
_face_exclu.color = _color_3;
|
||
_face_exclu.color_text = _color_3_text;
|
||
|
||
log('color',_face_exclu.color)
|
||
|
||
$_face_exclu.find('.imgface').css({'background-color' : _color_3,'background-image' : "none"});
|
||
|
||
copyToChocos();
|
||
});
|
||
|
||
|
||
//EXCLU FONT
|
||
$('#select-font').on('change',function(){
|
||
|
||
$_face_exclu.find('.txtface').removeClass(_face_exclu.font);
|
||
_face_exclu.font = $(this).val();
|
||
$_face_exclu.find('.txtface').addClass(_face_exclu.font);
|
||
copyToChocos();
|
||
|
||
//realign
|
||
var $txt_holder = $_face_exclu.find('.freetext-holder');
|
||
$txt_holder.css({'margin-top':-$txt_holder.height()*0.5})
|
||
|
||
//on applique la font aux autres faces si elles n'ont pas de font associées
|
||
$.each(_custom.faces_dc_exclu, function(index, face_exclu) {
|
||
|
||
if(face_exclu.font == "")
|
||
{
|
||
$('.exclu .cubeface').eq(face_exclu.index).find('.txtface').removeClass(_fontExcluOn);
|
||
$('.exclu .cubeface').eq(face_exclu.index).find('.txtface').addClass(_face_exclu.font);
|
||
}
|
||
});
|
||
|
||
$.each(_custom.faces_chocos_exclu, function(index, face_exclu) {
|
||
|
||
if(face_exclu.font == "")
|
||
{
|
||
//log(face_exclu.index,face_exclu.font)
|
||
$('.exclu .flipper').eq(face_exclu.index).find('.txtface').removeClass(_fontExcluOn);
|
||
$('.exclu .flipper').eq(face_exclu.index).find('.txtface').addClass(_face_exclu.font);
|
||
}
|
||
});
|
||
|
||
_fontExcluOn = _face_exclu.font;
|
||
|
||
});
|
||
|
||
}
|
||
|
||
|
||
function copyToChocos()
|
||
{
|
||
log("copyToChocos",$_face_exclu.attr('data-id'))
|
||
|
||
if( _faceSelected == "dc")
|
||
{
|
||
var $txt_holder = null;
|
||
var num_face_dc = $_face_exclu.attr('data-id');
|
||
var index_choco;
|
||
var num_face_choco;
|
||
var is_copy = false;
|
||
|
||
if( num_face_dc == 4)
|
||
{
|
||
index_choco = 0;
|
||
num_face_choco = 13
|
||
is_copy=true;
|
||
}
|
||
else if( num_face_dc == 1)
|
||
{
|
||
index_choco = 1;
|
||
num_face_choco = 15;
|
||
is_copy=true;
|
||
}
|
||
else if(num_face_dc == 6)
|
||
{
|
||
index_choco = 2;
|
||
num_face_choco = 17;
|
||
is_copy=true;
|
||
}
|
||
else if( num_face_dc == 7)
|
||
{
|
||
index_choco = 3;
|
||
num_face_choco = 19;
|
||
is_copy=true;
|
||
}
|
||
else if( num_face_dc == 9)
|
||
{
|
||
index_choco = 4;
|
||
num_face_choco = 21;
|
||
is_copy=true;
|
||
}
|
||
|
||
if(is_copy)
|
||
{
|
||
var $cubeface = $('.container-db .cubeface[data-id="'+num_face_dc+'"]').clone().contents();
|
||
$('.chocos-holder .flipper').eq(index_choco).find('.front').html($cubeface)
|
||
$txt_holder = $('.chocos-holder .flipper').eq(index_choco).find('.freetext-holder');
|
||
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].image = _custom.faces_dc_exclu["face_"+num_face_dc].image;
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].color = _custom.faces_dc_exclu["face_"+num_face_dc].color;
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].color_text = _custom.faces_dc_exclu["face_"+num_face_dc].color_text;
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].text = _custom.faces_dc_exclu["face_"+num_face_dc].text;
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].font = _custom.faces_dc_exclu["face_"+num_face_dc].font;
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].is_initials = _custom.faces_dc_exclu["face_"+num_face_dc].is_initials;
|
||
_custom.faces_chocos_exclu["face_"+num_face_choco].is_custom = _custom.faces_dc_exclu["face_"+num_face_dc].is_custom;
|
||
|
||
if($txt_holder) $txt_holder.css({'margin-top':-$txt_holder.height()*0.5})
|
||
}
|
||
|
||
}
|
||
|
||
for(var i=0; i<4; i++)
|
||
{
|
||
$('.exclu .container-pochette .pochette').eq(i).find('.front').html($('.exclu .chocos-holder .flipper').eq(i).find('.front').contents().clone())
|
||
$('.exclu .container-pochette .pochette').eq(i).find('.back').html($('.exclu .chocos-holder .flipper').eq(i).find('.front').contents().clone())
|
||
}
|
||
|
||
}
|
||
|
||
//==================================================================
|
||
// INITIALES
|
||
//==================================================================
|
||
|
||
function addInitials()
|
||
{
|
||
log("addInitials");
|
||
|
||
if(_simu.custom=="exclu")
|
||
{
|
||
//add last bg color
|
||
$_face_exclu.find('.imgface').css({'background-color' : _color_3,'background-image' : "none"});
|
||
|
||
_face_exclu.image = null
|
||
_face_exclu.color = _color_3;
|
||
_face_exclu.color_text = _color_3_text;
|
||
_face_exclu.text = ""
|
||
if(_face_exclu.font == "" ) _face_exclu.font = _fontExcluOn;
|
||
|
||
log('_face_exclu.font', _face_exclu.font)
|
||
|
||
_face_exclu.is_initials = true
|
||
var $txt_holder = $_face_exclu.find('.txtface');
|
||
$txt_holder.html($('#custom_elmts .initiales-holder').clone())
|
||
$txt_holder.addClass(_face_exclu.font)
|
||
|
||
// si color la face est valide
|
||
if(_face_exclu.color != "") _face_exclu.is_custom = true;
|
||
else _face_exclu.is_custom = false;
|
||
|
||
copyToChocos();
|
||
}
|
||
else
|
||
{
|
||
_custom.face_custom.image = null
|
||
_custom.face_custom.text = ""
|
||
_custom.face_custom.is_initials = true
|
||
|
||
$(".face-custom-txt").empty();
|
||
$('.face-custom-img').empty();
|
||
$('#custom_elmts .initiales-holder').clone().appendTo(".face-custom-txt")
|
||
}
|
||
|
||
}
|
||
|
||
|
||
//==================================================================
|
||
// FREE TEXTE
|
||
//==================================================================
|
||
|
||
function addFreeTxt()
|
||
{
|
||
log("addFreeTxt");
|
||
|
||
if(_simu.custom=="exclu")
|
||
{
|
||
var txt = $('#custom-exclu .freetext').val().replace(/\n/g, "<br />");
|
||
|
||
_face_exclu.image = null
|
||
_face_exclu.color = _color_3;
|
||
_face_exclu.color_text = _color_3_text;
|
||
_face_exclu.text = txt;
|
||
|
||
//log(_face_exclu.index,_face_exclu.text)
|
||
|
||
if(_face_exclu.font == "" ) _face_exclu.font = _fontExcluOn;
|
||
_face_exclu.is_initials = false
|
||
|
||
//add last bg color
|
||
$_face_exclu.find('.imgface').css({'background-color' : _color_3,'background-image' : "none"});
|
||
$_face_exclu.find('.txtface').html('<div class="freetext-holder"></div>');
|
||
var $txt_holder = $_face_exclu.find('.freetext-holder');
|
||
$_face_exclu.find('.txtface').addClass(_face_exclu.font)
|
||
|
||
$txt_holder.html(txt).css({'margin-top':-$txt_holder.height()*0.5})
|
||
|
||
if(_face_exclu.color != "" && _face_exclu.text != "") _face_exclu.is_custom = true;
|
||
else _face_exclu.is_custom = false;
|
||
|
||
copyToChocos();
|
||
}
|
||
else
|
||
{
|
||
var txt = $('.freetext').val().replace('/\n/g', "<br />")
|
||
|
||
_custom.face_custom.image = null
|
||
_custom.face_custom.text = txt
|
||
_custom.face_custom.is_initials = false
|
||
|
||
$('.face-custom-img').empty();
|
||
$(".face-custom-txt").html('<div class="freetext-holder"></div>');
|
||
$('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5})
|
||
|
||
}
|
||
}
|
||
|
||
|
||
//==================================================================
|
||
// IMAGE
|
||
//==================================================================
|
||
|
||
function addImage(input)
|
||
{
|
||
log('addImage')
|
||
|
||
$(".face-custom-txt").empty();
|
||
$('.face-custom-img').html('<div class="image-holder"></div>')
|
||
//log(input.files[0])
|
||
|
||
if (input.files && input.files[0]) {
|
||
|
||
_custom.face_custom.image = input.files[0]
|
||
_custom.face_custom.text = ""
|
||
_custom.face_custom.is_initials = false
|
||
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e)
|
||
{
|
||
$('.image-holder').css('background-image', 'url('+e.target.result+')');
|
||
}
|
||
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
else {
|
||
|
||
}
|
||
}
|
||
|
||
function addImageExclu(input)
|
||
{
|
||
|
||
$_face_exclu.find('.txtface').html('');
|
||
|
||
if (input.files && input.files[0]) {
|
||
|
||
_face_exclu.image = input.files[0];
|
||
_face_exclu.color = "";
|
||
_face_exclu.color_text = "";
|
||
_face_exclu.text = "";
|
||
_face_exclu.is_initials = false
|
||
_face_exclu.is_custom = true;
|
||
|
||
var reader = new FileReader();
|
||
|
||
reader.onload = function (e) {
|
||
|
||
$_face_exclu.find('.imgface').css('background-image', 'url('+e.target.result+')');
|
||
copyToChocos();
|
||
}
|
||
|
||
reader.readAsDataURL(input.files[0]);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// INIT FACES
|
||
//==================================================================
|
||
var _faceSelected = "dc"
|
||
var _face_exclu = {};
|
||
|
||
function checkfaceCustom()
|
||
{
|
||
log('checkfaceCustom');
|
||
|
||
if(_simu.offre == "doublecube")
|
||
{
|
||
if(_custom.face_custom.image != null)
|
||
{
|
||
if(_custom.face_custom.image != true) addImage($("#custom-freeface .input-image").get(0))
|
||
}
|
||
else if(_custom.face_custom.text != "") addFreeTxt()
|
||
else if(_custom.face_custom.is_initials != "") addInitials()
|
||
}
|
||
}
|
||
|
||
function updateFaces()
|
||
{
|
||
log('updateFaces');
|
||
|
||
// reset faces
|
||
$('.container-db').find('.noms-holder').remove();
|
||
$('.container-db').find('.date-holder').remove();
|
||
$('.chocos-holder').find('.noms-holder').remove();
|
||
$('.chocos-holder').find('.date-holder').remove();
|
||
$('.container-pochette').find('.noms-holder').remove();
|
||
$('.container-pochette').find('.date-holder').remove();
|
||
$('.face-custom-txt').removeClass('face-custom-txt');
|
||
$('.face-custom-img').removeClass('face-custom-img');
|
||
|
||
$(".container-db").empty()
|
||
$(".chocos-holder").empty()
|
||
$(".container-pochette").empty()
|
||
|
||
var chocos_style = "";
|
||
|
||
|
||
//thematique
|
||
if(_simu.custom == "thematique")
|
||
{
|
||
$(".container-db").html($('#temp-base .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-base .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-base .pochettes').contents().clone());
|
||
$(".container-db .db-cube1 .back").addClass('face-custom-txt');
|
||
$(".container-db .db-cube1 .back").addClass('face-custom-img');
|
||
|
||
checkfaceCustom();
|
||
|
||
//DOUBLECUBE
|
||
|
||
// 4 8 5
|
||
if(_simu.modele == "ivoire" || _simu.modele == "tendance" || _simu.modele == "champetre" || _simu.modele == "uv")
|
||
{
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube2 .bottom")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube1 .left")
|
||
}
|
||
// 4 8 7
|
||
if(_simu.modele == "oriental")
|
||
{
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube2 .bottom")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube2 .top")
|
||
}
|
||
// 4 8 12
|
||
else if(_simu.modele == "chocolate" || _simu.modele == "cinema" || _simu.modele == "oriental" || _simu.modele == "fleurs" || _simu.modele == "vintage" || _simu.modele == "voyage" || _simu.modele == "gourmandise")
|
||
{
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube2 .bottom")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube2 .right")
|
||
}
|
||
|
||
$('.container-db.'+_simu.modele+' .db-cube1 .top').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_1.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube1 .bottom').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_2.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube1 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_3.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube1 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_4.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube1 .left').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_5.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube1 .right').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_6.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube2 .top').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_7.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube2 .bottom').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_8.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube2 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_9.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube2 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_10.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube2 .left').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_11.png)'})
|
||
$('.container-db.'+_simu.modele+' .db-cube2 .right').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/db/face_12.png)'})
|
||
|
||
//CHOCOS
|
||
|
||
// faces chocos identiques
|
||
if(_simu.modele == "chocolate" || _simu.modele == "cinema" || _simu.modele == "oriental" || _simu.modele == "champetre")
|
||
{
|
||
//chocos
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .front")
|
||
$('#custom_elmts .date-holder-line').clone().appendTo(".chocos-holder .back")
|
||
|
||
$('.chocos-holder.'+_simu.modele+' .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_13.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_14.png)'})
|
||
|
||
//pochette
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .front")
|
||
$('#custom_elmts .date-holder-line').clone().appendTo(".container-pochette .back")
|
||
|
||
$('.container-pochette.'+_simu.modele+' .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_13.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_14.png)'})
|
||
}
|
||
// faces chocos différentes
|
||
else
|
||
{
|
||
//chocos
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco1 .front")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco4 .front")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".chocos-holder .choco2 .front")
|
||
|
||
$('.chocos-holder.'+_simu.modele+' .choco1 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_13.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco1 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_14.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco2 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_15.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco2 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_16.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco3 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_17.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco3 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_18.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco4 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_19.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco4 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_20.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco5 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_21.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco5 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_22.png)'})
|
||
|
||
//pochette
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .pochette1 .front")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .pochette4 .front")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-pochette .pochette2 .front")
|
||
|
||
$('.container-pochette.'+_simu.modele+' .pochette1 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_13.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette1 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_14.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette2 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_15.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette2 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_16.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette3 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_17.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette3 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_18.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette4 .front').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_19.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette4 .back').css({'background-image':'url(img/simulation/thematique/'+_simu.modele+'/chocos/face_20.png)'})
|
||
}
|
||
|
||
if(_simu.modele == "fleurs" || _simu.modele == "tendance" || _simu.modele == "uv" || _simu.modele == "voyage" || _simu.modele == "vintage" || _simu.modele == "gourmandise")
|
||
{
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco5 .front")
|
||
}
|
||
}
|
||
//bicolore
|
||
else if(_simu.custom == "bicolore")
|
||
{
|
||
$('#custom-freeface').hide()
|
||
|
||
if(_simu.modele == "damier")
|
||
{
|
||
|
||
if(_simu.offre == "doublecube") $('#custom-freeface').show()
|
||
|
||
$(".container-db").html($('#temp-base .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-base .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-base .pochettes').contents().clone());
|
||
|
||
$('.container-db .cubeface').html('<div class="colorface color_1"></div><div class="colorface color_2"></div>')
|
||
$('.chocos-holder .flipper .front').html('<div class="colorface color_1"></div><div class="colorface color_2"></div>')
|
||
$('.chocos-holder .flipper .back').html('<div class="colorface color_1"></div><div class="colorface color_2"></div>')
|
||
$('.container-pochette .pochette .front').html('<div class="colorface color_1"></div><div class="colorface color_2"></div>')
|
||
$('.container-pochette .pochette .back').html('<div class="colorface color_1"></div><div class="colorface color_2"></div>')
|
||
|
||
$(".color_1").addClass(_simu.color_1_id)
|
||
$(".color_2").addClass(_simu.color_2_id)
|
||
|
||
$('.switch').removeClass('switch');
|
||
|
||
$(".container-db .db-cube1 .back .color_2").addClass('face-custom-img');
|
||
$(".container-db .db-cube1 .back .color_1").addClass('face-custom-txt');
|
||
|
||
// dc
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front .color_2")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube2 .bottom .color_1")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube1 .left .color_1")
|
||
|
||
$(".container-db .db-cube1 .left").addClass('switch')
|
||
$(".container-db .db-cube1 .right").addClass('switch')
|
||
$(".container-db .db-cube1 .top").addClass('switch')
|
||
$(".container-db .db-cube1 .back").addClass('switch')
|
||
$(".container-db .db-cube2 .bottom").addClass('switch')
|
||
$(".container-db .db-cube2 .left").addClass('switch')
|
||
$(".container-db .db-cube2 .right").addClass('switch')
|
||
|
||
log("color_1_id : "+_simu.color_1_id);
|
||
|
||
$('.container-db .db-cube1 .top .color_1.'+_simu.color_1_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_1_id+'/face_1.png)'})
|
||
$('.container-db .db-cube1 .right .color_1.'+_simu.color_1_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_1_id+'/face_6.png)'})
|
||
$('.container-db .db-cube2 .top .color_2.'+_simu.color_2_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_2_id+'/face_7.png)'})
|
||
$('.container-db .db-cube2 .bottom .color_2.'+_simu.color_2_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_2_id+'/face_8.png)'})
|
||
$('.container-db .db-cube2 .back .color_2.'+_simu.color_2_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_2_id+'/face_9.png)'})
|
||
$('.container-db .db-cube2 .front .color_2.'+_simu.color_2_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_2_id+'/face_10.png)'})
|
||
$('.container-db .db-cube2 .left .color_1.'+_simu.color_1_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_1_id+'/face_11.png)'})
|
||
$('.container-db .db-cube2 .right .color_1.'+_simu.color_1_id).css({'background-image' : 'url(img/simulation/bicolore/damier/db/'+_simu.color_1_id+'/face_12.png)'})
|
||
|
||
var color = (_simu.color_1_id == "blanc" || _simu.color_1_id == "ivoire") ? 'noir' : _simu.color_2_id;
|
||
log(color);
|
||
|
||
$('.chocos-holder.'+_simu.modele+' .choco1 .back .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+color+'/face_14.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco2 .back .color_1').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_1_id+'/face_16.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco3 .front .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_2_id+'/face_17.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco3 .back .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+color+'/face_18.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco4 .back .color_1').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_1_id+'/face_20.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco5 .front .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_2_id+'/face_21.png)'})
|
||
$('.chocos-holder.'+_simu.modele+' .choco5 .back .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+color+'/face_22.png)'})
|
||
|
||
$('.container-pochette.'+_simu.modele+' .pochette1 .back .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+color+'/face_14.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette2 .back .color_1').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_1_id+'/face_16.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette3 .front .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_2_id+'/face_17.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette3 .back .color_2').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+color+'/face_18.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .pochette4 .back .color_1').css({'background-image':'url(img/simulation/bicolore/damier/chocos/'+_simu.color_1_id+'/face_20.png)'})
|
||
|
||
|
||
//chocos
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco1 .front .color_2")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco4 .front .color_1")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".chocos-holder .choco2 .front .color_1")
|
||
|
||
$(".chocos-holder .choco2").addClass('switch')
|
||
$(".chocos-holder .choco4").addClass('switch')
|
||
|
||
//pochette
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .pochette1 .front .color_2")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .pochette4 .front .color_1")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-pochette .pochette2 .front .color_1")
|
||
|
||
$(".container-pochette .pochette2").addClass('switch')
|
||
$(".container-pochette .pochette4").addClass('switch')
|
||
|
||
|
||
$('.damier .color_1').css({ 'background-color':_simu.color_1})
|
||
$('.damier .color_2').css({ 'color':_simu.color_2})
|
||
$('.damier .switch .color_1').css({ 'color':_simu.color_1})
|
||
$('.damier .switch .color_2').css({'background-color':_simu.color_2})
|
||
|
||
checkfaceCustom()
|
||
}
|
||
else if(_simu.modele == "ruban")
|
||
{
|
||
|
||
$(".container-db").html($('#temp-ruban .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-ruban .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-ruban .pochettes').contents().clone());
|
||
|
||
$(".container-db .cubeface").addClass('b-'+_simu.color_1_id)
|
||
$(".container-db .bande").addClass('b-'+_simu.color_2_id)
|
||
$(".container-db .txt").addClass('c-'+_simu.color_1_id)
|
||
|
||
$('.chocos-holder .front').addClass('b-'+_simu.color_1_id)
|
||
$('.chocos-holder .back').addClass('b-'+_simu.color_1_id)
|
||
$('.chocos-holder .bande').addClass('b-'+_simu.color_2_id)
|
||
$(".chocos-holder .txt").addClass('c-'+_simu.color_1_id)
|
||
|
||
$('.container-pochette .front').addClass('b-'+_simu.color_1_id)
|
||
$('.container-pochette .back').addClass('b-'+_simu.color_1_id)
|
||
$('.container-pochette .bande').addClass('b-'+_simu.color_2_id)
|
||
$(".container-pochette .txt").addClass('c-'+_simu.color_1_id)
|
||
|
||
$('.chocos-holder .back').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+_simu.color_2_id+'/face_14.png)'})
|
||
$('.container-pochette .back').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+_simu.color_2_id+'/face_14.png)'})
|
||
}
|
||
else if(_simu.modele == "bayadere")
|
||
{
|
||
|
||
if(_simu.offre == "doublecube") $('#custom-freeface').show()
|
||
|
||
$(".container-db").html($('#temp-base .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-base .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-base .pochettes').contents().clone());
|
||
|
||
$('.container-db .cubeface').html($('#temp-bayadere .bayaface').clone())
|
||
$('.chocos-holder .flipper .front').html($('#temp-bayadere .bayaface').clone())
|
||
$('.chocos-holder .flipper .back').html($('#temp-bayadere .bayaface').clone())
|
||
$('.container-pochette .pochette .front').html($('#temp-bayadere .bayaface').clone())
|
||
$('.container-pochette .pochette .back').html($('#temp-bayadere .bayaface').clone())
|
||
|
||
$(".container-db .db-cube1 .back").append('<div class="face-custom-txt face-custom-img"></div>')
|
||
|
||
$('.bayaface .col1').addClass('b-'+_simu.color_1_id)
|
||
$('.bayaface .col2').addClass('b-'+_simu.color_2_id)
|
||
$('.bayaface .col3').addClass('b-'+_simu.color_1_id)
|
||
$('.bayaface .col4').addClass('b-'+_simu.color_2_id)
|
||
|
||
// dc
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube2 .front")
|
||
$('.container-db .db-cube1 .right').append('<div class="coeur"></div>');
|
||
$('.container-db .db-cube2 .left').append('<div class="coeur"></div>');
|
||
$('.container-db .db-cube2 .back').append('<div class="oui"></div>');
|
||
|
||
//chocos
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .front")
|
||
$('#custom_elmts .date-holder-line').clone().appendTo(".chocos-holder .back")
|
||
|
||
//pochette
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .front")
|
||
$('#custom_elmts .date-holder-line').clone().appendTo(".container-pochette .back")
|
||
|
||
$('.chocos-holder .back .colover').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+_simu.color_2_id+'/face_14.png)'})
|
||
$('.container-pochette .back .colover').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+_simu.color_2_id+'/face_14.png)'})
|
||
|
||
checkfaceCustom()
|
||
}
|
||
else if(_simu.modele == "liseres")
|
||
{
|
||
|
||
if(_simu.offre == "doublecube") $('#custom-freeface').show()
|
||
|
||
$(".container-db").html($('#temp-base .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-base .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-base .pochettes').contents().clone());
|
||
|
||
$('.container-db .cubeface').html($('#temp-liseres .liseface').contents().clone())
|
||
$('.chocos-holder .flipper .front').html($('#temp-liseres .lisefacesmall').contents().clone())
|
||
$('.chocos-holder .flipper .back').html($('#temp-liseres .lisefacesmall').contents().clone())
|
||
$('.container-pochette .pochette .front').html($('#temp-liseres .lisefacesmall').contents().clone())
|
||
$('.container-pochette .pochette .back').html($('#temp-liseres .lisefacesmall').contents().clone())
|
||
|
||
$(".container-db .db-cube1 .back").append('<div class="face-custom-txt face-custom-img"></div>')
|
||
|
||
var file;
|
||
if(_simu.color_1_id == "blanc")
|
||
{
|
||
if(_simu.color_2_id == "argent" || _simu.color_2_id == "or")
|
||
{
|
||
file = _simu.color_2_id+'_et_blanc';
|
||
color = 'noir'
|
||
}
|
||
else
|
||
{
|
||
file = _simu.color_2_id;
|
||
color = _simu.color_2_id;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
file = _simu.color_2_id;
|
||
color = _simu.color_2_id;
|
||
}
|
||
|
||
// dc
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front")
|
||
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube2 .right")
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube2 .bottom")
|
||
|
||
$('.container-db .bkgface').addClass('b-'+_simu.color_1_id)
|
||
$('.container-db .imgface').addClass(color)
|
||
$('.container-db .noms-holder').addClass('c-'+color)
|
||
$('.container-db .date-holder').addClass('c-'+color)
|
||
$('.container-db .face-custom-txt').addClass('c-'+color)
|
||
|
||
|
||
|
||
$('.container-db .db-cube1 .top .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_1.png)'})
|
||
$('.container-db .db-cube1 .bottom .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_2.png)'})
|
||
$('.container-db .db-cube1 .front .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_4.png)'})
|
||
$('.container-db .db-cube1 .left .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_5.png)'})
|
||
$('.container-db .db-cube1 .right .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_6.png)'})
|
||
$('.container-db .db-cube2 .top .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_7.png)'})
|
||
$('.container-db .db-cube2 .bottom .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_8.png)'})
|
||
$('.container-db .db-cube2 .back .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_9.png)'})
|
||
$('.container-db .db-cube2 .front .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_10.png)'})
|
||
$('.container-db .db-cube2 .left .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_11.png)'})
|
||
$('.container-db .db-cube2 .right .imgface.'+color).css({'background-image' : 'url(img/simulation/bicolore/liseres/db/'+file+'/face_12.png)'})
|
||
|
||
|
||
|
||
$('.chocos-holder.'+_simu.modele+' .back .bkgface').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+(_simu.color_1_id == "blanc" || _simu.color_1_id == "ivoire") ? 'noir' : _simu.color_2_id+'/face_14.png)'})
|
||
$('.container-pochette.'+_simu.modele+' .back .bkgface').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+(_simu.color_1_id == "blanc" || _simu.color_1_id == "ivoire") ? 'noir' : _simu.color_2_id+'/face_14.png)'})
|
||
|
||
//chocos
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .front .txtface")
|
||
$('#custom_elmts .date-holder-line').clone().appendTo(".chocos-holder .back .txtface")
|
||
|
||
$('.chocos-holder .bkgface').addClass('b-'+_simu.color_1_id)
|
||
$('.chocos-holder .txtface').addClass('c-'+_simu.color_2_id)
|
||
|
||
//pochette
|
||
$('#custom_elmts .noms-holder').clone().appendTo(".container-pochette .front .txtface")
|
||
$('#custom_elmts .date-holder-line').clone().appendTo(".container-pochette .back .txtface")
|
||
|
||
$('.container-pochette .bkgface').addClass('b-'+_simu.color_1_id);
|
||
$('.container-pochette .txtface').addClass('c-'+_simu.color_2_id);
|
||
|
||
//$('.chocos-holder .back').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+file+'/face_14.png)'})
|
||
//$('.container-pochette .back').css({'background-image':'url(img/simulation/bicolore/liseres/chocos/'+file+'/face_14.png)'})
|
||
|
||
checkfaceCustom()
|
||
}
|
||
}
|
||
//exclu
|
||
else if(_simu.custom == "exclu")
|
||
{
|
||
$(".container-db").html($('#temp-base .doublecube').contents().clone());
|
||
$(".chocos-holder").html($('#temp-base .chocos').contents().clone());
|
||
$(".container-pochette").html($('#temp-base .pochettes').contents().clone());
|
||
|
||
$('.container-db .cubeface').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.chocos-holder .flipper .front').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.chocos-holder .flipper .back').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.container-pochette .pochette .front').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
$('.container-pochette .pochette .back').html($('#temp-exclu .excluface').contents().clone()).css({'background' : 'url(img/simulation/face.jpg)'})
|
||
|
||
|
||
if(_simu.offre == "doublecube")
|
||
{
|
||
setFacesExclu(_custom.faces_dc_exclu,$('.exclu .container-db .cubeface'))
|
||
setFacesExclu(_custom.faces_chocos_exclu,$('.exclu .chocos-holder .flipper .front'))
|
||
}
|
||
else
|
||
{
|
||
setFacesExclu(_custom.faces_chocos_exclu,$('.exclu .chocos-holder .flipper .front'))
|
||
}
|
||
|
||
|
||
|
||
$('.exclu .container-db .cubeface').on('click',function(){
|
||
|
||
_faceSelected = "dc";
|
||
$_face_exclu = $(this);
|
||
|
||
$('.imgface').removeClass('actif')
|
||
$(this).find('.imgface').addClass('actif');
|
||
_face_exclu_id = parseInt($(this).attr('data-id'));
|
||
_face_exclu = _custom.faces_dc_exclu["face_"+_face_exclu_id];
|
||
|
||
//log('_face_exclu : ' + _face_exclu.text)
|
||
|
||
});
|
||
|
||
$('.exclu .chocos-holder .flipper .front').on('click',function(){
|
||
|
||
_faceSelected = "chocos"
|
||
$_face_exclu = $(this);
|
||
|
||
$('.imgface').removeClass('actif')
|
||
$(this).find('.imgface').addClass('actif');
|
||
_choco_exclu_id = parseInt($(this).attr('data-id'));
|
||
_face_exclu = _custom.faces_chocos_exclu["face_"+_choco_exclu_id];
|
||
|
||
$('.exclu .container-pochette .pochette').eq(_choco_exclu_id-1).find('.front').html($('.exclu .chocos-holder .flipper').eq(_choco_exclu_id-1).find('.front').contents().clone())
|
||
$('.exclu .container-pochette .pochette').eq(_choco_exclu_id-1).find('.back').html($('.exclu .chocos-holder .flipper').eq(_choco_exclu_id-1).find('.front').contents().clone())
|
||
});
|
||
|
||
$('.container-pochette .pochette').on('click',function(){
|
||
|
||
var index = parseInt($(this).attr('data-id'))-1;
|
||
|
||
$('.exclu .chocos-holder .flipper').eq(index).find('.front').click()
|
||
$('.exclu .container-pochette .pochette').eq(index).find('.front').html($('.exclu .chocos-holder .flipper').eq(index).find('.front').contents().clone())
|
||
$('.exclu .container-pochette .pochette').eq(index).find('.back').html($('.exclu .chocos-holder .flipper').eq(index).find('.front').contents().clone())
|
||
});
|
||
|
||
|
||
|
||
if(_simu.offre == "doublecube")
|
||
{
|
||
$('.exclu .container-db .cubeface').eq(3).click()
|
||
}
|
||
else
|
||
{
|
||
$('.exclu .chocos-holder .flipper').eq(0).find('.front').click()
|
||
}
|
||
|
||
}
|
||
|
||
if(_simu.offre == "pochette")
|
||
{
|
||
$('.chocos-holder .flip-container').eq(4).hide();
|
||
}
|
||
else
|
||
{
|
||
$('.chocos-holder .flip-container').eq(4).show();
|
||
}
|
||
|
||
onPelliculageChange();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// FINITIONS
|
||
//==================================================================
|
||
var _lastChocoChecked = null;
|
||
var _class_emb;
|
||
|
||
function onEmballageChange()
|
||
{
|
||
|
||
}
|
||
|
||
function onPelliculageChange()
|
||
{
|
||
|
||
_simu.pelliculage = $('input[name=pelliculage]:checked').val();
|
||
log("onPelliculageChange",_simu.pelliculage)
|
||
$('.matface').remove();
|
||
|
||
if(_simu.pelliculage == "Mat" )
|
||
{
|
||
$('.cubeface').append('<div class="matface"></div>')
|
||
}
|
||
|
||
}
|
||
|
||
function initToolsFinit()
|
||
{
|
||
//pelliculage
|
||
$('input[name=pelliculage]').on('change',function(){
|
||
|
||
|
||
onPelliculageChange()
|
||
|
||
});
|
||
$('input[value="'+_simu.pelliculage+'"]').prop('checked', true);
|
||
onPelliculageChange()
|
||
|
||
//emballage
|
||
_class_emb = (_simu.emballage == "Argenté") ? "argent" : "or";
|
||
$('.flip-container').addClass(_class_emb);
|
||
$('.pochetteface').not('.front,.back').addClass(_class_emb);
|
||
$('input[name=emballage]').on('change',function(){
|
||
|
||
$('.flip-container').removeClass(_class_emb);
|
||
$('.pochetteface').removeClass(_class_emb);
|
||
|
||
_simu.emballage = $(this).val();
|
||
_class_emb = (_simu.emballage == "Argenté") ? "argent" : "or";
|
||
|
||
$('.flip-container').addClass(_class_emb);
|
||
$('.pochetteface').not('.front,.back').addClass(_class_emb);
|
||
|
||
});
|
||
$('input[value="'+_simu.emballage+'"]').prop('checked', true);
|
||
|
||
|
||
|
||
//type chocos
|
||
$('input[name=typeChoco]').on('change',function(){
|
||
|
||
var nbSelected = $('input[name=typeChoco]:checked').length;
|
||
|
||
if(_simu.offre=="doublecube")
|
||
{
|
||
if(nbSelected > 2)
|
||
{
|
||
_lastChocoChecked.attr('checked', false);
|
||
}
|
||
}
|
||
else if(_simu.offre=="chocos" || _simu.offre=="sachet" || _simu.offre=="pochette")
|
||
{
|
||
if(nbSelected > 1)
|
||
{
|
||
_lastChocoChecked.attr('checked', false);
|
||
}
|
||
}
|
||
|
||
_lastChocoChecked = $(this);
|
||
|
||
_simu.typeChoco_1 = $('input[name=typeChoco]:checked').eq(0).val();
|
||
_simu.typeChoco_2 = ($('input[name=typeChoco]:checked').eq(1).val() !== undefined) ? $('input[name=typeChoco]:checked').eq(1).val() : _simu.typeChoco_1;
|
||
|
||
log(_simu.offre,$(this).val(),nbSelected,_simu.typeChoco_1,_simu.typeChoco_2);
|
||
|
||
updatePrice();
|
||
});
|
||
|
||
}
|
||
|
||
|
||
|
||
//==================================================================
|
||
// PRIX / QUANTITE
|
||
//==================================================================
|
||
var _xmlTarifs = null;
|
||
var
|
||
_prixBase,
|
||
_prixAddon1,
|
||
_prixAddon2,
|
||
_prixPTV,
|
||
_prixPTDT,
|
||
_prixPTDM,
|
||
_prixVBIC,
|
||
_prixDBIC,
|
||
_prixVEXC,
|
||
_prixEXCD;
|
||
|
||
function getXML_tarifs()
|
||
{
|
||
$.ajax({
|
||
type: "GET",
|
||
url: "_php/xmlTarifs.php",
|
||
dataType: "xml",
|
||
complete : function(data, status)
|
||
{
|
||
_xmlTarifs = data.responseXML;
|
||
|
||
_prixPTV = $(_xmlTarifs).find('tarif[ref="PTV"]').text();
|
||
_prixPTDM = $(_xmlTarifs).find('tarif[ref="PTDM"]').text();
|
||
_prixPTDT = $(_xmlTarifs).find('tarif[ref="PTDT"]').text();
|
||
_prixVBIC = $(_xmlTarifs).find('tarif[ref="VBIC"]').text();
|
||
_prixDBIC = $(_xmlTarifs).find('tarif[ref="DBIC"]').text();
|
||
_prixVEXC = $(_xmlTarifs).find('tarif[ref="VEXC"]').text();
|
||
_prixEXCD = $(_xmlTarifs).find('tarif[ref="EXCD"]').text();
|
||
|
||
//log(_prixPTV,_prixPTDM,_prixPTDT,_prixVBIC,_prixDBIC,_prixVEXC,_prixEXCD)
|
||
|
||
initDrag();
|
||
initTools();
|
||
|
||
}});
|
||
}
|
||
|
||
var _is_quantite_init = false;
|
||
|
||
function updateSelectQuantite()
|
||
{
|
||
$('select#select-quantite').empty();
|
||
|
||
if(_simu.offre=="doublecube")
|
||
{
|
||
$(_xmlTarifs).find('tarif[produit="DB"]').each(function()
|
||
{
|
||
//log($(this).attr('ref'),$(this).attr('produit'),$(this).attr('quantite'),$(this).text())
|
||
$('select#select-quantite').append('<option value="'+$(this).attr('ref')+'">'+$(this).attr('quantite')+' doubles cubes remplis de '+ parseInt($(this).attr('quantite'))*12 +' chocolats personnalisés</option>' )
|
||
});
|
||
}
|
||
else if(_simu.offre=="chocos")
|
||
{
|
||
$(_xmlTarifs).find('tarif[produit="QP"]').each(function()
|
||
{
|
||
$('select#select-quantite').append('<option value="'+$(this).attr('ref')+'">'+$(this).attr('quantite')+' petits chocolats personnalisés</option>')
|
||
});
|
||
}
|
||
else if(_simu.offre=="pochette")
|
||
{
|
||
$(_xmlTarifs).find('tarif[produit="P4"]').each(function()
|
||
{
|
||
$('select#select-quantite').append('<option value="'+$(this).attr('ref')+'">'+$(this).attr('quantite')+' pochettes transparentes remplies de 4 chocolats personnalisés</option>')
|
||
});
|
||
}
|
||
else if(_simu.offre=="sachet")
|
||
{
|
||
$(_xmlTarifs).find('tarif[produit="SACH"]').each(function()
|
||
{
|
||
$('select#select-quantite').append('<option value="'+$(this).attr('ref')+'">'+$(this).attr('quantite')+' sachets remplis de 5 chocolats personnalisés</option>')
|
||
});
|
||
}
|
||
|
||
if( ! _is_quantite_init )
|
||
{
|
||
log('init quantite');
|
||
$('#select-quantite').val(_simu.ref_base);
|
||
onQuantiteChange()
|
||
}
|
||
else
|
||
{
|
||
onNbInvitesChange()
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
function updatePrice()
|
||
{
|
||
var nbPetillant = 0
|
||
|
||
_simu.prix = 0;
|
||
_simu.prix_unit = 0;
|
||
|
||
if(_simu.offre=="doublecube")
|
||
{
|
||
if(_simu.custom == "bicolore")
|
||
{
|
||
_prixAddon1 = _prixDBIC
|
||
_simu.ref_sup1 = "DBIC";
|
||
}
|
||
else if(_simu.custom == "exclu")
|
||
{
|
||
_prixAddon1 = _prixEXCD
|
||
_simu.ref_sup1 = "EXCD";
|
||
}
|
||
else
|
||
{
|
||
_prixAddon1 = 0
|
||
_simu.ref_sup1 = "";
|
||
}
|
||
|
||
|
||
if(_simu.typeChoco_1 == $('.chocoscheck_pet input').eq(0).val() || _simu.typeChoco_1 == $('.chocoscheck_pet input').eq(1).val() || _simu.typeChoco_1 == $('.chocoscheck_pet input').eq(2).val())
|
||
{
|
||
nbPetillant++
|
||
}
|
||
if(_simu.typeChoco_2 == $('.chocoscheck_pet input').eq(0).val() || _simu.typeChoco_2 == $('.chocoscheck_pet input').eq(1).val() || _simu.typeChoco_2 == $('.chocoscheck_pet input').eq(2).val())
|
||
{
|
||
nbPetillant++
|
||
}
|
||
|
||
if(nbPetillant==0)
|
||
{
|
||
_prixAddon2 = 0
|
||
_simu.ref_sup2 = ""
|
||
}
|
||
else if(nbPetillant==1)
|
||
{
|
||
_prixAddon2 = (_simu.typeChoco_2=="") ? _prixPTDT : _prixPTDM;
|
||
_simu.ref_sup2 = (_simu.typeChoco_2=="") ? "PTDT" : "PTDM";
|
||
}
|
||
else if(nbPetillant==2)
|
||
{
|
||
_prixAddon2 = _prixPTDT;
|
||
_simu.ref_sup2 = "PTDT"
|
||
}
|
||
}
|
||
else //if(_simu.offre=="chocos")
|
||
{
|
||
|
||
if(_simu.custom == "bicolore")
|
||
{
|
||
_prixAddon1 = _prixVBIC
|
||
_simu.ref_sup1 = "VBIC";
|
||
}
|
||
else if(_simu.custom == "exclu")
|
||
{
|
||
_prixAddon1 = _prixVEXC
|
||
_simu.ref_sup1 = "VEXC";
|
||
}
|
||
else
|
||
{
|
||
_prixAddon1 = 0
|
||
_simu.ref_sup1 = "";
|
||
}
|
||
|
||
|
||
if(_simu.typeChoco_1 == $('.chocoscheck_pet input').eq(0).val() || _simu.typeChoco_1 == $('.chocoscheck_pet input').eq(1).val() || _simu.typeChoco_1 == $('.chocoscheck_pet input').eq(2).val())
|
||
{
|
||
nbPetillant++
|
||
}
|
||
if(_simu.typeChoco_2 == $('.chocoscheck_pet input').eq(0).val() || _simu.typeChoco_2 == $('.chocoscheck_pet input').eq(1).val() || _simu.typeChoco_2 == $('.chocoscheck_pet input').eq(2).val())
|
||
{
|
||
nbPetillant++
|
||
}
|
||
|
||
if(nbPetillant==0)
|
||
{
|
||
_prixAddon2 = 0
|
||
_simu.ref_sup2 = ""
|
||
}
|
||
else if(nbPetillant==1 || nbPetillant==2)
|
||
{
|
||
_prixAddon2 = _prixPTV;
|
||
_simu.ref_sup2 = "PTV"
|
||
}
|
||
|
||
|
||
}
|
||
|
||
/*log("-------------")
|
||
log("nbPetillant : "+nbPetillant)
|
||
log("_prixBase : "+_prixBase)
|
||
log("_prixAddon1 : "+_prixAddon1)
|
||
log("_prixAddon2 : "+_prixAddon2)*/
|
||
|
||
_simu.prix = (parseFloat(_prixBase) + parseFloat(_prixAddon1) + parseFloat(_prixAddon2));
|
||
_simu.prix_unit = (_simu.prix / _simu.quantite).toFixed(2);
|
||
|
||
/*log("_simu.prix : "+_simu.prix)
|
||
log("_simu.prix_unit : "+_simu.prix_unit)*/
|
||
|
||
$('.prix').html(_simu.prix);
|
||
$('.prix_unit').html(_simu.prix_unit);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
//==================================================================
|
||
// COMMANDE
|
||
//==================================================================
|
||
var errors="";
|
||
|
||
function validateInfos(save_mode)
|
||
{
|
||
//RESET
|
||
errors=""
|
||
$('#errors').html("")
|
||
|
||
//INFOS
|
||
if($('#name_1').val() == "" || _simu.name_1 == "Marié(e)")
|
||
{
|
||
errors += "Merci de préciser le 1er nom <br/>"
|
||
}
|
||
|
||
if($('#name_2').val() == "" || _simu.name_2 == "Marié(e)")
|
||
{
|
||
errors += "Merci de préciser le 2nd nom <br/>"
|
||
}
|
||
|
||
if($('#nb_invites').val() == "" || _simu.nb_invites == 0)
|
||
{
|
||
errors += "Merci de préciser le nombre d'invités <br/>"
|
||
}
|
||
|
||
if($('#date_mariage').val() == "" || parseInt(_simu.date_mariage) <= parseInt(todaySimu()))
|
||
{
|
||
log('test : ' + _simu.date_mariage + ' / ' + todaySimu())
|
||
|
||
errors += "Merci de vérifier la date de votre mariage <br/>"
|
||
}
|
||
|
||
// check faces custom
|
||
|
||
var is_not_custom = false;
|
||
|
||
if(_simu.custom == "exclu")
|
||
{
|
||
if(_simu.offre == "doublecube")
|
||
{
|
||
log("--")
|
||
$.each(_custom.faces_dc_exclu, function(index, face_exclu) {
|
||
|
||
log(index,face_exclu.is_custom)
|
||
|
||
if(! face_exclu.is_custom)
|
||
{
|
||
is_not_custom = true;
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
log("--")
|
||
$.each(_custom.faces_chocos_exclu, function(index, face_exclu) {
|
||
|
||
log(index, face_exclu.is_custom)
|
||
|
||
if(_simu.offre == "pochette")
|
||
{
|
||
if(index != "face_21" && ! face_exclu.is_custom) is_not_custom = true;
|
||
}
|
||
else
|
||
{
|
||
if( ! face_exclu.is_custom) is_not_custom = true;
|
||
}
|
||
});
|
||
|
||
if(is_not_custom) errors += "Certaines faces ne sont pas customisées <br/>" ;
|
||
}
|
||
else
|
||
{
|
||
if(_simu.offre == "doublecube" && _simu.modele != "ruban")
|
||
{
|
||
if(_custom.face_custom.image != null || _custom.face_custom.text != '' || _custom.face_custom.is_initials != false) {} else
|
||
{
|
||
errors += "La face n'est pas customisée <br/>" ;
|
||
}
|
||
}
|
||
}
|
||
|
||
//check chocolate selected
|
||
|
||
if($('input[name=typeChoco]:checked').length == 0)
|
||
{
|
||
errors += "Sélectionner au moins 1 type de chocolat <br/>" ;
|
||
}
|
||
|
||
//save > email
|
||
if(save_mode == "save")
|
||
{
|
||
if($('#email_sauvegarde').val() == "")
|
||
{
|
||
errors += "Merci de préciser votre e-mail <br/>" ;
|
||
}
|
||
else if(! validateEmail($('#email_sauvegarde').val()))
|
||
{
|
||
errors += "Votre e-mail n’est pas valide" ;
|
||
}
|
||
else
|
||
{
|
||
_simu.email_sauvegarde = $('#email_sauvegarde').val();
|
||
}
|
||
}
|
||
|
||
//RESULT
|
||
return (errors == "") ? true : false;
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
var _refNode;
|
||
|
||
function onQuantiteChange()
|
||
{
|
||
_simu.ref_base = $('#select-quantite').val();
|
||
_refNode = $(_xmlTarifs).find('tarif[ref="'+_simu.ref_base+'"]');
|
||
_simu.quantite = _refNode.attr('quantite');
|
||
_prixBase = _refNode.text()
|
||
log("_simu.quantite",_simu.ref_base,_simu.quantite,_prixBase)
|
||
updatePrice();
|
||
}
|
||
|
||
var _dataForm;
|
||
|
||
function saveDatas()
|
||
{
|
||
logSimu()
|
||
|
||
$('#action-holder').hide();
|
||
$('#saving_status').show();
|
||
|
||
_dataForm = new FormData();
|
||
|
||
// faces custom
|
||
if(_simu.custom == "exclu")
|
||
{
|
||
_dataForm.append('face_custom','');
|
||
|
||
if(_simu.offre == "doublecube")
|
||
{
|
||
// copy object first cause replace image file by boolean for db
|
||
var faces_dc_exclu_copy = jQuery.extend(true, {}, _custom.faces_dc_exclu);
|
||
|
||
$.each(faces_dc_exclu_copy, function(index, face_exclu) {
|
||
|
||
//images
|
||
if(face_exclu.image != null)
|
||
{
|
||
_dataForm.append(index, face_exclu.image);
|
||
face_exclu.image = true;
|
||
}
|
||
|
||
});
|
||
|
||
//serialize faces_dc_exclu to DB
|
||
var faces_dc_exclu_srz = JSON.stringify( faces_dc_exclu_copy );
|
||
log(JSON.parse( faces_dc_exclu_srz ));
|
||
log(faces_dc_exclu_srz);
|
||
log(_custom.faces_dc_exclu.face_1.image);
|
||
_dataForm.append('faces_dc_exclu',faces_dc_exclu_srz);
|
||
}
|
||
|
||
log( _custom.faces_chocos_exclu);
|
||
|
||
var faces_chocos_exclu_copy = jQuery.extend(true, {}, _custom.faces_chocos_exclu);
|
||
|
||
$.each(faces_chocos_exclu_copy, function(index, face_exclu) {
|
||
|
||
//images
|
||
if(face_exclu.image != null)
|
||
{
|
||
_dataForm.append(index, face_exclu.image);
|
||
face_exclu.image = true
|
||
}
|
||
|
||
});
|
||
|
||
//serialize faces_chocos_exclu to DB
|
||
var faces_chocos_exclu_srz = JSON.stringify( faces_chocos_exclu_copy );
|
||
log(JSON.parse( faces_chocos_exclu_srz ));
|
||
log(faces_chocos_exclu_srz);
|
||
log(_custom.faces_chocos_exclu.face_13.image);
|
||
_dataForm.append('faces_chocos_exclu',faces_chocos_exclu_srz);
|
||
|
||
|
||
_dataForm.append('upload','image');
|
||
}
|
||
else if(_simu.offre == "doublecube")
|
||
{
|
||
var face_custom_copy = jQuery.extend(true, {}, _custom.face_custom);
|
||
|
||
if(face_custom_copy.image != null)
|
||
{
|
||
_dataForm.append('face_3', face_custom_copy.image);
|
||
face_custom_copy.image = true;
|
||
_dataForm.append('upload','image');
|
||
}
|
||
// faces custom
|
||
var faceCustom_srz = JSON.stringify( face_custom_copy );
|
||
log(JSON.parse( faceCustom_srz ));
|
||
log(faceCustom_srz);
|
||
log(_custom.face_custom.image);
|
||
_dataForm.append('face_custom',faceCustom_srz);
|
||
_dataForm.append('faces_dc_exclu','');
|
||
_dataForm.append('faces_chocos_exclu','');
|
||
}
|
||
|
||
//datas _simu
|
||
$.each(_simu, function(index, value) {
|
||
|
||
_dataForm.append(index,value);
|
||
});
|
||
}
|
||
|
||
|
||
function initToolsCommande()
|
||
{
|
||
//quantite
|
||
$('#select-quantite').on('change',function(){
|
||
|
||
onQuantiteChange();
|
||
});
|
||
|
||
$("#btn-sauvegarder").on('click',function(){
|
||
|
||
logSimu()
|
||
|
||
if ( ! validateInfos("save"))
|
||
{
|
||
$('#errors').html(errors)
|
||
}
|
||
else
|
||
{
|
||
saveDatas();
|
||
|
||
_dataForm.append('action','sauvegarder');
|
||
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "php/simulation/save.php",
|
||
data: _dataForm,
|
||
processData: false,
|
||
contentType: false
|
||
})
|
||
.done(function( backdata ) {
|
||
|
||
|
||
$('#action-holder').show();
|
||
$('#saving_status').hide();
|
||
|
||
//$('#errors').html('Votre simulation a bien été sauvegardée. <br>Vous allez recevoir un email qui vous permettra de reprendre la commande à ce stade.')
|
||
//navigateToURL(new URLRequest(Model.rootPath + "commander.php?id="+Model.dossierUser),"_self");
|
||
|
||
var callback = jQuery.parseJSON(backdata);
|
||
log( "Data Saved: " + backdata);
|
||
|
||
if(callback.isValid==1)
|
||
{
|
||
// MODIFS OK!
|
||
$('#errors').html(callback.mess)
|
||
|
||
}
|
||
else
|
||
{
|
||
$('#errors').html(callback.mess)
|
||
}
|
||
|
||
});
|
||
}
|
||
})
|
||
|
||
$("#btn-commander").on('click',function(){
|
||
|
||
if ( ! validateInfos("com"))
|
||
{
|
||
$('#errors').html(errors)
|
||
}
|
||
else
|
||
{
|
||
saveDatas();
|
||
|
||
_dataForm.append('action','commander');
|
||
|
||
$.ajax({
|
||
type: "POST",
|
||
url: "php/simulation/save.php",
|
||
data: _dataForm,
|
||
processData: false,
|
||
contentType: false
|
||
})
|
||
.done(function( backdata ) {
|
||
|
||
$('#action-holder').show();
|
||
$('#saving_status').hide();
|
||
|
||
|
||
var callback = jQuery.parseJSON(backdata);
|
||
log( "Data Saved: " + backdata);
|
||
|
||
if(callback.isValid==1)
|
||
{
|
||
window.location = "commander.php?id=" + callback.dossier;
|
||
|
||
}
|
||
else
|
||
{
|
||
$('#errors').html(callback.mess)
|
||
}
|
||
|
||
|
||
});
|
||
}
|
||
})
|
||
}
|
||
|
||
|
||
|
||
function validateEmail(email) {
|
||
var re = /^(([^<>()[\]\\.,;:\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,}))$/;
|
||
return re.test(email);
|
||
}
|