You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2019/12/02 13:50:12 UTC

[sling-org-apache-sling-app-cms] branch master updated: Fixing SLING-8871: ensuring the click handler is scoped to the new element

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

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git


The following commit(s) were added to refs/heads/master by this push:
     new 9e5966c  Fixing SLING-8871: ensuring the click handler is scoped to the new element
9e5966c is described below

commit 9e5966c78359680deab6c35b43477d3c8652282c
Author: Dan Klco <dk...@apache.org>
AuthorDate: Mon Dec 2 08:49:56 2019 -0500

    Fixing SLING-8871: ensuring the click handler is scoped to the new element
---
 ui/src/main/frontend/js/cms.fields.js | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/ui/src/main/frontend/js/cms.fields.js b/ui/src/main/frontend/js/cms.fields.js
index 612ddc4..3a8ad84 100644
--- a/ui/src/main/frontend/js/cms.fields.js
+++ b/ui/src/main/frontend/js/cms.fields.js
@@ -17,13 +17,13 @@
  * under the License.
  */
 
-/** 
+/**
  * Utility scripts for decorating form fields
  */
 /* eslint-env browser, es6 */
 (function (rava, wysihtml, wysihtmlParserRules) {
     'use strict';
-    
+
     /* Support for file uploads */
     var setProgress = function(meter, progress){
         meter.innerText = Math.round(progress)+'%';
@@ -31,10 +31,10 @@
     }
     var uploadFile = function(meter, action, file) {
         var formData = new FormData();
-        
+
         formData.append('*', file);
         formData.append("*@TypeHint", "sling:File");
-        
+
         var xhr = new XMLHttpRequest();
         xhr.upload.addEventListener('loadstart', function(){
             setProgress(meter, 0);
@@ -76,7 +76,7 @@
         it.querySelector('.file-item-name').innerText = file.name;
         ctr.classList.remove('is-hidden');
         ctr.appendChild(it);
-        
+
         uploadFile(meter,scope.closest('form').action, file);
     }
     rava.bind(".file", {
@@ -116,15 +116,11 @@
                 close.addEventListener('click', function(event){
                     window.Sling.CMS.ui.reloadContext();
                 });
-            }
-        },
-        events: {
-            input: {
-                change : function (event) {
+                field.querySelector('input').addEventListener('change', function(event){
                     for(var i = 0; i < event.target.files.length; i++){
                         handleFile(event.target, event.target.files[i]);
                     }
-                }
+                })
             }
         }
     });
@@ -141,7 +137,7 @@
             }
         }
     });
-    
+
     /* Support for repeating form fields */
     rava.bind(".repeating", {
         callbacks: {
@@ -169,7 +165,7 @@
             }
         }
     });
-    
+
     rava.bind('.rte', {
         callbacks : {
             created : function () {
@@ -180,4 +176,4 @@
             }
         }
     });
-}(window.rava = window.rava || {}, window.wysihtml = window.wysihtml || {}, window.wysihtmlParserRules = window.wysihtmlParserRules || {}));
\ No newline at end of file
+}(window.rava = window.rava || {}, window.wysihtml = window.wysihtml || {}, window.wysihtmlParserRules = window.wysihtmlParserRules || {}));