Customer portal : Preview for attachments

SVN:trunk[4093]
This commit is contained in:
Guillaume Lajarige
2016-05-15 09:43:53 +00:00
parent 7790f770a7
commit 754604b009

View File

@@ -97,7 +97,7 @@ class BsFileUploadFieldRenderer extends FieldRenderer
}
else
{
var sDownloadLink = '{$this->oField->GetDownloadEndpoint()}'.replace(/-sAttId-/, data.result.att_id);
var sDownloadLink = '{$this->oField->GetDownloadEndpoint()}'.replace(/-sAttachmentId-/, data.result.att_id);
$(this).closest('.fileupload_field_content').find('.attachments_container').append(
'<div class="attachment col-xs-6 col-sm-3 col-md-2" id="display_attachment_'+data.result.att_id+'">'+
@@ -109,15 +109,22 @@ class BsFileUploadFieldRenderer extends FieldRenderer
' <input type="button" class="btn btn-xs btn-danger hidden" value="{$sDeleteBtn}"/>'+
'</div>'
);
// Preview tooltip
if(data.result.preview){
$('#display_attachment_'+data.result.att_id).tooltip({
html: true,
title: function(){ return '<img src="'+sDownloadLink+'" style="max-width: 100%;" />'; }
});
}
// Showing remove button on hover
$('#display_attachment_'+data.result.att_id).hover( function(){
$(this).children(':button').toggleClass('hidden');
});
// Remove button handler
$('#display_attachment_'+data.result.att_id+' :button').click(function(oEvent){
oEvent.preventDefault();
RemoveAttachment(data.result.att_id);
});
$('#display_attachment_'+data.result.att_id).hover( function(){
$(this).children(':button').toggleClass('hidden');
});
}
},
start: function() {
@@ -136,12 +143,21 @@ class BsFileUploadFieldRenderer extends FieldRenderer
});
}
});
// Preview tooltip
$('.attachment [data-preview="true"]').each(function(iIndex, oElem){
$(oElem).parent().tooltip({
html: true,
title: function(){ return '<img src="'+$(oElem).attr('href')+'" style="max-width: 100%;" />'; }
});
});
// Remove button handler
$('.attachments_container .attachment :button').click(function(oEvent){
oEvent.preventDefault();
RemoveAttachment($(this).closest('.attachment').find(':input[name="attachments[]"]').val());
});
// Remove button showing
if($sIsDeleteAllowed)
{
$('.attachment').hover( function(){