|
17 | 17 | this.el = el;
|
18 | 18 | this.tabTriggers = this.el.getElementsByClassName('js-tabs-trigger');
|
19 | 19 | this.tabPanels = this.el.getElementsByClassName('js-tabs-panel');
|
20 |
| - this.accordeonTriggers = this.el.getElementsByClassName('js-accordeon-trigger'); |
| 20 | + this.accordionTriggers = this.el.getElementsByClassName('js-accordion-trigger'); |
21 | 21 |
|
22 | 22 | this.options = this._extend({
|
23 | 23 | breakpoint: 640,
|
|
56 | 56 | var _this = this;
|
57 | 57 |
|
58 | 58 | this.tabTriggersLength = this.tabTriggers.length;
|
59 |
| - this.accordeonTriggersLength = this.accordeonTriggers.length; |
| 59 | + this.accordionTriggersLength = this.accordionTriggers.length; |
60 | 60 | this.selectedTab = 0;
|
61 | 61 | this.prevSelectedTab = null;
|
62 | 62 | this.clickListener = this._clickEvent.bind(this);
|
|
69 | 69 | };
|
70 | 70 |
|
71 | 71 | if(window.innerWidth >= this.options.breakpoint && this.options.tabsAllowed) {
|
72 |
| - this.isAccordeon = false; |
| 72 | + this.isAccordion = false; |
73 | 73 | } else {
|
74 |
| - this.isAccordeon = true; |
| 74 | + this.isAccordion = true; |
75 | 75 | }
|
76 | 76 |
|
77 | 77 | for (var i = 0; i < this.tabTriggersLength; i++) {
|
|
86 | 86 | this._hide(i);
|
87 | 87 | }
|
88 | 88 |
|
89 |
| - for (var i = 0; i < this.accordeonTriggersLength; i++) { |
90 |
| - this.accordeonTriggers[i].index = i; |
91 |
| - this.accordeonTriggers[i].addEventListener('click', this.clickListener, false); |
92 |
| - this.accordeonTriggers[i].addEventListener('keydown', this.keydownListener, false); |
| 89 | + for (var i = 0; i < this.accordionTriggersLength; i++) { |
| 90 | + this.accordionTriggers[i].index = i; |
| 91 | + this.accordionTriggers[i].addEventListener('click', this.clickListener, false); |
| 92 | + this.accordionTriggers[i].addEventListener('keydown', this.keydownListener, false); |
93 | 93 |
|
94 |
| - if (this.accordeonTriggers[i].classList.contains('is-selected')) { |
| 94 | + if (this.accordionTriggers[i].classList.contains('is-selected')) { |
95 | 95 | this.selectedTab = i;
|
96 | 96 | }
|
97 | 97 | }
|
|
113 | 113 | var resizeTabs = this._debounce(function() {
|
114 | 114 | // This gets delayed for performance reasons
|
115 | 115 | if(window.innerWidth >= _this.options.breakpoint && _this.options.tabsAllowed) {
|
116 |
| - _this.isAccordeon = false; |
| 116 | + _this.isAccordion = false; |
117 | 117 | if (_this.options.tabsAllowed) {
|
118 | 118 | _this.el.classList.add('tabs-allowed');
|
119 | 119 | }
|
120 | 120 | _this.selectTab(_this.selectedTab);
|
121 | 121 | } else {
|
122 |
| - _this.isAccordeon = true; |
| 122 | + _this.isAccordion = true; |
123 | 123 | _this.el.classList.remove('tabs-allowed');
|
124 | 124 | if(_this.options.startCollapsed != "true" || _this.options.startCollapsed != true){
|
125 | 125 | _this.selectTab(_this.selectedTab);
|
|
140 | 140 | var closestTab = 0;
|
141 | 141 |
|
142 | 142 | if (closestTrigger == null) {
|
143 |
| - closestTrigger = this._getClosest(e.target, '.js-accordeon-trigger'); |
| 143 | + closestTrigger = this._getClosest(e.target, '.js-accordion-trigger'); |
144 | 144 | closestTab = this._getClosest(closestTrigger, '.js-tabs-panel');
|
145 |
| - this.isAccordeon = true; |
| 145 | + this.isAccordion = true; |
146 | 146 | } else {
|
147 |
| - this.isAccordeon = false; |
| 147 | + this.isAccordion = false; |
148 | 148 | }
|
149 | 149 |
|
150 | 150 | var targetIndex = e.target.index != null ? e.target.index : closestTab.index;
|
151 | 151 |
|
152 |
| - if (targetIndex === this.selectedTab && !this.isAccordeon) { |
| 152 | + if (targetIndex === this.selectedTab && !this.isAccordion) { |
153 | 153 | return;
|
154 | 154 | }
|
155 | 155 |
|
|
167 | 167 | return;
|
168 | 168 | }
|
169 | 169 |
|
170 |
| - if (e.keyCode === this.keys.prev && e.target.index > 0 && !this.isAccordeon) { |
| 170 | + if (e.keyCode === this.keys.prev && e.target.index > 0 && !this.isAccordion) { |
171 | 171 | targetIndex = e.target.index - 1;
|
172 | 172 | }
|
173 |
| - else if (e.keyCode === this.keys.next && e.target.index < this.tabTriggersLength - 1 && !this.isAccordeon) { |
| 173 | + else if (e.keyCode === this.keys.next && e.target.index < this.tabTriggersLength - 1 && !this.isAccordion) { |
174 | 174 | targetIndex = e.target.index + 1;
|
175 | 175 | }
|
176 | 176 | else if (e.keyCode === this.keys.space || e.keyCode === this.keys.enter) {
|
|
191 | 191 | this.tabTriggers[index].classList.add('is-selected');
|
192 | 192 | this.tabTriggers[index].setAttribute('aria-selected', true);
|
193 | 193 |
|
194 |
| - this.accordeonTriggers[index].setAttribute('aria-expanded', true); |
| 194 | + this.accordionTriggers[index].setAttribute('aria-expanded', true); |
195 | 195 |
|
196 | 196 | var panelContent = this.tabPanels[index].getElementsByClassName("content")[0];
|
197 | 197 | panelContent.setAttribute('aria-hidden', false);
|
|
212 | 212 | this.tabTriggers[index].setAttribute('aria-selected', false);
|
213 | 213 | this.tabTriggers[index].setAttribute('tabindex', -1);
|
214 | 214 |
|
215 |
| - this.accordeonTriggers[index].setAttribute('aria-expanded', false); |
| 215 | + this.accordionTriggers[index].setAttribute('aria-expanded', false); |
216 | 216 |
|
217 | 217 | var panelContent = this.tabPanels[index].getElementsByClassName("content")[0];
|
218 | 218 | panelContent.setAttribute('aria-hidden', true);
|
|
227 | 227 | AccordionTabs.prototype.selectTab = function (index, userInvoked) {
|
228 | 228 |
|
229 | 229 | if (index === null) {
|
230 |
| - if(this.isAccordeon) { |
| 230 | + if(this.isAccordion) { |
231 | 231 | return;
|
232 | 232 | } else {
|
233 | 233 | index = 0;
|
|
248 | 248 | return;
|
249 | 249 | }
|
250 | 250 |
|
251 |
| - if (this.isAccordeon) { |
| 251 | + if (this.isAccordion) { |
252 | 252 |
|
253 | 253 | this.prevSelectedTab = this.selectedTab;
|
254 | 254 | this.selectedTab = index;
|
255 | 255 |
|
256 | 256 | } else {
|
257 |
| - if (this.prevSelectedTab === null || !this.isAccordeon) { |
| 257 | + if (this.prevSelectedTab === null || !this.isAccordion) { |
258 | 258 | for (var i = 0; i < this.tabTriggersLength; i++) {
|
259 | 259 | if (i !== index) {
|
260 | 260 | this._hide(i);
|
|
0 commit comments