]> _ Git - fluidbook-toolbox.git/commitdiff
wait #6582 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 18 Dec 2023 17:16:39 +0000 (18:16 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 18 Dec 2023 17:16:39 +0000 (18:16 +0100)
resources/linkeditor/js/linkeditor.form.js

index bc36bee4a7464c0c020034ab0b2a6c5b5d101914..88782a3800d618cb0fcfe25135b3536af4f86e9f 100644 (file)
@@ -3,6 +3,7 @@ function LinkeditorForm(linkeditor) {
     this.loadingFields = {};
     this._maskChangeEvent = false;
     this._maskChangeEventTimeout = null;
+    this._saveFormDataAfterTextChangeTimeout=null;
     this.init();
 }
 
@@ -64,11 +65,22 @@ LinkeditorForm.prototype = {
             }
         }, 250);
 
-        $(document).on('change keyup', "#linkeditor-panel-form input,#linkeditor-panel-form select,#linkeditor-panel-form textarea", function () {
+        $(document).on('change keyup', "#linkeditor-panel-form input,#linkeditor-panel-form select,#linkeditor-panel-form textarea", function (e) {
             if ($this._maskChangeEvent) {
                 return;
             }
-            $this.saveFormDataInLink();
+
+            let callback = function () {
+                console.log('Save form data in link after change');
+                $this.saveFormDataInLink();
+            }
+
+            clearTimeout($this._saveFormDataAfterTextChangeTimeout);
+            if (e.type === 'change') {
+                callback();
+            } else {
+                $this._saveFormDataAfterTextChangeTimeout = setTimeout(callback, 500);
+            }
         });