summaryrefslogtreecommitdiff
path: root/sites/all/modules/wysiwyg/editors/js/epiceditor.js
blob: 03c48017cd0dc2d6443d59fd4d7e959f8801f6b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
(function($) {

/**
 * Attach this editor to a target element.
 */
Drupal.wysiwyg.editor.attach.epiceditor = function (context, params, settings) {
  var $target = $('#' + params.field);
  var containerId = params.field + '-epiceditor';
  var defaultContent = $target.val();
  $target.hide().after('<div id="' + containerId + '" />');

  settings.container = containerId;
  settings.file = {
    defaultContent: defaultContent
  };
  settings.theme = {
    preview: '/themes/preview/preview-dark.css',
    editor: '/themes/editor/' + settings.theme + '.css'
  }
  var editor = new EpicEditor(settings).load();
  $target.data('epiceditor', editor);
};

/**
 * Detach a single or all editors.
 */
Drupal.wysiwyg.editor.detach.epiceditor = function (context, params, trigger) {
  var $target = $('#' + params.field);
  var editor = $target.data('epiceditor');

  $target.val(editor.exportFile());

  editor.unload(function () {
    $target.show();
  });
};

})(jQuery);