Skip to content

Commit c1d0c65

Browse files
committed
added default labels from text, plus aria-checked
1 parent ada3329 commit c1d0c65

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lib/glow/canvas.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
canvas.selected = this
9393
canvas.hasmouse = null
9494

95-
this.__title_anchor = $("<div/>") // title anchor point
95+
this.__title_anchor = $('<div aria-live="assertive"/>') // title anchor point
9696
this.__caption_anchor = $('<div aria-live="assertive"/>') // caption anchor point
9797
this.__titletext = ''
9898
this.__captiontext = ''

lib/glow/primitives.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2902,11 +2902,12 @@
29022902
if (attrs.name !== null && (__radio_buttons[attrs.name] === undefined))
29032903
__radio_buttons[attrs.name] = null
29042904

2905-
attrs.jradio = $(`<input aria-label="${attrs.aria_label}" type="radio">`).css({width:'16px', height:'16px'}).appendTo(attrs.pos)
2905+
let aria_label = attrs.aria_label || attrs.text
2906+
attrs.jradio = $(`<input aria-label="${aria_label}" type="radio">`).css({width:'16px', height:'16px'}).appendTo(attrs.pos)
29062907
.click( function() {
29072908
if (attrs.name === null) {
29082909
attrs.checked = !attrs.checked
2909-
$(attrs.jradio).prop('checked', attrs.checked)
2910+
$(attrs.jradio).prop('checked', attrs.checked).attrs('aria-checked', attrs.checked)
29102911
attrs.bind(cradio)
29112912
} else if (!attrs.checked) {
29122913
let name = attrs.name
@@ -2915,6 +2916,7 @@
29152916
rb[name] = cradio
29162917
attrs.checked = true
29172918
$(attrs.jradio).prop('checked', attrs.checked)
2919+
$(attrs.jradio).attr('aria-checked', attrs.checked)
29182920
attrs.bind(cradio)
29192921
}
29202922
} )
@@ -2951,7 +2953,7 @@
29512953
}
29522954
}
29532955
attrs.checked = value
2954-
$(attrs.jradio).prop('checked', value)
2956+
$(attrs.jradio).prop('checked', value).attr('aria-checked', value)
29552957
},
29562958
get text() {return attrs.text},
29572959
set text(value) {
@@ -3013,10 +3015,12 @@
30133015
attrs.disabled = booleanize(attrs.disabled)
30143016
widgetid++
30153017
attrs._id = widgetid.toString()
3016-
attrs.jcheckbox = $(`<input aria-label="${attrs.aria_label}" type="checkbox"/>`).css({width:'16px', height:'16px'}).appendTo(attrs.pos)
3018+
let aria_label = attrs.aria_label || attrs.text
3019+
attrs.jcheckbox = $(`<input aria-checked="${attrs.checked}" aria-label="${aria_label}" type="checkbox"/>`).css({width:'16px', height:'16px'}).appendTo(attrs.pos)
30173020
.click( function() {
30183021
attrs.checked = !attrs.checked
30193022
$(attrs.jcheckbox).prop("checked", attrs.checked)
3023+
$(attrs.jcheckbox).attr('aria-checked', attrs.checked)
30203024
attrs.bind(ccheckbox)
30213025
} )
30223026
$('<span id='+attrs._id+'> '+attrs.text+'</span>').appendTo(attrs.pos)
@@ -3151,7 +3155,8 @@
31513155
widgetid++
31523156
attrs._id = widgetid.toString()
31533157
if (attrs.prompt != '') attrs.__wprompt = wtext({text:attrs.prompt+' ', pos:attrs.pos})
3154-
attrs.jwinput = $(`<input type="text" id="${attrs._id}" aria-label="${attrs.aria_label}"/>`).val(attrs.text).appendTo(attrs.pos)
3158+
let aria_label = attrs.aria_label || attrs.text
3159+
attrs.jwinput = $(`<input type="text" id="${attrs._id}" aria-label="${aria_label}"/>`).val(attrs.text).appendTo(attrs.pos)
31553160
.css({"width":attrs.width.toString()+'px', "height":attrs.height.toString()+'px',
31563161
"font-size":(attrs.height-5).toString()+"px", "font-family":"sans-serif"})
31573162
.keypress( function(k) {
@@ -3217,7 +3222,8 @@
32173222
}
32183223
}
32193224
attrs.disabled = booleanize(attrs.disabled)
3220-
attrs.jbutton = $(`<button aria-label:"${attrs.aria_label}"/>`).html(attrs.text).appendTo(attrs.pos)
3225+
let aria_label = attrs.aria_label || attrs.text
3226+
attrs.jbutton = $(`<button aria-label="${aria_label}"/>`).html(attrs.text).appendTo(attrs.pos)
32213227
.css({color:rgb_to_css(attrs.color), backgroundColor:rgb_to_css(attrs.background), "font-size":"15px"})
32223228
.click( function() { attrs.bind(cbutton) } )
32233229
attrs.prefix = wtext(' ')
@@ -3235,7 +3241,7 @@
32353241
get text() {return attrs.text},
32363242
set text(value) {
32373243
attrs.text = value
3238-
$(attrs.jbutton).html(attrs.text)
3244+
$(attrs.jbutton).html(attrs.text).attr('aria-label', value)
32393245
},
32403246
get textcolor() {return attrs.color}, // legacy name; no apparent reason why it was "textcolor" instead of "color"
32413247
set textcolor(value) {
@@ -3342,8 +3348,9 @@
33423348
// otherwise the slider value has been changed by program, in which case
33433349
// we do NOT call the bound function, as it makes it difficult to manage
33443350
// multiple sliders that interact, as in the RGB-HSV demo program.
3345-
3346-
$(`<span aria-label="${attrs.aria_label}" id="${attrs._id}"></span>`).css({float:attrs.align,
3351+
3352+
$(`<span aria-role="slider" aria-label="${attrs.aria_label}" aria-valuemin="${attrs.min}"
3353+
aria-valuemax="${attrs.max}" id="${attrs._id}"></span>`).css({float:attrs.align,
33473354
width:w, height:h, margin:m, display:"inline-block"}).appendTo(attrs.pos)
33483355
attrs.jslider = $( '#'+attrs._id ).slider({orientation:o, range:"min",
33493356
min:attrs.min, max:attrs.max, value:attrs.value, step:attrs.step,

0 commit comments

Comments
 (0)