markitup.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. (function($) {
  2. /**
  3. * Attach this editor to a target element.
  4. */
  5. Drupal.wysiwyg.editor.attach.markitup = function(context, params, settings) {
  6. $('#' + params.field, context).markItUp(settings);
  7. // Adjust CSS for editor buttons.
  8. $.each(settings.markupSet, function (button) {
  9. $('.' + settings.nameSpace + ' .' + this.className + ' a')
  10. .css({ backgroundImage: 'url(' + settings.root + 'sets/default/images/' + button + '.png' + ')' })
  11. .parents('li').css({ backgroundImage: 'none' });
  12. });
  13. };
  14. /**
  15. * Detach a single or all editors.
  16. */
  17. Drupal.wysiwyg.editor.detach.markitup = function (context, params, trigger) {
  18. if (trigger == 'serialize') {
  19. return;
  20. }
  21. if (typeof params != 'undefined') {
  22. $('#' + params.field, context).markItUpRemove();
  23. }
  24. else {
  25. $('.markItUpEditor', context).markItUpRemove();
  26. }
  27. };
  28. Drupal.wysiwyg.editor.instance.markitup = {
  29. insert: function (content) {
  30. $.markItUp({ replaceWith: content });
  31. },
  32. setContent: function (content) {
  33. $('#' + this.field).val(content);
  34. },
  35. getContent: function () {
  36. return $('#' + this.field).val();
  37. }
  38. };
  39. })(jQuery);