You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2018/12/13 14:14:06 UTC

[myfaces-tobago] branch master updated (7bee817 -> d70b4e0)

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

lofwyr pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git.


    from 7bee817  TOBAGO-1966: <tc:sheet> with columns contains "auto" ist not displayed
     new 4de3751  TOBAGO-1633: Use TypeScript instead of JavaScript.
     new d70b4e0  TOBAGO-1633: Use TypeScript instead of JavaScript.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../webapp/content/10-intro/20-docker/docker.js    |  6 +-
 .../content/10-intro/20-docker/docker.js.map       |  2 +-
 .../webapp/content/10-intro/20-docker/docker.ts    | 64 ++++++++---------
 .../tobago-bootstrap/_version/js/tobago-panel.js   | 10 +--
 .../tobago-bootstrap/_version/js/tobago-sheet.js   | 19 ++---
 .../tobago-bootstrap/_version/js/tobago.js         | 81 +---------------------
 6 files changed, 54 insertions(+), 128 deletions(-)


[myfaces-tobago] 01/02: TOBAGO-1633: Use TypeScript instead of JavaScript.

Posted by lo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4de3751ad9d7f2721306886d57212835419ea50f
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Wed Dec 12 22:36:21 2018 +0100

    TOBAGO-1633: Use TypeScript instead of JavaScript.
    
    using a loop for all matching elements
---
 .../webapp/content/10-intro/20-docker/docker.js    |  6 +-
 .../content/10-intro/20-docker/docker.js.map       |  2 +-
 .../webapp/content/10-intro/20-docker/docker.ts    | 64 +++++++++++-----------
 3 files changed, 38 insertions(+), 34 deletions(-)

diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js
index be2c235..2b9e57c 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js
@@ -37,7 +37,7 @@ var Demo;
                     }
                     try {
                         var result = document.execCommand("copy");
-                        alert("result: " + result);
+                        console.debug("result: " + result);
                     }
                     catch (error) {
                         console.error("Copying text not possible");
@@ -46,7 +46,9 @@ var Demo;
             }
             return ToClipboardButton;
         }());
