@qhealth-design-system/core 1.22.2 → 1.23.0
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/.storybook/assets/image-position-demo-portrait.svg +54 -0
- package/.storybook/assets/image-position-demo.svg +55 -0
- package/.storybook/globals.js +9 -0
- package/.storybook/preview.js +8 -1
- package/CHANGELOG.md +2 -0
- package/README.md +0 -6
- package/package.json +13 -33
- package/src/assets/img/svg-icons.svg +154 -154
- package/src/component-loader.js +11 -2
- package/src/components/_global/css/admin/component.scss +1 -0
- package/src/components/_global/css/btn/component.scss +9 -0
- package/src/components/_global/css/img/image-position-utility-classes.scss +30 -0
- package/src/components/_global/css/img/image-ratio-utility-classes.scss +41 -0
- package/src/components/_global/css/img/images.scss +74 -5
- package/src/components/_global/css/modal/component.scss +1 -0
- package/src/components/_global/js/animate/global.js +272 -294
- package/src/components/_global/js/collapsible.js +3 -3
- package/src/components/_global/js/global.js +304 -316
- package/src/components/_global/js/legacyGlobal.js +63 -0
- package/src/components/_global/js/modal/global.js +218 -223
- package/src/components/_global/js/popover/controller.js +4 -4
- package/src/components/_global/js/tabs/global.js +264 -276
- package/src/components/a-z_listing/js/global.js +106 -92
- package/src/components/accordion/css/component.scss +24 -41
- package/src/components/accordion/html/component.hbs +23 -5
- package/src/components/accordion/js/global.js +5 -10
- package/src/components/basic_search/js/global.js +0 -7
- package/src/components/code/js/global.js +6 -12
- package/src/components/file_upload/js/global.js +1 -5
- package/src/components/internal_navigation/css/component.scss +2 -2
- package/src/components/internal_navigation/html/component.hbs +16 -1
- package/src/components/main_navigation/js/global.js +341 -335
- package/src/components/overflow_menu/css/component.scss +1 -0
- package/src/components/search_box/css/component.scss +0 -1
- package/src/components/tab/js/global.js +5 -10
- package/src/components/toggle_tip/js/global.js +0 -6
- package/src/components/tool_tip/js/global.js +0 -6
- package/src/components/video_player/css/component.scss +27 -9
- package/src/components/video_player/html/component.hbs +32 -6
- package/src/components/video_player/js/global.js +8 -1
- package/src/index.js +4 -0
- package/src/stories/Accordion/accordion.stories.js +1 -0
- package/src/stories/Banner/bannerContained.stories.js +123 -0
- package/src/stories/Flexbox/Flexbox.stories.js +316 -0
- package/src/stories/Image/Image.stories.js +182 -0
- package/src/stories/Templates/ContentPage.stories.js +101 -0
- package/src/stories/Templates/LandingPage.stories.js +193 -0
- package/src/stories/Templates/templateHelpers.js +102 -0
- package/src/stories/VideoPlayer/VideoPlayer.stories.js +16 -0
- package/src/styles/imports/utilities.scss +15 -25
- package/src/styles/imports/variables.scss +26 -0
- package/src/components/_global/html/head.html +0 -22
- package/src/components/_global/html/scripts.html +0 -28
- package/src/components/_global/js/_polyfills/global.js +0 -19
- package/src/components/_template/html/component-page.html +0 -75
- package/src/components/_template/js/global.js +0 -3
- package/src/components/accordion/html/accordion-group.html +0 -163
- package/src/components/accordion/html/default.html +0 -99
- package/src/components/banner_basic/js/global.js +0 -3
- package/src/components/loading_spinner/js/global.js +0 -3
- package/src/components/pagination/html/default.html +0 -39
- package/src/components/search_box/html/component.html +0 -26
- package/src/data/current.json +0 -400
- package/src/data/current_admin.json +0 -305
- package/src/data/model_component.js +0 -14
- package/src/data/site.json +0 -977
- package/src/externals/tinymce_classes.css +0 -62
- package/src/html/component-global-elements.html +0 -2857
- package/src/html/component-horizontal_rule.html +0 -647
- package/src/html/component-internal_navigation.html +0 -583
- package/src/html/component-left_hand_navigation.html +0 -57
- package/src/html/component-main_navigation.html +0 -583
- package/src/html/component-multi_column.html +0 -582
- package/src/html/components.html +0 -354
- package/src/html/home.html +0 -1898
- package/src/html/index.html +0 -129
- package/src/html/inner-with-nav.html +0 -605
- package/src/html/inner.html +0 -618
|
@@ -1,313 +1,301 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* @module tabs
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
4
|
+
import utils from "../global.js";
|
|
5
|
+
|
|
6
|
+
// For easy reference
|
|
7
|
+
var keys = {
|
|
8
|
+
end: 35,
|
|
9
|
+
home: 36,
|
|
10
|
+
left: 37,
|
|
11
|
+
up: 38,
|
|
12
|
+
right: 39,
|
|
13
|
+
down: 40,
|
|
14
|
+
delete: 46,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Add or substract depending on key pressed
|
|
18
|
+
var direction = {
|
|
19
|
+
37: -1,
|
|
20
|
+
38: -1,
|
|
21
|
+
39: 1,
|
|
22
|
+
40: 1,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
var tabs = {
|
|
26
|
+
// Vars
|
|
27
|
+
buttons: null,
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
var tabs = {
|
|
28
|
-
// Vars
|
|
29
|
-
buttons: null,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Initialise any tab components on the page
|
|
33
|
-
*
|
|
34
|
-
* @memberof module:tabs
|
|
35
|
-
*/
|
|
36
|
-
init: function () {
|
|
37
|
-
tabs.buttons = QLD.utils.listToArray(
|
|
38
|
-
document.querySelectorAll('[role="tab"]'),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
// Bind listeners
|
|
42
|
-
for (var i = 0; i < tabs.buttons.length; i++) {
|
|
43
|
-
addListeners(i);
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Add event listeners for given tab
|
|
50
|
-
*
|
|
51
|
-
* @memberof module:tabs
|
|
52
|
-
* @instance
|
|
53
|
-
* @private
|
|
54
|
-
*
|
|
55
|
-
* @param {number} index
|
|
56
|
-
*/
|
|
57
|
-
function addListeners(index) {
|
|
58
|
-
var tab = tabs.buttons[index];
|
|
59
|
-
tab.addEventListener("click", clickEventListener);
|
|
60
|
-
tab.addEventListener("keydown", keydownEventListener);
|
|
61
|
-
tab.addEventListener("keyup", keyupEventListener);
|
|
62
|
-
|
|
63
|
-
// Build an array with all tabs (<button>s) in it
|
|
64
|
-
tab.index = index;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* When a tab is clicked, activateTab is fired to activate it.
|
|
69
|
-
* Always retrieve the closest tab button to ensure the event is
|
|
70
|
-
* triggered on the correct element as we reference specific data
|
|
71
|
-
* attributes on the button.
|
|
30
|
+
* Initialise any tab components on the page
|
|
72
31
|
*
|
|
73
32
|
* @memberof module:tabs
|
|
74
|
-
* @instance
|
|
75
|
-
* @private
|
|
76
|
-
*
|
|
77
|
-
* @param {Document.event} event
|
|
78
33
|
*/
|
|
79
|
-
function
|
|
80
|
-
|
|
81
|
-
activateTab(tab, false);
|
|
82
|
-
}
|
|
34
|
+
init: function () {
|
|
35
|
+
tabs.buttons = utils.listToArray(document.querySelectorAll('[role="tab"]'));
|
|
83
36
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
* @memberof module:tabs
|
|
88
|
-
* @instance
|
|
89
|
-
* @private
|
|
90
|
-
*
|
|
91
|
-
* @param {Document.event} event
|
|
92
|
-
*/
|
|
93
|
-
function keydownEventListener(event) {
|
|
94
|
-
var key = event.keyCode;
|
|
95
|
-
var tab = event.target;
|
|
96
|
-
var tablist = tab.parentNode;
|
|
97
|
-
var siblingTabs = QLD.utils.listToArray(
|
|
98
|
-
tablist.querySelectorAll('[role="tab"]'),
|
|
99
|
-
);
|
|
100
|
-
var firstTab = siblingTabs[0];
|
|
101
|
-
var lastTab = siblingTabs[siblingTabs.length - 1];
|
|
102
|
-
|
|
103
|
-
switch (key) {
|
|
104
|
-
case keys.end:
|
|
105
|
-
event.preventDefault();
|
|
106
|
-
// Activate last tab
|
|
107
|
-
activateTab(lastTab);
|
|
108
|
-
break;
|
|
109
|
-
case keys.home:
|
|
110
|
-
event.preventDefault();
|
|
111
|
-
// Activate first tab
|
|
112
|
-
activateTab(firstTab);
|
|
113
|
-
break;
|
|
114
|
-
|
|
115
|
-
// Up and down are in keydown
|
|
116
|
-
// because we need to prevent page scroll >:)
|
|
117
|
-
case keys.up:
|
|
118
|
-
case keys.down:
|
|
119
|
-
determineOrientation(event);
|
|
120
|
-
break;
|
|
37
|
+
// Bind listeners
|
|
38
|
+
for (var i = 0; i < tabs.buttons.length; i++) {
|
|
39
|
+
addListeners(i);
|
|
121
40
|
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Add event listeners for given tab
|
|
46
|
+
*
|
|
47
|
+
* @memberof module:tabs
|
|
48
|
+
* @instance
|
|
49
|
+
* @private
|
|
50
|
+
*
|
|
51
|
+
* @param {number} index
|
|
52
|
+
*/
|
|
53
|
+
function addListeners(index) {
|
|
54
|
+
var tab = tabs.buttons[index];
|
|
55
|
+
tab.addEventListener("click", clickEventListener);
|
|
56
|
+
tab.addEventListener("keydown", keydownEventListener);
|
|
57
|
+
tab.addEventListener("keyup", keyupEventListener);
|
|
58
|
+
|
|
59
|
+
// Build an array with all tabs (<button>s) in it
|
|
60
|
+
tab.index = index;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* When a tab is clicked, activateTab is fired to activate it.
|
|
65
|
+
* Always retrieve the closest tab button to ensure the event is
|
|
66
|
+
* triggered on the correct element as we reference specific data
|
|
67
|
+
* attributes on the button.
|
|
68
|
+
*
|
|
69
|
+
* @memberof module:tabs
|
|
70
|
+
* @instance
|
|
71
|
+
* @private
|
|
72
|
+
*
|
|
73
|
+
* @param {Document.event} event
|
|
74
|
+
*/
|
|
75
|
+
function clickEventListener(event) {
|
|
76
|
+
var tab = event.target.closest('[role="tab"]');
|
|
77
|
+
activateTab(tab, false);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Handle keydown on tabs
|
|
82
|
+
*
|
|
83
|
+
* @memberof module:tabs
|
|
84
|
+
* @instance
|
|
85
|
+
* @private
|
|
86
|
+
*
|
|
87
|
+
* @param {Document.event} event
|
|
88
|
+
*/
|
|
89
|
+
function keydownEventListener(event) {
|
|
90
|
+
var key = event.keyCode;
|
|
91
|
+
var tab = event.target;
|
|
92
|
+
var tablist = tab.parentNode;
|
|
93
|
+
var siblingTabs = utils.listToArray(tablist.querySelectorAll('[role="tab"]'));
|
|
94
|
+
var firstTab = siblingTabs[0];
|
|
95
|
+
var lastTab = siblingTabs[siblingTabs.length - 1];
|
|
96
|
+
|
|
97
|
+
switch (key) {
|
|
98
|
+
case keys.end:
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
// Activate last tab
|
|
101
|
+
activateTab(lastTab);
|
|
102
|
+
break;
|
|
103
|
+
case keys.home:
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
// Activate first tab
|
|
106
|
+
activateTab(firstTab);
|
|
107
|
+
break;
|
|
108
|
+
|
|
109
|
+
// Up and down are in keydown
|
|
110
|
+
// because we need to prevent page scroll >:)
|
|
111
|
+
case keys.up:
|
|
112
|
+
case keys.down:
|
|
113
|
+
determineOrientation(event);
|
|
114
|
+
break;
|
|
122
115
|
}
|
|
116
|
+
}
|
|
123
117
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
118
|
+
/**
|
|
119
|
+
* Handle keyup on tabs
|
|
120
|
+
*
|
|
121
|
+
* @memberof module:tabs
|
|
122
|
+
* @instance
|
|
123
|
+
* @private
|
|
124
|
+
*
|
|
125
|
+
* @param {Document.event} event
|
|
126
|
+
*/
|
|
127
|
+
function keyupEventListener(event) {
|
|
128
|
+
var key = event.keyCode;
|
|
129
|
+
|
|
130
|
+
switch (key) {
|
|
131
|
+
case keys.left:
|
|
132
|
+
case keys.right:
|
|
133
|
+
determineOrientation(event);
|
|
134
|
+
break;
|
|
142
135
|
}
|
|
136
|
+
}
|
|
143
137
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
167
|
-
} else {
|
|
168
|
-
if (key === keys.left || key === keys.right) {
|
|
169
|
-
proceed = true;
|
|
170
|
-
}
|
|
138
|
+
/**
|
|
139
|
+
* When a tablist's aria-orientation is set to vertical,
|
|
140
|
+
* only up and down arrow should function.
|
|
141
|
+
* In all other cases only left and right arrow function.
|
|
142
|
+
*
|
|
143
|
+
* @memberof module:tabs
|
|
144
|
+
* @instance
|
|
145
|
+
* @private
|
|
146
|
+
*
|
|
147
|
+
* @param {Document.event} event
|
|
148
|
+
*/
|
|
149
|
+
function determineOrientation(event) {
|
|
150
|
+
var key = event.keyCode;
|
|
151
|
+
var tab = event.target;
|
|
152
|
+
var tablist = tab.parentNode;
|
|
153
|
+
var vertical = tablist.getAttribute("aria-orientation") == "vertical";
|
|
154
|
+
var proceed = false;
|
|
155
|
+
|
|
156
|
+
if (vertical) {
|
|
157
|
+
if (key === keys.up || key === keys.down) {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
proceed = true;
|
|
171
160
|
}
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
|
|
161
|
+
} else {
|
|
162
|
+
if (key === keys.left || key === keys.right) {
|
|
163
|
+
proceed = true;
|
|
175
164
|
}
|
|
176
165
|
}
|
|
177
166
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
* @memberof module:tabs
|
|
183
|
-
* @instance
|
|
184
|
-
* @private
|
|
185
|
-
*
|
|
186
|
-
* @param {Document.event} event
|
|
187
|
-
*/
|
|
188
|
-
function switchTabOnArrowPress(event) {
|
|
189
|
-
var pressed = event.keyCode;
|
|
190
|
-
var tab = event.target;
|
|
191
|
-
var tablist = tab.parentNode;
|
|
192
|
-
var siblingTabs = QLD.utils.listToArray(
|
|
193
|
-
tablist.querySelectorAll('[role="tab"]'),
|
|
194
|
-
);
|
|
195
|
-
var firstTabIndex = siblingTabs[0].index;
|
|
196
|
-
|
|
197
|
-
for (var x = 0; x < siblingTabs.length; x++) {
|
|
198
|
-
siblingTabs[x].addEventListener("focus", focusEventHandler);
|
|
199
|
-
}
|
|
167
|
+
if (proceed) {
|
|
168
|
+
switchTabOnArrowPress(event);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
200
171
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Either focus the next, previous, first, or last tab
|
|
174
|
+
* depending on key pressed
|
|
175
|
+
*
|
|
176
|
+
* @memberof module:tabs
|
|
177
|
+
* @instance
|
|
178
|
+
* @private
|
|
179
|
+
*
|
|
180
|
+
* @param {Document.event} event
|
|
181
|
+
*/
|
|
182
|
+
function switchTabOnArrowPress(event) {
|
|
183
|
+
var pressed = event.keyCode;
|
|
184
|
+
var tab = event.target;
|
|
185
|
+
var tablist = tab.parentNode;
|
|
186
|
+
var siblingTabs = utils.listToArray(tablist.querySelectorAll('[role="tab"]'));
|
|
187
|
+
var firstTabIndex = siblingTabs[0].index;
|
|
188
|
+
|
|
189
|
+
for (var x = 0; x < siblingTabs.length; x++) {
|
|
190
|
+
siblingTabs[x].addEventListener("focus", focusEventHandler);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (direction[pressed]) {
|
|
194
|
+
if (tab.index !== undefined) {
|
|
195
|
+
var newIndex = tab.index - firstTabIndex + direction[pressed];
|
|
196
|
+
if (siblingTabs[newIndex]) {
|
|
197
|
+
siblingTabs[newIndex].focus();
|
|
198
|
+
} else if (pressed === keys.left || pressed === keys.up) {
|
|
199
|
+
siblingTabs[0].focus();
|
|
200
|
+
} else if (pressed === keys.right || pressed == keys.down) {
|
|
201
|
+
siblingTabs[siblingTabs.length - 1].focus();
|
|
211
202
|
}
|
|
212
203
|
}
|
|
213
204
|
}
|
|
205
|
+
}
|
|
214
206
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
207
|
+
/**
|
|
208
|
+
* Activates any given tab panel
|
|
209
|
+
*
|
|
210
|
+
* @memberof module:tabs
|
|
211
|
+
* @instance
|
|
212
|
+
* @private
|
|
213
|
+
*
|
|
214
|
+
* @param {Node} tab
|
|
215
|
+
* @param {boolean} setFocus
|
|
216
|
+
*/
|
|
217
|
+
function activateTab(tab, setFocus) {
|
|
218
|
+
setFocus = setFocus || true;
|
|
227
219
|
|
|
228
|
-
|
|
229
|
-
|
|
220
|
+
// Deactivate all other tabs
|
|
221
|
+
deactivatetabs(tab);
|
|
230
222
|
|
|
231
|
-
|
|
232
|
-
|
|
223
|
+
// Remove tabindex attribute
|
|
224
|
+
tab.removeAttribute("tabindex");
|
|
233
225
|
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
// Set the tab as selected
|
|
227
|
+
tab.setAttribute("aria-selected", "true");
|
|
236
228
|
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
// Get the value of aria-controls (which is an ID)
|
|
230
|
+
var controls = tab.getAttribute("aria-controls");
|
|
239
231
|
|
|
240
|
-
|
|
241
|
-
|
|
232
|
+
// Remove hidden attribute from tab panel to make it visible
|
|
233
|
+
document.getElementById(controls).removeAttribute("hidden");
|
|
242
234
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
235
|
+
// Set focus when required
|
|
236
|
+
if (setFocus) {
|
|
237
|
+
tab.focus();
|
|
247
238
|
}
|
|
239
|
+
}
|
|
248
240
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
tablist.querySelectorAll('[role="tab"]'),
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
for (var t = 0; t < siblingTabs.length; t++) {
|
|
263
|
-
var tab = siblingTabs[t];
|
|
264
|
-
tab.setAttribute("tabindex", "-1");
|
|
265
|
-
tab.setAttribute("aria-selected", "false");
|
|
266
|
-
tab.removeEventListener("focus", focusEventHandler);
|
|
267
|
-
|
|
268
|
-
var controls = tab.getAttribute("aria-controls");
|
|
269
|
-
var panel = document.getElementById(controls);
|
|
270
|
-
panel.setAttribute("hidden", "hidden");
|
|
271
|
-
}
|
|
272
|
-
}
|
|
241
|
+
/**
|
|
242
|
+
* Deactivate all tabs and tab panels
|
|
243
|
+
*
|
|
244
|
+
* @memberof module:tabs
|
|
245
|
+
* @instance
|
|
246
|
+
* @private
|
|
247
|
+
*/
|
|
248
|
+
function deactivatetabs(tab) {
|
|
249
|
+
var tablist = tab.parentNode;
|
|
250
|
+
var siblingTabs = utils.listToArray(tablist.querySelectorAll('[role="tab"]'));
|
|
273
251
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
function focusEventHandler(event) {
|
|
284
|
-
var target = event.target;
|
|
285
|
-
setTimeout(checkTabFocus, 300, target);
|
|
252
|
+
for (var t = 0; t < siblingTabs.length; t++) {
|
|
253
|
+
let tab = siblingTabs[t];
|
|
254
|
+
tab.setAttribute("tabindex", "-1");
|
|
255
|
+
tab.setAttribute("aria-selected", "false");
|
|
256
|
+
tab.removeEventListener("focus", focusEventHandler);
|
|
257
|
+
|
|
258
|
+
var controls = tab.getAttribute("aria-controls");
|
|
259
|
+
var panel = document.getElementById(controls);
|
|
260
|
+
panel.setAttribute("hidden", "hidden");
|
|
286
261
|
}
|
|
262
|
+
}
|
|
287
263
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Handle focus event on tab
|
|
266
|
+
*
|
|
267
|
+
* @memberof module:tabs
|
|
268
|
+
* @instance
|
|
269
|
+
* @private
|
|
270
|
+
*
|
|
271
|
+
* @param {Document.event} event
|
|
272
|
+
*/
|
|
273
|
+
function focusEventHandler(event) {
|
|
274
|
+
var target = event.target;
|
|
275
|
+
setTimeout(checkTabFocus, 300, target);
|
|
276
|
+
}
|
|
298
277
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
278
|
+
/**
|
|
279
|
+
* Check if given tab is currently focused
|
|
280
|
+
* @memberof module:tabs
|
|
281
|
+
* @instance
|
|
282
|
+
* @private
|
|
283
|
+
*
|
|
284
|
+
* @param {Node} target
|
|
285
|
+
*/
|
|
286
|
+
function checkTabFocus(target) {
|
|
287
|
+
var focused = document.activeElement;
|
|
288
|
+
|
|
289
|
+
if (target === focused) {
|
|
290
|
+
activateTab(target, false);
|
|
302
291
|
}
|
|
292
|
+
}
|
|
303
293
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
294
|
+
/**
|
|
295
|
+
* Initialise any tab components on the page.
|
|
296
|
+
*/
|
|
297
|
+
export default function initTabs() {
|
|
298
|
+
tabs.init();
|
|
299
|
+
}
|
|
308
300
|
|
|
309
|
-
|
|
310
|
-
window.addEventListener("DOMContentLoaded", function () {
|
|
311
|
-
QLD.tabs.init();
|
|
312
|
-
});
|
|
313
|
-
})(window.QLD);
|
|
301
|
+
export { tabs };
|