Fixed merge conflict. Cleaned up code
This commit is contained in:
parent
b123e8eba5
commit
38925ea4ca
2 changed files with 29 additions and 33 deletions
|
@ -102,7 +102,7 @@
|
||||||
<div class="custom-file-chooser">
|
<div class="custom-file-chooser">
|
||||||
<div class="custom-file">
|
<div class="custom-file">
|
||||||
<input type="file" class="custom-file-input" th:name="${name}" th:id="${name}+'-input'" th:multiple="${multiple}">
|
<input type="file" class="custom-file-input" th:name="${name}" th:id="${name}+'-input'" th:multiple="${multiple}">
|
||||||
<label class="custom-file-label" th:for="${name}+'-input'">Choose file</label>
|
<label class="custom-file-label" th:for="${name}+'-input'" th:text="#{pdfPrompt}"></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
if (fileNames) {
|
if (fileNames) {
|
||||||
$(this).siblings(".custom-file-label").addClass("selected").html(fileNames);
|
$(this).siblings(".custom-file-label").addClass("selected").html(fileNames);
|
||||||
} else {
|
} else {
|
||||||
$(this).siblings(".custom-file-label").addClass("selected").html("Choose file");
|
$(this).siblings(".custom-file-label").addClass("selected").html([[#{pdfPrompt}]]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<div th:replace="fragments/common :: fileSelector(name='fileInput', multiple=false)"></div>
|
<div th:replace="fragments/common :: fileSelector(name='fileInput', multiple=false)"></div>
|
||||||
<input type="hidden" id="angleInput" name="angle" value="0">
|
<input type="hidden" id="angleInput" name="angle" value="0">
|
||||||
|
|
||||||
|
<div id="editSection" style="display: none">
|
||||||
<div class="previewContainer">
|
<div class="previewContainer">
|
||||||
<img id="pdf-preview"/>
|
<img id="pdf-preview"/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,6 +39,7 @@
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -54,14 +56,11 @@
|
||||||
fileInput.addEventListener("change", async function() {
|
fileInput.addEventListener("change", async function() {
|
||||||
console.log("loading pdf");
|
console.log("loading pdf");
|
||||||
|
|
||||||
preview.parentElement.style.display = "block";
|
document.querySelector("#editSection").style.display = "";
|
||||||
document.querySelector(".buttonContainer").style.display = "flex";
|
|
||||||
|
|
||||||
var file = fileInput.files[0];
|
var url = URL.createObjectURL(fileInput.files[0])
|
||||||
var url = URL.createObjectURL(file)
|
|
||||||
var loadingTask = pdfjsLib.getDocument(url);
|
|
||||||
|
|
||||||
const pdf = await loadingTask.promise;
|
const pdf = await pdfjsLib.getDocument(url).promise;
|
||||||
const page = await pdf.getPage(1);
|
const page = await pdf.getPage(1);
|
||||||
|
|
||||||
const canvas = document.createElement("canvas");
|
const canvas = document.createElement("canvas");
|
||||||
|
@ -115,20 +114,17 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border: 1px solid rgba(0,0,0,.125);
|
border: 1px solid rgba(0,0,0,.125);
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
margin: 1rem 0 0;
|
margin: 1rem 0;
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
display: none;
|
display: block;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonContainer {
|
.buttonContainer {
|
||||||
display: none;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
}
|
}
|
||||||
button {
|
|
||||||
top-margin: -100%;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue