bgneal@45: /** bgneal@45: * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ bgneal@45: * bgneal@45: * @author Moxiecode bgneal@45: * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. bgneal@45: */ bgneal@45: bgneal@45: (function() { bgneal@45: tinymce.create('tinymce.plugins.PageBreakPlugin', { bgneal@45: init : function(ed, url) { bgneal@45: var pb = '', cls = 'mcePageBreak', sep = ed.getParam('pagebreak_separator', ''), pbRE; bgneal@45: bgneal@45: pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g'); bgneal@45: bgneal@45: // Register commands bgneal@45: ed.addCommand('mcePageBreak', function() { bgneal@45: ed.execCommand('mceInsertContent', 0, pb); bgneal@45: }); bgneal@45: bgneal@45: // Register buttons bgneal@45: ed.addButton('pagebreak', {title : 'pagebreak.desc', cmd : cls}); bgneal@45: bgneal@45: ed.onInit.add(function() { bgneal@45: if (ed.settings.content_css !== false) bgneal@45: ed.dom.loadCSS(url + "/css/content.css"); bgneal@45: bgneal@45: if (ed.theme.onResolveName) { bgneal@45: ed.theme.onResolveName.add(function(th, o) { bgneal@45: if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls)) bgneal@45: o.name = 'pagebreak'; bgneal@45: }); bgneal@45: } bgneal@45: }); bgneal@45: bgneal@45: ed.onClick.add(function(ed, e) { bgneal@45: e = e.target; bgneal@45: bgneal@45: if (e.nodeName === 'IMG' && ed.dom.hasClass(e, cls)) bgneal@45: ed.selection.select(e); bgneal@45: }); bgneal@45: bgneal@45: ed.onNodeChange.add(function(ed, cm, n) { bgneal@45: cm.setActive('pagebreak', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls)); bgneal@45: }); bgneal@45: bgneal@45: ed.onBeforeSetContent.add(function(ed, o) { bgneal@45: o.content = o.content.replace(pbRE, pb); bgneal@45: }); bgneal@45: bgneal@45: ed.onPostProcess.add(function(ed, o) { bgneal@45: if (o.get) bgneal@45: o.content = o.content.replace(/]+>/g, function(im) { bgneal@45: if (im.indexOf('class="mcePageBreak') !== -1) bgneal@45: im = sep; bgneal@45: bgneal@45: return im; bgneal@45: }); bgneal@45: }); bgneal@45: }, bgneal@45: bgneal@45: getInfo : function() { bgneal@45: return { bgneal@45: longname : 'PageBreak', bgneal@45: author : 'Moxiecode Systems AB', bgneal@45: authorurl : 'http://tinymce.moxiecode.com', bgneal@45: infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/pagebreak', bgneal@45: version : tinymce.majorVersion + "." + tinymce.minorVersion bgneal@45: }; bgneal@45: } bgneal@45: }); bgneal@45: bgneal@45: // Register plugin bgneal@45: tinymce.PluginManager.add('pagebreak', tinymce.plugins.PageBreakPlugin); bgneal@45: })();