mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
Added input fetching and validation
This commit is contained in:
parent
7583adb3d1
commit
3cf72dd928
@ -1007,10 +1007,20 @@ svg {
|
|||||||
input {
|
input {
|
||||||
position:relative;
|
position:relative;
|
||||||
margin-left:10px;
|
margin-left:10px;
|
||||||
width:10px;
|
height:10px;
|
||||||
height:10px;
|
width:20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
input::-webkit-outer-spin-button,
|
||||||
|
input::-webkit-inner-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
/* Firefox */
|
||||||
|
input[type=number] {
|
||||||
|
-moz-appearance: textfield;
|
||||||
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
position:relative;
|
position:relative;
|
||||||
display:inline-block;
|
display:inline-block;
|
||||||
|
@ -1,46 +1,61 @@
|
|||||||
let resizeCanvasContainer = document.getElementById("resize-canvas");
|
let resizeCanvasContainer = document.getElementById("resize-canvas");
|
||||||
|
let pivot = "middle";
|
||||||
|
let resizeCanvasInitialized = false;
|
||||||
|
let borders = {left: 0, right: 0, top: 0, bottom: 0};
|
||||||
|
|
||||||
function openResizeCanvasWindow() {
|
function openResizeCanvasWindow() {
|
||||||
|
if (!resizeCanvasInitialized) {
|
||||||
|
resizeCanvasInitialized = true;
|
||||||
|
initResizeCanvasInputs();
|
||||||
|
}
|
||||||
showDialogue('resize-canvas');
|
showDialogue('resize-canvas');
|
||||||
console.log("aperta");
|
|
||||||
initButtons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initButtons() {
|
function initResizeCanvasInputs() {
|
||||||
let buttons = document.getElementsByClassName("pivot-button");
|
let buttons = document.getElementsByClassName("pivot-button");
|
||||||
|
|
||||||
console.log("length: " + buttons.length);
|
|
||||||
|
|
||||||
for (let i=0; i<buttons.length; i++) {
|
for (let i=0; i<buttons.length; i++) {
|
||||||
buttons[i].addEventListener("click", changePivot);
|
buttons[i].addEventListener("click", changePivot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePivot(event) {
|
function changePivot(event) {
|
||||||
console.log("sas");
|
pivot = event.target.getAttribute("value");
|
||||||
console.log(event.target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use a dialogue
|
// Use a dialogue
|
||||||
// Let the user specify data
|
|
||||||
// Borders
|
|
||||||
// Pivot
|
|
||||||
// Apply the new sizing
|
// Apply the new sizing
|
||||||
// Move the images on the layers to fit what the user actually decided
|
// Move the images on the layers to fit what the user actually decided
|
||||||
|
|
||||||
// Function to handle dropdown menu for pivots
|
|
||||||
// Open when clicking on the button
|
|
||||||
// Save the chosen pivot
|
|
||||||
// Close the menu
|
|
||||||
|
|
||||||
// Function to retrieve data from the input field
|
|
||||||
// Store the data in the form into variables
|
|
||||||
// Call the function to resize the canvases
|
|
||||||
|
|
||||||
// Function to actually resize the canvases
|
// Function to actually resize the canvases
|
||||||
// Save all imageDatas
|
// Save all imageDatas
|
||||||
// Resize the canvases
|
// Resize the canvases
|
||||||
// Clear the canvases
|
// Clear the canvases
|
||||||
|
|
||||||
// Function to place the imageDatas as specified in the pivot section
|
// Function to place the imageDatas as specified in the pivot section
|
||||||
// Put the imageDatas in the right position
|
// Put the imageDatas in the right position
|
||||||
|
// Must crop the imageDatas if the canvas has being reduced
|
@ -269,19 +269,23 @@
|
|||||||
<!--BORDERS-->
|
<!--BORDERS-->
|
||||||
<span id = "borders-menu">
|
<span id = "borders-menu">
|
||||||
<span>
|
<span>
|
||||||
Left: <input id="border-left" value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
Left: <input id="rc-border-left" type="number" default="0" step="1"
|
||||||
|
value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
Right: <input id="border-right" value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
Right: <input id="rc-border-right" type="number" default="0" step="1"
|
||||||
|
value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
Top: <input id="border-top" value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
Top: <input id="rc-border-top" type="number" default="0" step="1"
|
||||||
|
value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
Bottom: <input id="border-bottom" value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
Bottom: <input id="rc-border-bottom" default="0" step="1" type="number"
|
||||||
|
value="{{#if border}}{{border}}{{else}}0{{/if}}" autocomplete="off"/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<button id = "resize-canvas-confirm">Resize canvas</button>
|
<button id = "resize-canvas-confirm">Resize canvas</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user