author | Daniel Diniz <ajaksu@gmail.com> |
Sun, 28 Jun 2009 14:40:55 +0200 | |
changeset 2433 | 0ba41e115dbc |
parent 154 | d2377425d3f2 |
permissions | -rwxr-xr-x |
126
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
1 |
/** |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
2 |
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
3 |
* |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
4 |
* @author Moxiecode |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
5 |
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
6 |
*/ |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
7 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
8 |
(function() { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
9 |
tinymce.create('tinymce.plugins.PageBreakPlugin', { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
10 |
init : function(ed, url) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
11 |
var pb = '<img src="' + url + '/img/trans.gif" class="mcePageBreak mceItemNoResize" />', cls = 'mcePageBreak', sep = ed.getParam('pagebreak_separator', '<!-- pagebreak -->'), pbRE; |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
12 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
13 |
pbRE = new RegExp(sep.replace(/[\?\.\*\[\]\(\)\{\}\+\^\$\:]/g, function(a) {return '\\' + a;}), 'g'); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
14 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
15 |
// Register commands |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
16 |
ed.addCommand('mcePageBreak', function() { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
17 |
ed.execCommand('mceInsertContent', 0, pb); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
18 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
19 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
20 |
// Register buttons |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
21 |
ed.addButton('pagebreak', {title : 'pagebreak.desc', cmd : cls}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
22 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
23 |
ed.onInit.add(function() { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
24 |
if (ed.settings.content_css !== false) |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
25 |
ed.dom.loadCSS(url + "/css/content.css"); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
26 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
27 |
if (ed.theme.onResolveName) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
28 |
ed.theme.onResolveName.add(function(th, o) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
29 |
if (o.node.nodeName == 'IMG' && ed.dom.hasClass(o.node, cls)) |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
30 |
o.name = 'pagebreak'; |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
31 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
32 |
} |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
33 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
34 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
35 |
ed.onClick.add(function(ed, e) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
36 |
e = e.target; |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
37 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
38 |
if (e.nodeName === 'IMG' && ed.dom.hasClass(e, cls)) |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
39 |
ed.selection.select(e); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
40 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
41 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
42 |
ed.onNodeChange.add(function(ed, cm, n) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
43 |
cm.setActive('pagebreak', n.nodeName === 'IMG' && ed.dom.hasClass(n, cls)); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
44 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
45 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
46 |
ed.onBeforeSetContent.add(function(ed, o) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
47 |
o.content = o.content.replace(pbRE, pb); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
48 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
49 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
50 |
ed.onPostProcess.add(function(ed, o) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
51 |
if (o.get) |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
52 |
o.content = o.content.replace(/<img[^>]+>/g, function(im) { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
53 |
if (im.indexOf('class="mcePageBreak') !== -1) |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
54 |
im = sep; |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
55 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
56 |
return im; |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
57 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
58 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
59 |
}, |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
60 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
61 |
getInfo : function() { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
62 |
return { |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
63 |
longname : 'PageBreak', |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
64 |
author : 'Moxiecode Systems AB', |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
65 |
authorurl : 'http://tinymce.moxiecode.com', |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
66 |
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/pagebreak', |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
67 |
version : tinymce.majorVersion + "." + tinymce.minorVersion |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
68 |
}; |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
69 |
} |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
70 |
}); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
71 |
|
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
72 |
// Register plugin |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
73 |
tinymce.PluginManager.add('pagebreak', tinymce.plugins.PageBreakPlugin); |
6186c115a210
Added TinyMCE to Melange in soc/content/js
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
diff
changeset
|
74 |
})(); |