2882
2882
function radio ( args ) { // a radio button
2883
2883
if ( ! ( this instanceof radio ) ) return new radio ( args ) // so radio() is like new radio()
2884
2884
var cvs = canvas . get_selected ( )
2885
- var attrs = { pos :cvs . caption_anchor , checked :false , text :'' , disabled :false , name :null }
2885
+ var attrs = { pos :cvs . caption_anchor , aria_label : "" , checked :false , text :'' , disabled :false , name :null }
2886
2886
if ( args . bind !== undefined ) {
2887
2887
attrs . bind = args . bind
2888
2888
delete args . bind
2902
2902
if ( attrs . name !== null && ( __radio_buttons [ attrs . name ] === undefined ) )
2903
2903
__radio_buttons [ attrs . name ] = null
2904
2904
2905
- attrs . jradio = $ ( ' <input type="radio"/>' ) . css ( { width :'16px' , height :'16px' } ) . appendTo ( attrs . pos )
2905
+ attrs . jradio = $ ( ` <input aria-label=" ${ attrs . aria_label } " type="radio">` ) . css ( { width :'16px' , height :'16px' } ) . appendTo ( attrs . pos )
2906
2906
. click ( function ( ) {
2907
2907
if ( attrs . name === null ) {
2908
2908
attrs . checked = ! attrs . checked
2919
2919
}
2920
2920
} )
2921
2921
2922
- $ ( ' <span id=' + attrs . _id + '> ' + attrs . text + ' </span>' ) . appendTo ( attrs . pos )
2922
+ $ ( ` <span id=" ${ attrs . _id } "> ${ attrs . text } </span>` ) . appendTo ( attrs . pos )
2923
2923
2924
2924
var cradio = { // this structure implements a JavaScript "closure", essential for radio to work
2925
2925
get disabled ( ) { return attrs . disabled } ,
2999
2999
function checkbox ( args ) { // a checkbox
3000
3000
if ( ! ( this instanceof checkbox ) ) return new checkbox ( args ) // so checkbox() is like new checkbox()
3001
3001
var cvs = canvas . get_selected ( )
3002
- var attrs = { pos :cvs . caption_anchor , checked :false , text :'' , disabled :false }
3002
+ var attrs = { pos :cvs . caption_anchor , aria_label : "" , checked :false , text :'' , disabled :false }
3003
3003
if ( args . bind !== undefined ) {
3004
3004
attrs . bind = args . bind
3005
3005
delete args . bind
3013
3013
attrs . disabled = booleanize ( attrs . disabled )
3014
3014
widgetid ++
3015
3015
attrs . _id = widgetid . toString ( )
3016
- attrs . jcheckbox = $ ( ' <input type="checkbox"/>' ) . css ( { width :'16px' , height :'16px' } ) . appendTo ( attrs . pos )
3016
+ attrs . jcheckbox = $ ( ` <input aria-label=" ${ attrs . aria_label } " type="checkbox"/>` ) . css ( { width :'16px' , height :'16px' } ) . appendTo ( attrs . pos )
3017
3017
. click ( function ( ) {
3018
3018
attrs . checked = ! attrs . checked
3019
3019
$ ( attrs . jcheckbox ) . prop ( "checked" , attrs . checked )
3091
3091
// Would like to implement scrolling number: https://github.com/juancgarcia/dragIt, which was inspired by an idea of Bret Victor
3092
3092
args = args || { }
3093
3093
var cvs = canvas . get_selected ( )
3094
- var attrs = { pos :cvs . caption_anchor , text :'' , prompt :'' , width :100 , height :20 , type :'numeric' , number :null , disabled :false }
3094
+ var attrs = { pos :cvs . caption_anchor , aria_label : '' , text :'' , prompt :'' , width :100 , height :20 , type :'numeric' , number :null , disabled :false }
3095
3095
for ( var a in attrs ) {
3096
3096
if ( args [ a ] !== undefined ) {
3097
3097
attrs [ a ] = args [ a ]
3151
3151
widgetid ++
3152
3152
attrs . _id = widgetid . toString ( )
3153
3153
if ( attrs . prompt != '' ) attrs . __wprompt = wtext ( { text :attrs . prompt + ' ' , pos :attrs . pos } )
3154
- attrs . jwinput = $ ( ' <input type="text" id="' + attrs . _id + '"/>' ) . val ( attrs . text ) . appendTo ( attrs . pos )
3154
+ attrs . jwinput = $ ( ` <input type="text" id="${ attrs . _id } " aria-label=" ${ attrs . aria_label } "/>` ) . val ( attrs . text ) . appendTo ( attrs . pos )
3155
3155
. css ( { "width" :attrs . width . toString ( ) + 'px' , "height" :attrs . height . toString ( ) + 'px' ,
3156
3156
"font-size" :( attrs . height - 5 ) . toString ( ) + "px" , "font-family" :"sans-serif" } )
3157
3157
. keypress ( function ( k ) {
3205
3205
function button ( args ) {
3206
3206
if ( ! ( this instanceof button ) ) return new button ( args ) // so button() is like new button()
3207
3207
var cvs = canvas . get_selected ( )
3208
- var attrs = { pos :cvs . caption_anchor , text :' ' , color :vec ( 0 , 0 , 0 ) , background :vec ( 1 , 1 , 1 ) , disabled :false }
3208
+ var attrs = { pos :cvs . caption_anchor , aria_label : "" , text :' ' , color :vec ( 0 , 0 , 0 ) , background :vec ( 1 , 1 , 1 ) , disabled :false }
3209
3209
if ( args . bind !== undefined ) {
3210
3210
attrs . bind = args . bind
3211
3211
delete args . bind
3217
3217
}
3218
3218
}
3219
3219
attrs . disabled = booleanize ( attrs . disabled )
3220
- attrs . jbutton = $ ( ' <button/>' ) . html ( attrs . text ) . appendTo ( attrs . pos )
3220
+ attrs . jbutton = $ ( ` <button aria-label:" ${ attrs . aria_label } "/>` ) . html ( attrs . text ) . appendTo ( attrs . pos )
3221
3221
. css ( { color :rgb_to_css ( attrs . color ) , backgroundColor :rgb_to_css ( attrs . background ) , "font-size" :"15px" } )
3222
3222
. click ( function ( ) { attrs . bind ( cbutton ) } )
3223
3223
attrs . prefix = wtext ( ' ' )
3272
3272
if ( ! ( this instanceof slider ) ) return new slider ( args ) // so slider() is like new slider()
3273
3273
var margin = 12 // minimum margin to ensure that drag element doesn't intrude on neighboring text
3274
3274
var cvs = canvas . get_selected ( )
3275
- var attrs = { pos :cvs . caption_anchor , length :400 , width :10 , vertical :false , disabled :false ,
3275
+ var attrs = { pos :cvs . caption_anchor , aria_label : "" , length :400 , width :10 , vertical :false , disabled :false ,
3276
3276
min :0 , max :1 , align :'none' , top :0 , right :0 , bottom :0 , left :0 }
3277
3277
if ( args . bind !== undefined ) {
3278
3278
attrs . bind = args . bind
3343
3343
// we do NOT call the bound function, as it makes it difficult to manage
3344
3344
// multiple sliders that interact, as in the RGB-HSV demo program.
3345
3345
3346
- $ ( " <span id="+ attrs . _id + "></span>" ) . css ( { float :attrs . align ,
3346
+ $ ( ` <span aria-label=" ${ attrs . aria_label } " id="${ attrs . _id } "></span>` ) . css ( { float :attrs . align ,
3347
3347
width :w , height :h , margin :m , display :"inline-block" } ) . appendTo ( attrs . pos )
3348
3348
attrs . jslider = $ ( '#' + attrs . _id ) . slider ( { orientation :o , range :"min" ,
3349
3349
min :attrs . min , max :attrs . max , value :attrs . value , step :attrs . step ,
3389
3389
function menu ( args ) {
3390
3390
if ( ! ( this instanceof menu ) ) return new menu ( args ) // so menu() is like new menu()
3391
3391
var cvs = canvas . get_selected ( )
3392
- var attrs = { pos :cvs . caption_anchor , selected :null , disabled :false }
3392
+ var attrs = { pos :cvs . caption_anchor , aria_label : "" , selected :null , disabled :false }
3393
3393
if ( args . bind !== undefined ) {
3394
3394
attrs . bind = args . bind
3395
3395
delete args . bind
3413
3413
else s += '<option>' + cc + '</option>\n'
3414
3414
}
3415
3415
attrs . disabled = booleanize ( attrs . disabled )
3416
- attrs . jmenu = $ ( ' <select>' + s + ' </select>' ) . css ( "font-size" , "15px" ) . change ( function ( ) {
3416
+ attrs . jmenu = $ ( ` <select aria-label=" ${ attrs . aria_label } "> ${ s } </select>` ) . css ( "font-size" , "15px" ) . change ( function ( ) {
3417
3417
attrs . bind ( cmenu )
3418
3418
} ) . appendTo ( attrs . pos )
3419
3419
attrs . postfix = wtext ( ' ' )
3498
3498
}
3499
3499
3500
3500
Export ( exports )
3501
- } ) ( )
3501
+ } ) ( )
0 commit comments