@leapdev/gui 0.2.240 → 0.2.241
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 +137 -64
- package/package.json +1 -1
|
@@ -48,19 +48,11 @@
|
|
|
48
48
|
win.ready = ready;
|
|
49
49
|
})(this);
|
|
50
50
|
|
|
51
|
+
//LEAP Help Centre JS for Components generated via Chrome Extension
|
|
51
52
|
(function () {
|
|
52
|
-
|
|
53
|
-
var r = [];
|
|
54
|
-
for (; n; n = n.nextSibling)
|
|
55
|
-
if (n.nodeType == 1 && n != skipMe) r.push(n);
|
|
56
|
-
return r;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
var getSiblings = function (n) {
|
|
60
|
-
return getChildren(n.parentNode.firstChild, n);
|
|
61
|
-
};
|
|
53
|
+
const topicsTabAccordion = {};
|
|
62
54
|
|
|
63
|
-
|
|
55
|
+
const getClosestParent = function (elem, selector) {
|
|
64
56
|
if (!Element.prototype.matches) {
|
|
65
57
|
Element.prototype.matches =
|
|
66
58
|
Element.prototype.matchesSelector ||
|
|
@@ -83,15 +75,18 @@
|
|
|
83
75
|
return null;
|
|
84
76
|
};
|
|
85
77
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
const getChildren = function (n, skipMe) {
|
|
79
|
+
let r = [];
|
|
80
|
+
for (; n; n = n.nextSibling)
|
|
81
|
+
if (n.nodeType == 1 && n != skipMe) r.push(n);
|
|
82
|
+
return r;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const getSiblings = function (n) {
|
|
86
|
+
return getChildren(n.parentNode.firstChild, n);
|
|
92
87
|
};
|
|
93
88
|
|
|
94
|
-
|
|
89
|
+
const getDeviceType = function () {
|
|
95
90
|
const ua = navigator.userAgent;
|
|
96
91
|
const isiOS = () => {
|
|
97
92
|
return /iPad|iPhone/.test(ua) || navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1;
|
|
@@ -109,18 +104,28 @@
|
|
|
109
104
|
return;
|
|
110
105
|
};
|
|
111
106
|
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
// #@desktop:accordion-2;sub-accordion-1@parent-accordion-1
|
|
108
|
+
const urlHash = {
|
|
109
|
+
list: window.location.hash,
|
|
110
|
+
init: function () {
|
|
111
|
+
this.openedTopics = window.location.hash.substring(1).split('@').splice(1);
|
|
112
|
+
},
|
|
113
|
+
setItem: function (id) {
|
|
114
|
+
const childText = topicsTabAccordion[id].isMainParent ? '' : (':' + topicsTabAccordion[id].text);
|
|
115
|
+
const parentText = topicsTabAccordion[id].isMainParent ? topicsTabAccordion[id].text : topicsTabAccordion[id].parentLabel;
|
|
116
|
+
return `@${parentText}${childText}`;
|
|
117
|
+
}
|
|
114
118
|
};
|
|
115
119
|
|
|
120
|
+
// Tab and Accordion Toggling
|
|
116
121
|
document.addEventListener('click', function (event) {
|
|
117
|
-
|
|
122
|
+
const
|
|
118
123
|
targetElem = event.target,
|
|
119
124
|
className = targetElem.classList;
|
|
120
125
|
|
|
121
126
|
if (className.value.indexOf('sf-tab-item-link') !== -1) {
|
|
122
127
|
event.preventDefault();
|
|
123
|
-
|
|
128
|
+
let targetID,
|
|
124
129
|
activeTabBtn,
|
|
125
130
|
targetTab,
|
|
126
131
|
targetTabSiblings,
|
|
@@ -136,8 +141,6 @@
|
|
|
136
141
|
activeTabBtn.classList.add('active');
|
|
137
142
|
targetTab.classList.add('in');
|
|
138
143
|
|
|
139
|
-
appendHash(targetElem.textContent);
|
|
140
|
-
|
|
141
144
|
activeBtnTabSiblings.forEach(function (element) {
|
|
142
145
|
if (element.classList.value.indexOf('active') !== -1) element.classList.remove('active');
|
|
143
146
|
});
|
|
@@ -147,58 +150,128 @@
|
|
|
147
150
|
}
|
|
148
151
|
|
|
149
152
|
if (className.value.indexOf('sf-accordion-toggle') !== -1) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
className.value.indexOf('in') == -1 ? className.add('in') : className.remove('in');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (
|
|
157
|
+
className.value.indexOf('sf-tab-item-link') !== -1 ||
|
|
158
|
+
className.value.indexOf('sf-accordion-toggle') !== -1
|
|
159
|
+
) {
|
|
160
|
+
window.location.hash = urlHash.setItem(targetElem.id);
|
|
153
161
|
}
|
|
154
162
|
|
|
155
163
|
return false;
|
|
156
164
|
}, false);
|
|
157
165
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
// Set default tab via URL hash parameters or device type if present on tabs
|
|
167
|
+
let articleTabsInit = false;
|
|
168
|
+
let articleAccordionInit = false;
|
|
161
169
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
urlHash.init();
|
|
171
|
+
|
|
172
|
+
const closestParent = (child) => {
|
|
173
|
+
const tabContent = getClosestParent(child, '.sf-tab-content');
|
|
174
|
+
const accordionContent = getClosestParent(child, '.sf-accordion-content');
|
|
175
|
+
const parentLabel = () => {
|
|
176
|
+
if (tabContent !== null) {
|
|
177
|
+
return document.getElementById(`target_${tabContent.id}`).textContent;
|
|
178
|
+
}
|
|
179
|
+
else if (accordionContent !== null) {
|
|
180
|
+
return document.getElementById(`target_${accordionContent.id}`).querySelector('.sf-accordion-text').textContent;
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
return '';
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
return {
|
|
187
|
+
parentLabel: parentLabel().split(' ').join('-').toLowerCase(),
|
|
188
|
+
flag: tabContent !== null || accordionContent !== null ? false : true
|
|
189
|
+
};
|
|
168
190
|
};
|
|
169
191
|
|
|
170
|
-
// Set default tab via URL hash or device type if present on tabs
|
|
171
192
|
ready('.sf-tabs', function () {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
193
|
+
if (!articleTabsInit) {
|
|
194
|
+
|
|
195
|
+
const toggleTabs = (params) => {
|
|
196
|
+
// Remove existing active CSS classes
|
|
197
|
+
const currentTabContentID = params.tabNav.querySelector('.sf-tab-item.active').firstElementChild.id.substring(7);
|
|
198
|
+
params.tabNav.querySelector('.sf-tab-item.active').classList.remove('active');
|
|
199
|
+
document.getElementById(currentTabContentID).classList.remove('in');
|
|
200
|
+
|
|
201
|
+
//Update tab according to device with active and in css class
|
|
202
|
+
params.targetTabLink.parentNode.classList.add('active');
|
|
203
|
+
document.getElementById(params.targetTabLink.id.substring(7)).classList.add('in');
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
document.querySelectorAll('.sf-tabs').forEach(tab => {
|
|
207
|
+
const deviceType = getDeviceType();
|
|
208
|
+
tab.querySelectorAll('.sf-tab-item-link').forEach(tabitem => {
|
|
209
|
+
const tabItemText = tabitem.textContent.toLowerCase().replace(/\s/g, '');
|
|
210
|
+
|
|
211
|
+
const _closestParent = closestParent(tabitem);
|
|
212
|
+
|
|
213
|
+
topicsTabAccordion[tabitem.id] = {
|
|
214
|
+
text: tabItemText,
|
|
215
|
+
isMainParent: _closestParent.flag,
|
|
216
|
+
parentLabel: _closestParent.parentLabel
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// If URL hash is not present, we locate the name of the device tab
|
|
220
|
+
const sfTabNav = tabitem.parentNode.parentNode;
|
|
221
|
+
if (tabItemText === deviceType && urlHash.list === '') {
|
|
222
|
+
if (sfTabNav.querySelector('.sf-tab-item.active').classList.contains('active')) {
|
|
223
|
+
toggleTabs({
|
|
224
|
+
targetTabLink: tabitem,
|
|
225
|
+
tabNav: sfTabNav
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (urlHash.list !== '' && urlHash.list.search(tabItemText) > -1) {
|
|
231
|
+
Object.keys(topicsTabAccordion).forEach(key => {
|
|
232
|
+
if (tabItemText == topicsTabAccordion[key].text) {
|
|
233
|
+
toggleTabs({
|
|
234
|
+
targetTabLink: tabitem,
|
|
235
|
+
tabNav: sfTabNav
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
});
|
|
187
241
|
});
|
|
188
|
-
|
|
242
|
+
|
|
243
|
+
articleTabsInit = true;
|
|
244
|
+
console.log(topicsTabAccordion);
|
|
245
|
+
}
|
|
189
246
|
});
|
|
190
247
|
|
|
191
248
|
ready('.sf-accordion', function () {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
249
|
+
if (!articleAccordionInit) {
|
|
250
|
+
const urlHashList = window.location.hash;
|
|
251
|
+
document.querySelectorAll('.sf-accordion-toggle').forEach(accordionToggle => {
|
|
252
|
+
const accordionText = accordionToggle
|
|
253
|
+
.querySelector('.sf-accordion-text')
|
|
254
|
+
.textContent.split(' ').join('-').toLowerCase();
|
|
255
|
+
|
|
256
|
+
const _closestParent = closestParent(accordionToggle);
|
|
257
|
+
|
|
258
|
+
topicsTabAccordion[accordionToggle.id] = {
|
|
259
|
+
text: accordionText,
|
|
260
|
+
isMainParent: _closestParent.flag,
|
|
261
|
+
parentLabel: _closestParent.parentLabel
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
if (urlHashList !== '' && urlHash.list.search(accordionText) > -1) {
|
|
265
|
+
Object.keys(topicsTabAccordion).forEach(key => {
|
|
266
|
+
if (accordionText == topicsTabAccordion[key].text) {
|
|
267
|
+
document.getElementById(key).classList.add('in');
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
articleAccordionInit = true;
|
|
275
|
+
}
|
|
203
276
|
});
|
|
204
277
|
})();
|