This commit is contained in:
Michael RICOIS 2017-10-06 13:01:02 +02:00
parent 72bcb7021f
commit ac5d48222a
5 changed files with 46 additions and 17 deletions

View File

@ -79,21 +79,22 @@ function initFaces()
if (type == 'IMAGE') {
var url = $('#DOUBLECUBEIMAGE').data('dl');
var ref = 'CUBE'+cube+'-'+i.toUpperCase()+'IMG';
console.log(ref);
var img = $('#'+ref).val();
if (img.length > 0) {
var imgUrl = url+'/'+ref+'/'+img;
if (imgUrl != undefined && imgUrl.length > 0) {
var request = new XMLHttpRequest();
request.open('GET', url+'/'+ref+'/'+img, true);
request.open('GET', imgUrl, true);
request.responseType = 'blob';
request.onload = function() {
var reader = new FileReader();
reader.onload = function(e){
$('.db-cube'+cube+' .cubeface.'+i+' .imgface').css('background-image', 'url('+e.target.result+')');
reader.onload = function(e){
$('.db-cube'+cube+' .cubeface.'+i+' .imgface').css('background-image', 'url('+e.target.result+')');
};
reader.readAsDataURL(request.response);
};
request.send();
}
} else {
if (type == 'TEXT') {
color = $('#CUBE'+cube+'-'+i.toUpperCase()+'COLOR').val();
@ -198,9 +199,15 @@ $('#colorpicker1').simplecolorpicker({picker: true, theme: 'glyphicons'})
initFaces();
});
$('span#response-optgroup-exclusif').on('change', function(e){
e.preventDefault();
$('select[name=select-custom]').val('IMAGE').trigger('change');
});
$('select[name=select-custom]').on('change', function(e){
e.preventDefault();
defCUSTOM($('.imgface.actif'));
refreshSelect($('select[name=select-custom]'));
initFaces();
});

View File

@ -183,6 +183,7 @@ $('span#response-optgroup-exclusif').on('change', function(e){
$('select[name=select-custom]').on('change', function(e){
e.preventDefault();
defCUSTOM($('.imgface.actif'));
refreshSelect($('select[name=select-custom]'));
initFaces();
});

View File

@ -1,8 +1,7 @@
{addJsDef theme=$themeName}
{addJsDef themeImg=$themeImagePath}
<div id="custom_elmts">
<div id="custom_elmts">
<!--COMMONS-->
<div class="noms-holder">
<div class="nom nom_1"></div>
@ -128,17 +127,18 @@
</div>
</div>
<div class="clearfix form-group type-file">
<div class="form-group type-file clearfix">
<label class="label DOUBLECUBEIMAGE">{l s='Télécharger votre image (max 8Mo)' mod='antadissimulator'}</label>
<div class="ctn-input">
<div class="custom-file">
<input id="DOUBLECUBEIMAGE" class="configurator-opt-file" name="files" data-field="optgroup-exclusif"
data-url="/configurator/upload/{$id_product}"
<input id="DOUBLECUBEIMAGE" class="configurator-opt-file-cube" name="files" data-field="optgroup-exclusif"
data-url="/configurator/upload/{$id_product}/CUBE"
data-dl="{$base_dir}upload/simu/{$id_product}" type="file">
<span class="filename">{l s='No file selected' mod='antadissimulator'}</span>
<span class="action">{l s='Choose File' mod='antadissimulator'}</span></div></div>
<span id="response-optgroup-exclusif"></span>
<input name="optgroup-exclusif" value="" type="hidden" />
<span class="action">{l s='Choose File' mod='antadissimulator'}</span></div>
</div>
<span id="response-optgroup-exclusif"></span>
<input name="optgroup-exclusif" value="" type="hidden" />
</div>
<div class="clearfix form-group">

View File

@ -140,7 +140,7 @@
<label class="label DOUBLECUBEIMAGE">{l s='Télécharger votre image (max 8Mo)' mod='antadissimulator'}</label>
<div class="ctn-input">
<div class="custom-file">
<input id="DOUBLECUBEIMAGE" class="configurator-opt-file-exclusif" name="files" data-field="optgroup-exclusif"
<input id="DOUBLECUBEIMAGE" class="configurator-opt-file-pochette" name="files" data-field="optgroup-exclusif"
data-url="/configurator/upload/{$id_product}/POCHETTE"
data-dl="{$base_dir}upload/simu/{$id_product}" type="file">
<span class="filename">{l s='No file selected' mod='antadissimulator'}</span>
@ -156,7 +156,7 @@
<div class="mgin-b-5">
<span class="c-maroon" style="padding-right:8px">{l s='Couleur 1 :' mod='antadissimulator'}</span>
<select name="colorpicker" id="colorpicker1" style="display: none;">
<option value="#B5DC10" data-id="anis">{l s='Anis' mod='antadissimulator'}</option>
<option value="#B5DC10" data-id="anis">{l s='Anis' mod='antadissimulator'}</option>
<option value="#F0037F" data-id="fuschia">{l s='Fuchsia' mod='antadissimulator'}</option>
<option value="#FFC211" data-id="or">{l s='Or/Jaune' mod='antadissimulator'}</option>
<option value="#7FCDD0" data-id="turquoise">{l s='Turquoise' mod='antadissimulator'}</option>

View File

@ -38,9 +38,9 @@ $(function(){
}
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
$('.configurator-opt-file-exclusif').fileupload({
$('.configurator-opt-file-pochette').fileupload({
dataType: 'json',
add: function (e, data) {
add: function (e, data) {
data.url = $(this).data('url') + $('input[name=item]').val()+'-IMG';
data.submit();
},
@ -59,6 +59,27 @@ $(function(){
}
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
$('.configurator-opt-file-cube').fileupload({
dataType: 'json',
add: function (e, data) {
data.url = $(this).data('url') + $('input[name=item]').val()+'-'+$('input[name=face]').val()+'IMG';
data.submit();
},
done: function (e, data) {
$.each(data.result.files, function (index, file) {
// Set hidden field
$('input[name='+$(e.target).data('field')+']').val(file.name).attr('data-url', file.url);
// Set Response
$('span#response-'+$(e.target).data('field')).text(file.name).trigger('change');
$(e.target).parent().find('span.filename').text('');
});
},
progressall: function (e, data) {
$('span#response-'+$(e.target).data('field')).text("Envoi en cours...");
var progress = parseInt(data.loaded / data.total * 100, 10);
}
}).prop('disabled', !$.support.fileInput).parent().addClass($.support.fileInput ? undefined : 'disabled');
$('input.PARFUMS1').on('click', function(e){
var inputElems = $('input.PARFUMS1');