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 89e88ac  Improving the handling if a user is no longer logged in and 
removing dependency on jQuery
89e88ac is described below

commit 89e88acda542410fb45a03bee4138c02f5d43003
Author: Dan Klco <[email protected]>
AuthorDate: Fri Oct 19 19:29:52 2018 -0400

    Improving the handling if a user is no longer logged in and removing
    dependency on jQuery
---
 ui/src/main/frontend/src/js/cms.modal.js | 63 +++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 26 deletions(-)

diff --git a/ui/src/main/frontend/src/js/cms.modal.js 
b/ui/src/main/frontend/src/js/cms.modal.js
index 3aef3e2..64d50a8 100644
--- a/ui/src/main/frontend/src/js/cms.modal.js
+++ b/ui/src/main/frontend/src/js/cms.modal.js
@@ -16,33 +16,44 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-nomnom.decorate("a.Fetch-Modal", {
-    
-    events :{
-        click: function(event){
-            event.preventDefault();
-            this.setAttribute("disabled",'disabled');
-            this.getModal(this.getAttribute('data-title'), 
encodeURI(this.getAttribute('href')), this.getAttribute('data-path'));
-        }
-    },
-    
-    methods : {
-        getModal: function(title, link, path, complete) {
-            var button = this;
-            var $modal = $('<div class="modal"><div 
class="modal-background"></div><div class="modal-card is-draggable"><header 
class="modal-card-head"><p class="modal-card-title">'+title+'</p><button 
class="delete" aria-label="close"></button></header><section 
class="modal-card-body"><div class="loader is-loading"></div></section><footer 
class="modal-card-foot"></footer></div>');
-            $('body').append($modal);
-            $modal.find('.modal-card-body').load(link,function(){
-                $modal.addClass('is-active');
-                $modal.find('.delete,.close-modal').click(function(){
-                    $modal.css('display','none').remove();
+
+/* eslint-env browser, es6 */
+(function (nomnom) {
+    'use strict';
+    nomnom.decorate("a.Fetch-Modal", {
+        events: {
+            click: function (event) {
+                event.preventDefault();
+                this.setAttribute("disabled", "disabled");
+                this.getModal(this.getAttribute('data-title'), 
encodeURI(this.getAttribute('href')), this);
+            }
+        },
+        methods: {
+            getModal: function (title, link, button) {
+                var modal = document.createElement('div');
+                modal.classList.add('modal');
+                modal.innerHTML = '<div class="modal-background"></div><div 
class="modal-card is-draggable"><header class="modal-card-head"><p 
class="modal-card-title">' + title + '</p><button class="delete" 
aria-label="close"></button></header><section class="modal-card-body"><div 
class="loader is-loading"></div></section><footer 
class="modal-card-foot"></footer>';
+                document.querySelector('body').appendChild(modal);
+                
+                var request = new XMLHttpRequest();
+                request.open('GET', link, true);
+                request.onload = function() {
+                    button.removeAttribute("disabled");
+                    if 
(request.responseURL.indexOf('/system/sling/form/login?resource=') !== -1) {
+                        window.location.reload();
+                    } else {
+                        modal.querySelector('.modal-card-body').innerHTML = 
request.responseText;
+                    }
+                };
+                request.send();
+                
+                
modal.querySelector('.delete,.close-modal').addEventListener("click", 
function(){
+                    modal.remove();
                     return false;
                 });
-                button.removeAttribute("disabled");
-            });
-            
-            $modal.addClass('is-active');
-            return $modal;
+                modal.classList.add('is-active');
+            }
         }
-    }
+    });
 
-});
+}(window.nomnom = window.nomnom || {}));
\ No newline at end of file

Reply via email to