@leapdev/gui 0.2.239 → 0.2.242
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 +224 -75
- package/package.json +1 -1
|
@@ -1,16 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (n.nodeType == 1 && n != skipMe) r.push(n);
|
|
6
|
-
return r;
|
|
7
|
-
};
|
|
1
|
+
// Mutation Observer for Accordion and Tabs
|
|
2
|
+
//https://gist.github.com/matthewmorrone/da487467501e8b815430
|
|
3
|
+
(function (win) {
|
|
4
|
+
'use strict';
|
|
8
5
|
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
var listeners = [],
|
|
7
|
+
doc = win.document,
|
|
8
|
+
MutationObserver = win.MutationObserver || win.WebKitMutationObserver,
|
|
9
|
+
observer;
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
function ready(selector, fn) {
|
|
12
|
+
// Store the selector and callback to be monitored
|
|
13
|
+
listeners.push({
|
|
14
|
+
selector: selector,
|
|
15
|
+
fn: fn
|
|
16
|
+
});
|
|
17
|
+
if (!observer) {
|
|
18
|
+
// Watch for changes in the document
|
|
19
|
+
observer = new MutationObserver(check);
|
|
20
|
+
observer.observe(doc.documentElement, {
|
|
21
|
+
childList: true,
|
|
22
|
+
subtree: true
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// Check if the element is currently in the DOM
|
|
26
|
+
check();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function check() {
|
|
30
|
+
// Check the DOM for elements matching a stored selector
|
|
31
|
+
for (var i = 0, len = listeners.length, listener, elements; i < len; i++) {
|
|
32
|
+
listener = listeners[i];
|
|
33
|
+
// Query for elements matching the specified selector
|
|
34
|
+
elements = doc.querySelectorAll(listener.selector);
|
|
35
|
+
for (var j = 0, jLen = elements.length, element; j < jLen; j++) {
|
|
36
|
+
element = elements[j];
|
|
37
|
+
// Make sure the callback isn't invoked with the
|
|
38
|
+
// same element more than once
|
|
39
|
+
if (!element.ready) {
|
|
40
|
+
element.ready = true;
|
|
41
|
+
// Invoke the callback with the element
|
|
42
|
+
listener.fn.call(element, element);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Expose `ready`
|
|
48
|
+
win.ready = ready;
|
|
49
|
+
})(this);
|
|
50
|
+
|
|
51
|
+
//LEAP Help Centre JS for Components generated via Chrome Extension
|
|
52
|
+
(function () {
|
|
53
|
+
const getClosestParent = function (elem, selector) {
|
|
14
54
|
if (!Element.prototype.matches) {
|
|
15
55
|
Element.prototype.matches =
|
|
16
56
|
Element.prototype.matchesSelector ||
|
|
@@ -33,15 +73,18 @@
|
|
|
33
73
|
return null;
|
|
34
74
|
};
|
|
35
75
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
76
|
+
const getChildren = function (n, skipMe) {
|
|
77
|
+
let r = [];
|
|
78
|
+
for (; n; n = n.nextSibling)
|
|
79
|
+
if (n.nodeType == 1 && n != skipMe) r.push(n);
|
|
80
|
+
return r;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const getSiblings = function (n) {
|
|
84
|
+
return getChildren(n.parentNode.firstChild, n);
|
|
42
85
|
};
|
|
43
86
|
|
|
44
|
-
|
|
87
|
+
const getDeviceType = function () {
|
|
45
88
|
const ua = navigator.userAgent;
|
|
46
89
|
const isiOS = () => {
|
|
47
90
|
return /iPad|iPhone/.test(ua) || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
|
|
@@ -59,14 +102,166 @@
|
|
|
59
102
|
return;
|
|
60
103
|
};
|
|
61
104
|
|
|
105
|
+
// #@desktop:accordion-2;sub-accordion-1@parent-accordion-1
|
|
106
|
+
// Set default tab via URL hash parameters or device type if present on tabs
|
|
107
|
+
const urlHash = {
|
|
108
|
+
topicsTabAccordion: {},
|
|
109
|
+
articleTabsInit: false,
|
|
110
|
+
articleAccordionInit: false,
|
|
111
|
+
deviceType: getDeviceType(),
|
|
112
|
+
list: window.location.hash,
|
|
113
|
+
init: function () {
|
|
114
|
+
urlHash.openedTopics = window.location.hash.substring(1).split('@').splice(1);
|
|
115
|
+
|
|
116
|
+
ready('.sf-tabs', function () {
|
|
117
|
+
if (!urlHash.articleTabsInit) {
|
|
118
|
+
|
|
119
|
+
const toggleTabs = (params) => {
|
|
120
|
+
// Remove existing active CSS classes
|
|
121
|
+
const currentTabContentID = params.tabNav.querySelector('.sf-tab-item.active').firstElementChild.id.substring(7);
|
|
122
|
+
params.tabNav.querySelector('.sf-tab-item.active').classList.remove('active');
|
|
123
|
+
document.getElementById(currentTabContentID).classList.remove('in');
|
|
124
|
+
|
|
125
|
+
//Update tab according to device with active and in css class
|
|
126
|
+
params.targetTabLink.parentNode.classList.add('active');
|
|
127
|
+
document.getElementById(params.targetTabLink.id.substring(7)).classList.add('in');
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
document.querySelectorAll('.sf-tabs').forEach(tab => {
|
|
131
|
+
tab.querySelectorAll('.sf-tab-item-link').forEach(tabitem => {
|
|
132
|
+
const tabItemText = tabitem.textContent.toLowerCase().replace(/\s/g, '');
|
|
133
|
+
|
|
134
|
+
const _closestParent = urlHash.closestParent(tabitem);
|
|
135
|
+
|
|
136
|
+
urlHash.topicsTabAccordion[tabitem.id] = {
|
|
137
|
+
text: tabItemText,
|
|
138
|
+
isMainParent: _closestParent.flag,
|
|
139
|
+
parentLabel: _closestParent.parentLabel,
|
|
140
|
+
directParentID: _closestParent.directParentID
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// If URL hash is not present, we locate the name of the device tab
|
|
144
|
+
const sfTabNav = tabitem.parentNode.parentNode;
|
|
145
|
+
if (tabItemText === urlHash.deviceType && urlHash.list === '') {
|
|
146
|
+
if (sfTabNav.querySelector('.sf-tab-item.active').classList.contains('active')) {
|
|
147
|
+
toggleTabs({
|
|
148
|
+
targetTabLink: tabitem,
|
|
149
|
+
tabNav: sfTabNav
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (urlHash.list !== '' && urlHash.list.search(tabItemText) > -1) {
|
|
155
|
+
Object.keys(urlHash.topicsTabAccordion).forEach(key => {
|
|
156
|
+
if (tabItemText == urlHash.topicsTabAccordion[key].text) {
|
|
157
|
+
toggleTabs({
|
|
158
|
+
targetTabLink: tabitem,
|
|
159
|
+
tabNav: sfTabNav
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
urlHash.articleTabsInit = true;
|
|
168
|
+
console.log(urlHash.topicsTabAccordion);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
ready('.sf-accordion', function () {
|
|
173
|
+
if (!urlHash.articleAccordionInit) {
|
|
174
|
+
const urlHashList = window.location.hash;
|
|
175
|
+
document.querySelectorAll('.sf-accordion-toggle').forEach(accordionToggle => {
|
|
176
|
+
const accordionText = accordionToggle
|
|
177
|
+
.querySelector('.sf-accordion-text')
|
|
178
|
+
.textContent.split(' ').join('-').toLowerCase();
|
|
179
|
+
|
|
180
|
+
const _closestParent = urlHash.closestParent(accordionToggle);
|
|
181
|
+
|
|
182
|
+
urlHash.topicsTabAccordion[accordionToggle.id] = {
|
|
183
|
+
text: accordionText,
|
|
184
|
+
isMainParent: _closestParent.flag,
|
|
185
|
+
parentLabel: _closestParent.parentLabel
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
if (urlHashList !== '' && urlHash.list.split(':')[1] === accordionText) {
|
|
189
|
+
Object.keys(urlHash.topicsTabAccordion).forEach(key => {
|
|
190
|
+
if (accordionText == urlHash.topicsTabAccordion[key].text) {
|
|
191
|
+
document.getElementById(key).classList.add('in');
|
|
192
|
+
|
|
193
|
+
const hasAccordionParent = getClosestParent(accordionToggle, '.sf-accordion-content');
|
|
194
|
+
if (hasAccordionParent !== null) {
|
|
195
|
+
document.getElementById(`target_${hasAccordionParent.id}`).classList.add('in');
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
urlHash.articleAccordionInit = true;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
if (window.location.pathname.includes('/article')) {
|
|
208
|
+
urlHash.observe();
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
observe: function () {
|
|
212
|
+
const previousState = window.history.state;
|
|
213
|
+
let t = setInterval(function () {
|
|
214
|
+
if (previousState !== window.history.state) {
|
|
215
|
+
previousState = window.history.state;
|
|
216
|
+
clearInterval(t);
|
|
217
|
+
urlHash.reset();
|
|
218
|
+
}
|
|
219
|
+
}, 100);
|
|
220
|
+
},
|
|
221
|
+
closestParent: function (child) {
|
|
222
|
+
const tabContent = getClosestParent(child, '.sf-tab-content');
|
|
223
|
+
const accordionContent = getClosestParent(child, '.sf-accordion-content');
|
|
224
|
+
const parentLabel = () => {
|
|
225
|
+
if (tabContent !== null) {
|
|
226
|
+
return document.getElementById(`target_${tabContent.id}`).textContent;
|
|
227
|
+
}
|
|
228
|
+
else if (accordionContent !== null) {
|
|
229
|
+
return document.getElementById(`target_${accordionContent.id}`).querySelector('.sf-accordion-text').textContent;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return '';
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
// console.log(tabContent, accordionContent);
|
|
236
|
+
return {
|
|
237
|
+
parentLabel: parentLabel().split(' ').join('-').toLowerCase(),
|
|
238
|
+
flag: tabContent !== null || accordionContent !== null ? false : true,
|
|
239
|
+
directParentID: 'test'
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
setItem: function (id) {
|
|
243
|
+
const childText = urlHash.topicsTabAccordion[id].isMainParent ? '' : (':' + urlHash.topicsTabAccordion[id].text);
|
|
244
|
+
const parentText = urlHash.topicsTabAccordion[id].isMainParent ? urlHash.topicsTabAccordion[id].text : urlHash.topicsTabAccordion[id].parentLabel;
|
|
245
|
+
return `@${parentText}${childText}`;
|
|
246
|
+
},
|
|
247
|
+
reset: function () {
|
|
248
|
+
urlHash.topicsTabAccordion = {};
|
|
249
|
+
urlHash.articleTabsInit = false;
|
|
250
|
+
urlHash.articleAccordionInit = false;
|
|
251
|
+
urlHash.init();
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
urlHash.init();
|
|
256
|
+
// Tab and Accordion Toggling
|
|
62
257
|
document.addEventListener('click', function (event) {
|
|
63
|
-
|
|
258
|
+
const
|
|
64
259
|
targetElem = event.target,
|
|
65
260
|
className = targetElem.classList;
|
|
66
261
|
|
|
67
262
|
if (className.value.indexOf('sf-tab-item-link') !== -1) {
|
|
68
263
|
event.preventDefault();
|
|
69
|
-
|
|
264
|
+
let targetID,
|
|
70
265
|
activeTabBtn,
|
|
71
266
|
targetTab,
|
|
72
267
|
targetTabSiblings,
|
|
@@ -82,8 +277,6 @@
|
|
|
82
277
|
activeTabBtn.classList.add('active');
|
|
83
278
|
targetTab.classList.add('in');
|
|
84
279
|
|
|
85
|
-
appendHash(targetElem.textContent);
|
|
86
|
-
|
|
87
280
|
activeBtnTabSiblings.forEach(function (element) {
|
|
88
281
|
if (element.classList.value.indexOf('active') !== -1) element.classList.remove('active');
|
|
89
282
|
});
|
|
@@ -93,61 +286,17 @@
|
|
|
93
286
|
}
|
|
94
287
|
|
|
95
288
|
if (className.value.indexOf('sf-accordion-toggle') !== -1) {
|
|
96
|
-
|
|
97
|
-
className.value.indexOf('in') == -1 ?
|
|
98
|
-
className.add('in') : className.remove('in');
|
|
289
|
+
className.value.indexOf('in') == -1 ? className.add('in') : className.remove('in');
|
|
99
290
|
}
|
|
100
291
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
-
});
|
|
292
|
+
if (
|
|
293
|
+
className.value.indexOf('sf-tab-item-link') !== -1 ||
|
|
294
|
+
className.value.indexOf('sf-accordion-toggle') !== -1
|
|
295
|
+
) {
|
|
296
|
+
// console.log(urlHash.topicsTabAccordion);
|
|
297
|
+
window.location.hash = urlHash.setItem(targetElem.id);
|
|
150
298
|
}
|
|
151
|
-
});
|
|
152
299
|
|
|
300
|
+
return false;
|
|
301
|
+
}, false);
|
|
153
302
|
})();
|