Skip to content
Snippets Groups Projects
Commit ef0ff6b0 authored by Sebastien's avatar Sebastien
Browse files

Fix don't open image edition until image is loaded

parent 519a8f63
No related branches found
No related tags found
1 merge request!98refresh the mosaic on annotation modification
...@@ -1041,7 +1041,18 @@ function closePasteModal() { $('#paste_modal').hide(); $('#paste_modal_content') ...@@ -1041,7 +1041,18 @@ function closePasteModal() { $('#paste_modal').hide(); $('#paste_modal_content')
function openImageEdition(message, tag) { function openImageEdition(message, tag) {
$('#edit_pic_modal').show(); $('#edit_pic_modal').show();
let keyDoc = tag.document.key; let keyDoc = tag.document.key;
let annotationEdit = $('#annotation_img_edit')[0];
$('#annotation_img_edit').attr('src', tag.getDownloadLink(true)); $('#annotation_img_edit').attr('src', tag.getDownloadLink(true));
function loadImage(url, elem) {
return new Promise((resolve, reject) => {
elem.onload = () => resolve(elem);
elem.onerror = reject;
elem.src = url;
});
}
function openMakerArea() {
// eslint-disable-next-line no-empty
let markerArea = new markerjs2.MarkerArea($('#annotation_img_edit')[0]); let markerArea = new markerjs2.MarkerArea($('#annotation_img_edit')[0]);
let imageState; let imageState;
...@@ -1064,7 +1075,9 @@ function openImageEdition(message, tag) { ...@@ -1064,7 +1075,9 @@ function openImageEdition(message, tag) {
while (n--) uar[n] = bin_str.charCodeAt(n); while (n--) uar[n] = bin_str.charCodeAt(n);
let file = new File([uar], keyDoc.substr(1), {type: type + '/' + subtype}); let file = new File([uar], keyDoc.substr(1), {type: type + '/' + subtype});
$('#left_menu_item_btn_addfile').files = [file]; $('#left_menu_item_btn_addfile').files = [file];
uploadFiles([file], {'edited': 1}, function(){$('#popupImg').attr('src', tag.getDownloadLink());}); uploadFiles([file], {'edited': 1}, function () {
$('#popupImg').attr('src', tag.getDownloadLink());
});
setMetaFromDom(tag.document.key, "Rekall->MarkerjsState", tag.getMetadata('Rekall->MarkerjsState')); setMetaFromDom(tag.document.key, "Rekall->MarkerjsState", tag.getMetadata('Rekall->MarkerjsState'));
}); });
...@@ -1075,5 +1088,13 @@ function openImageEdition(message, tag) { ...@@ -1075,5 +1088,13 @@ function openImageEdition(message, tag) {
markerArea.show(); markerArea.show();
if (imageState) if (imageState)
markerArea.restoreState(imageState); markerArea.restoreState(imageState);
}
async function changeImageSrc() {
await loadImage(tag.getDownloadLink(true), annotationEdit);
openMakerArea();
}
// noinspection JSIgnoredPromiseFromCall
changeImageSrc();
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment