aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/a11yhelp/dialogs/a11yhelp.js
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/a11yhelp/dialogs/a11yhelp.js')
-rw-r--r--sources/plugins/a11yhelp/dialogs/a11yhelp.js55
1 files changed, 25 insertions, 30 deletions
diff --git a/sources/plugins/a11yhelp/dialogs/a11yhelp.js b/sources/plugins/a11yhelp/dialogs/a11yhelp.js
index 3936e43..eb12d4c 100644
--- a/sources/plugins/a11yhelp/dialogs/a11yhelp.js
+++ b/sources/plugins/a11yhelp/dialogs/a11yhelp.js
@@ -1,33 +1,34 @@
1/** 1/**
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. 2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license 3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */ 4 */
5 5
6CKEDITOR.dialog.add( 'a11yHelp', function( editor ) { 6CKEDITOR.dialog.add( 'a11yHelp', function( editor ) {
7 var lang = editor.lang.a11yhelp, 7 var lang = editor.lang.a11yhelp,
8 coreLang = editor.lang.common.keyboard,
8 id = CKEDITOR.tools.getNextId(); 9 id = CKEDITOR.tools.getNextId();
9 10
10 // CharCode <-> KeyChar. 11 // CharCode <-> KeyChar.
11 var keyMap = { 12 var keyMap = {
12 8: lang.backspace, 13 8: coreLang[ 8 ],
13 9: lang.tab, 14 9: lang.tab,
14 13: lang.enter, 15 13: coreLang[ 13 ],
15 16: lang.shift, 16 16: coreLang[ 16 ],
16 17: lang.ctrl, 17 17: coreLang[ 17 ],
17 18: lang.alt, 18 18: coreLang[ 18 ],
18 19: lang.pause, 19 19: lang.pause,
19 20: lang.capslock, 20 20: lang.capslock,
20 27: lang.escape, 21 27: lang.escape,
21 33: lang.pageUp, 22 33: lang.pageUp,
22 34: lang.pageDown, 23 34: lang.pageDown,
23 35: lang.end, 24 35: coreLang[ 35 ],
24 36: lang.home, 25 36: coreLang[ 36 ],
25 37: lang.leftArrow, 26 37: lang.leftArrow,
26 38: lang.upArrow, 27 38: lang.upArrow,
27 39: lang.rightArrow, 28 39: lang.rightArrow,
28 40: lang.downArrow, 29 40: lang.downArrow,
29 45: lang.insert, 30 45: lang.insert,
30 46: lang[ 'delete' ], 31 46: coreLang[ 46 ],
31 91: lang.leftWindowKey, 32 91: lang.leftWindowKey,
32 92: lang.rightWindowKey, 33 92: lang.rightWindowKey,
33 93: lang.selectKey, 34 93: lang.selectKey,
@@ -74,9 +75,9 @@ CKEDITOR.dialog.add( 'a11yHelp', function( editor ) {
74 }; 75 };
75 76
76 // Modifier keys override. 77 // Modifier keys override.
77 keyMap[ CKEDITOR.ALT ] = lang.alt; 78 keyMap[ CKEDITOR.ALT ] = coreLang[ 18 ];
78 keyMap[ CKEDITOR.SHIFT ] = lang.shift; 79 keyMap[ CKEDITOR.SHIFT ] = coreLang[ 16 ];
79 keyMap[ CKEDITOR.CTRL ] = lang.ctrl; 80 keyMap[ CKEDITOR.CTRL ] = CKEDITOR.env.mac ? coreLang[ 224 ] : coreLang[ 17 ];
80 81
81 // Sort in desc. 82 // Sort in desc.
82 var modifiers = [ CKEDITOR.ALT, CKEDITOR.SHIFT, CKEDITOR.CTRL ]; 83 var modifiers = [ CKEDITOR.ALT, CKEDITOR.SHIFT, CKEDITOR.CTRL ];
@@ -84,7 +85,6 @@ CKEDITOR.dialog.add( 'a11yHelp', function( editor ) {
84 function representKeyStroke( keystroke ) { 85 function representKeyStroke( keystroke ) {
85 var quotient, modifier, 86 var quotient, modifier,
86 presentation = []; 87 presentation = [];
87
88 for ( var i = 0; i < modifiers.length; i++ ) { 88 for ( var i = 0; i < modifiers.length; i++ ) {
89 modifier = modifiers[ i ]; 89 modifier = modifiers[ i ];
90 quotient = keystroke / modifiers[ i ]; 90 quotient = keystroke / modifiers[ i ];
@@ -99,23 +99,14 @@ CKEDITOR.dialog.add( 'a11yHelp', function( editor ) {
99 return presentation.join( '+' ); 99 return presentation.join( '+' );
100 } 100 }
101 101
102 var variablesPattern = /\$\{(.*?)\}/g; 102 var variablesPattern = /\$\{(.*?)\}/g,
103 103 replaceVariables = function( match, name ) {
104 var replaceVariables = ( function() { 104 var keystrokeCode = editor.getCommandKeystroke( name );
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 = {};
109
110 for ( var i in keystrokesByCode )
111 keystrokesByName[ keystrokesByCode[ i ] ] = i;
112 105
113 return function( match, name ) {
114 // Return the keystroke representation or leave match untouched 106 // Return the keystroke representation or leave match untouched
115 // if there's no keystroke for such command. 107 // if there's no keystroke for such command.
116 return keystrokesByName[ name ] ? representKeyStroke( keystrokesByName[ name ] ) : match; 108 return keystrokeCode ? representKeyStroke( keystrokeCode ) : match;
117 }; 109 };
118 } )();
119 110
120 // Create the help list directly from lang file entries. 111 // Create the help list directly from lang file entries.
121 function buildHelpContents() { 112 function buildHelpContents() {
@@ -136,13 +127,17 @@ CKEDITOR.dialog.add( 'a11yHelp', function( editor ) {
136 127
137 for ( var j = 0; j < itemsLength; j++ ) { 128 for ( var j = 0; j < itemsLength; j++ ) {
138 var item = items[ j ], 129 var item = items[ j ],
139 itemLegend = item.legend.replace( variablesPattern, replaceVariables ); 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;
140 132
141 // (#9765) If some commands haven't been replaced in the legend, 133 itemLegend = itemLegend.replace( variablesPattern, replaceVariables );
134
135 // (http://dev.ckeditor.com/ticket/9765) If some commands haven't been replaced in the legend,
142 // most likely their keystrokes are unavailable and we shouldn't include 136 // most likely their keystrokes are unavailable and we shouldn't include
143 // them in our help list. 137 // them in our help list.
144 if ( itemLegend.match( variablesPattern ) ) 138 if ( itemLegend.match( variablesPattern ) ) {
145 continue; 139 continue;
140 }
146 141
147 sectionHtml.push( itemTpl.replace( '%1', item.name ).replace( '%2', itemLegend ) ); 142 sectionHtml.push( itemTpl.replace( '%1', item.name ).replace( '%2', itemLegend ) );
148 } 143 }
@@ -178,7 +173,7 @@ CKEDITOR.dialog.add( 'a11yHelp', function( editor ) {
178 'overflow-y:auto;' + 173 'overflow-y:auto;' +
179 'overflow-x:hidden;' + 174 'overflow-x:hidden;' +
180 '}' + 175 '}' +
181 // Some adjustments are to be done for Quirks to work "properly" (#5757) 176 // Some adjustments are to be done for Quirks to work "properly" (http://dev.ckeditor.com/ticket/5757)
182 '.cke_browser_quirks .cke_accessibility_legend,' + 177 '.cke_browser_quirks .cke_accessibility_legend,' +
183 '{' + 178 '{' +
184 'height:390px' + 179 'height:390px' +