From ab910d3cc80766c58c6b7aad4d0308f1de42c332 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Thu, 18 Apr 2013 17:41:14 +0300 Subject: [PATCH] Links: Append popup accessibility attributes. Fixes #5898. --- js/jquery.mobile.links.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/js/jquery.mobile.links.js b/js/jquery.mobile.links.js index d5b8e9a54c4..95b1554179f 100644 --- a/js/jquery.mobile.links.js +++ b/js/jquery.mobile.links.js @@ -14,6 +14,24 @@ $.mobile._enhancer.add( "mobile.links", undefined, function( target ) { $( target ) .find( "a" ) .jqmEnhanceable() + .filter( ":jqmData(rel='popup')[href][href!='']" ) + .each( function() { + // Accessibility info for popups + var e = this, + href = $( this ).attr( "href" ); + + e.setAttribute( "aria-haspopup", true ); + e.setAttribute( "aria-owns", href ); + e.setAttribute( "aria-expanded", false ); + $( document ) + .on( "popupafteropen", href, function() { + e.setAttribute( "aria-expanded", true ); + }) + .on( "popupafterclose", href, function() { + e.setAttribute( "aria-expanded", false ); + }); + }) + .end() .not( ".ui-btn, .ui-link-inherit, :jqmData(role='none'), :jqmData(role='nojs')" ) .addClass( "ui-link" );