2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
6 CKEDITOR.dialog.add( 'a11yHelp', function( editor )
8 var lang = editor.lang.accessibilityHelp,
9 id = CKEDITOR.tools.getNextId();
11 // CharCode <-> KeyChar.
33 91 : "LEFT WINDOW KEY" ,
34 92 : "RIGHT WINDOW KEY" ,
49 110 : "DECIMAL POINT" ,
70 191 : "FORWARD SLASH" ,
71 192 : "GRAVE ACCENT" ,
72 219 : "OPEN BRACKET" ,
74 221 : "CLOSE BRAKET" ,
78 // Modifier keys override.
79 keyMap[ CKEDITOR.ALT ] = 'ALT';
80 keyMap[ CKEDITOR.SHIFT ] = 'SHIFT';
81 keyMap[ CKEDITOR.CTRL ] = 'CTRL';
84 var modifiers = [ CKEDITOR.ALT, CKEDITOR.SHIFT, CKEDITOR.CTRL ];
86 function representKeyStroke( keystroke )
92 for ( var i = 0; i < modifiers.length; i++ )
94 modifier = modifiers[ i ];
95 quotient = keystroke / modifiers[ i ];
96 if ( quotient > 1 && quotient <= 2 )
98 keystroke -= modifier;
99 presentation.push( keyMap[ modifier ] );
103 presentation.push( keyMap[ keystroke ]
104 || String.fromCharCode( keystroke ) );
106 return presentation.join( '+' );
109 var variablesPattern = /\$\{(.*?)\}/g;
110 function replaceVariables( match, name )
112 var keystrokes = editor.config.keystrokes,
114 length = keystrokes.length;
116 for ( var i = 0; i < length; i++ )
118 definition = keystrokes[ i ];
119 if ( definition[ 1 ] == name )
122 return representKeyStroke( definition[ 0 ] );
125 // Create the help list directly from lang file entries.
126 function buildHelpContents()
128 var pageTpl = '<div class="cke_accessibility_legend" role="document" aria-labelledby="' + id + '_arialbl" tabIndex="-1">%1</div>' +
129 '<span id="' + id + '_arialbl" class="cke_voice_label">' + lang.contents + ' </span>',
130 sectionTpl = '<h1>%1</h1><dl>%2</dl>',
131 itemTpl = '<dt>%1</dt><dd>%2</dd>';
134 sections = lang.legend,
135 sectionLength = sections.length;
137 for ( var i = 0; i < sectionLength; i++ )
139 var section = sections[ i ],
141 items = section.items,
142 itemsLength = items.length;
144 for ( var j = 0; j < itemsLength; j++ )
146 var item = items[ j ],
148 itemHtml = itemTpl.replace( '%1', item.name ).
149 replace( '%2', item.legend.replace( variablesPattern, replaceVariables ) );
150 sectionHtml.push( itemHtml );
153 pageHtml.push( sectionTpl.replace( '%1', section.name ).replace( '%2', sectionHtml.join( '' ) ) );
156 return pageTpl.replace( '%1', pageHtml.join( '' ) );
166 label : editor.lang.common.generalTab,
173 focus : function() {},
174 html : buildHelpContents() +
175 '<style type="text/css">' +
176 '.cke_accessibility_legend' +
180 'padding-right:5px;' +
182 'overflow-x:hidden;' +
184 '.cke_accessibility_legend h1' +
187 'border-bottom: 1px solid #AAA;' +
188 'margin: 5px 0px 15px;' +
190 '.cke_accessibility_legend dl' +
192 'margin-left: 5px;' +
194 '.cke_accessibility_legend dt' +
197 'font-weight: bold;' +
199 '.cke_accessibility_legend dd' +
201 'white-space:normal;' +
209 buttons : [ CKEDITOR.dialog.cancelButton ]