1/** 2 * Adds and removes classes to a list of links to allow keyboard accessibility 3 * 4 * @param string dropDownId 5 * @param string hoverClass 6 * @param int mouseOffDelay 7 */ 8function dropdown(dropdownId, hoverClass, mouseOffDelay) { 9 if(dropdown = document.getElementById(dropdownId)) { 10 var listItems = dropdown.getElementsByTagName('li'); 11 for(var i = 0; i < listItems.length; i++) { 12 listItems[i].onmouseover = function() { this.className = addClass(this); } 13 listItems[i].onmouseout = function() { 14 var that = this; 15 setTimeout(function() { that.className = removeClass(that); }, mouseOffDelay); 16 this.className = that.className; 17 } 18 19 var anchor = listItems[i].getElementsByTagName('*'); 20 anchor = anchor[0]; 21 anchor.onfocus = function() { tabOn(this.parentNode); } 22 anchor.onblur = function() { tabOff(this.parentNode); } 23 } 24 } 25 26 function tabOn(li) { 27 if(li.nodeName == 'LI') { 28 li.className = addClass(li); 29 tabOn(li.parentNode.parentNode); 30 } 31 } 32 33 function tabOff(li) { 34 if(li.nodeName == 'LI') { 35 li.className = removeClass(li); 36 tabOff(li.parentNode.parentNode); 37 } 38 } 39 40 function addClass(li) { return li.className + ' ' + hoverClass; } 41 function removeClass(li) { return li.className.replace(hoverClass, ""); } 42}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.