1 2// JavaScript source code 3// see whether device supports touch events (a bit simplistic, but...) 4jQuery(document).ready(function () { 5 // see whether device supports touch events (a bit simplistic, but...) 6 var hasTouch = ("ontouchstart" in window); 7 var iOS5 = /iPad|iPod|iPhone/.test(navigator.platform) && "matchMedia" in window; 8 9 // hook touch events for drop-down menus 10 // NB: if has touch events, then has standards event handling too 11 // but we don't want to run this code on iOS5+ 12 if (hasTouch && document.querySelectorAll && !iOS5) { 13 var i, len, element; 14 15 jQuery(document).bind('click', function (event) { 16 if (!jQuery(event.target).closest('.CMSMenu').length) { 17 18 var highlightedItem = jQuery('.oneCMSMenuHighlightedMenuItemMouseOver'); 19 if (highlightedItem && highlightedItem.length) { 20 highlightedItem.mouseout(); 21 highlightedItem[0].dataNoclick = false; 22 } 23 24 jQuery('.CMSMenu').each(function (index, elm) { 25 if (elm.style.display !== 'none') { 26 { 27 elm.style.display = 'none'; 28 } 29 } 30 }); 31 } 32 }); 33 34 35 var dropdowns = Array.prototype.slice.call(document.querySelectorAll('.oneCMSMenu td')).concat(Array.prototype.slice.call(document.querySelectorAll('.CMSMenu td'))); 36 37 function menuTouch(event) { 38 // toggle flag for preventing click for this link 39 var i, len, noclick = !(this.dataNoclick); 40 41 // reset flag on all links 42 for (i = 0, len = dropdowns.length; i < len; ++i) { 43 dropdowns[i].dataNoclick = false; 44 } 45 46 // set new flag value and focus on dropdown menu 47 this.dataNoclick = noclick; 48 this.focus(); 49 } 50 51 function menuClick(event) { 52 // if click isn't wanted, prevent it 53 if (this.dataNoclick) { 54 this.onmouseover(); 55 event.preventDefault(); 56 } 57 } 58 59 for (i = 0, len = dropdowns.length; i < len; ++i) { 60 element = dropdowns[i]; 61 element.dataNoclick = false; 62 63 var hasChildren = jQuery("[id^=" + element.id + "-]").length > 0; 64 if (hasChildren) 65 element.addEventListener("touchstart", menuTouch, false); 66 67 element.addEventListener("touchend", menuClick, false); 68 element.addEventListener("click", menuClick, false); 69 } 70 } 71 72});
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.