comand-component-library 4.0.73 → 4.0.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,6 +87,7 @@ export default {
87
87
  * (styledAsButton-property must be activated)
88
88
  */
89
89
  iconDarkMode: {
90
+ type: Object,
90
91
  default() {
91
92
  return {
92
93
  iconClass: "icon-moon",
@@ -100,6 +101,7 @@ export default {
100
101
  * (styledAsButton-property must be activated)
101
102
  */
102
103
  iconLightMode: {
104
+ type: Object,
103
105
  default() {
104
106
  return {
105
107
  iconClass: "icon-sun",
@@ -488,6 +488,7 @@ export default {
488
488
  * @requiredForAccessiblity: true
489
489
  */
490
490
  legend: {
491
+ type: Object,
491
492
  default() {
492
493
  return {
493
494
  show: true,
@@ -1,49 +1,54 @@
1
- import {openFancyBox} from "../components/CmdFancyBox.vue"
1
+ import {openFancyBox} from "comand-component-library"
2
+
2
3
  function addClickHandlerToFancyboxLinks(fancyboxLinks) {
3
4
  for(let i = 0; i < fancyboxLinks.length; i++) {
4
- fancyboxLinks[i].addEventListener("click", (event) => {
5
- event.preventDefault()
6
- openFancyBox({url: fancyboxLinks[i].href})
7
- })
5
+ if (!fancyboxLinks[i].dataset.cmdFancyBoxHandlerRegistered) {
6
+ fancyboxLinks[i].addEventListener("click", (event) => {
7
+ event.preventDefault()
8
+ openFancyBox({url: fancyboxLinks[i].href})
9
+ })
10
+ fancyboxLinks[i].dataset.cmdFancyBoxHandlerRegistered = "true"
11
+ }
8
12
  }
9
13
  }
10
14
 
11
- export default {
12
- // el = real dom-element
13
- mounted(el) {
14
- // get initially loaded elements
15
- const fancyboxLinks = el.querySelectorAll(".fancybox")
16
- addClickHandlerToFancyboxLinks(fancyboxLinks)
17
-
18
- // get elements added later to dom (and watched by mutationObserver)
19
- const observer = new MutationObserver((mutationList) => {
20
- const targetElements = []
15
+ const observer = new MutationObserver(onDomChange)
21
16
 
22
- for(let i = 0; i < mutationList.length; i++) {
23
- if (mutationList[i].type === "attributes") {
24
- if(mutationList[i].target.classList.contains("fancybox")) {
25
- targetElements.push(mutationList[i].target)
26
- }
27
- } else if (mutationList[i].type === "childList") {
28
- let childNodes = Array.from(mutationList[i].addedNodes).filter((node) => {
29
- if(node.classList) {
30
- return node.classList.contains("fancybox")
31
- }
32
- return false
33
- })
34
- if(childNodes.length) {
35
- targetElements.push(...childNodes)
36
- }
17
+ function onDomChange(mutationList) {
18
+ const targetElements = []
19
+ for(let i = 0; i < mutationList.length; i++) {
20
+ if (mutationList[i].type === "attributes") {
21
+ if(mutationList[i].target.classList.contains("fancybox")) {
22
+ targetElements.push(mutationList[i].target)
23
+ }
24
+ } else if (mutationList[i].type === "childList") {
25
+ let childNodes = Array.from(mutationList[i].addedNodes).filter((node) => {
26
+ if(node.classList) {
27
+ return node.classList.contains("fancybox")
37
28
  }
29
+ return false
30
+ });
31
+ if(childNodes.length) {
32
+ targetElements.push(...childNodes)
38
33
  }
39
- addClickHandlerToFancyboxLinks(targetElements)
40
- })
41
-
42
- observer.observe(el, {
43
- subtree: true, // observe nested elements
44
- childList: true,
45
- attributeFilter: ["class"], // set filter
46
- characterData: false // observe text changes
47
- })
34
+ }
35
+ }
36
+ if (targetElements.length > 0) {
37
+ addClickHandlerToFancyboxLinks(targetElements)
48
38
  }
49
- }
39
+ }
40
+
41
+ export default el => {
42
+ // get initially loaded elements
43
+ const fancyboxLinks = el.querySelectorAll(".fancybox")
44
+ addClickHandlerToFancyboxLinks(fancyboxLinks)
45
+
46
+ observer?.disconnect()
47
+ observer.observe(el, {
48
+ subtree: true, // observe nested elements
49
+ childList: true,
50
+ attributes: true,
51
+ attributeFilter: ["class"], // set filter
52
+ characterData: false
53
+ })
54
+ }