markitup.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. $('#' + params.field, context).markItUpRemove();
  22. };
  23. Drupal.wysiwyg.editor.instance.markitup = {
  24. insert: function (content) {
  25. $.markItUp({ replaceWith: content });
  26. },
  27. setContent: function (content) {
  28. $('#' + this.field).val(content);
  29. },
  30. getContent: function () {
  31. return $('#' + this.field).val();
  32. }
  33. };
  34. })(jQuery);