@leapdev/gui 0.2.234 → 0.2.235
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.
- package/dist/scss/xsf-crx/sf-leap.js +103 -2
- package/package.json +1 -1
|
@@ -10,6 +10,55 @@
|
|
|
10
10
|
return getChildren(n.parentNode.firstChild, n);
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
var getClosestParent = function (elem, selector) {
|
|
14
|
+
if (!Element.prototype.matches) {
|
|
15
|
+
Element.prototype.matches =
|
|
16
|
+
Element.prototype.matchesSelector ||
|
|
17
|
+
Element.prototype.mozMatchesSelector ||
|
|
18
|
+
Element.prototype.msMatchesSelector ||
|
|
19
|
+
Element.prototype.oMatchesSelector ||
|
|
20
|
+
Element.prototype.webkitMatchesSelector ||
|
|
21
|
+
function (s) {
|
|
22
|
+
const matches = (this.document || this.ownerDocument).querySelectorAll(s),
|
|
23
|
+
i = matches.length;
|
|
24
|
+
while (--i >= 0 && matches.item(i) !== this) { }
|
|
25
|
+
return i > -1;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Get the closest matching element
|
|
30
|
+
for (; elem && elem !== document; elem = elem.parentNode) {
|
|
31
|
+
if (elem.matches(selector)) return elem;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// For Version 1 the order of Hash appendages is Tab -> Accordion -> Subaccordion
|
|
37
|
+
var appendHash = function (str) {
|
|
38
|
+
window.location.hash = (() => {
|
|
39
|
+
const lowercasedStr = str.toLowerCase();
|
|
40
|
+
return lowercasedStr.split(' ').join('-');
|
|
41
|
+
})();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
var getDeviceType = function () {
|
|
45
|
+
const ua = navigator.userAgent;
|
|
46
|
+
const isiOS = () => {
|
|
47
|
+
return /iPad|iPhone/.test(ua) || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
|
|
48
|
+
};
|
|
49
|
+
const isAndroid = () => { return /android/i.test(ua); };
|
|
50
|
+
|
|
51
|
+
if (isAndroid()) {
|
|
52
|
+
return 'android';
|
|
53
|
+
}
|
|
54
|
+
else if (isiOS()) {
|
|
55
|
+
if (/iPad/.test(ua)) { return 'ipad'; }
|
|
56
|
+
else if (/iPhone/.test(ua)) { return 'iphone'; }
|
|
57
|
+
else { return 'ios'; }
|
|
58
|
+
}
|
|
59
|
+
return;
|
|
60
|
+
};
|
|
61
|
+
|
|
13
62
|
document.addEventListener('click', function (event) {
|
|
14
63
|
var
|
|
15
64
|
targetElem = event.target,
|
|
@@ -33,15 +82,18 @@
|
|
|
33
82
|
activeTabBtn.classList.add('active');
|
|
34
83
|
targetTab.classList.add('in');
|
|
35
84
|
|
|
36
|
-
|
|
85
|
+
appendHash(targetElem.textContent);
|
|
86
|
+
|
|
87
|
+
activeBtnTabSiblings.forEach(function (element) {
|
|
37
88
|
if (element.classList.value.indexOf('active') !== -1) element.classList.remove('active');
|
|
38
89
|
});
|
|
39
|
-
targetTabSiblings.forEach(function (element
|
|
90
|
+
targetTabSiblings.forEach(function (element) {
|
|
40
91
|
if (element.classList.value.indexOf('in') !== -1) element.classList.remove('in');
|
|
41
92
|
});
|
|
42
93
|
}
|
|
43
94
|
|
|
44
95
|
if (className.value.indexOf('sf-accordion-toggle') !== -1) {
|
|
96
|
+
appendHash(targetElem.querySelector('.sf-accordion-text').textContent);
|
|
45
97
|
className.value.indexOf('in') == -1 ?
|
|
46
98
|
className.add('in') : className.remove('in');
|
|
47
99
|
}
|
|
@@ -49,4 +101,53 @@
|
|
|
49
101
|
return false;
|
|
50
102
|
}, false);
|
|
51
103
|
|
|
104
|
+
// Set default tab via URL hash or device type if present on tabs
|
|
105
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
106
|
+
const tabs = document.querySelectorAll('.sf-tabs');
|
|
107
|
+
const accordion = document.querySelectorAll('.sf-accordion-toggle');
|
|
108
|
+
const urlHashList = window.location.hash !== '' ? window.location.hash.substring(1).split('#') : undefined;
|
|
109
|
+
|
|
110
|
+
const openParent = (childElement) => {
|
|
111
|
+
const closestTab = getClosestParent(childElement, '.sf-tab-content');
|
|
112
|
+
const closestAccordion = getClosestParent(childElement, '.sf-accordion-content');
|
|
113
|
+
|
|
114
|
+
if (closestTab !== null) {
|
|
115
|
+
document.getElementById(`target_${closestTab.id}`).click();
|
|
116
|
+
}
|
|
117
|
+
if (closestAccordion !== null) {
|
|
118
|
+
document.getElementById(`target_${closestAccordion.id}`).click();
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (tabs.length !== 0) {
|
|
123
|
+
tabs.forEach(tab => {
|
|
124
|
+
const deviceType = getDeviceType();
|
|
125
|
+
tab.querySelectorAll('.sf-tab-item-link').forEach(tabitem => {
|
|
126
|
+
const tabItemText = tabitem.textContent.toLowerCase().replace(/\s/g, '');
|
|
127
|
+
|
|
128
|
+
if (tabItemText === deviceType && typeof (urlHashList) === 'undefined') {
|
|
129
|
+
tabitem.click();
|
|
130
|
+
}
|
|
131
|
+
else if (typeof (urlHashList) !== 'undefined' && urlHashList.includes(tabItemText)) {
|
|
132
|
+
openParent(tabitem);
|
|
133
|
+
tabitem.click();
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (accordion.length !== 0) {
|
|
140
|
+
accordion.forEach(accordionToggle => {
|
|
141
|
+
const accordionText = accordionToggle
|
|
142
|
+
.querySelector('.sf-accordion-text')
|
|
143
|
+
.textContent.split(' ').join('-').toLowerCase();
|
|
144
|
+
|
|
145
|
+
if (typeof (urlHashList) !== 'undefined' && urlHashList.includes(accordionText)) {
|
|
146
|
+
openParent(accordionToggle);
|
|
147
|
+
accordionToggle.click();
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
52
153
|
})();
|