jwysiwyg.js 968 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. (function($) {
  2. /**
  3. * Attach this editor to a target element.
  4. */
  5. Drupal.wysiwyg.editor.attach.jwysiwyg = function(context, params, settings) {
  6. // Attach editor.
  7. $('#' + params.field).wysiwyg();
  8. };
  9. /**
  10. * Detach a single or all editors.
  11. */
  12. Drupal.wysiwyg.editor.detach.jwysiwyg = function (context, params, trigger) {
  13. var $field = $('#' + params.field);
  14. var editor = $field.data('wysiwyg');
  15. if (typeof editor != 'undefined') {
  16. editor.saveContent();
  17. if (trigger != 'serialize') {
  18. editor.element.remove();
  19. }
  20. }
  21. $field.removeData('wysiwyg');
  22. if (trigger != 'serialize') {
  23. $field.show();
  24. }
  25. };
  26. Drupal.wysiwyg.editor.instance.jwysiwyg = {
  27. insert: function (content) {
  28. $('#' + this.field).wysiwyg('insertHtml', content);
  29. },
  30. setContent: function (content) {
  31. $('#' + this.field).wysiwyg('setContent', content);
  32. },
  33. getContent: function () {
  34. return $('#' + this.field).wysiwyg('getContent');
  35. }
  36. };
  37. })(jQuery);