]>
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
] = CKEDITOR
.env
.mac
? coreLang
[ 224 ] : coreLang
[ 17 ];
83 var modifiers
= [ CKEDITOR
.ALT
, CKEDITOR
.SHIFT
, CKEDITOR
.CTRL
];
85 function representKeyStroke( keystroke
) {
86 var quotient
, modifier
,
88 for ( var i
= 0; i
< modifiers
.length
; i
++ ) {
89 modifier
= modifiers
[ i
];
90 quotient
= keystroke
/ modifiers
[ i
];
91 if ( quotient
> 1 && quotient
<= 2 ) {
92 keystroke
-= modifier
;
93 presentation
.push( keyMap
[ modifier
] );
97 presentation
.push( keyMap
[ keystroke
] || String
.fromCharCode( keystroke
) );
99 return presentation
.join( '+' );
102 var variablesPattern
= /\$\{(.*?)\}/g,
103 replaceVariables = function( match
, name
) {
104 var keystrokeCode
= editor
.getCommandKeystroke( name
);
106 // Return the keystroke representation or leave match untouched
107 // if there's no keystroke for such command.
108 return keystrokeCode
? representKeyStroke( keystrokeCode
) : match
;
111 // Create the help list directly from lang file entries.
112 function buildHelpContents() {
113 var pageTpl
= '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id
+ '_arialbl" tabIndex="-1">%1</div>' +
114 '<span id="' + id
+ '_arialbl" class="cke_voice_label">' + lang
.contents
+ ' </span>',
115 sectionTpl
= '<h1>%1</h1><dl>%2</dl>',
116 itemTpl
= '<dt>%1</dt><dd>%2</dd>';
119 sections
= lang
.legend
,
120 sectionLength
= sections
.length
;
122 for ( var i
= 0; i
< sectionLength
; i
++ ) {
123 var section
= sections
[ i
],
125 items
= section
.items
,
126 itemsLength
= items
.length
;
128 for ( var j
= 0; j
< itemsLength
; j
++ ) {
129 var item
= items
[ j
],
130 // (http://dev.ckeditor.com/ticket/16980) There should be a different hotkey shown in Commands on Edge browser.
131 itemLegend
= CKEDITOR
.env
.edge
&& item
.legendEdge
? item
.legendEdge : item
.legend
;
133 itemLegend
= itemLegend
.replace( variablesPattern
, replaceVariables
);
135 // (http://dev.ckeditor.com/ticket/9765) If some commands haven't been replaced in the legend,
136 // most likely their keystrokes are unavailable and we shouldn't include
137 // them in our help list.
138 if ( itemLegend
.match( variablesPattern
) ) {
142 sectionHtml
.push( itemTpl
.replace( '%1', item
.name
).replace( '%2', itemLegend
) );
145 pageHtml
.push( sectionTpl
.replace( '%1', section
.name
).replace( '%2', sectionHtml
.join( '' ) ) );
148 return pageTpl
.replace( '%1', pageHtml
.join( '' ) );
157 label: editor
.lang
.common
.generalTab
,
163 style: 'white-space:normal;',
165 this.getElement().focus();
167 html: buildHelpContents() + '<style type="text/css">' +
168 '.cke_accessibility_legend' +
172 'padding-right:5px;' +
174 'overflow-x:hidden;' +
176 // Some adjustments are to be done for Quirks to work "properly" (http://dev.ckeditor.com/ticket/5757)
177 '.cke_browser_quirks .cke_accessibility_legend,' +
181 // Override non-wrapping white-space rule in reset css.
182 '.cke_accessibility_legend *' +
184 'white-space:normal;' +
186 '.cke_accessibility_legend h1' +
189 'border-bottom: 1px solid #AAA;' +
190 'margin: 5px 0px 15px;' +
192 '.cke_accessibility_legend dl' +
194 'margin-left: 5px;' +
196 '.cke_accessibility_legend dt' +
199 'font-weight: bold;' +
201 '.cke_accessibility_legend dd' +
209 buttons: [ CKEDITOR
.dialog
.cancelButton
]