[1] | 1 | /** |
---|
| 2 | * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
---|
| 3 | * |
---|
| 4 | * @author Moxiecode |
---|
| 5 | * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | (function() { |
---|
| 9 | tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', { |
---|
| 10 | init : function(ed, url) { |
---|
| 11 | // Register commands |
---|
| 12 | ed.addCommand('mceCite', function() { |
---|
| 13 | ed.windowManager.open({ |
---|
| 14 | file : url + '/cite.htm', |
---|
| 15 | width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)), |
---|
| 16 | height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)), |
---|
| 17 | inline : 1 |
---|
| 18 | }, { |
---|
| 19 | plugin_url : url |
---|
| 20 | }); |
---|
| 21 | }); |
---|
| 22 | |
---|
| 23 | ed.addCommand('mceAcronym', function() { |
---|
| 24 | ed.windowManager.open({ |
---|
| 25 | file : url + '/acronym.htm', |
---|
| 26 | width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), |
---|
| 27 | height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), |
---|
| 28 | inline : 1 |
---|
| 29 | }, { |
---|
| 30 | plugin_url : url |
---|
| 31 | }); |
---|
| 32 | }); |
---|
| 33 | |
---|
| 34 | ed.addCommand('mceAbbr', function() { |
---|
| 35 | ed.windowManager.open({ |
---|
| 36 | file : url + '/abbr.htm', |
---|
| 37 | width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), |
---|
| 38 | height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), |
---|
| 39 | inline : 1 |
---|
| 40 | }, { |
---|
| 41 | plugin_url : url |
---|
| 42 | }); |
---|
| 43 | }); |
---|
| 44 | |
---|
| 45 | ed.addCommand('mceDel', function() { |
---|
| 46 | ed.windowManager.open({ |
---|
| 47 | file : url + '/del.htm', |
---|
| 48 | width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), |
---|
| 49 | height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), |
---|
| 50 | inline : 1 |
---|
| 51 | }, { |
---|
| 52 | plugin_url : url |
---|
| 53 | }); |
---|
| 54 | }); |
---|
| 55 | |
---|
| 56 | ed.addCommand('mceIns', function() { |
---|
| 57 | ed.windowManager.open({ |
---|
| 58 | file : url + '/ins.htm', |
---|
| 59 | width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), |
---|
| 60 | height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), |
---|
| 61 | inline : 1 |
---|
| 62 | }, { |
---|
| 63 | plugin_url : url |
---|
| 64 | }); |
---|
| 65 | }); |
---|
| 66 | |
---|
| 67 | ed.addCommand('mceAttributes', function() { |
---|
| 68 | ed.windowManager.open({ |
---|
| 69 | file : url + '/attributes.htm', |
---|
| 70 | width : 380, |
---|
| 71 | height : 370, |
---|
| 72 | inline : 1 |
---|
| 73 | }, { |
---|
| 74 | plugin_url : url |
---|
| 75 | }); |
---|
| 76 | }); |
---|
| 77 | |
---|
| 78 | // Register buttons |
---|
| 79 | ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'}); |
---|
| 80 | ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'}); |
---|
| 81 | ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'}); |
---|
| 82 | ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'}); |
---|
| 83 | ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'}); |
---|
| 84 | ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'}); |
---|
| 85 | |
---|
| 86 | if (tinymce.isIE) { |
---|
| 87 | function fix(ed, o) { |
---|
| 88 | if (o.set) { |
---|
| 89 | o.content = o.content.replace(/<abbr([^>]+)>/gi, '<html:abbr $1>'); |
---|
| 90 | o.content = o.content.replace(/<\/abbr>/gi, '</html:abbr>'); |
---|
| 91 | } |
---|
| 92 | }; |
---|
| 93 | |
---|
| 94 | ed.onBeforeSetContent.add(fix); |
---|
| 95 | ed.onPostProcess.add(fix); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | ed.onNodeChange.add(function(ed, cm, n, co) { |
---|
| 99 | n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS'); |
---|
| 100 | |
---|
| 101 | cm.setDisabled('cite', co); |
---|
| 102 | cm.setDisabled('acronym', co); |
---|
| 103 | cm.setDisabled('abbr', co); |
---|
| 104 | cm.setDisabled('del', co); |
---|
| 105 | cm.setDisabled('ins', co); |
---|
| 106 | cm.setDisabled('attribs', n && n.nodeName == 'BODY'); |
---|
| 107 | |
---|
| 108 | if (n) { |
---|
| 109 | cm.setDisabled(n.nodeName.toLowerCase(), 0); |
---|
| 110 | cm.setActive(n.nodeName.toLowerCase(), 1); |
---|
| 111 | } else { |
---|
| 112 | cm.setActive('cite', 0); |
---|
| 113 | cm.setActive('acronym', 0); |
---|
| 114 | cm.setActive('abbr', 0); |
---|
| 115 | cm.setActive('del', 0); |
---|
| 116 | cm.setActive('ins', 0); |
---|
| 117 | } |
---|
| 118 | }); |
---|
| 119 | }, |
---|
| 120 | |
---|
| 121 | getInfo : function() { |
---|
| 122 | return { |
---|
| 123 | longname : 'XHTML Xtras Plugin', |
---|
| 124 | author : 'Moxiecode Systems AB', |
---|
| 125 | authorurl : 'http://tinymce.moxiecode.com', |
---|
| 126 | infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', |
---|
| 127 | version : tinymce.majorVersion + "." + tinymce.minorVersion |
---|
| 128 | }; |
---|
| 129 | } |
---|
| 130 | }); |
---|
| 131 | |
---|
| 132 | // Register plugin |
---|
| 133 | tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin); |
---|
| 134 | })(); |
---|