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