/** * key press handler for buttons. enables space and enter to activate a button * @param {type} e * @returns {undefined} */ function keyPressButtonHandler(e) { if($j(e.target).is("a")) { if(!$j(e.target).is(".to-open-popup") && e.which == 32) { e.target.click(); e.stopPropagation(); e.preventDefault(); } } else { if(e.which == 13) { e.target.click(); e.stopPropagation(); e.preventDefault(); } } } /** * key press handler for links. calls the onclick handlers on enter key * @param {type} e * @returns {undefined} */ function keyPressLinkHandler(e) { if(e.which == 13) { e.target.click(); e.stopPropagation(); e.preventDefault(); } } /** * transform some special classnames into aria attributes * @returns {undefined} */ function addAriaInformation() { $j(".ariaHasPopup").attr("aria-haspopup","true"); $j(".ariaExpanded").attr("aria-expanded","true"); $j(".ariaSelected").attr("aria-selected","true"); $j(".ariaRequired").attr("aria-required","true"); $j(".ariaHidden").attr("aria-hidden","true"); $j(".ariaMenu").attr("role","menu"); $j(".ariaMenuItem").attr("role","menuitem"); $j(".ariaListbox").attr("role","listbox"); $j(".ariaOption").attr("role","option"); $j(".ariaPresentation").attr("role","presentation"); $j(".ariaContentInfo").attr("role","contentinfo"); $j(".ariaBanner").attr("role","banner"); $j(".ariaTabPanel").attr("role","tabpanel"); $j(".rf-pp-cntr").attr("role","dialog"); $j(".errormessage").attr("role","alert"); $j(".successmessage").attr("role","alert"); $j(".errorvalidation").attr("role","alert"); $j(".errorvalidation").attr("aria-invalid","true"); $j(".rf-pp-btn").attr("aria-hidden", "true").append("-"); $j("a[href^='http:'], a[href^='https:']").not(":has('.externalLink')").not(".textEditorBlock a").each(function(){ $j(this).attr("aria-label",$j(this).text() + " " + externalLinkLabel); $j(this).append(""+externalLinkLabel+""); }); //use title as aria label $j(".ariaTitleAsLabel").each(function(){ var title; if($j(this).text().trim() === $j(this).attr("title").trim()){ title = $j(this).attr("title"); } else { title = $j(this).text() + " " + $j(this).attr("title"); } if(title) { $j(this).attr("aria-label",title.trim()); } }); $j(".ariaTitleAsLabelSimple").each(function(){ var title = $j(this).attr("title"); if(title) { $j(this).attr("aria-label",title); } }); $j(".ariaMoveTitleToLabel").each(function(){ var title = $j(this).attr("title"); if(title) { $j(this).attr("aria-label",title); $j(this).removeAttr("title"); } }); $j(".ariaTooltip").each(function(){ var id = $j(this).parent().find(".rf-tt-cnt").attr("id"); if(id) { $j(this).parent().find(".rf-tt-cnt").attr("role","tooltip"); $j(this).attr("aria-describedby",id); } }); //add role button to converis buttons with class "buttons" $j('.buttons, .ariaButton, .rf-ds-btn, .firstpage, .lastpage, .nextpage, .previouspage').attr("role","button"); $j('span.buttons, span.ariaButton, span.rf-ds-btn, span.firstpage, span.lastpage, span.nextpage, span.previouspage').attr("aria-disabled","true"); $j("a:empty").each(function() { var label = $j(this).attr("aria-label"); if(label) { $j(this).append(""+label+""); } else { label = $j(this).attr("title"); if(label) { $j(this).append(""+label+""); } else { $j(this).append("-"); } } }); $j(".deduplicationFieldRow").each(function() { $j(this).append($j(this).find(".deduplicationValues .deduplicationValueTable td").addClass("deduplicationValue")); $j(this).find(".deduplicationValues").remove(); $j(this).find(".deduplicationValue input").wrap(""); $j(this).find(".deduplicationValue label").wrap(""); $j(this).find(".deduplicationValue").wrapInner("
"); if(typeof emptyValue !== 'undefined'){ $j(this).find(".deduplicationValue label").each(function() { if($j(this).text().trim() === "") { $j(this).attr("aria-label",emptyValue); } }); } }); } $j(document).ready(function(){ //add aria information for all elements already in document tree addAriaInformation(); //add aria information after an ajax call because there might be new elements in the document tree if(typeof jsf !== "undefined") { jsf.ajax.addOnEvent(function(data) { if (data.status === 'success') { addAriaInformation(); } }); } //delegated event handlers for clicks $j(document).on("keypress","a",keyPressLinkHandler); $j(document).on("keypress",".buttons, .ariaButton, .rf-ds-btn, .firstpage, .lastpage, .nextpage, .previouspage",keyPressButtonHandler); // $j(document).on("keydown",".rf-pp-shade",function(event){ // event.preventDefault(); // event.stopPropagation(); // }); // // $j(document).on("keypress",".rf-pp-shade",function(event){ // event.preventDefault(); // event.stopPropagation(); // }); // // $j(document).on("keyup",".rf-pp-shade",function(event){ // event.preventDefault(); // event.stopPropagation(); // }); }); function onCollabsiblePanelSwitch(event) { $j(document.getElementById(event.rf.data.id +":header")).attr("aria-expanded",event.rf.data.isExpanded); }