mirror of
https://github.com/lus/pasty.git
synced 2023-08-10 21:13:09 +03:00
Only enable save button when content is not empty
This commit is contained in:
parent
e8e2b49466
commit
7a8d8e1573
@ -92,7 +92,7 @@ export async function initialize() {
|
|||||||
ENCRYPTION_IV = json.metadata.pf_encryption.iv;
|
ENCRYPTION_IV = json.metadata.pf_encryption.iv;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
Notifications.error("Could not decrrypt paste; make sure the decryption key is correct.");
|
Notifications.error("Could not decrypt paste; make sure the decryption key is correct.");
|
||||||
setTimeout(() => location.replace(location.protocol + "//" + location.host), 3000);
|
setTimeout(() => location.replace(location.protocol + "//" + location.host), 3000);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -112,6 +112,12 @@ export async function initialize() {
|
|||||||
|
|
||||||
INPUT_ELEMENT.addEventListener("input", () => {
|
INPUT_ELEMENT.addEventListener("input", () => {
|
||||||
updateLineNumbers(INPUT_ELEMENT.value);
|
updateLineNumbers(INPUT_ELEMENT.value);
|
||||||
|
if (BUTTON_SAVE_ELEMENT.hasAttribute("disabled") && INPUT_ELEMENT.value.length > 0) {
|
||||||
|
BUTTON_SAVE_ELEMENT.removeAttribute("disabled");
|
||||||
|
}
|
||||||
|
if (!BUTTON_SAVE_ELEMENT.hasAttribute("disabled") && INPUT_ELEMENT.value.length == 0) {
|
||||||
|
BUTTON_SAVE_ELEMENT.setAttribute("disabled", true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +166,6 @@ function updateButtonState() {
|
|||||||
BUTTON_REPORT_ELEMENT.classList.remove("hidden");
|
BUTTON_REPORT_ELEMENT.classList.remove("hidden");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BUTTON_SAVE_ELEMENT.removeAttribute("disabled");
|
|
||||||
BUTTON_EDIT_ELEMENT.setAttribute("disabled", true);
|
BUTTON_EDIT_ELEMENT.setAttribute("disabled", true);
|
||||||
BUTTON_DELETE_ELEMENT.setAttribute("disabled", true);
|
BUTTON_DELETE_ELEMENT.setAttribute("disabled", true);
|
||||||
BUTTON_COPY_ELEMENT.setAttribute("disabled", true);
|
BUTTON_COPY_ELEMENT.setAttribute("disabled", true);
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<line x1="12" y1="9" x2="12" y2="15" />
|
<line x1="12" y1="9" x2="12" y2="15" />
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
<button class="button" id="btn_save" title="Save paste (Ctrl + S)">
|
<button class="button" id="btn_save" title="Save paste (Ctrl + S)" disabled>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-device-floppy" width="40"
|
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-device-floppy" width="40"
|
||||||
height="40" viewBox="0 0 24 24" stroke-width="1.5" stroke="#bebebe" fill="none"
|
height="40" viewBox="0 0 24 24" stroke-width="1.5" stroke="#bebebe" fill="none"
|
||||||
stroke-linecap="round" stroke-linejoin="round">
|
stroke-linecap="round" stroke-linejoin="round">
|
||||||
|
Loading…
Reference in New Issue
Block a user