Left: | ||
Right: |
OLD | NEW |
---|---|
1 (function(){ | 1 (function(){ |
2 document.addEventListener("DOMContentLoaded", function() | 2 document.addEventListener("DOMContentLoaded", function() |
3 { | 3 { |
4 | 4 |
5 /************************************************************************** | 5 /************************************************************************** |
6 * General | 6 * General |
7 **************************************************************************/ | 7 **************************************************************************/ |
8 | 8 |
9 // Change html class name from "no-js" to "js" | 9 // Change html class name from "no-js" to "js" |
10 document.documentElement.className = "js"; | 10 document.documentElement.className = "js"; |
(...skipping 20 matching lines...) Expand all Loading... | |
31 } | 31 } |
32 | 32 |
33 /************************************************************************** | 33 /************************************************************************** |
34 * CustomSelect | 34 * CustomSelect |
35 **************************************************************************/ | 35 **************************************************************************/ |
36 | 36 |
37 function CustomSelect(select) | 37 function CustomSelect(select) |
38 { | 38 { |
39 this.select = select; | 39 this.select = select; |
40 this.close(); | 40 this.close(); |
41 select.addEventListener("click", this._onClick.bind(this), false); | 41 this.select |
42 .addEventListener("click", this._onClick.bind(this), false); | |
43 this.select | |
44 .addEventListener("focusout", this._onFocusOut.bind(this), false); | |
45 } | |
46 | |
47 CustomSelect.prototype._onFocusOut = function() | |
48 { | |
49 // setTimeout to allow document.activeElement | |
50 // to move to newly focused element | |
51 setTimeout(function() | |
52 { | |
53 var newFocus = document.activeElement; | |
54 | |
55 if (newFocus | |
juliandoucette
2017/10/24 10:15:25
Suggest:
{{{
var classList = document.activeEleme
ire
2017/10/24 14:51:09
This particular way doesn't work because I'm not o
| |
56 .classList.contains("custom-select-selected") || | |
57 newFocus | |
58 .parentElement | |
59 .classList.contains("custom-select-option")) | |
60 { | |
61 return; | |
62 } | |
63 | |
64 this.close(); | |
65 | |
66 }.bind(this), 1); | |
42 } | 67 } |
43 | 68 |
44 CustomSelect.prototype._onClick = function(event) | 69 CustomSelect.prototype._onClick = function(event) |
45 { | 70 { |
46 if (event.target.classList.contains("custom-select-selected")) | 71 if (event.target.classList.contains("custom-select-selected")) |
47 { | 72 { |
48 var options = this.select.querySelector(".custom-select-options"); | 73 var options = this.select.querySelector(".custom-select-options"); |
49 if (options.getAttribute("aria-hidden") == "true") | 74 if (options.getAttribute("aria-hidden") == "true") |
50 { | 75 { |
51 this.open(); | 76 this.open(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 } | 219 } |
195 | 220 |
196 var productTopicsAccordion = document.getElementById('product-topics-accordi on'); | 221 var productTopicsAccordion = document.getElementById('product-topics-accordi on'); |
197 if (productTopicsAccordion) | 222 if (productTopicsAccordion) |
198 { | 223 { |
199 new Accordion(productTopicsAccordion); | 224 new Accordion(productTopicsAccordion); |
200 } | 225 } |
201 | 226 |
202 }, false); | 227 }, false); |
203 }()); | 228 }()); |
OLD | NEW |