2017-09-21 17:58:08 +02:00

123 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Start when DOM is ready
$(function() {
initInfos();
initFaces();
});
var monthR = ["","Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"];
//=== Functions
function initInfos()
{
defNOM1($('#NOM1'));
defNOM2($('#NOM2'));
defDATEMARIAGE($('#DATEMARIAGE'));
defEMBALLAGE($('#EMBALLAGE'));
}
function defDATEMARIAGE(obj){
var day = obj.val().substring(0,2);
var month = obj.val().substring(3,5);
var year = obj.val().substring(6,10);
$('.day').html(day);
$('.month').html(monthR[parseInt(month)]);
$('.year').html(year);
}
function defNOM1(obj){
$('.nom_1').html(obj.val())
$('.initiale_1').html(obj.val().substring(0,1));
}
function defNOM2(obj){
$('.nom_2').html(obj.val())
$('.initiale_2').html(obj.val().substring(0,1));
}
function defFACELIBRE(obj){
var choice = obj.find('option:selected').text();
$(".face-custom-txt").empty();
$('.face-custom-img').empty();
if(choice == "Texte") {
var txt = $('#PERSOTXT').val().replace(/\n/g, "<br/>");
$('.face-custom-txt').html('<div class="freetext-holder"></div>');
$('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5});
} else if(choice == "Initiales") {
$('#custom_elmts .initiales-holder').clone().appendTo(".face-custom-txt");
}
}
function defEMBALLAGE(obj){
var choice = obj.find('option:selected').text();
$('.flip-container').removeClass('argent');
$('.flip-container').removeClass('or');
if (choice == "Argenté") {
$('.flip-container').addClass('argent');
} else if (choice == "Doré") {
$('.flip-container').addClass('or');
}
}
function initFaces()
{
// Background
var chocosNum = 5;
for (i = 1; i < chocosNum+1; i++) {
$('.chocos-holder .choco'+i+' .front').css('background-image', 'url('+themeImg+'/chocos/'+i+'F.png)');
$('.chocos-holder .choco'+i+' .back').css('background-image', 'url('+themeImg+'/chocos/'+i+'B.png)');
}
// Faces chocos identiques
if(theme == "chocolate" || theme == "cinema" || theme == "oriental" || theme == "champetre") {
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .front");
$('#custom_elmts .date-holder-line').clone().appendTo(".chocos-holder .back");
}
// 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") {
$('#custom_elmts .noms-holder').clone().appendTo(".chocos-holder .choco5 .front");
}
$('.chocos-holder').addClass(theme);
}
//=== Events
$('#NOM1').on('keyup click', function(){
defNOM1($(this));
});
$('#NOM2').on('keyup click', function(){
defNOM2($(this));
});
$('#PERSOTXT').on('keyup click', function(){
var txt = $(this).val().replace(/\n/g, "<br />");
$('.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});
});
$('#DATEMARIAGE').on('change click', function(e) {
defDATEMARIAGE($(this));
});
$('.FACELIBRE').on('change', function(e) {
defFACELIBRE($(this));
});
$('#EMBALLAGE').on('change', function(e) {
defEMBALLAGE($(this));
});
$('#PELLICULAGE').on('change', function(e) {
defPELLICULAGE($(this));
});