summaryrefslogtreecommitdiff
path: root/sites/all/modules/wysiwyg/editors/js/jwysiwyg.js
blob: d3e7490f78e0d4614b40c723329354c8cc7d0b25 (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
39
40
41
42
43
(function($) {

/**
 * Attach this editor to a target element.
 */
Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, settings) {
  // Attach editor.
  $('#' + params.field).wysiwyg();
};

/**
 * Detach a single or all editors.
 */
Drupal.wysiwyg.editor.detach.jwysiwyg = function (context, params, trigger) {
  var $field = $('#' + params.field);
  var editor = $field.data('wysiwyg');
  if (typeof editor != 'undefined') {
    editor.saveContent();
    if (trigger != 'serialize') {
      editor.element.remove();
    }
  }
  $field.removeData('wysiwyg');
  if (trigger != 'serialize') {
    $field.show();
  }
};

Drupal.wysiwyg.editor.instance.jwysiwyg = {
  insert: function (content) {
    $('#' + this.field).wysiwyg('insertHtml', content);
  },

  setContent: function (content) {
    $('#' + this.field).wysiwyg('setContent', content);
  },

  getContent: function () {
    return $('#' + this.field).wysiwyg('getContent');
  }
};

})(jQuery);