Lazy load invoice documents

This commit is contained in:
Hillel Coren 2016-05-25 11:59:46 +03:00
parent ea2f154b1f
commit ee2ef4608e

View File

@ -998,7 +998,18 @@
})
// Initialize document upload
dropzone = new Dropzone('#document-upload .dropzone', {
window.dropzone = false;
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
if (window.dropzone) {
return;
}
var target = $(e.target).attr('href') // activated tab
if (target != '#attached-documents') {
return;
}
window.dropzone = new Dropzone('#document-upload .dropzone', {
url:{!! json_encode(url('document')) !!},
params:{
_token:"{{ Session::getToken() }}"
@ -1031,7 +1042,7 @@
dropzone.emit('addedfile', mockFile);
dropzone.emit('complete', mockFile);
if(document.preview_url()){
dropzone.emit('thumbnail', mockFile, document.preview_url()||document.url());
dropzone.emit('thumbnail', mockFile, document.preview_url());
}
else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){
dropzone.emit('thumbnail', mockFile, document.url());
@ -1039,6 +1050,7 @@
dropzone.files.push(mockFile);
}
}
});
@endif
});