var
_factor = 1,
_max_amount = 460,
_unit = 360/_max_amount ,
_flag = false,
_angle = {'x': 0, 'y': 0};
_anglelast = {'x': 0, 'y': 0};
monthR = ["","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"];
;
var faceDeg = {
'top': { 'x': 0, 'y': 0, },
'bottom': { 'x': 0, 'y': 0, },
'back': { 'x': 0, 'y': 180, },
'front': { 'x': 0, 'y': 45, },
'left': { 'x': 0, 'y': 90, },
'right': { 'x': 0, 'y': -90, },
};
// Start when DOM is ready
$(function() {
initFaces();
initInfos();
initDrag();
});
function initFaces()
{
// Reset faces
$(".container-db .db-cube1 .back").addClass('face-custom-txt');
$(".container-db .db-cube1 .back").addClass('face-custom-img');
// Doublecube holder
switch(theme) {
case "ivoire":
$('#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");
break;
case "fleurs":
$('#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");
break;
case "dentellechic":
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .front");
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube2 .front");
break;
case "enfantin":
$('#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 .front");
break;
case "liberty":
$('#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-line').clone().appendTo(".container-db .db-cube2 .front");
$('#custom_elmts .noms-holder').clone().appendTo(".container-db .db-cube1 .top");
break;
case "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 .front");
$('#custom_elmts .date-holder').clone().appendTo(".container-db .db-cube2 .right");
break;
case "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");
break;
case "vintage":
$('#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");
break;
case "voyage":
$('#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");
break;
case "tendance":
$('#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");
break;
case "champetre":
$('#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");
break;
case "cinema":
$('#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");
break;
case "chocolate":
$('#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");
break;
case "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");
break;
}
$('.container-db .db-cube1 .top').css({'background-image':'url('+themeImg+'/box/1-TOP.png)'});
$('.container-db .db-cube1 .bottom').css({'background-image':'url('+themeImg+'/box/1-BOTTOM.png)'});
$('.container-db .db-cube1 .back').css({'background-image':'url('+themeImg+'/box/1-BACK.png)'});
$('.container-db .db-cube1 .front').css({'background-image':'url('+themeImg+'/box/1-FRONT.png)'});
$('.container-db .db-cube1 .left').css({'background-image':'url('+themeImg+'/box/1-LEFT.png)'});
$('.container-db .db-cube1 .right').css({'background-image':'url('+themeImg+'/box/1-RIGHT.png)'});
$('.container-db .db-cube2 .top').css({'background-image':'url('+themeImg+'/box/2-TOP.png)'});
$('.container-db .db-cube2 .bottom').css({'background-image':'url('+themeImg+'/box/2-BOTTOM.png)'});
$('.container-db .db-cube2 .back').css({'background-image':'url('+themeImg+'/box/2-BACK.png)'});
$('.container-db .db-cube2 .front').css({'background-image':'url('+themeImg+'/box/2-FRONT.png)'});
$('.container-db .db-cube2 .left').css({'background-image':'url('+themeImg+'/box/2-LEFT.png)'});
$('.container-db .db-cube2 .right').css({'background-image':'url('+themeImg+'/box/2-RIGHT.png)'});
$('.container-db').addClass(theme);
// Faces chocos identiques
if(theme == "chocolate" || theme == "cinema" || theme == "champetre") {
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .front");
$('#custom_elmts .date-holder-line').clone().appendTo(".chocos-holder .back");
}
else if (theme == "liberty") {
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco1 .front");
$('#custom_elmts .date-holder-line').clone().appendTo(".chocos-holder .choco2 .front");
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco4 .front");
}
// Faces chocos différentes
else {
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco1 .front");
$('#custom_elmts .date-holder').clone().appendTo(".chocos-holder .choco2 .front");
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco4 .front");
}
// Specific theme
if(theme == "fleurs" || theme == "tendance" || theme == "uv" || theme == "voyage" || theme == "vintage"
|| theme == "gourmandise" || theme == "dentellechic" || theme == "enfantin" || theme == "liberty"
|| theme == "oriental") {
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco5 .front");
}
// Chocos background image
$('.chocos-holder .choco1 .front').css({'background-image':'url('+themeImg+'/chocos/1F.png)'});
$('.chocos-holder .choco1 .back').css({'background-image':'url('+themeImg+'/chocos/1B.png)'});
$('.chocos-holder .choco2 .front').css({'background-image':'url('+themeImg+'/chocos/2F.png)'});
$('.chocos-holder .choco2 .back').css({'background-image':'url('+themeImg+'/chocos/2B.png)'});
$('.chocos-holder .choco3 .front').css({'background-image':'url('+themeImg+'/chocos/3F.png)'});
$('.chocos-holder .choco3 .back').css({'background-image':'url('+themeImg+'/chocos/3B.png)'});
$('.chocos-holder .choco4 .front').css({'background-image':'url('+themeImg+'/chocos/4F.png)'});
$('.chocos-holder .choco4 .back').css({'background-image':'url('+themeImg+'/chocos/4B.png)'});
$('.chocos-holder .choco5 .front').css({'background-image':'url('+themeImg+'/chocos/5F.png)'});
$('.chocos-holder .choco5 .back').css({'background-image':'url('+themeImg+'/chocos/5B.png)'});
$('.chocos-holder').addClass(theme);
$('.chocos-holder .flip-container').eq(4).show();
}
//=== Events
$('#NOM1').on('keyup click', function(){
defNOM1($(this));
rotateDC(faceDeg['front']['x'],faceDeg['front']['y']);
});
$('#NOM2').on('keyup click', function(){
defNOM2($(this));
rotateDC(faceDeg['front']['x'],faceDeg['front']['y']);
});
$('#PERSOTXT').on('keyup click', function(){
var txt = $(this).val().replace(/\n/g, "
");
$('.face-custom-img').empty();
$('.face-custom-txt').html('