]>
git.immae.eu Git - perso/Immae/Projets/packagist/ludivine-ckeditor-component.git/blob - sources/plugins/a11yhelp/dialogs/a11yhelp.js
2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
6 CKEDITOR
.dialog
.add( 'a11yHelp', function( editor
) {
7 var lang
= editor
.lang
.a11yhelp
,
8 coreLang
= editor
.lang
.common
.keyboard
,
9 id
= CKEDITOR
.tools
.getNextId();
11 // CharCode <-> KeyChar.
32 91: lang
.leftWindowKey
,
33 92: lang
.rightWindowKey
,
48 110: lang
.decimalPoint
,
69 191: lang
.forwardSlash
,
70 192: lang
.graveAccent
,
71 219: lang
.openBracket
,
73 221: lang
.closeBracket
,
77 // Modifier keys override.
78 keyMap
[ CKEDITOR
.ALT
] = coreLang
[ 18 ];
79 keyMap
[ CKEDITOR
.SHIFT
] = coreLang
[ 16 ];
80 keyMap
[ CKEDITOR
.CTRL
] = coreLang
[ 17 ];
83 var modifiers
= [ CKEDITOR
.ALT
, CKEDITOR
.SHIFT
, CKEDITOR
.CTRL
];
85 function representKeyStroke( keystroke
) {
86 var quotient
, modifier
,
89 for ( var i
= 0; i
< modifiers
.length
; i
++ ) {
90 modifier
= modifiers
[ i
];
91 quotient
= keystroke
/ modifiers
[ i
];
92 if ( quotient
> 1 && quotient
<= 2 ) {
93 keystroke
-= modifier
;
94 presentation
.push( keyMap
[ modifier
] );
98 presentation
.push( keyMap
[ keystroke
] || String
.fromCharCode( keystroke
) );
100 return presentation
.join( '+' );
103 var variablesPattern
= /\$\{(.*?)\}/g;
105 var replaceVariables
= ( function() {
106 // Swaps keystrokes with their commands in object literal.
107 // This makes searching keystrokes by command much easier.
108 var keystrokesByCode
= editor
.keystrokeHandler
.keystrokes
,
109 keystrokesByName
= {};
111 for ( var i
in keystrokesByCode
)
112 keystrokesByName
[ keystrokesByCode
[ i
] ] = i
;
114 return function( match
, name
) {
115 // Return the keystroke representation or leave match untouched
116 // if there's no keystroke for such command.
117 return keystrokesByName
[ name
] ? representKeyStroke( keystrokesByName
[ name
] ) : match
;
121 // Create the help list directly from lang file entries.
122 function buildHelpContents() {
123 var pageTpl
= '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id
+ '_arialbl" tabIndex="-1">%1</div>' +
124 '<span id="' + id
+ '_arialbl" class="cke_voice_label">' + lang
.contents
+ ' </span>',
125 sectionTpl
= '<h1>%1</h1><dl>%2</dl>',
126 itemTpl
= '<dt>%1</dt><dd>%2</dd>';
129 sections
= lang
.legend
,
130 sectionLength
= sections
.length
;
132 for ( var i
= 0; i
< sectionLength
; i
++ ) {
133 var section
= sections
[ i
],
135 items
= section
.items
,
136 itemsLength
= items
.length
;
138 for ( var j
= 0; j
< itemsLength
; j
++ ) {
139 var item
= items
[ j
],
140 itemLegend
= item
.legend
.replace( variablesPattern
, replaceVariables
);
142 // (#9765) If some commands haven't been replaced in the legend,
143 // most likely their keystrokes are unavailable and we shouldn't include
144 // them in our help list.
145 if ( itemLegend
.match( variablesPattern
) )
148 sectionHtml
.push( itemTpl
.replace( '%1', item
.name
).replace( '%2', itemLegend
) );
151 pageHtml
.push( sectionTpl
.replace( '%1', section
.name
).replace( '%2', sectionHtml
.join( '' ) ) );
154 return pageTpl
.replace( '%1', pageHtml
.join( '' ) );
163 label: editor
.lang
.common
.generalTab
,
169 style: 'white-space:normal;',
171 this.getElement().focus();
173 html: buildHelpContents() + '<style type="text/css">' +
174 '.cke_accessibility_legend' +
178 'padding-right:5px;' +
180 'overflow-x:hidden;' +
182 // Some adjustments are to be done for Quirks to work "properly" (#5757)
183 '.cke_browser_quirks .cke_accessibility_legend,' +
187 // Override non-wrapping white-space rule in reset css.
188 '.cke_accessibility_legend *' +
190 'white-space:normal;' +
192 '.cke_accessibility_legend h1' +
195 'border-bottom: 1px solid #AAA;' +
196 'margin: 5px 0px 15px;' +
198 '.cke_accessibility_legend dl' +
200 'margin-left: 5px;' +
202 '.cke_accessibility_legend dt' +
205 'font-weight: bold;' +
207 '.cke_accessibility_legend dd' +
215 buttons: [ CKEDITOR
.dialog
.cancelButton
]