Lazy load invoice documents

This commit is contained in:
Hillel Coren 2016-05-25 12:00:37 +03:00
parent e201651aa6
commit f502e5952e

View File

@ -974,15 +974,26 @@
}) })
// Initialize document upload // 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')) !!}, url:{!! json_encode(url('document')) !!},
params:{ params:{
_token:"{{ Session::getToken() }}" _token:"{{ Session::getToken() }}"
}, },
acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!}, acceptedFiles:{!! json_encode(implode(',',\App\Models\Document::$allowedMimes)) !!},
addRemoveLinks:true, addRemoveLinks:true,
@foreach(trans('texts.dropzone') as $key=>$text) @foreach(['default_message', 'fallback_message', 'fallback_text', 'file_too_big', 'invalid_file_type', 'response_error', 'cancel_upload', 'cancel_upload_confirmation', 'remove_file'] as $key)
"dict{{strval($key)}}":"{{strval($text)}}", "dict{{Utils::toClassCase($key)}}":"{{trans('texts.dropzone_'.$key)}}",
@endforeach @endforeach
maxFileSize:{{floatval(MAX_DOCUMENT_SIZE/1000)}}, maxFileSize:{{floatval(MAX_DOCUMENT_SIZE/1000)}},
}); });
@ -1007,7 +1018,7 @@
dropzone.emit('addedfile', mockFile); dropzone.emit('addedfile', mockFile);
dropzone.emit('complete', mockFile); dropzone.emit('complete', mockFile);
if(document.preview_url()){ 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'){ else if(document.type()=='jpeg' || document.type()=='png' || document.type()=='svg'){
dropzone.emit('thumbnail', mockFile, document.url()); dropzone.emit('thumbnail', mockFile, document.url());
@ -1015,6 +1026,7 @@
dropzone.files.push(mockFile); dropzone.files.push(mockFile);
} }
} }
});
@endif @endif
}); });