127 lines
3.6 KiB
JavaScript
127 lines
3.6 KiB
JavaScript
// 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 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);
|
||
}
|
||
|
||
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 == "Aucune") {
|
||
//Nothing
|
||
} else if(choice == "Image") {
|
||
|
||
} else 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');
|
||
}
|
||
}
|
||
|
||
//=== 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));
|
||
});
|