fckeditor.config.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. Drupal = window.parent.Drupal;
  2. /**
  3. * Fetch and provide original editor settings as local variable.
  4. *
  5. * FCKeditor does not support to pass complex variable types to the editor.
  6. * Instance settings passed to FCKinstance.Config are temporarily stored in
  7. * FCKConfig.PageConfig.
  8. */
  9. var wysiwygFormat = FCKConfig.PageConfig.wysiwygFormat;
  10. var wysiwygSettings = Drupal.settings.wysiwyg.configs.fckeditor[wysiwygFormat];
  11. var pluginSettings = (Drupal.settings.wysiwyg.plugins[wysiwygFormat] ? Drupal.settings.wysiwyg.plugins[wysiwygFormat] : { 'native': {}, 'drupal': {} });
  12. /**
  13. * Apply format-specific settings.
  14. */
  15. for (var setting in wysiwygSettings) {
  16. if (setting == 'buttons') {
  17. // Apply custom Wysiwyg toolbar for this format.
  18. // FCKConfig.ToolbarSets['Wysiwyg'] = wysiwygSettings.buttons;
  19. // Temporarily stack buttons into multiple button groups and remove
  20. // separators until #277954 is solved.
  21. FCKConfig.ToolbarSets['Wysiwyg'] = [];
  22. for (var i = 0; i < wysiwygSettings.buttons[0].length; i++) {
  23. FCKConfig.ToolbarSets['Wysiwyg'].push([wysiwygSettings.buttons[0][i]]);
  24. }
  25. FCKTools.AppendStyleSheet(document, '#xToolbar .TB_Start { display:none; }');
  26. // Set valid height of select element in silver and office2003 skins.
  27. if (FCKConfig.SkinPath.match(/\/office2003\/$/)) {
  28. FCKTools.AppendStyleSheet(document, '#xToolbar .SC_FieldCaption { height: 24px; } #xToolbar .TB_End { display: none; }');
  29. }
  30. else if (FCKConfig.SkinPath.match(/\/silver\/$/)) {
  31. FCKTools.AppendStyleSheet(document, '#xToolbar .SC_FieldCaption { height: 27px; }');
  32. }
  33. }
  34. else {
  35. FCKConfig[setting] = wysiwygSettings[setting];
  36. }
  37. }
  38. // Fix Drupal toolbar obscuring editor toolbar in fullscreen mode.
  39. var oldFitWindowExecute = FCKFitWindow.prototype.Execute;
  40. var $drupalToolbar = window.parent.jQuery('#toolbar', Drupal.overlayChild ? window.parent.window.parent.document : window.parent.document);
  41. FCKFitWindow.prototype.Execute = function() {
  42. oldFitWindowExecute.apply(this, arguments);
  43. if (this.IsMaximized) {
  44. $drupalToolbar.hide();
  45. }
  46. else {
  47. $drupalToolbar.show();
  48. }
  49. }
  50. /**
  51. * Initialize this editor instance.
  52. */
  53. Drupal.wysiwyg.editor.instance.fckeditor.init(window);
  54. /**
  55. * Register native plugins for this input format.
  56. *
  57. * Parameters to Plugins.Add are:
  58. * - Plugin name.
  59. * - Languages the plugin is available in.
  60. * - Location of the plugin folder; <plugin_name>/fckplugin.js is appended.
  61. */
  62. for (var plugin in pluginSettings['native']) {
  63. // Languages and path may be undefined for internal plugins.
  64. FCKConfig.Plugins.Add(plugin, pluginSettings['native'][plugin].languages, pluginSettings['native'][plugin].path);
  65. }
  66. /**
  67. * Register Drupal plugins for this input format.
  68. *
  69. * Parameters to addPlugin() are:
  70. * - Plugin name.
  71. * - Format specific plugin settings.
  72. * - General plugin settings.
  73. * - A reference to this window so the plugin setup can access FCKConfig.
  74. */
  75. for (var plugin in pluginSettings.drupal) {
  76. Drupal.wysiwyg.editor.instance.fckeditor.addPlugin(plugin, pluginSettings.drupal[plugin], Drupal.settings.wysiwyg.plugins.drupal[plugin], window);
  77. }