bgneal@45: /** bgneal@183: * editor_plugin_src.js bgneal@45: * bgneal@183: * Copyright 2009, Moxiecode Systems AB bgneal@183: * Released under LGPL License. bgneal@183: * bgneal@183: * License: http://tinymce.moxiecode.com/license bgneal@183: * Contributing: http://tinymce.moxiecode.com/contributing bgneal@45: */ bgneal@45: bgneal@45: (function() { bgneal@45: tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', { bgneal@45: init : function(ed, url) { bgneal@45: // Register commands bgneal@45: ed.addCommand('mceCite', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/cite.htm', bgneal@45: width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)), bgneal@45: height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)), bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: ed.addCommand('mceAcronym', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/acronym.htm', bgneal@45: width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), bgneal@45: height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: ed.addCommand('mceAbbr', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/abbr.htm', bgneal@45: width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), bgneal@45: height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: ed.addCommand('mceDel', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/del.htm', bgneal@45: width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), bgneal@45: height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: ed.addCommand('mceIns', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/ins.htm', bgneal@45: width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), bgneal@45: height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: ed.addCommand('mceAttributes', function() { bgneal@45: ed.windowManager.open({ bgneal@45: file : url + '/attributes.htm', bgneal@45: width : 380, bgneal@45: height : 370, bgneal@45: inline : 1 bgneal@45: }, { bgneal@45: plugin_url : url bgneal@45: }); bgneal@45: }); bgneal@45: bgneal@45: // Register buttons bgneal@45: ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'}); bgneal@45: ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'}); bgneal@45: ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'}); bgneal@45: ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'}); bgneal@45: ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'}); bgneal@45: ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'}); bgneal@45: bgneal@45: if (tinymce.isIE) { bgneal@45: function fix(ed, o) { bgneal@45: if (o.set) { bgneal@45: o.content = o.content.replace(/]+)>/gi, ''); bgneal@45: o.content = o.content.replace(/<\/abbr>/gi, ''); bgneal@45: } bgneal@45: }; bgneal@45: bgneal@45: ed.onBeforeSetContent.add(fix); bgneal@45: ed.onPostProcess.add(fix); bgneal@45: } bgneal@45: bgneal@45: ed.onNodeChange.add(function(ed, cm, n, co) { bgneal@45: n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS'); bgneal@45: bgneal@45: cm.setDisabled('cite', co); bgneal@45: cm.setDisabled('acronym', co); bgneal@45: cm.setDisabled('abbr', co); bgneal@45: cm.setDisabled('del', co); bgneal@45: cm.setDisabled('ins', co); bgneal@45: cm.setDisabled('attribs', n && n.nodeName == 'BODY'); bgneal@45: cm.setActive('cite', 0); bgneal@45: cm.setActive('acronym', 0); bgneal@45: cm.setActive('abbr', 0); bgneal@45: cm.setActive('del', 0); bgneal@45: cm.setActive('ins', 0); bgneal@45: bgneal@45: // Activate all bgneal@45: if (n) { bgneal@45: do { bgneal@45: cm.setDisabled(n.nodeName.toLowerCase(), 0); bgneal@45: cm.setActive(n.nodeName.toLowerCase(), 1); bgneal@45: } while (n = n.parentNode); bgneal@45: } bgneal@45: }); bgneal@183: bgneal@183: ed.onPreInit.add(function() { bgneal@183: // Fixed IE issue where it can't handle these elements correctly bgneal@183: ed.dom.create('abbr'); bgneal@183: }); bgneal@45: }, bgneal@45: bgneal@45: getInfo : function() { bgneal@45: return { bgneal@45: longname : 'XHTML Xtras Plugin', bgneal@45: author : 'Moxiecode Systems AB', bgneal@45: authorurl : 'http://tinymce.moxiecode.com', bgneal@45: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', bgneal@45: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@45: }; bgneal@45: } bgneal@45: }); bgneal@45: bgneal@45: // Register plugin bgneal@45: tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin); bgneal@45: })();