ins.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * $Id: editor_plugin_src.js 42 2006-08-08 14:32:24Z spocke $
  3. *
  4. * @author Moxiecode - based on work by Andrew Tetlaw
  5. * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
  6. */
  7. function init() {
  8. SXE.initElementDialog('ins');
  9. if (SXE.currentAction == "update") {
  10. setFormValue('datetime', tinyMCEPopup.editor.dom.getAttrib(SXE.updateElement, 'datetime'));
  11. setFormValue('cite', tinyMCEPopup.editor.dom.getAttrib(SXE.updateElement, 'cite'));
  12. SXE.showRemoveButton();
  13. }
  14. }
  15. function setElementAttribs(elm) {
  16. setAllCommonAttribs(elm);
  17. setAttrib(elm, 'datetime');
  18. setAttrib(elm, 'cite');
  19. }
  20. function insertIns() {
  21. var elm = tinyMCEPopup.editor.dom.getParent(SXE.focusElement, 'INS');
  22. tinyMCEPopup.execCommand('mceBeginUndoLevel');
  23. if (elm == null) {
  24. var s = SXE.inst.selection.getContent();
  25. if(s.length > 0) {
  26. insertInlineElement('INS');
  27. var elementArray = tinymce.grep(SXE.inst.dom.select('ins'), function(n) {return n.id == '#sxe_temp_ins#';});
  28. for (var i=0; i<elementArray.length; i++) {
  29. var elm = elementArray[i];
  30. setElementAttribs(elm);
  31. }
  32. }
  33. } else {
  34. setElementAttribs(elm);
  35. }
  36. tinyMCEPopup.editor.nodeChanged();
  37. tinyMCEPopup.execCommand('mceEndUndoLevel');
  38. tinyMCEPopup.close();
  39. }
  40. function removeIns() {
  41. SXE.removeElement('ins');
  42. tinyMCEPopup.close();
  43. }
  44. function insertInlineElement(en) {
  45. var ed = tinyMCEPopup.editor, dom = ed.dom;
  46. ed.getDoc().execCommand('FontName', false, 'mceinline');
  47. tinymce.each(dom.select(tinymce.isWebKit ? 'span' : 'font'), function(n) {
  48. if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline')
  49. dom.replace(dom.create(en), n, 1);
  50. });
  51. }
  52. tinyMCEPopup.onInit.add(init);