derafu-js 0.1.0 → 0.1.1
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/package.json +4 -4
- package/src/derafu.js +5 -0
- package/src/tabs.js +12 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "derafu-js",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Why use a JS framework if we can do all from scratch?",
|
|
5
5
|
"main": "src/derafu.js",
|
|
6
6
|
"files": [
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/derafu/
|
|
31
|
+
"url": "git+https://github.com/derafu/js.git"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/derafu/
|
|
33
|
+
"homepage": "https://github.com/derafu/js#readme",
|
|
34
34
|
"bugs": {
|
|
35
|
-
"url": "https://github.com/derafu/
|
|
35
|
+
"url": "https://github.com/derafu/js/issues"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"eslint": "^8.57.0",
|
package/src/derafu.js
CHANGED
|
@@ -134,6 +134,11 @@ if (typeof Form !== 'undefined') {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
// Make derafu available globally for browser usage.
|
|
138
|
+
if (typeof window !== 'undefined') {
|
|
139
|
+
window.derafu = derafu;
|
|
140
|
+
}
|
|
141
|
+
|
|
137
142
|
// Export module for use in Node.js.
|
|
138
143
|
if (typeof module === 'object' && module.exports) {
|
|
139
144
|
module.exports = derafu;
|
package/src/tabs.js
CHANGED
|
@@ -29,7 +29,9 @@ Tabs.init = function () {
|
|
|
29
29
|
'use strict';
|
|
30
30
|
|
|
31
31
|
// Open the first tab by default.
|
|
32
|
-
const firstTabLink = document.querySelector(
|
|
32
|
+
const firstTabLink = document.querySelector(
|
|
33
|
+
'.nav-tabs [data-bs-toggle="tab"]',
|
|
34
|
+
);
|
|
33
35
|
if (firstTabLink) {
|
|
34
36
|
new bootstrap.Tab(firstTabLink).show();
|
|
35
37
|
}
|
|
@@ -38,10 +40,17 @@ Tabs.init = function () {
|
|
|
38
40
|
Tabs.handleURLDeeplink();
|
|
39
41
|
|
|
40
42
|
// Update URL when clicking on each tab.
|
|
41
|
-
const tabLinks = document.querySelectorAll('
|
|
43
|
+
const tabLinks = document.querySelectorAll('[data-bs-toggle="tab"]');
|
|
42
44
|
tabLinks.forEach(tabLink => {
|
|
43
45
|
tabLink.addEventListener('click', function () {
|
|
44
|
-
|
|
46
|
+
const tabId =
|
|
47
|
+
tabLink.getAttribute('aria-controls') ||
|
|
48
|
+
(
|
|
49
|
+
tabLink.getAttribute('data-bs-target') ||
|
|
50
|
+
tabLink.getAttribute('href') ||
|
|
51
|
+
''
|
|
52
|
+
).replace('#', '');
|
|
53
|
+
Tabs.deeplink(tabId);
|
|
45
54
|
});
|
|
46
55
|
});
|
|
47
56
|
|