| 29 | function speak( textToSpeech, manner ) |
| 30 | { |
| 31 | var speaker = CKEDITOR.document.getById( 'live-region' ); |
| 32 | if( !speaker ) |
| 33 | { |
| 34 | speaker = CKEDITOR.dom.element.createFromHtml( |
| 35 | '<span class="cke_live_region" id="live-region" ' + |
| 36 | 'style="position: absolute; display: block; width: 0; height: 0; overflow: hidden;"' + |
| 37 | '> </span>' ); |
| 38 | CKEDITOR.document.getBody().append( speaker ); |
| 39 | } |
| 40 | |
| 41 | speaker.setText( textToSpeech ); |
| 42 | speaker.setAttribute( 'aria-live', manner || 'rude' ); |
| 43 | CKEDITOR.tools.setTimeout( function() |
| 44 | { |
| 45 | speaker.setText( '\xa0' ); |
| 46 | speaker.setAttribute( 'aria-live', 'off' ); |
| 47 | }, 500, this ); |
| 48 | } |
| 49 | |
| 50 | function extracAriaInfo( element ) |
| 51 | { |
| 52 | var doc = element.getDocument(), |
| 53 | role = element.getAttribute( 'role' ) || ''; |
| 54 | |
| 55 | var attrValue, |
| 56 | labelText = element.getAttribute( 'aria-label' ) || ( attrValue = element.getAttribute( 'aria-labelledby' ) ) && doc.getById( attrValue ).getText() || '', |
| 57 | descriptionText = ( attrValue = element.getAttribute( 'aria-describedby' ) ) && doc.getById( attrValue ).getText() || '', |
| 58 | composition = [ labelText, role in silentRoles ? '' : role, descriptionText ].join( ' ' ); |
| 59 | |
| 60 | return composition; |
| 61 | } |
| 62 | |
58 | | // Translate 'dialog' role by wrapping all containing form fields with a legend that composed of all ARIA |
59 | | // attributes of the dialog which leads to be announced by ATs. |
60 | | if ( role == 'dialog' ) |
61 | | { |
62 | | var fieldset = CKEDITOR.dom.element.createFromHtml( |
63 | | '<fieldset style="position: relative;height: 100%;">' + |
64 | | '<legend class="cke_voice_label">' + |
65 | | CKEDITOR.tools.htmlEncode( allInOne ) + |
66 | | '</legend>' + |
67 | | '</fieldset>', doc ); |
68 | | |
69 | | var parent; |
70 | | while( ( parent = element.getParent() ) && !parent.getDtd()[ fieldset.getName() ] ) |
71 | | element = parent; |
72 | | fieldset.insertBefore( element ); |
73 | | fieldset.append( element ); |
74 | | } |