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/08/08 13:02:01 UTC

[myfaces-tobago] branch master updated: clean up setup

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 cdeb89c  clean up setup
cdeb89c is described below

commit cdeb89c4c3894168f9e3f23a9613e28ba95e894a
Author: Udo Schnurpfeil <lo...@apache.org>
AuthorDate: Thu Aug 8 15:01:51 2019 +0200

    clean up setup
    
    issue: TOBAGO-1633: TS refactoring
---
 .../src/main/npm/ts/declare.d.ts                   |  1 -
 .../src/main/npm/ts/tobago-command.ts              |  4 +-
 .../src/main/npm/ts/tobago-core.ts                 | 64 ++++++----------------
 .../src/main/npm/ts/tobago-focus.ts                |  1 -
 .../src/main/npm/ts/tobago-listener.ts             |  1 -
 .../src/main/npm/ts/tobago-sheet.ts                |  1 -
 6 files changed, 20 insertions(+), 52 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/declare.d.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/declare.d.ts
index b3dbf5d..11457f4 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/declare.d.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/declare.d.ts
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-declare var Tobago4;
 declare var moment;
 declare var jsf;
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts
index 7724cf5..b66d8c4 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-command.ts
@@ -19,7 +19,7 @@ import {Listener, Order, Phase} from "./tobago-listener";
 import {Overlay} from "./tobago-overlay";
 import {DomUtils, Tobago4Utils} from "./tobago-utils";
 import {Collapse, Popup} from "./tobago-popup";
-import {Tobago4} from "./tobago-core";
+import {Setup} from "./tobago-core";
 
 export class CommandMap {
 
@@ -313,7 +313,7 @@ export class Command {
     */
     Command.isSubmit = true;
 
-    Tobago4.onBeforeUnload();
+    Setup.onBeforeUnload();
 
     return true;
   };
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 b664e9e..a81648d 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
@@ -15,11 +15,14 @@
  * limitations under the License.
  */
 
-import {Listener, Phase, Order} from "./tobago-listener";
+import {Listener} from "./tobago-listener";
 import {Overlay} from "./tobago-overlay";
-import {DomUtils, Tobago4Utils} from "./tobago-utils";
+import {DomUtils} from "./tobago-utils";
 import {Command} from "./tobago-command";
 
+/**
+ * @deprecated since 5.0.0
+ */
 export class Tobago {
   /**
    * Backward compatible listener registration. In the case of an AJAX call (phase = Phase.AFTER_UPDATE)
@@ -34,73 +37,42 @@ export class Tobago {
   }
 }
 
-export class Tobago4 {
-
-  // -------- Variables -------------------------------------------------------
-
-  static initMarker = false;
-
-  // -------- Functions -------------------------------------------------------
-
-  /**
-   * Tobago's central init function.
-   * Called when the document (DOM) is ready
-   */
-  static init = function () {
+export class Setup {
 
-    if (Tobago4.initMarker) {
-      console.warn("Tobago is already initialized!");
-      return;
-    }
-    Tobago4.initMarker = true;
+  static transition: boolean;
+  static oldTransition: boolean;
 
+  static init = function() {
     console.time("[tobago] init");
-
     document.querySelector("form").addEventListener('submit', Command.onSubmit);
-
-    window.addEventListener('unload', Tobago4.onUnload);
-
+    window.addEventListener('unload', Setup.onUnload);
     Listener.executeDocumentReady(document.documentElement);
-    /*
-        for (var order = 0; order < Listeners.documentReady.length; order++) {
-          var list = Listeners.documentReady[order];
-          for (var i = 0; i < list.length; i++) {
-            console.time("[tobago] init " + order + " " + i);
-            list[i]();
-            console.timeEnd("[tobago] init " + order + " " + i);
-          }
-        }
-    */
-
     console.timeEnd("[tobago] init");
   };
 
   static onBeforeUnload = function () {
-    if (this.transition) {
+    if (Setup.transition) {
       new Overlay(DomUtils.page());
     }
-    this.transition = this.oldTransition;
+    Setup.transition = Setup.oldTransition;
   };
 
   /**
    * Wrapper function to call application generated onunload function
    */
   static onUnload = function () {
-
     console.info('on onload');
-
     if (Command.isSubmit) {
-      Listener.executeBeforeUnload();
+      if (Setup.transition) {
+        new Overlay(DomUtils.page());
+      }
+      Setup.transition = Setup.oldTransition;
     } else {
       Listener.executeBeforeExit();
     }
   };
 }
 
-document.addEventListener('DOMContentLoaded', function () {
-  Tobago4.init();
-});
+document.addEventListener('DOMContentLoaded', Setup.init);
 
-window.addEventListener("load", function () {
-  Listener.executeWindowLoad();
-});
+window.addEventListener("load", Listener.executeWindowLoad);
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 b65585e..f6c19d5 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
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-import {Tobago4} from "./tobago-core";
 import {DomUtils} from "./tobago-utils";
 import {Listener, Phase} from "./tobago-listener";
 
diff --git a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-listener.ts b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-listener.ts
index 48b1e8d..7f7acd1 100644
--- a/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-listener.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/npm/ts/tobago-listener.ts
@@ -148,4 +148,3 @@ export class Listener {
     console.timeEnd("[tobago] execute beforeExit");
   }
 }
-
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 f20dac6..6a252b8 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
@@ -17,7 +17,6 @@
 
 import {Listener, Phase} from "./tobago-listener";
 import {DomUtils} from "./tobago-utils";
-import {Tobago4} from "./tobago-core";
 import {Command} from "./tobago-command";
 
 class Sheet {