]>
git.immae.eu Git - perso/Immae/Projets/packagist/piedsjaloux-ckeditor-component.git/blob - sources/plugins/a11yhelp/dialogs/a11yhelp.js
2 * @license Copyright (c) 2003-2016, 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 id
= CKEDITOR
.tools
.getNextId();
10 // CharCode <-> KeyChar.
31 91: lang
.leftWindowKey
,
32 92: lang
.rightWindowKey
,
47 110: lang
.decimalPoint
,
68 191: lang
.forwardSlash
,
69 192: lang
.graveAccent
,
70 219: lang
.openBracket
,
72 221: lang
.closeBracket
,
76 // Modifier keys override.
77 keyMap
[ CKEDITOR
.ALT
] = lang
.alt
;
78 keyMap
[ CKEDITOR
.SHIFT
] = lang
.shift
;
79 keyMap
[ CKEDITOR
.CTRL
] = lang
.ctrl
;
82 var modifiers
= [ CKEDITOR
.ALT
, CKEDITOR
.SHIFT
, CKEDITOR
.CTRL
];
84 function representKeyStroke( keystroke
) {
85 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;
104 var replaceVariables
= ( function() {
105 // Swaps keystrokes with their commands in object literal.
106 // This makes searching keystrokes by command much easier.
107 var keystrokesByCode
= editor
.keystrokeHandler
.keystrokes
,
108 keystrokesByName
= {};
110 for ( var i
in keystrokesByCode
)
111 keystrokesByName
[ keystrokesByCode
[ i
] ] = i
;
113 return function( match
, name
) {
114 // Return the keystroke representation or leave match untouched
115 // if there's no keystroke for such command.
116 return keystrokesByName
[ name
] ? representKeyStroke( keystrokesByName
[ name
] ) : match
;
120 // Create the help list directly from lang file entries.
121 function buildHelpContents() {
122 var pageTpl
= '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id
+ '_arialbl" tabIndex="-1">%1</div>' +
123 '<span id="' + id
+ '_arialbl" class="cke_voice_label">' + lang
.contents
+ ' </span>',
124 sectionTpl
= '<h1>%1</h1><dl>%2</dl>',
125 itemTpl
= '<dt>%1</dt><dd>%2</dd>';
128 sections
= lang
.legend
,
129 sectionLength
= sections
.length
;
131 for ( var i
= 0; i
< sectionLength
; i
++ ) {
132 var section
= sections
[ i
],
134 items
= section
.items
,
135 itemsLength
= items
.length
;
137 for ( var j
= 0; j
< itemsLength
; j
++ ) {
138 var item
= items
[ j
],
139 itemLegend
= item
.legend
.replace( variablesPattern
, replaceVariables
);
141 // (#9765) If some commands haven't been replaced in the legend,
142 // most likely their keystrokes are unavailable and we shouldn't include
143 // them in our help list.
144 if ( itemLegend
.match( variablesPattern
) )
147 sectionHtml
.push( itemTpl
.replace( '%1', item
.name
).replace( '%2', itemLegend
) );
150 pageHtml
.push( sectionTpl
.replace( '%1', section
.name
).replace( '%2', sectionHtml
.join( '' ) ) );
153 return pageTpl
.replace( '%1', pageHtml
.join( '' ) );
162 label: editor
.lang
.common
.generalTab
,
168 style: 'white-space:normal;',
170 this.getElement().focus();
172 html: buildHelpContents() + '<style type="text/css">' +
173 '.cke_accessibility_legend' +
177 'padding-right:5px;' +
179 'overflow-x:hidden;' +
181 // Some adjustments are to be done for Quirks to work "properly" (#5757)
182 '.cke_browser_quirks .cke_accessibility_legend,' +
186 // Override non-wrapping white-space rule in reset css.
187 '.cke_accessibility_legend *' +
189 'white-space:normal;' +
191 '.cke_accessibility_legend h1' +
194 'border-bottom: 1px solid #AAA;' +
195 'margin: 5px 0px 15px;' +
197 '.cke_accessibility_legend dl' +
199 'margin-left: 5px;' +
201 '.cke_accessibility_legend dt' +
204 'font-weight: bold;' +
206 '.cke_accessibility_legend dd' +
214 buttons: [ CKEDITOR
.dialog
.cancelButton
]