myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hno...@apache.org
Subject [myfaces-tobago] 02/06: tobago-dropdown: custom elements, remove jQuery
Date Mon, 02 Mar 2020 08:23:23 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit fadb65946d6748fc430a0484cffd56478c613d0b
Author: Henning Noeth <hnoeth@apache.org>
AuthorDate: Wed Feb 26 15:55:44 2020 +0100

    tobago-dropdown: custom elements, remove jQuery
    
    * add events
    
    issue: TOBAGO-1633: TS refactoring
---
 .../tobago-theme-standard/src/main/npm/ts/tobago-dropdown.ts | 12 ++++++++++++
 1 file changed, 12 insertions(+)

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 f026821..9e4f1be 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
@@ -17,6 +17,13 @@
 
 import Popper from "popper.js";
 
+const Event = {
+  HIDE: "tobago.dropdown.hide",
+  HIDDEN: "tobago.dropdown.hidden",
+  SHOW: "tobago.dropdown.show",
+  SHOWN: "tobago.dropdown.shown"
+};
+
 class Dropdown extends HTMLElement {
 
   private dropdownEntries: DropdownEntry[] = [];
@@ -107,6 +114,8 @@ class Dropdown extends HTMLElement {
   }
 
   openDropdown(): void {
+    this.dispatchEvent(new CustomEvent(Event.HIDE));
+
     if (!this.inStickyHeader()) {
       this.menuStore.appendChild(this.dropdownMenu);
       new Popper(this.toggleButton, this.dropdownMenu, {
@@ -119,11 +128,14 @@ class Dropdown extends HTMLElement {
     }
 
     this.dropdownMenu.classList.add("show");
+    this.dispatchEvent(new CustomEvent(Event.HIDDEN));
   }
 
   closeDropdown(): void {
+    this.dispatchEvent(new CustomEvent(Event.SHOW));
     this.dropdownMenu.classList.remove("show");
     this.appendChild(this.dropdownMenu);
+    this.dispatchEvent(new CustomEvent(Event.SHOWN));
   }
 
   private get toggleButton(): HTMLElement {


Mime
View raw message