editor.tinymce.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /**
  2. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  3. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  4. *
  5. * @defgroup TridentCore Trident Core
  6. * @{
  7. */
  8. function bx_editor_insert_img (sEditorId, sImgId, sImgUrl, sClasses) {
  9. var eEditor = 'object' == typeof(tinymce) ? tinymce.get(sEditorId) : undefined;
  10. if ('undefined' == typeof(eEditor))
  11. return;
  12. if (eEditor.dom && eEditor.dom.doc && eEditor.dom.doc.getElementById(sImgId))
  13. return;
  14. if ('undefined' == typeof(sClasses))
  15. sClasses = '';
  16. eEditor.execCommand('mceInsertContent', false, '<img id="' + sImgId + '" class="' + sClasses + '" src="' + sImgUrl + '" />');
  17. }
  18. function bx_editor_remove_img (aEditorIds, aMarkers) {
  19. if ('object' != typeof(tinymce))
  20. return;
  21. var aEditors = [];
  22. for (var i in aEditorIds)
  23. aEditors.push(tinymce.get(aEditorIds[i]));
  24. for (var j in aEditors) {
  25. var eEditor = aEditors[j];
  26. if ('object' == typeof(eEditor) && 'object' == typeof(eEditor) && eEditor.dom && eEditor.dom.doc) {
  27. // delete images in html editor
  28. for (var i in aMarkers) {
  29. var jFiles = $(eEditor.dom.doc).find(aMarkers[i]);
  30. jFiles.each(function () {
  31. eEditor.execCommand('mceRemoveNode', false, this);
  32. });
  33. }
  34. }
  35. }
  36. }
  37. /** @} */