2020-07-23 00:29:27 +03:00
|
|
|
let resizeCanvasContainer = document.getElementById("resize-canvas");
|
2020-09-13 12:58:46 +03:00
|
|
|
let pivot = "middle";
|
|
|
|
let resizeCanvasInitialized = false;
|
|
|
|
let borders = {left: 0, right: 0, top: 0, bottom: 0};
|
2020-07-23 00:29:27 +03:00
|
|
|
|
|
|
|
function openResizeCanvasWindow() {
|
2020-09-13 12:58:46 +03:00
|
|
|
if (!resizeCanvasInitialized) {
|
|
|
|
resizeCanvasInitialized = true;
|
|
|
|
initResizeCanvasInputs();
|
|
|
|
}
|
2020-07-23 00:29:27 +03:00
|
|
|
showDialogue('resize-canvas');
|
2020-09-13 12:21:23 +03:00
|
|
|
}
|
|
|
|
|
2020-09-13 12:58:46 +03:00
|
|
|
function initResizeCanvasInputs() {
|
2020-09-13 12:21:23 +03:00
|
|
|
let buttons = document.getElementsByClassName("pivot-button");
|
|
|
|
|
|
|
|
for (let i=0; i<buttons.length; i++) {
|
|
|
|
buttons[i].addEventListener("click", changePivot);
|
|
|
|
}
|
2020-09-13 12:58:46 +03:00
|
|
|
|
|
|
|
document.getElementById("resize-canvas-confirm").addEventListener("click", resizeCanvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeCanvas(event) {
|
|
|
|
resizeCanvasUpdateBorders();
|
|
|
|
}
|
|
|
|
|
|
|
|
function resizeCanvasUpdateBorders() {
|
|
|
|
console.log(document.getElementById("rc-border-left").value);
|
|
|
|
|
|
|
|
// Getting input
|
|
|
|
borders.left = document.getElementById("rc-border-left").value;
|
|
|
|
borders.right = document.getElementById("rc-border-right").value;
|
|
|
|
borders.top = document.getElementById("rc-border-top").value;
|
|
|
|
borders.bottom = document.getElementById("rc-border-bottom").value;
|
|
|
|
|
|
|
|
// Validating input
|
|
|
|
borders.left == "" ? borders.left = 0 : borders.left = Math.round(parseInt(borders.left));
|
|
|
|
borders.right == "" ? borders.right = 0 : borders.right = Math.round(parseInt(borders.right));
|
|
|
|
borders.top == "" ? borders.top = 0 : borders.top = Math.round(parseInt(borders.top));
|
|
|
|
borders.bottom == "" ? borders.bottom = 0 : borders.bottom = Math.round(parseInt(borders.bottom));
|
|
|
|
|
|
|
|
console.log(borders);
|
2020-09-13 12:21:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function changePivot(event) {
|
2020-09-13 12:58:46 +03:00
|
|
|
pivot = event.target.getAttribute("value");
|
2020-07-23 00:29:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Use a dialogue
|
|
|
|
// Apply the new sizing
|
|
|
|
// Move the images on the layers to fit what the user actually decided
|
|
|
|
|
|
|
|
// Function to actually resize the canvases
|
|
|
|
// Save all imageDatas
|
|
|
|
// Resize the canvases
|
|
|
|
// Clear the canvases
|
|
|
|
|
|
|
|
// Function to place the imageDatas as specified in the pivot section
|
2020-09-13 12:58:46 +03:00
|
|
|
// Put the imageDatas in the right position
|
|
|
|
// Must crop the imageDatas if the canvas has being reduced
|