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 2019/06/13 14:19:04 UTC

[myfaces-tobago] branch master updated: TOBAGO-1633: TS refactoring: clean up

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


The following commit(s) were added to refs/heads/master by this push:
     new 46222da  TOBAGO-1633: TS refactoring: clean up
46222da is described below

commit 46222da8e92c6c6844c3b6692ba1a38c3961056c
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Jun 13 16:13:15 2019 +0200

    TOBAGO-1633: TS refactoring: clean up
---
 .../src/main/npm/ts/tobago-core.ts                  | 21 +--------------------
 .../src/main/npm/ts/tobago-dropdown.ts              |  2 +-
 .../src/main/npm/ts/tobago-focus.ts                 |  2 +-
 .../src/main/npm/ts/tobago-sheet.ts                 | 10 +++++-----
 .../src/main/npm/ts/tobago-utils.ts                 | 13 +++++++++++++
 5 files changed, 21 insertions(+), 27 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts
index 3e0428c..820d802 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-core.ts
@@ -35,18 +35,6 @@ export class Tobago {
 
 export class Tobago4 {
 
-  // -------- Constants -------------------------------------------------------
-
-  /**
-   * JSF's component separator constant
-   */
-  static readonly COMPONENT_SEP = ':';
-
-  /**
-   * Tobago's sub-coponent separator constant
-   */
-  static readonly SUB_COMPONENT_SEP = '::';
-
   // -------- Variables -------------------------------------------------------
 
   /**
@@ -62,20 +50,13 @@ export class Tobago4 {
   // -------- Functions -------------------------------------------------------
 
   /**
-   * Find a sub-element of the page. Like the form with id e.g. page::form
-   * @param suffix
-   */
-  static findSubElementOfPage = function (suffix) {
-    return jQuery(DomUtils.escapeClientId(DomUtils.page().id + Tobago4.SUB_COMPONENT_SEP + suffix));
-  };
-
-  /**
    * Tobago's central init function.
    * Called when the document (DOM) is ready
    */
   static init = function () {
 
     if (Tobago4.initMarker) {
+      console.warn("Tobago is already initialized!");
       return;
     }
     Tobago4.initMarker = true;
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-dropdown.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-dropdown.ts
index e9ad6f3..e107342 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-dropdown.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-dropdown.ts
@@ -42,7 +42,7 @@ class Dropdown {
         });
       }
     });
-  };
+  }
 }
 
 function removeDuplicates($dropdownMenu) {
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-focus.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-focus.ts
index 15e5350..c406aa5 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-focus.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-focus.ts
@@ -22,7 +22,7 @@ import {Listener, Phase} from "./tobago-listener";
 export class Focus {
 
   private static getHidden(): HTMLInputElement {
-    return <HTMLInputElement>document.getElementById(DomUtils.page().id + Tobago4.SUB_COMPONENT_SEP + "lastFocusId");
+    return <HTMLInputElement>document.getElementById(DomUtils.page().id + DomUtils.SUB_COMPONENT_SEP + "lastFocusId");
   }
 
   static setLastFocusId(id: string): void {
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
index b332208..2045db9 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-sheet.ts
@@ -35,7 +35,7 @@ class Sheet {
   mousedownOnRowData: any;
 
   loadColumnWidths(): number[] {
-    const hidden = document.getElementById(this.id + Tobago4.SUB_COMPONENT_SEP + "widths");
+    const hidden = document.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "widths");
     if (hidden) {
       return JSON.parse(hidden.getAttribute("value"));
     } else {
@@ -44,7 +44,7 @@ class Sheet {
   }
 
   saveColumnWidths(widths: number[]) {
-    const hidden = document.getElementById(this.id + Tobago4.SUB_COMPONENT_SEP + "widths");
+    const hidden = document.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "widths");
     if (hidden) {
       hidden.setAttribute("value", JSON.stringify(widths));
     } else {
@@ -57,7 +57,7 @@ class Sheet {
   }
 
   isColumnRendered(): boolean[] {
-    const hidden = document.getElementById(this.id + Tobago4.SUB_COMPONENT_SEP + "rendered");
+    const hidden = document.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "rendered");
     return JSON.parse(hidden.getAttribute("value"));
   };
 
@@ -485,11 +485,11 @@ class Sheet {
   };
 
   getHiddenSelected(): HTMLInputElement {
-    return <HTMLInputElement>document.getElementById(this.id + Tobago4.SUB_COMPONENT_SEP + "selected");
+    return <HTMLInputElement>document.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "selected");
   };
 
   getHiddenScrollPosition() {
-    return document.getElementById(this.id + Tobago4.SUB_COMPONENT_SEP + "scrollPosition");
+    return document.getElementById(this.id + DomUtils.SUB_COMPONENT_SEP + "scrollPosition");
   };
 
   static getScrollBarSize() {
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts
index 7b6d2bb..c933f60 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-utils.ts
@@ -17,6 +17,19 @@
 
 export class DomUtils {
 
+  /**
+   * JSF's component separator constant
+   */
+  static readonly COMPONENT_SEP = ':';
+
+  /**
+   * Tobago's sub-coponent separator constant
+   */
+  static readonly SUB_COMPONENT_SEP = '::';
+
+  /**
+   * The Tobago root element
+   */
   static page(): HTMLElement {
     const pages = document.getElementsByClassName("tobago-page");
     if (pages.length > 0) {