1 |
3 |
ahitrov@rambler.ru |
/** |
2 |
|
|
* editor_plugin_src.js |
3 |
|
|
* |
4 |
|
|
* Copyright 2009, Moxiecode Systems AB |
5 |
|
|
* Released under LGPL License. |
6 |
|
|
* |
7 |
|
|
* License: http://tinymce.moxiecode.com/license |
8 |
|
|
* Contributing: http://tinymce.moxiecode.com/contributing |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
(function() { |
12 |
|
|
tinymce.create('tinymce.plugins.XHTMLXtrasPlugin', { |
13 |
|
|
init : function(ed, url) { |
14 |
|
|
// Register commands |
15 |
|
|
ed.addCommand('mceCite', function() { |
16 |
|
|
ed.windowManager.open({ |
17 |
|
|
file : url + '/cite.htm', |
18 |
|
|
width : 350 + parseInt(ed.getLang('xhtmlxtras.cite_delta_width', 0)), |
19 |
|
|
height : 250 + parseInt(ed.getLang('xhtmlxtras.cite_delta_height', 0)), |
20 |
|
|
inline : 1 |
21 |
|
|
}, { |
22 |
|
|
plugin_url : url |
23 |
|
|
}); |
24 |
|
|
}); |
25 |
|
|
|
26 |
|
|
ed.addCommand('mceAcronym', function() { |
27 |
|
|
ed.windowManager.open({ |
28 |
|
|
file : url + '/acronym.htm', |
29 |
|
|
width : 350 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), |
30 |
|
|
height : 250 + parseInt(ed.getLang('xhtmlxtras.acronym_delta_width', 0)), |
31 |
|
|
inline : 1 |
32 |
|
|
}, { |
33 |
|
|
plugin_url : url |
34 |
|
|
}); |
35 |
|
|
}); |
36 |
|
|
|
37 |
|
|
ed.addCommand('mceAbbr', function() { |
38 |
|
|
ed.windowManager.open({ |
39 |
|
|
file : url + '/abbr.htm', |
40 |
|
|
width : 350 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), |
41 |
|
|
height : 250 + parseInt(ed.getLang('xhtmlxtras.abbr_delta_width', 0)), |
42 |
|
|
inline : 1 |
43 |
|
|
}, { |
44 |
|
|
plugin_url : url |
45 |
|
|
}); |
46 |
|
|
}); |
47 |
|
|
|
48 |
|
|
ed.addCommand('mceDel', function() { |
49 |
|
|
ed.windowManager.open({ |
50 |
|
|
file : url + '/del.htm', |
51 |
|
|
width : 340 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), |
52 |
|
|
height : 310 + parseInt(ed.getLang('xhtmlxtras.del_delta_width', 0)), |
53 |
|
|
inline : 1 |
54 |
|
|
}, { |
55 |
|
|
plugin_url : url |
56 |
|
|
}); |
57 |
|
|
}); |
58 |
|
|
|
59 |
|
|
ed.addCommand('mceIns', function() { |
60 |
|
|
ed.windowManager.open({ |
61 |
|
|
file : url + '/ins.htm', |
62 |
|
|
width : 340 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), |
63 |
|
|
height : 310 + parseInt(ed.getLang('xhtmlxtras.ins_delta_width', 0)), |
64 |
|
|
inline : 1 |
65 |
|
|
}, { |
66 |
|
|
plugin_url : url |
67 |
|
|
}); |
68 |
|
|
}); |
69 |
|
|
|
70 |
|
|
ed.addCommand('mceAttributes', function() { |
71 |
|
|
ed.windowManager.open({ |
72 |
|
|
file : url + '/attributes.htm', |
73 |
|
|
width : 380, |
74 |
|
|
height : 370, |
75 |
|
|
inline : 1 |
76 |
|
|
}, { |
77 |
|
|
plugin_url : url |
78 |
|
|
}); |
79 |
|
|
}); |
80 |
|
|
|
81 |
|
|
// Register buttons |
82 |
|
|
ed.addButton('cite', {title : 'xhtmlxtras.cite_desc', cmd : 'mceCite'}); |
83 |
|
|
ed.addButton('acronym', {title : 'xhtmlxtras.acronym_desc', cmd : 'mceAcronym'}); |
84 |
|
|
ed.addButton('abbr', {title : 'xhtmlxtras.abbr_desc', cmd : 'mceAbbr'}); |
85 |
|
|
ed.addButton('del', {title : 'xhtmlxtras.del_desc', cmd : 'mceDel'}); |
86 |
|
|
ed.addButton('ins', {title : 'xhtmlxtras.ins_desc', cmd : 'mceIns'}); |
87 |
|
|
ed.addButton('attribs', {title : 'xhtmlxtras.attribs_desc', cmd : 'mceAttributes'}); |
88 |
|
|
|
89 |
|
|
if (tinymce.isIE) { |
90 |
|
|
function fix(ed, o) { |
91 |
|
|
if (o.set) { |
92 |
|
|
o.content = o.content.replace(/<abbr([^>]+)>/gi, '<html:abbr $1>'); |
93 |
|
|
o.content = o.content.replace(/<\/abbr>/gi, '</html:abbr>'); |
94 |
|
|
} |
95 |
|
|
}; |
96 |
|
|
|
97 |
|
|
ed.onBeforeSetContent.add(fix); |
98 |
|
|
ed.onPostProcess.add(fix); |
99 |
|
|
} |
100 |
|
|
|
101 |
|
|
ed.onNodeChange.add(function(ed, cm, n, co) { |
102 |
|
|
n = ed.dom.getParent(n, 'CITE,ACRONYM,ABBR,DEL,INS'); |
103 |
|
|
|
104 |
|
|
cm.setDisabled('cite', co); |
105 |
|
|
cm.setDisabled('acronym', co); |
106 |
|
|
cm.setDisabled('abbr', co); |
107 |
|
|
cm.setDisabled('del', co); |
108 |
|
|
cm.setDisabled('ins', co); |
109 |
|
|
cm.setDisabled('attribs', n && n.nodeName == 'BODY'); |
110 |
|
|
cm.setActive('cite', 0); |
111 |
|
|
cm.setActive('acronym', 0); |
112 |
|
|
cm.setActive('abbr', 0); |
113 |
|
|
cm.setActive('del', 0); |
114 |
|
|
cm.setActive('ins', 0); |
115 |
|
|
|
116 |
|
|
// Activate all |
117 |
|
|
if (n) { |
118 |
|
|
do { |
119 |
|
|
cm.setDisabled(n.nodeName.toLowerCase(), 0); |
120 |
|
|
cm.setActive(n.nodeName.toLowerCase(), 1); |
121 |
|
|
} while (n = n.parentNode); |
122 |
|
|
} |
123 |
|
|
}); |
124 |
|
|
|
125 |
|
|
ed.onPreInit.add(function() { |
126 |
|
|
// Fixed IE issue where it can't handle these elements correctly |
127 |
|
|
ed.dom.create('abbr'); |
128 |
|
|
}); |
129 |
|
|
}, |
130 |
|
|
|
131 |
|
|
getInfo : function() { |
132 |
|
|
return { |
133 |
|
|
longname : 'XHTML Xtras Plugin', |
134 |
|
|
author : 'Moxiecode Systems AB', |
135 |
|
|
authorurl : 'http://tinymce.moxiecode.com', |
136 |
|
|
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/xhtmlxtras', |
137 |
|
|
version : tinymce.majorVersion + "." + tinymce.minorVersion |
138 |
|
|
}; |
139 |
|
|
} |
140 |
|
|
}); |
141 |
|
|
|
142 |
|
|
// Register plugin |
143 |
|
|
tinymce.PluginManager.add('xhtmlxtras', tinymce.plugins.XHTMLXtrasPlugin); |
144 |
|
|
})(); |