comand-component-library 4.0.73 → 4.0.75
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/comand-component-library.js +8488 -5330
- package/dist/comand-component-library.umd.cjs +15 -7
- package/dist/style.css +1 -1
- package/package.json +2 -2
- package/src/components/CmdBasicForm.vue +4 -2
- package/src/components/CmdForm.vue +27 -19
- package/src/components/CmdMainNavigation.vue +2 -2
- package/src/components/CmdSiteSearch.vue +1 -0
- package/src/components/CmdToggleDarkMode.vue +2 -0
- package/src/components/CmdUploadForm.vue +1 -0
- package/src/directives/fancybox.js +45 -40
@@ -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",
|
@@ -1,49 +1,54 @@
|
|
1
|
-
import {openFancyBox} from "
|
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].
|
5
|
-
|
6
|
-
|
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
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
+
}
|