You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by je...@apache.org on 2018/12/21 14:47:08 UTC

[sling-org-apache-sling-app-cms] branch master updated: SLING-8190 updated Rava and API

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

jeb 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 352e932  SLING-8190 updated Rava and API
352e932 is described below

commit 352e932698398a7581507df0ee86b8d7d1338e15
Author: Jason E Bailey <je...@apache.org>
AuthorDate: Fri Dec 21 09:47:01 2018 -0500

    SLING-8190 updated Rava and API
---
 core/pom.xml                                 | 26 ++++++++++++++-----
 ui/src/main/frontend/package.json            |  2 +-
 ui/src/main/frontend/src/js/cms.draggable.js | 39 +++++++++++++---------------
 ui/src/main/frontend/src/js/cms.fields.js    | 20 +++++++-------
 ui/src/main/frontend/src/js/cms.form.js      | 25 +++++++-----------
 ui/src/main/frontend/src/js/cms.js           |  4 +--
 ui/src/main/frontend/src/js/cms.modal.js     |  4 +--
 ui/src/main/frontend/src/js/cms.nav.js       |  2 +-
 ui/src/main/frontend/src/js/cms.pathfield.js |  6 ++---
 ui/src/main/frontend/src/js/cms.table.js     |  6 ++---
 ui/src/main/frontend/src/js/cms.taxonomy.js  |  4 +--
 ui/src/main/frontend/src/js/cms.toggle.js    |  4 +--
 12 files changed, 75 insertions(+), 67 deletions(-)

diff --git a/core/pom.xml b/core/pom.xml
index d40b1c6..955c181 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -1,10 +1,17 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional 
-    information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except 
-    in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to 
-    in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See 
-    the License for the specific language governing permissions and limitations under the License. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor 
+    license agreements. See the NOTICE file distributed with this work for additional 
+    information regarding copyright ownership. The ASF licenses this file to 
+    you under the Apache License, Version 2.0 (the "License"); you may not use 
+    this file except in compliance with the License. You may obtain a copy of 
+    the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required 
+    by applicable law or agreed to in writing, software distributed under the 
+    License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 
+    OF ANY KIND, either express or implied. See the License for the specific 
+    language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <artifactId>org.apache.sling.cms</artifactId>
@@ -52,6 +59,13 @@
                     <password>${sling.password}</password>
                 </configuration>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <useSystemClassLoader>false</useSystemClassLoader>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/ui/src/main/frontend/package.json b/ui/src/main/frontend/package.json
index fcbf919..0d053f3 100644
--- a/ui/src/main/frontend/package.json
+++ b/ui/src/main/frontend/package.json
@@ -10,7 +10,7 @@
     "jquery": "^3.3.1",
   	"handlebars": "^4.0.11",
     "wysihtml": "^0.6.0-beta1",
-    "rava": "^1.2.0-beta",
+    "rava": "^2.0.0",
     "jam-icons": "^2.0.0",
     "js-autocomplete": "^1.0.4",
     "datatables": "^1.10.18",
diff --git a/ui/src/main/frontend/src/js/cms.draggable.js b/ui/src/main/frontend/src/js/cms.draggable.js
index df148fb..91285b9 100644
--- a/ui/src/main/frontend/src/js/cms.draggable.js
+++ b/ui/src/main/frontend/src/js/cms.draggable.js
@@ -27,27 +27,7 @@
         elementX : 0,
         elementY : 0
     };
