From 10374e37403e2eaf4b3adb2ed05b6b5615a8df95 Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 20 Sep 2017 11:56:47 +0200 Subject: [PATCH] Select and get backup value --- .../views/js/doublecube-bicolor.js | 51 +++++++++++++++---- .../views/js/doublecube-thematique.js | 19 ++++--- 2 files changed, 53 insertions(+), 17 deletions(-) diff --git a/www/modules/antadissimulator/views/js/doublecube-bicolor.js b/www/modules/antadissimulator/views/js/doublecube-bicolor.js index f0ccd181..b8ba4aff 100644 --- a/www/modules/antadissimulator/views/js/doublecube-bicolor.js +++ b/www/modules/antadissimulator/views/js/doublecube-bicolor.js @@ -46,11 +46,10 @@ var colorRGB = violet: '#6B1687', } - // Start when DOM is ready $(function() { initInfos(); - initFaces(); + initFaces(); initDrag(); }); @@ -271,8 +270,17 @@ $('#PERSOTXT').on('keyup click', function(){ var txt = $(this).val().replace(/\n/g, "
"); $('.face-custom-img').empty(); $('.face-custom-txt').html('
'); - $('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5}); - rotateDC(0,180); + $('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5}); + // Set custom-select + options = $('.ref-FACELIBRE').find('.custom-select li'); + options.each(function(i, el) { + el = $(el); + if (el.text() == 'Texte') { + el.trigger('click'); + } + }); + // Rotate + rotateDC(0,180); }); $('#DATEMARIAGE').on('change click', function(e) { @@ -295,6 +303,14 @@ $('#PELLICULAGE').on('change', function(e) { $('#DOUBLECUBEIMAGE').on('change', function(e) { defDOUBLECUBEIMAGE(this); + // Set custom-select + options = $('.ref-FACELIBRE').find('.custom-select li'); + options.each(function(i, el) { + el = $(el); + if (el.text() == "Image") { + el.trigger('click'); + } + }); rotateDC(0,145); }); @@ -321,9 +337,26 @@ function initInfos() defNOM1($('#NOM1')); defNOM2($('#NOM2')); defDATEMARIAGE($('#DATEMARIAGE')); - defFACELIBRE($('.FACELIBRE')); + defFACELIBRE($('#FACELIBRE')); defPELLICULAGE($('#PELLICULAGE')); defEMBALLAGE($('#EMBALLAGE')); + + if ($('input#BICOLOR1').val() != '') { + $('#colorpicker1 > option').each(function(i, el){ + if ($(this).text() == $('input#BICOLOR1').val()) { + color1 = $(this).data('id'); + } + }); + } + + if ($('input#BICOLOR2').val() != '') { + $('#colorpicker2 > option').each(function(i, el){ + if ($(this).text() == $('input#BICOLOR2').val()) { + color1 = $(this).data('id'); + } + }); + } + $('#colorpicker1').simplecolorpicker('selectColor', colorRGB[color1]); $('.color1text').html($('#colorpicker1 option:selected').text()); $('input#BICOLOR1').val($('#colorpicker1 option:selected').text()); @@ -353,7 +386,7 @@ function defNOM2(obj){ function defFACELIBRE(obj){ var choice = obj.find('option:selected').text(); - $(".face-custom-txt").empty(); + $('.face-custom-txt').empty(); $('.face-custom-img').empty(); if (choice == "Aucune") { //Nothing @@ -362,10 +395,10 @@ function defFACELIBRE(obj){ } else if(choice == "Texte") { var txt = $('#PERSOTXT').val().replace(/\n/g, "
"); $('.face-custom-txt').html('
'); - $('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5}); + $('.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 defPELLICULAGE(obj){ @@ -416,7 +449,7 @@ function defDOUBLECUBEIMAGE(obj){ }; request.send(); } - } + } } function formatDateInput(date) diff --git a/www/modules/antadissimulator/views/js/doublecube-thematique.js b/www/modules/antadissimulator/views/js/doublecube-thematique.js index e90c68ff..f2a20039 100644 --- a/www/modules/antadissimulator/views/js/doublecube-thematique.js +++ b/www/modules/antadissimulator/views/js/doublecube-thematique.js @@ -96,7 +96,8 @@ $('#PERSOTXT').on('keyup click', function(){ $('.face-custom-img').empty(); $('.face-custom-txt').html('
'); $('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5}); - var face = facename($('.freetext-holder')); + var face = facename($('.freetext-holder')); + // Rotate rotateDC(faceDeg[face]['x'],faceDeg[face]['y']); }); @@ -180,7 +181,7 @@ function initInfos() defFACELIBRE($('#FACELIBRE')); defPELLICULAGE($('#PELLICULAGE')); defEMBALLAGE($('#EMBALLAGE')); - defDOUBLECUBEIMAGE($('#DOUBLECUBEIMAGE')); + defDOUBLECUBEIMAGE($('#DOUBLECUBEIMAGE')); } function defDATEMARIAGE(obj){ @@ -193,12 +194,12 @@ function defDATEMARIAGE(obj){ } function defNOM1(obj){ - $('.nom_1').html(obj.val()) + $('.nom_1').html(obj.val()); $('.initiale_1').html(obj.val().substring(0,1)); } function defNOM2(obj){ - $('.nom_2').html(obj.val()) + $('.nom_2').html(obj.val()); $('.initiale_2').html(obj.val().substring(0,1)); } @@ -215,15 +216,17 @@ function defFACELIBRE(obj){ $('.face-custom-txt').html('
'); $('.freetext-holder').html(txt).css({'margin-top':-$('.freetext-holder').height()*0.5}); } else if(choice == "Initiales") { + console.log('coucou'); $('#custom_elmts .initiales-holder').clone().appendTo(".face-custom-txt"); } } function defPELLICULAGE(obj){ $('.matface').remove(); - if(obj.find('option:selected').text() == "Mat") { - $('.cubeface').append('
') - } + var choice = obj.find('option:selected').text(); + if(choice == "Mat") { + $('.cubeface').append('
') + } } function defEMBALLAGE(obj){ @@ -234,7 +237,7 @@ function defEMBALLAGE(obj){ $('.flip-container').addClass('argent'); } else if (choice == "Doré") { $('.flip-container').addClass('or'); - } + } } function defDOUBLECUBEIMAGE(obj){