1
0
forked from ScoDoc/ScoDoc

Copié/collé notes: fix #990

This commit is contained in:
Emmanuel Viennet 2024-09-09 21:23:20 +02:00
parent 368914ebf7
commit a3a71a3f4f

View File

@ -6,12 +6,7 @@ document.addEventListener("DOMContentLoaded", function () {
input.addEventListener("input", function() {
this.setAttribute("data-modified", "true");
});
input.addEventListener("blur", function() {
if (this.getAttribute("data-modified") === "true" && this.value !== this.getAttribute("data-last-saved-value")) {
valid_note.call(this);
this.setAttribute("data-modified", "false"); // Reset the modified flag
}
});
input.addEventListener("blur", input.addEventListener("blur", function(event){write_on_blur(event.currentTarget)} ));
});
var formInputs = document.querySelectorAll("#formnotes input");
@ -23,6 +18,13 @@ document.addEventListener("DOMContentLoaded", function () {
masquerBtn.addEventListener("click", masquer_DEM);
});
function write_on_blur(elt) {
if (elt.getAttribute("data-modified") === "true" && elt.value !== elt.getAttribute("data-last-saved-value")) {
valid_note.call(elt);
elt.setAttribute("data-modified", "false"); // Reset the modified flag
}
}
function is_valid_note(v) {
if (!v) return true;
@ -143,11 +145,10 @@ function change_history(e) {
// Contribution S.L.: copier/coller des notes
function paste_text(e) {
var event = e.originalEvent;
function paste_text(event) {
event.stopPropagation();
event.preventDefault();
var clipb = e.originalEvent.clipboardData;
var clipb = event.clipboardData;
var data = clipb.getData("Text");
var list = data.split(/\r\n|\r|\n|\t| /g);
var currentInput = event.currentTarget;
@ -159,9 +160,11 @@ function paste_text(e) {
if (!currentInput.disabled) { // skip DEM
currentInput.value = list[i];
}
var evt = document.createEvent("HTMLEvents");
evt.initEvent("blur", false, true);
// --- trigger blur
currentInput.setAttribute("data-modified", "true");
var evt = new Event("blur", { bubbles: true, cancelable: true});
currentInput.dispatchEvent(evt);
// --- next input
var sibbling = currentInput.parentElement.parentElement.nextElementSibling;
while (
sibbling &&