-    rava.decorate(".is-draggable", {
-        callbacks: {
-            created : function () {
-                var draggable = this;
-                document.addEventListener('mouseup', function () {
-                    if (data.mouseDown === true) {
-                        draggable.moveComplete();
-                    }
-                });
-                document.addEventListener('mousemove', function (event) {
-                    if (data.mouseDown === false) {
-                        return false;
-                    }
-                    var deltaX = event.clientX - data.mouseX,
-                        deltaY = event.clientY - data.mouseY;
-                    draggable.style.left = data.elementX + deltaX + 'px';
-                    draggable.style.top = data.elementY + deltaY + 'px';
-                    return false;
-                });
-            }
-        },
+    rava.bind(".is-draggable", {
         methods : {
             moveComplete: function () {
                 data.mouseDown = false;
@@ -57,6 +37,23 @@
             }
         },
         events : {
+            ":root" : {
+                mouseup : function(){
+                    if (data.mouseDown === true) {
+                        this.moveComplete();
+                    }
+                },
+                mousemove : function(event){
+                    if (data.mouseDown === false) {
+                        return false;
+                    }
+                    var deltaX = event.clientX - data.mouseX,
+                        deltaY = event.clientY - data.mouseY;
+                    this.style.left = data.elementX + deltaX + 'px';
+                    this.style.top = data.elementY + deltaY + 'px';
+                    return false;
+                }
+            },
             mousedown: function (event) {
                 if (!event.target.matches('.modal-title, .modal-title *')) {
                     return;
diff --git a/ui/src/main/frontend/src/js/cms.fields.js b/ui/src/main/frontend/src/js/cms.fields.js
index e392c93..044d63d 100644
--- a/ui/src/main/frontend/src/js/cms.fields.js
+++ b/ui/src/main/frontend/src/js/cms.fields.js
@@ -25,7 +25,7 @@
     'use strict';
     
     /* Update the name on file selection */
-    rava.decorate(".file", {
+    rava.bind(".file", {
         events: {
             input: {
                 change : function (event) {
@@ -39,7 +39,7 @@
     });
 
     /* Support for updating the namehint when creating a component */
-    rava.decorate(".namehint", {
+    rava.bind(".namehint", {
         callbacks: {
             created : function () {
                 var field = this;
@@ -52,7 +52,7 @@
     });
     
     /* Support for repeating form fields */
-    rava.decorate(".repeating", {
+    rava.bind(".repeating", {
         callbacks: {
             created : function () {
                 var ctr = this;
@@ -67,17 +67,19 @@
             }
         }
     });
-    rava.decorate(".repeating__remove", {
+    rava.bind(".repeating__item", {
         events: {
-            click: function (event) {
-                event.stopPropagation();
-                event.preventDefault();
-                event.target.closest('.repeating__item').remove();
+            ":scope .repeating__remove" : {
+                click: function (event) {
+                    event.stopPropagation();
+                    event.preventDefault();
+                    this.remove();
+                }
             }
         }
     });
     
-    rava.decorate('.rte', {
+    rava.bind('.rte', {
         callbacks : {
             created : function () {
                 new wysihtml.Editor(this.querySelector('.rte-editor'), {
diff --git a/ui/src/main/frontend/src/js/cms.form.js b/ui/src/main/frontend/src/js/cms.form.js
index 9d41e3d..9320386 100644
--- a/ui/src/main/frontend/src/js/cms.form.js
+++ b/ui/src/main/frontend/src/js/cms.form.js
@@ -18,20 +18,15 @@ w * Licensed to the Apache Software Foundation (ASF) under one
  */
 
 
-rava.decorate(".Form-Ajax", {
-    callbacks: {
-        created : function () {
-            var close = this.querySelector('.close');
-            if(close){
-                close.addEventListener('click', function(){
-                    if(window.parent && window.parent.window && window.parent.window.CMSEditor) {
-                        window.parent.window.CMSEditor.ui.hideModal();
-                    }
-                });
-            }
-        }
-    },
+rava.bind(".Form-Ajax", {
     events :{
+        ":scope .close" : {
+            click : function() {
+                if(window.parent && window.parent.window && window.parent.window.CMSEditor) {
+                    window.parent.window.CMSEditor.ui.hideModal();
+                }
+            }
+        },
         submit : function(event){
             event.preventDefault();
             var $form = $(this);
@@ -103,7 +98,7 @@ rava.decorate(".Form-Ajax", {
 });
 
 
-rava.decorate('.Get-Form', {
+rava.bind('.Get-Form', {
     events : {
         submit : function (event) {
             event.preventDefault();
@@ -120,7 +115,7 @@ rava.decorate('.Get-Form', {
 });
 
 
-rava.decorate('.suffix-form', {
+rava.bind('.suffix-form', {
     events: {
         submit: function (event) {
             event.preventDefault();
diff --git a/ui/src/main/frontend/src/js/cms.js b/ui/src/main/frontend/src/js/cms.js
index d8f3bf5..4f11404 100644
--- a/ui/src/main/frontend/src/js/cms.js
+++ b/ui/src/main/frontend/src/js/cms.js
@@ -149,7 +149,7 @@ window.onbeforeunload = function() {
     }
 }
     
-rava.decorate('.page-properties-container', {
+rava.bind('.page-properties-container', {
     callbacks : {
         created :  function(){
             var $ctr = $(this);
@@ -177,7 +177,7 @@ rava.decorate('.page-properties-container', {
     }
 });
 
-rava.decorate('.sling-cms-include-config', {
+rava.bind('.sling-cms-include-config', {
     callbacks : {
         created :  function() {
             var $ctr = $(this);
diff --git a/ui/src/main/frontend/src/js/cms.modal.js b/ui/src/main/frontend/src/js/cms.modal.js
index 5954574..e4d0135 100644
--- a/ui/src/main/frontend/src/js/cms.modal.js
+++ b/ui/src/main/frontend/src/js/cms.modal.js
@@ -20,7 +20,7 @@
 /* eslint-env browser, es6 */
 (function (rava, Sling) {
     'use strict';
-    rava.decorate("a.Fetch-Modal", {
+    rava.bind("a.Fetch-Modal", {
         events: {
             click: function (event) {
                 event.preventDefault();
@@ -50,7 +50,7 @@
         }
     });
     
-    rava.decorate(".modal", {
+    rava.bind(".modal", {
         events: {
             ".close,.modal-close,.close-modal,.modal-background": {
                 click: function () {
diff --git a/ui/src/main/frontend/src/js/cms.nav.js b/ui/src/main/frontend/src/js/cms.nav.js
index a64a6d6..bb7bf01 100644
--- a/ui/src/main/frontend/src/js/cms.nav.js
+++ b/ui/src/main/frontend/src/js/cms.nav.js
@@ -19,7 +19,7 @@
 /* eslint-env browser, es6 */
 (function (rava) {
     'use strict';
-    rava.decorate(".navbar-burger", {
+    rava.bind(".navbar-burger", {
         events: {
             click: function () {
                 var target = document.querySelector(this.dataset.target);
diff --git a/ui/src/main/frontend/src/js/cms.pathfield.js b/ui/src/main/frontend/src/js/cms.pathfield.js
index 8ed80ae..81091eb 100644
--- a/ui/src/main/frontend/src/js/cms.pathfield.js
+++ b/ui/src/main/frontend/src/js/cms.pathfield.js
@@ -20,7 +20,7 @@
 (function (rava, Sling) {
     'use strict';
     var pathfield = null;
-    rava.decorate("input.pathfield", {
+    rava.bind("input.pathfield", {
         callbacks: {
             created : function () {
                 var type = this.dataset.type,
@@ -29,14 +29,14 @@
             }
         }
     });
-    rava.decorate('.search-button', {
+    rava.bind('.search-button', {
         events: {
             click: function () {
                 pathfield =  this.closest('.field').querySelector('.pathfield');
             }
         }
     });
-    rava.decorate('.search-select-button', {
+    rava.bind('.search-select-button', {
         events: {
             click : function () {
                 pathfield.value = this.dataset.path;
diff --git a/ui/src/main/frontend/src/js/cms.table.js b/ui/src/main/frontend/src/js/cms.table.js
index 1bb3768..bf4a6be 100644
--- a/ui/src/main/frontend/src/js/cms.table.js
+++ b/ui/src/main/frontend/src/js/cms.table.js
@@ -20,7 +20,7 @@
 /* eslint-env browser, es6 */
 (function (rava, $) {
     'use strict';
-    rava.decorate(".table", {
+    rava.bind(".table", {
         callbacks : {
             created: function () {
                 var table = this,
@@ -30,7 +30,7 @@
                     sort: sort,
                     paginate: paginate
                 }).on('page.dt', function () {
-                    table.querySelectorAll('tr.is-selected').forEach(function (tr) {
+                    rava.findAll('tr.is-selected').forEach(function (tr) {
                         tr.classList.remove('is-selected');
                     });
                     document.querySelector('.actions-target').innerHTML = '';
@@ -39,7 +39,7 @@
         }
     });
 
-    rava.decorate(".table tbody tr", {
+    rava.bind(".table tbody tr", {
         events: {
             click: function () {
                 this.closest('.table').querySelectorAll('tr.is-selected').forEach(function (tr) {
diff --git a/ui/src/main/frontend/src/js/cms.taxonomy.js b/ui/src/main/frontend/src/js/cms.taxonomy.js
index b42c518..13c3c55 100644
--- a/ui/src/main/frontend/src/js/cms.taxonomy.js
+++ b/ui/src/main/frontend/src/js/cms.taxonomy.js
@@ -19,7 +19,7 @@
 /* eslint-env browser, es6 */
 (function (rava, $) {
     'use strict';
-    rava.decorate('.taxonomy', {
+    rava.bind('.taxonomy', {
         events: {
             '.taxonomy__add, .taxonomy__add *': {
                 click: function (event) {
@@ -50,7 +50,7 @@
         }
     });
 
-    rava.decorate('.taxonomy__item, .taxonomy__item *', {
+    rava.bind('.taxonomy__item, .taxonomy__item *', {
         events: {
             click: function () {
                 $(this).remove();
diff --git a/ui/src/main/frontend/src/js/cms.toggle.js b/ui/src/main/frontend/src/js/cms.toggle.js
index 3f5e7c0..e859ff4 100644
--- a/ui/src/main/frontend/src/js/cms.toggle.js
+++ b/ui/src/main/frontend/src/js/cms.toggle.js
@@ -21,7 +21,7 @@
 (function (rava) {
     'use strict';
     
-    rava.decorate('.toggle-hidden', {
+    rava.bind('.toggle-hidden', {
         events : {
             click: function () {
                 var target = document.querySelectorAll(this.dataset.target);
@@ -32,7 +32,7 @@
         }
     });
 
-    rava.decorate('.toggle-value', {
+    rava.bind('.toggle-value', {
         callbacks: {
             created: function () {
                 var source = this.getAttribute('data-toggle-source'),