Skip to content

Commit

Permalink
fixes #2531505. build files for ARIA labelledby unique attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
jconniff committed Dec 3, 2011
1 parent f51c5d3 commit 32a5074
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
25 changes: 14 additions & 11 deletions build/dial/dial-debug.js
Expand Up @@ -265,20 +265,19 @@ YUI.add('dial', function(Y) {
dragging : Y.ClassNameManager.getClassName("dd-dragging")
};


/* Static constants used to define the markup templates used to create Dial DOM elements */
var labelId = Dial.CSS_CLASSES.label + Y.guid(); //get this unique id once then use


/**
* template that will contain the Dial's label.
*
* @property LABEL_TEMPLATE
* @type {HTML}
* @default <div id="' + labelId + '" class="[...-label]"><span class="[...-label-string]">{label}</span><span class="[...-value-string]"></span></div>
* @default <div class="[...-label]"><span id="" class="[...-label-string]">{label}</span><span class="[...-value-string]"></span></div>
* @protected
*/

Dial.LABEL_TEMPLATE = '<div id="' + labelId + '" class="' + Dial.CSS_CLASSES.label + '"><span class="' + Dial.CSS_CLASSES.labelString + '">{label}</span><span class="' + Dial.CSS_CLASSES.valueString + '"></span></div>';
Dial.LABEL_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.label + '"><span id="" class="' + Dial.CSS_CLASSES.labelString + '">{label}</span><span class="' + Dial.CSS_CLASSES.valueString + '"></span></div>';

if(supportsVML === false){
/**
Expand Down Expand Up @@ -316,10 +315,10 @@ YUI.add('dial', function(Y) {
*
* @property HANDLE_TEMPLATE
* @type {HTML}
* @default &lt;div class="[...-handle]">&lt;div class="[...-handleUser]" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0">&lt;/div>&lt;/div>';// title="{tooltipHandle}"
* @default &lt;div class="[...-handle]">&lt;div class="[...-handleUser]" aria-labelledby="" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0">&lt;/div>&lt;/div>';// title="{tooltipHandle}"
* @protected
*/
Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handle + '" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">';
Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handle + '" aria-labelledby="" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">';

}else{ // VML case
Dial.RING_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.ring + ' ' + Dial.CSS_CLASSES.ringVml + '">'+
Expand All @@ -341,7 +340,7 @@ YUI.add('dial', function(Y) {
'<div class="' + Dial.CSS_CLASSES.resetString + ' ' + Dial.CSS_CLASSES.hidden + '">{resetStr}</div>'+
'</div>'+
'';
Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handleVml + '" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">'+
Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handleVml + '" aria-labelledby="" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">'+
'<v:oval stroked="false">'+
'<v:fill opacity="20%" color="#6C3A3A"/>'+
'</v:oval>'+
Expand Down Expand Up @@ -964,11 +963,14 @@ YUI.add('dial', function(Y) {
* @method _renderHandle
* @protected
*/
_renderHandle : function() {
var contentBox = this.get("contentBox"),
handle = contentBox.one("." + Dial.CSS_CLASSES.handle);
_renderHandle : function() {
var labelId = Dial.CSS_CLASSES.label + Y.guid(), //get this unique id once then use for handle and label for ARIA
contentBox = this.get("contentBox"),
handle = contentBox.one("." + Dial.CSS_CLASSES.handle);
if (!handle) {
handle = Node.create(Y.substitute(Dial.HANDLE_TEMPLATE, this.get('strings')));
handle.setAttribute('aria-labelledby', labelId); // get unique id for specifying a label & handle for ARIA
this._labelNode.one('.' + Dial.CSS_CLASSES.labelString).setAttribute('id', labelId); // When handle gets focus, screen reader will include label text when reading the value.
contentBox.one('.' + Dial.CSS_CLASSES.ring).append(handle);
}
this._handleNode = handle;
Expand Down Expand Up @@ -1265,4 +1267,5 @@ YUI.add('dial', function(Y) {
Y.Dial = Dial;


}, '@VERSION@' ,{lang:['en','es' ], skinnable:true, requires:['widget', 'dd-drag', 'substitute', 'event-mouseenter', 'event-move', 'event-key', 'transition', 'intl']});

}, '@VERSION@' ,{requires:['widget', 'dd-drag', 'substitute', 'event-mouseenter', 'event-move', 'event-key', 'transition', 'intl'], lang:['en','es' ], skinnable:true});

0 comments on commit 32a5074

Please sign in to comment.