6
6
var DOM = tinymce.DOM;
8
8
tinymce.create('tinymce.plugins.WordPress', {
9
11
init : function(ed, url) {
10
12
var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML;
11
13
moreHTML = '<img src="' + url + '/img/trans.gif" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />';
17
19
// Hides the specified toolbar and resizes the iframe
18
20
ed.onPostRender.add(function() {
19
if ( ed.getParam('wordpress_adv_hidden', 1) ) {
20
DOM.hide(ed.controlManager.get(tbId).id);
21
var adv_toolbar = ed.controlManager.get(tbId);
22
if ( ed.getParam('wordpress_adv_hidden', 1) && adv_toolbar ) {
23
DOM.hide(adv_toolbar.id);
21
24
t._resizeIframe(ed, tbId, 28);
43
46
ed.addCommand('WP_Adv', function() {
44
var id = ed.controlManager.get(tbId).id, cm = ed.controlManager;
46
if (DOM.isHidden(id)) {
47
var cm = ed.controlManager, id = cm.get(tbId).id;
49
if ( 'undefined' == id )
52
if ( DOM.isHidden(id) ) {
47
53
cm.setActive('wp_adv', 1);
49
55
t._resizeIframe(ed, tbId, -28);
123
129
// Add Media buttons to fullscreen
124
130
ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
131
var DOM = tinymce.DOM;
125
132
if ( 'mceFullScreen' != cmd ) return;
126
if ( 'mce_fullscreen' != ed.id )
133
if ( 'mce_fullscreen' != ed.id && DOM.get('add_audio') && DOM.get('add_video') && DOM.get('add_image') && DOM.get('add_media') )
127
134
ed.settings.theme_advanced_buttons1 += ',|,add_image,add_video,add_audio,add_media';
171
ed.onSaveContent.add(function(ed, o) {
172
if ( typeof(switchEditors) == 'object' ) {
174
o.content = o.element.value;
176
o.content = switchEditors.pre_wpautop(o.content);
181
ed.onBeforeSetContent.add(function(ed, o) {
182
o.content = t._setEmbed(o.content);
185
ed.onPostProcess.add(function(ed, o) {
187
o.content = t._getEmbed(o.content);
164
191
// Add listeners to handle more break
165
192
t._handleMoreBreak(ed, url);
188
215
ed.addShortcut('alt+shift+b', ed.getLang('bold_desc'), 'Bold');
189
216
ed.addShortcut('alt+shift+i', ed.getLang('italic_desc'), 'Italic');
219
ed.onInit.add(function(ed) {
220
tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
221
ed.plugins.wordpress._hideButtons();
223
tinymce.dom.Event.add(ed.getBody(), 'dragstart', function(e) {
224
ed.plugins.wordpress._hideButtons();
228
ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
229
ed.plugins.wordpress._hideButtons();
232
ed.onSaveContent.add(function(ed, o) {
233
ed.plugins.wordpress._hideButtons();
236
ed.onMouseDown.add(function(ed, e) {
237
if ( e.target.nodeName != 'IMG' )
238
ed.plugins.wordpress._hideButtons();
193
242
getInfo : function() {
203
252
// Internal functions
253
_setEmbed : function(c) {
254
return c.replace(/\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g, function(a,b){
255
return '<img width="300" height="200" src="' + tinymce.baseURL + '/plugins/wordpress/img/trans.gif" class="wp-oembed mceItemNoResize" alt="'+b+'" title="'+b+'" />';
259
_getEmbed : function(c) {
260
return c.replace(/<img[^>]+>/g, function(a) {
261
if ( a.indexOf('class="wp-oembed') != -1 ) {
262
var u = a.match(/alt="([^\"]+)"/);
264
a = '[embed]' + u[1] + '[/embed]';
270
_showButtons : function(n, id) {
271
var ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
273
vp = ed.dom.getViewPort(ed.getWin());
274
p1 = DOM.getPos(ed.getContentAreaContainer());
275
p2 = ed.dom.getPos(n);
277
X = Math.max(p2.x - vp.x, 0) + p1.x;
278
Y = Math.max(p2.y - vp.y, 0) + p1.y;
287
clearTimeout(this.mceTout);
289
this.mceTout = setTimeout( function(){ed.plugins.wordpress._hideButtons();}, 5000 );
292
_hideButtons : function() {
296
if ( document.getElementById('wp_editbtns') )
297
tinymce.DOM.hide('wp_editbtns');
299
if ( document.getElementById('wp_gallerybtns') )
300
tinymce.DOM.hide('wp_gallerybtns');
302
clearTimeout(this.mceTout);
204
306
do_align : function(n, a) {
205
307
var P, DL, DIV, cls, c, ed = tinyMCE.activeEditor;
240
342
_handleMoreBreak : function(ed, url) {
241
343
var moreHTML, nextpageHTML;
243
345
moreHTML = '<img src="' + url + '/img/trans.gif" alt="$1" class="mceWPmore mceItemNoResize" title="'+ed.getLang('wordpress.wp_more_alt')+'" />';
244
346
nextpageHTML = '<img src="' + url + '/img/trans.gif" class="mceWPnextpage mceItemNoResize" title="'+ed.getLang('wordpress.wp_page_alt')+'" />';