nmxSiteAccessibility(20, 100); //window.setTimeout(function(){ nmxSiteAccessibility(30, 100); },3000); /* 67 alerts BEFORE TURNING ON - fix the two product links at the bottom of the home page */ // jQuery(window).on("resize",function(){ // nmxSiteAccessibilityNMXS(20, 100); // }); /* jb20200921a - added speak function for screen readers */ function Speak(text){ console.log("acs speak "+text); jQuery("#speakerbox").text(" "); window.setTimeout(function(){ jQuery("#speakerbox").text(text); }, 100); } AddSpeakers(); function AddSpeakers(){ if (!jQuery("#speakerbox").length){ console.log("acs created speaker box"); jQuery("body").append('
'); } jQuery(".owl-prev").not("[speak]").attr("speak","previous").on("click",function(){ Speak("Scroll left"); }); jQuery(".owl-next").not("[speak]").attr("speak","next").on("click",function(){ Speak("Scroll right"); }); window.setTimeout(function(){ AddSpeakers(); }, 1000); } function nmxSiteAccessibility(c, i){ if (c > 0){ c--;window.setTimeout(function(){ nmxSiteAccessibility(c--, i); },i); } else { console.log("acs done."); } //CheckMouseNav(); CheckTabNav(); ScrollToMainLink(); //return; if (navigator.userAgent.toLowerCase().indexOf("pope") > -1 || jQuery("#wave5topbar").length || jQuery("#wave_sidebar_container").length || top.location.href != self.location.href){ jQuery("noscript, a[href*='pdf']").remove(); } jQuery(".nivo-nextNav").unbind("click").on("click",function(){ Speak("next slide: "); window.setTimeout(function(){ Speak(""+jQuery(".nivo-main-image").attr("alt")); },2000); }); jQuery(".nivo-prevNav").unbind("click").on("click",function(){ Speak("previous slide: "); window.setTimeout(function(){ Speak(""+jQuery(".nivo-main-image").attr("alt")); },2000); }); /* begin custom */ //jQuery('.owl-next').attr("alt","ContactFormFName"); jQuery("a+span.collapse:hidden").remove(); jQuery('[name="contact[first-name]"]').attr("id","ContactFormFName"); jQuery('[name="contact[last-name]"]').attr("id","ContactFormLName"); jQuery(".nivo-main-image").attr("aria-hidden","true");//.attr("role","status"); //jQuery(".nivoSlider").attr("aria-hidden","true"); jQuery(".mobile-enlarged-image").removeAttr("onclick"); //jQuery('[data-original-title="Add to Cart"][href*="/products/"],[href*="/products/"]:hidden').removeAttr("href"); // jQuery('.product-name > a').removeAttr("href"); /* cleanup redundant links jQuery("a[href='javascript:void(0);'],a[href='javascript:;']").each(function(index){ if (jQuery(this).attr("href").replace("javascript:","").replace("void","").length < 10){ jQuery(this).removeAttr("href") } else { jQuery(this).attr("href",jQuery(this).attr("href")+'; //'+index); } }); */ jQuery(".product-name>a[title]").removeAttr("title"); jQuery(".product-site-link a:contains('here')").each(function(){ jQuery(this).addClass("more-info-link"); jQuery(this).text(jQuery(this).parent().text().replace("For more","More").replace(", click here","")); //jQuery(this).parent().addClass("hidden"); jQuery(this).insertBefore(jQuery(this).parent()); }); jQuery(".more-info-link+.product-site-link").remove(); jQuery(".banner-single-image-wrapper > img").unwrap(); jQuery(".banner-single-image-wrapper:empty").remove(); jQuery('[role="alert"] .product-title').attr("aria-hidden","true"); // jQuery('[role="alert"] .product-link').attr("tabindex",1); // jQuery('[role="alert"] a.btn-button').attr("role","button").attr("tabindex",0); // jQuery('[value="Proceed to checkout"]').attr("role","button").attr("tabindex",0); //jQuery('[role="alert"] button').attr("aria-label","keep shopping"); /* end custom */ /* redundant links */ // jQuery("a[href*='/products/']").not("[acs]").each(function(index){ // if (jQuery("[href='"+jQuery(this).attr("href")+"']").length > 1 && jQuery(this).not("[acs]")){ // jQuery("[href='"+jQuery(this).attr("href")+"']").attr("acs","1"); // console.log("acs dup"+index+": x"+jQuery("[href='"+jQuery(this).attr("href")+"']").length+" "+jQuery(this).attr("href")); // } // }); /* common shopify */ jQuery(".quickview:hidden").remove(); jQuery(".actions .addtocart .i").unwrap(); jQuery("input#qty").attr("aria-label","quantity"); jQuery(".reduced.items").attr("aria-label","reduced quantity"); jQuery(".increase.items").attr("aria-label","increase quantity"); /* wrap in fieldset */ var wrap_in_fieldset_selector = ".swatch.size"; jQuery(wrap_in_fieldset_selector).each(function(){ if (!jQuery(this).parent("fieldset").length){ jQuery(this).wrap('
'); } }); /* add missing legends */ jQuery("fieldset").each(function(){ if (!jQuery(this).find("legend").length){ jQuery(this).prepend(''+jQuery(this).find(":header:first").text()+':'); } }); /* remove duplicate labels */ jQuery("[for]").each(function(index){ if (jQuery('[for="'+jQuery(this).attr("for")+'"]').length > 1){ console.log("acs for: "+jQuery('[for="'+jQuery(this).attr("for")+'"]').length+" x "+jQuery(this).attr("for")); jQuery('[for="'+jQuery(this).attr("for")+'"]:last').remove(); } }); /* remove orphaned labels */ // jQuery("[for]").each(function(index){ // if (jQuery(this).attr("for") != "qty"){ // if (!jQuery("#"+jQuery(this).attr("for")).length && jQuery(this).attr("for").trim() == jQuery(this).text().trim()){ // jQuery(this).remove(); // } // } else { // jQuery('[for="Quantity"]').attr("acs","1").attr("for","qty"); // } // }); /* add headings */ jQuery(':header').each(function(){ var level = jQuery(this).prop("tagName").replace("H",""); if (level > 1 && jQuery(this).parents().find("H"+(level-1))){ if (!jQuery(this).prev("h"+(level-1)).length){ jQuery(this).before('h'+(level-1)+''); } } }); /* fix broken same page links jQuery('[href*="#"]').not('[href*="javascript"]').each(function(){ if (!jQuery('[name="'+jQuery(this).attr("href").replace("#","")+'"]').length){ var a = ''+jQuery(this).text()+''; jQuery("body").prepend(a); } }); */ /* this is ridiculous, but we can do this rather than removing from html */ //jQuery("noscript").remove(); /* rather than dismiss all of these, we can do this - just e sure to check PDFs for accessibility */ // jQuery("a[href*='pdf']").each(function(index){ // if (jQuery(this).attr("href").indexOf("javascript")==-1){ // jQuery(this).attr("href",'javascript:(function(){ var i='+index+'; document.location="'+jQuery(this).attr("href")+'"; })();').attr("aria-hidden","true").attr("role","presentation"); // } // }); /* add missing form field labels */ jQuery("input,select,textarea").not('[type="image"],[type="submit"],[type="reset"],[type="button"],[type="hidden"]').each(function(index){ if (!jQuery(this).filter("[id]").length){ jQuery(this).attr("id","fld"+index); } if (jQuery(this).filter("[id]").length){ if (!jQuery("[for='"+jQuery(this).attr("id")+"']").length){ if (jQuery(this).parent().is("label") && !jQuery(this).parent().has("[for]")){ jQuery(this).parent().attr("for",jQuery(this).attr("id")); } else { jQuery(this).before(''); } } } }); /* alt tags */ jQuery("img:not([alt])").filter("[src]").each(function(index){ var alt=""; jQuery(this).attr("alt", alt); console.log("acs no alt - "+jQuery(this).attr("src")); if (jQuery(this).attr("title") != ""){ alt = jQuery(this).attr("title"); } else { alt = jQuery(this).attr("src").replace(".png","").replace(".svg","").replace(".jpg","").replace(".gif","").replace(/[-_]/g," ").replace(/^.*[\\\/]/, ''); } alt = "img "+index; console.log("acs set alt: "+alt); jQuery(this).attr("alt", alt); }); /* empty buttons and links jQuery("a[href], button").each(function(index){ if (jQuery(this).text().trim() == ""){ //var txt = (jQuery(this).attr("alt").replace("undefined","")+" "+jQuery(this).attr("title").replace("undefined","")+" "+jQuery(this).val()).trim(); jQuery(this).append(''+index+''); } }); */ /* shopify template fixes */ jQuery('.product-link [src*="noimage"]').parent().remove(); // jQuery('.product-name > a').removeAttr("href"); /* fix layout table false-pos */ var non_layout_table_selector = "table"; jQuery(' tbody').prepend('-'); /* device dependant handler */ jQuery('[onclick]').each(function(){ jQuery(this).attr("onmousedown",jQuery(this).attr("onclick")).removeAttr("onclick"); }); /* remove redundant titles */ jQuery("[alt][title]").each(function(){ if (jQuery(this).text() == jQuery(this).attr("title") || jQuery(this).attr("alt") == jQuery(this).attr("title")){ jQuery(this).removeAttr("title"); } }); jQuery("img[alt][title]").removeAttr("title"); /* cleanup */ jQuery("[acs]:hidden").css("font-size","18px"); /* end accessibility */ } function CheckTabNav(){ $("html").off("keyup").on("keyup",function(e) { var keyCode = e.keyCode; if (keyCode == 9) { e.preventDefault(); if (!$("body[tabage]").length){ $("body").attr("tabage",0); } $("body").attr("tabage", ($("body").attr("tabage")*1)+1); console.log("acs tabage "+$("body").attr("tabage")); } }); } function CheckMouseNav(){ $("body").unbind("mousemove").on("mousemove",function(e) { if (!$("body[mouseage]").length){ $("body").attr("mouseage",0); } $("body").attr("mouseage", ($("body").attr("mouseage")*1)+(e.pageX*1)+(e.pageY*1)); console.log("acs mouseage "+$("body").attr("mouseage")); }); } // var timeout = null; // $(document).on('mousemove', function() { // clearTimeout(timeout); // timeout = setTimeout(function() { // console.log('Mouse idle for 3 sec'); // }, 3000); // }); function ScrollToMainLink(){ // jQuery(".skip-link,.skip-link-style").remove(); jQuery("header").prepend(''); jQuery("head").append(''); if (!jQuery("body[main]").length){ if (jQuery("[main]").length){ jQuery("body").attr("main","[main]"); } else if (jQuery("#main").length){ jQuery("body").attr("main","#main"); } else if (jQuery("[roll='main']").length){ jQuery("body").attr("main","[roll='main']"); } else if (jQuery("div.main").length){ jQuery("body").attr("main","div.main"); } else { jQuery("[roll='main']").attr("main","[roll='main']"); } jQuery(jQuery("body").attr("main")).attr("role","main"); console.log("acs main: "+jQuery("body").attr("main")); } } function ScrollToMain(){ console.log("acs scroll to main"); var $container = $("html,body"); var $scrollTo = $(jQuery("body").attr("main")); $container.animate({scrollTop: $scrollTo.offset().top - $container.offset().top + $container.scrollTop(), scrollLeft: 0},300); } function luminanace(r, g, b){ var a = [r, g, b].map(function (v) { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow( (v + 0.055) / 1.055, 2.4 ); }); return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722; } function contrast(rgb1, rgb2){ var lum1 = luminanace(rgb1[0], rgb1[1], rgb1[2]); var lum2 = luminanace(rgb2[0], rgb2[1], rgb2[2]); var brightest = Math.max(lum1, lum2); var darkest = Math.min(lum1, lum2); return (brightest + 0.05) / (darkest + 0.05); } //contrast([255, 255, 255], [255, 255, 0]); // 1.074 for yellow //contrast([255, 255, 255], [0, 0, 255]); // 8.592 for blue var hexDigits = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"); function rgb2hex(rgb){ rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); } function hex(x) { return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16]; } function invertColor(hex, bw){ if (hex.indexOf('#') === 0) { hex = hex.slice(1); } // convert 3-digit hex to 6-digits. if (hex.length === 3) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } if (hex.length !== 6) { throw new Error('Invalid HEX color.'); } var r = parseInt(hex.slice(0, 2), 16), g = parseInt(hex.slice(2, 4), 16), b = parseInt(hex.slice(4, 6), 16); if (bw) { // http://stackoverflow.com/a/3943023/112731 return (r * 0.299 + g * 0.587 + b * 0.114) > 186 ? '#000000' : '#FFFFFF'; } // invert color components r = (255 - r).toString(16); g = (255 - g).toString(16); b = (255 - b).toString(16); // pad each with zeros and return return "#" + padZero(r) + padZero(g) + padZero(b); } // jQuery(document).ready(function(){ // jQuery("#subscribe_footer").on("submit",function(e){ // e.preventDefault(); // OpenEmailSignupFormPopup(); // jQuery('#mc-embedded-subscribe-form #mce-EMAIL').val(jQuery('#subscribe_footer #fc-email').val()); // }); // jQuery('#subscribe_footer .btn-button.effect').on('click', function(){ // OpenEmailSignupFormPopup(); // jQuery('#mc-embedded-subscribe-form #mce-EMAIL').val(jQuery('#subscribe_footer #fc-email').val()); // }); // });