annotate static/js/tiny_mce/plugins/pagebreak/editor_plugin_src.js @ 624:5d79b09aa52b

Tweaked wording to the help text on the search page.
author Brian Neal <bgneal@gmail.com>
date Wed, 31 Oct 2012 20:23:12 -0500
parents 6c182ceb7147
children
rev   line source
bgneal@312 1 /**
bgneal@312 2 * editor_plugin_src.js
bgneal@312 3 *
bgneal@312 4 * Copyright 2009, Moxiecode Systems AB
bgneal@312 5 * Released under LGPL License.
bgneal@312 6 *
bgneal@312 7 * License: http://tinymce.moxiecode.com/license
bgneal@312 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@312 9 */
bgneal@312 10
bgneal@312 11 (function() {
bgneal@312 12 tinymce.create('tinymce.plugins.PageBreakPlugin', {
bgneal@312 13 init : function(ed, url) {
bgneal@442 14 var pb = '<img src="' + ed.theme.url + '/img/trans.gif" class="mcePageBreak mceItemNoResize" />', cls = 'mcePageBreak', sep = ed.getParam('pagebreak_separator', '<!-- pagebreak -->'), pbRE;
bgneal@312 15
bgneal@312 16 pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g');
bgneal@312 17
bgneal@312 18 // Register commands
bgneal@312 19 ed.addCommand('mcePageBreak', function() {
bgneal@312 20 ed.execCommand('mceInsertContent', 0, pb);
bgneal@312 21 });
bgneal@312 22
bgneal@312 23 // Register buttons
bgneal@312 24 ed.addButton('pagebreak', {title : 'pagebreak.desc', cmd : cls});
bgneal@312 25
bgneal@312 26 ed.onInit.add(function() {
bgneal@312 27 if (ed.theme.onResolveName) {
bgneal@312 28 ed.theme.onResolveName.add(function(th, o) {
bgneal@312 29 if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls))
bgneal@312 30 o.name = 'pagebreak';
bgneal@312 31 });
bgneal@312 32 }
bgneal@312 33 });
bgneal@312 34
bgneal@312 35 ed.onClick.add(function(ed, e) {
bgneal@312 36 e = e.target;
bgneal@312 37
bgneal@312 38 if (e.nodeName === 'IMG' && ed.dom.hasClass(e, cls))
bgneal@312 39 ed.selection.select(e);
bgneal@312 40 });
bgneal@312 41
bgneal@312 42 ed.onNodeChange.add(function(ed, cm, n) {
bgneal@312 43 cm.setActive('pagebreak', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls));
bgneal@312 44 });
bgneal@312 45
bgneal@312 46 ed.onBeforeSetContent.add(function(ed, o) {
bgneal@312 47 o.content = o.content.replace(pbRE, pb);
bgneal@312 48 });
bgneal@312 49
bgneal@312 50 ed.onPostProcess.add(function(ed, o) {
bgneal@312 51 if (o.get)
bgneal@312 52 o.content = o.content.replace(/<img[^>]+>/g, function(im) {
bgneal@312 53 if (im.indexOf('class="mcePageBreak') !== -1)
bgneal@312 54 im = sep;
bgneal@312 55
bgneal@312 56 return im;
bgneal@312 57 });
bgneal@312 58 });
bgneal@312 59 },
bgneal@312 60
bgneal@312 61 getInfo : function() {
bgneal@312 62 return {
bgneal@312 63 longname : 'PageBreak',
bgneal@312 64 author : 'Moxiecode Systems AB',
bgneal@312 65 authorurl : 'http://tinymce.moxiecode.com',
bgneal@312 66 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/pagebreak',
bgneal@312 67 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@312 68 };
bgneal@312 69 }
bgneal@312 70 });
bgneal@312 71
bgneal@312 72 // Register plugin
bgneal@312 73 tinymce.PluginManager.add('pagebreak', tinymce.plugins.PageBreakPlugin);
bgneal@312 74 })();