2017-06-26 12:12:22 +02:00
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 ) ;
}
/ * l o g ( _ c u s t o m . f a c e s _ d c _ e x c l u . f a c e _ 1 . i m a g e )
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
/ * $ ( " . c o n t a i n e r - d b " ) . h t m l ( $ ( ' # t e m p - b a s e . d o u b l e c u b e ' ) . c o n t e n t s ( ) . c l o n e ( ) ) ;
$ ( ".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
{
2017-08-01 16:09:05 +02:00
var txt = $ ( '.freetext' ) . val ( ) . replace ( '/\n/g' , "<br />" )
2017-06-26 12:12:22 +02:00
_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"
}
}
/ * l o g ( " - - - - - - - - - - - - - " )
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 ) ;
/ * l o g ( " _ s i m u . p r i x : " + _ s i m u . p r i x )
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 ) ;
}