You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2021/07/26 08:38:12 UTC

[myfaces-tobago] branch tobago-2.x updated: TOBAGO-2090 Tobago 2.x: FileDrop: inclomplete cancel on empty list

This is an automated email from the ASF dual-hosted git repository.

weber pushed a commit to branch tobago-2.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git


The following commit(s) were added to refs/heads/tobago-2.x by this push:
     new 701ffc7  TOBAGO-2090 Tobago 2.x: FileDrop: inclomplete cancel on empty list
701ffc7 is described below

commit 701ffc70dd996f5d093de12f0cdac7182ffb7450
Author: Volker Weber <v....@inexso.de>
AuthorDate: Fri Jul 23 16:57:32 2021 +0200

    TOBAGO-2090 Tobago 2.x: FileDrop: inclomplete cancel on empty list
---
 .../html/standard/standard/script/tobago-file.js       | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-file.js b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-file.js
index 01f7295..ae249c9 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-file.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-file.js
@@ -207,15 +207,12 @@ Tobago.registerListener(Tobago.File.init, Tobago.Phase.AFTER_UPDATE);
 
     hide: function () {
       // console.info("hide"); // @DEV_ONLY
-      this.fileDropArea.off("drop");
+      this.fileDropArea.off("drop", this.filesDropped);
       this.fileDropArea.css({display: 'none'});
     },
 
     filesDropped: function (event) {
       console.info("dropFile"); // @DEV_ONLY
-      event.stopPropagation();
-      event.stopImmediatePropagation();
-      event.preventDefault();
 
       var dropThis = jQuery(this);
       var fileDrop = dropThis.data("widget-element");
@@ -225,15 +222,20 @@ Tobago.registerListener(Tobago.File.init, Tobago.Phase.AFTER_UPDATE);
       //noinspection JSUnresolvedVariable
       var files = event.originalEvent.dataTransfer.files;
       console.info("files.length: " + files.length); // @DEV_ONLY
+
+      if (files.length === 0) {
+        console.warn("no files dropped, aborting upload!");
+        return
+      }
+
+      event.stopPropagation();
+      event.stopImmediatePropagation();
+      event.preventDefault();
       for (var i = 0; i < files.length; i++) {
         var file = files[i];
         console.info("file: " + file.name); // @DEV_ONLY
       }
 
-      if (files.length == 0) {
-        console.warn("no files dropped, aborting upload!");
-      }
-
       var fileElement = fileDrop.find("input[type='file']");
       var commands = fileElement.data("tobago-commands");
       if (!commands || !commands.change || !commands.change.partially) {