plugin.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or http://ckeditor.com/license
  4. */
  5. /**
  6. * @fileOverview Plugin definition for the a11yhelp, which provides a dialog
  7. * with accessibility related help.
  8. */
  9. ( function() {
  10. var pluginName = 'a11yhelp',
  11. commandName = 'a11yHelp';
  12. CKEDITOR.plugins.add( pluginName, {
  13. requires: 'dialog',
  14. // List of available localizations.
  15. // jscs:disable
  16. availableLangs: { af:1,ar:1,bg:1,ca:1,cs:1,cy:1,da:1,de:1,el:1,en:1,'en-gb':1,eo:1,es:1,et:1,fa:1,fi:1,fo:1,fr:1,'fr-ca':1,gl:1,gu:1,he:1,hi:1,hr:1,hu:1,id:1,it:1,ja:1,km:1,ko:1,ku:1,lt:1,lv:1,mk:1,mn:1,nb:1,nl:1,no:1,pl:1,pt:1,'pt-br':1,ro:1,ru:1,si:1,sk:1,sl:1,sq:1,sr:1,'sr-latn':1,sv:1,th:1,tr:1,tt:1,ug:1,uk:1,vi:1,zh:1,'zh-cn':1 },
  17. // jscs:enable
  18. init: function( editor ) {
  19. var plugin = this;
  20. editor.addCommand( commandName, {
  21. exec: function() {
  22. var langCode = editor.langCode;
  23. langCode =
  24. plugin.availableLangs[ langCode ] ? langCode :
  25. plugin.availableLangs[ langCode.replace( /-.*/, '' ) ] ? langCode.replace( /-.*/, '' ) :
  26. 'en';
  27. CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( plugin.path + 'dialogs/lang/' + langCode + '.js' ), function() {
  28. editor.lang.a11yhelp = plugin.langEntries[ langCode ];
  29. editor.openDialog( commandName );
  30. } );
  31. },
  32. modes: { wysiwyg: 1, source: 1 },
  33. readOnly: 1,
  34. canUndo: false
  35. } );
  36. editor.setKeystroke( CKEDITOR.ALT + 48 /*0*/, 'a11yHelp' );
  37. CKEDITOR.dialog.add( commandName, this.path + 'dialogs/a11yhelp.js' );
  38. editor.on( 'ariaEditorHelpLabel', function( evt ) {
  39. evt.data.label = editor.lang.common.editorHelp;
  40. } );
  41. }
  42. } );
  43. } )();