-        var init = function () { return new ToClipboardButton(document.querySelector("[data-copy-clipboard-from]")); };
+        var init = function () {
+            document.querySelectorAll("[data-copy-clipboard-from]").forEach(function (value) { return new ToClipboardButton(value); });
+        };
         Tobago.registerListener(init, Tobago.Phase.DOCUMENT_READY);
         Tobago.registerListener(init, Tobago.Phase.AFTER_UPDATE);
     })(ToClipboardButton = Demo.ToClipboardButton || (Demo.ToClipboardButton = {}));
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map
index 3ce7225..4b780f5 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.js.map
@@ -1 +1 @@
-{"version":3,"file":"docker.js","sourceRoot":"","sources":["docker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,IAAO,IAAI,CAuCV;AAvCD,WAAO,IAAI;IAAC,IAAA,iBAAiB,CAuC5B;IAvCW,WAAA,mBAAiB;QAEzB;YAEI,2BAAY,OAAoB;gBAE5B;mBACG;gBACH,OAAO,CAAC,gBAAgB,CACpB,OAAO,EACP,UAAC,KAAiB;oBACd,IAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;oBAC9D,IAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAElD,IAAI,MAAM,CAAC,YAAY,EAAE;wBACrB,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;wBACxC,IAAM,KA [...]
\ No newline at end of file
+{"version":3,"file":"docker.js","sourceRoot":"","sources":["docker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,IAAO,IAAI,CAyCV;AAzCD,WAAO,IAAI;IAAC,IAAA,iBAAiB,CAyC5B;IAzCW,WAAA,mBAAiB;QAE3B;YAEE,2BAAY,OAAoB;gBAE9B;mBACG;gBACH,OAAO,CAAC,gBAAgB,CACpB,OAAO,EACP,UAAC,KAAiB;oBAChB,IAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,0BAA0B,CAAC,CAAC;oBAC9D,IAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;oBAElD,IAAI,MAAM,CAAC,YAAY,EAAE;wBACvB,IAAM,SAAS,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;wBACxC,IAAM,K [...]
\ No newline at end of file
diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts
index 9b03408..b5704a3 100644
--- a/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts
+++ b/tobago-example/tobago-example-demo/src/main/webapp/content/10-intro/20-docker/docker.ts
@@ -17,41 +17,43 @@
 
 module Demo.ToClipboardButton {
 
-    class ToClipboardButton {
+  class ToClipboardButton {
 
-        constructor(element: HTMLElement) {
+    constructor(element: HTMLElement) {
 
-            /* Copy the command lines to the clipboard.
-             */
-            element.addEventListener(
-                "click",
-                (event: MouseEvent) => {
-                    const from = element.getAttribute("data-copy-clipboard-from");
-                    const commandLine = document.getElementById(from);
+      /* Copy the command lines to the clipboard.
+       */
+      element.addEventListener(
+          "click",
+          (event: MouseEvent) => {
+            const from = element.getAttribute("data-copy-clipboard-from");
+            const commandLine = document.getElementById(from);
 
-                    if (window.getSelection) {
-                        const selection = window.getSelection();
-                        const range = document.createRange();
-                        range.selectNodeContents(commandLine);
-                        selection.removeAllRanges();
-                        selection.addRange(range);
-                    } else {
-                        console.warn("Text select not possible: Unsupported browser.");
-                    }
-                    try {
-                        const result = document.execCommand("copy");
-                        alert("result: " + result);
-                    } catch (error) {
-                        console.error("Copying text not possible");
-                    }
-                });
-        }
+            if (window.getSelection) {
+              const selection = window.getSelection();
+              const range = document.createRange();
+              range.selectNodeContents(commandLine);
+              selection.removeAllRanges();
+              selection.addRange(range);
+            } else {
+              console.warn("Text select not possible: Unsupported browser.");
+            }
+            try {
+              const result = document.execCommand("copy");
+              console.debug("result: " + result);
+            } catch (error) {
+              console.error("Copying text not possible");
+            }
+          });
     }
+  }
 
-    const init = () => new ToClipboardButton(
-        document.querySelector("[data-copy-clipboard-from]")
-    );
+  const init = function () {
+    document.querySelectorAll<HTMLElement>("[data-copy-clipboard-from]").forEach(
+        (value) => new ToClipboardButton(value)
+    )
+  };
 
-    Tobago.registerListener(init, Tobago.Phase.DOCUMENT_READY, Tobago.Phase.Order.LATER);
-    Tobago.registerListener(init, Tobago.Phase.AFTER_UPDATE);
+  Tobago.registerListener(init, Tobago.Phase.DOCUMENT_READY);
+  Tobago.registerListener(init, Tobago.Phase.AFTER_UPDATE);
 }


[myfaces-tobago] 02/02: TOBAGO-1633: Use TypeScript instead of JavaScript.

Posted by lo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d70b4e09e0e187f7d32cc73c90b7349bfa08a07c
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Dec 13 15:13:50 2018 +0100

    TOBAGO-1633: Use TypeScript instead of JavaScript.
    
    * remove unused functions
    * refactor "bind2"
---
 .../tobago-bootstrap/_version/js/tobago-panel.js   | 10 +--
 .../tobago-bootstrap/_version/js/tobago-sheet.js   | 19 ++---
 .../tobago-bootstrap/_version/js/tobago.js         | 81 +---------------------
 3 files changed, 16 insertions(+), 94 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-panel.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-panel.js
index 2bd83bc..a74cfaa 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-panel.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-panel.js
@@ -40,18 +40,18 @@ Tobago.Panel.prototype.setup = function() {
 
 Tobago.Panel.prototype.initReload = function() {
   if (typeof this.autoReload == 'number' && this.autoReload > 0) {
-    Tobago.addReloadTimeout(this.id, Tobago.bind2(this, 'reloadWithAction', null, this.id), this.autoReload);
+    Tobago.addReloadTimeout(this.id, Tobago.Panel.reloadWithAction, this.autoReload);
   }
 };
 
-Tobago.Panel.prototype.reloadWithAction = function(source, action) {
+Tobago.Panel.reloadWithAction = function(elementId) {
   jsf.ajax.request(
-      action,
+      elementId,
       null,
       {
         "javax.faces.behavior.event": "reload",
-        execute: this.id,
-        render: this.id
+        execute: elementId,
+        render: elementId
       });
 };
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
index 6cfba04..29ed6da 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
@@ -86,20 +86,21 @@ Tobago.Sheet.init = function(elements) {
 Tobago.registerListener(Tobago.Sheet.init, Tobago.Phase.DOCUMENT_READY);
 Tobago.registerListener(Tobago.Sheet.init, Tobago.Phase.AFTER_UPDATE);
 
-Tobago.Sheet.prototype.reloadWithAction = function(source, action) {
-    console.debug("reload sheet with action '" + action + "'"); // @DEV_ONLY
-  var executeIds = this.id;
-  var renderIds = this.id;
+Tobago.Sheet.reloadWithAction = function(elementId) {
+    console.debug("reload sheet with action '" + elementId + "'"); // @DEV_ONLY
+  var executeIds = elementId;
+  var renderIds = elementId;
+  // XXX FIXME: behaviorCommands will probably be empty and not working!
   if (this.behaviorCommands && this.behaviorCommands.reload) {
     if (this.behaviorCommands.reload.execute) {
-      executeIds +=  " " + this.behaviorCommands.reload.execute;
+      executeIds += " " + this.behaviorCommands.reload.execute;
     }
     if (this.behaviorCommands.reload.render) {
-      renderIds +=  " " + this.behaviorCommands.reload.render;
+      renderIds += " " + this.behaviorCommands.reload.render;
     }
   }
   jsf.ajax.request(
-      action,
+      elementId,
       null,
       {
         "javax.faces.behavior.event": "reload",
@@ -459,7 +460,7 @@ Tobago.Sheet.hideInputOrSubmit = function(input) {
   var sheetId = input.parents(".tobago-sheet:first").attr("id");
   output.html(input.val());
   if (changed) {
-    Tobago.Sheets.get(sheetId).reloadWithAction(input.get(0), input.attr("id"));
+    Tobago.Sheets.get(sheetId).reloadWithAction(input.attr("id"));
   } else {
     console.info("no update needed"); // @DEV_ONLY
     input.hide();
@@ -510,7 +511,7 @@ Tobago.Sheet.prototype.initReload = function() {
   var $sheet = jQuery(Tobago.Utils.escapeClientId(this.id));
   var reload = $sheet.data("tobago-reload");
   if (typeof reload === "number") {
-    Tobago.addReloadTimeout(this.id, Tobago.bind2(this, "reloadWithAction", null, this.id), reload);
+    Tobago.addReloadTimeout(this.id, Tobago.Sheet.reloadWithAction, reload);
   }
 };
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js
index 5d50596..2774715 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago.js
@@ -365,7 +365,7 @@ var Tobago = {
 
   addReloadTimeout: function(id, func, time) {
     Tobago.clearReloadTimer(id);
-    Tobago.reloadTimer[id] = setTimeout(func, time);
+    Tobago.reloadTimer[id] = setTimeout(function() {func(id)}, time);
   },
 
   initDom: function(elements) {
@@ -475,23 +475,6 @@ var Tobago = {
   },
 
   /**
-   * Create a HTML input element with given type, name and value.
-   */
-  createInput: function(type, name, value) {
-    var input = document.createElement('INPUT');
-    if (type) {
-      input.type = type;
-    }
-    if (name) {
-      input.name = name;
-    }
-    if (value) {
-      input.value = value;
-    }
-    return input;
-  },
-
-  /**
    * Clear the selection.
    */
   clearSelection: function() {
@@ -506,68 +489,6 @@ var Tobago = {
     }
   },
 
-  /**
-   * Returns a function which binds the named function 'func' of the object 'object'.
-   * additional arguments to bind function are added to the arguments at
-   * function call.
-   * E.g.:
-   * var f = Tobago.bind(Tobago, "setElementWidth");
-   * will bind Tobago.setElementWidth(...) to f(...)
-   * and
-   * var f = Tobago.bind(Tobago, "setElementWidth", id, width);
-   * will bind Tobago.setElementWidth(id, widt) to f()
-   * and
-   * var f = Tobago.bind(Tobago, "setElementWidth", width);
-   * will bind Tobago.setElementWidth(id, width) to f(id)
-   *
-   */
-  /* XXX please remove */
-  bind2: function(object, func) {
-    var rest = [];
-    for (var i = 2; i < arguments.length; i++) {
-      rest.push(arguments[i]);
-    }
-    return function() {
-      for (var i = 0; i < arguments.length; i++) {
-        rest.push(arguments[i]);
-      }
-      object[func].apply(object, rest);
-    };
-  },
-
-  /**
-   * Stop event bubbling
-   */
-  stopEventPropagation: function(event) {
-    event.cancelBubble = true;  // this is IE, no matter if not supported by actual browser
-    if (event.stopPropagation) {
-      event.stopPropagation(); // this is DOM2
-    }
-    if (event.preventDefault) {
-      event.preventDefault();
-    } else {
-      event.returnValue = false;
-    }
-  },
-
-  /**
-   * Returns the absolute top value, related to the body element, for an HTML element.
-   */
-  getAbsoluteTop: function(element) {
-    var top = 0;
-    var parent = false;
-    while (element && element.offsetParent) {
-      top += element.offsetTop;
-      top -= element.scrollTop;
-      if (parent && element.currentStyle) { // IE only
-        top += element.currentStyle.borderTopWidth.replace(/\D/g, '') - 0;
-      }
-      element = element.offsetParent;
-      parent = true;
-    }
-    return Math.max(top, 0);
-  },
-
   extend: function(target, source) {
     for (var property in source) {
       target[property] = source[property];