~katiekitty/+junk/wordpress-byet

« back to all changes in this revision

Viewing changes to wp-includes/js/tinymce/plugins/wordpress/editor_plugin.dev.js

  • Committer: kserver
  • Date: 2010-05-15 01:16:36 UTC
  • Revision ID: kserver@kserver-desktop-20100515011636-mnr1j7t637suptdq
Wordpress 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
        var DOM = tinymce.DOM;
7
7
 
8
8
        tinymce.create('tinymce.plugins.WordPress', {
 
9
                mceTout : 0,
 
10
 
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')+'" />';
16
18
 
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);
22
25
                                }
23
26
                        });
41
44
                                });
42
45
 
43
46
                        ed.addCommand('WP_Adv', function() {
44
 
                                var id = ed.controlManager.get(tbId).id, cm = ed.controlManager;
45
 
 
46
 
                                if (DOM.isHidden(id)) {
 
47
                                var cm = ed.controlManager, id = cm.get(tbId).id;
 
48
 
 
49
                                if ( 'undefined' == id )
 
50
                                        return;
 
51
 
 
52
                                if ( DOM.isHidden(id) ) {
47
53
                                        cm.setActive('wp_adv', 1);
48
54
                                        DOM.show(id);
49
55
                                        t._resizeIframe(ed, tbId, -28);
122
128
 
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';
128
135
                        });
129
136
 
161
168
                                });
162
169
                        };
163
170
 
 
171
                        ed.onSaveContent.add(function(ed, o) {
 
172
                                if ( typeof(switchEditors) == 'object' ) {
 
173
                                        if ( ed.isHidden() )
 
174
                                                o.content = o.element.value;
 
175
                                        else
 
176
                                                o.content = switchEditors.pre_wpautop(o.content);
 
177
                                }
 
178
                        });
 
179
 
 
180
                        /* disable for now
 
181
                        ed.onBeforeSetContent.add(function(ed, o) {
 
182
                                o.content = t._setEmbed(o.content);
 
183
                        });
 
184
 
 
185
                        ed.onPostProcess.add(function(ed, o) {
 
186
                                if ( o.get )
 
187
                                        o.content = t._getEmbed(o.content);
 
188
                        });
 
189
                        */
 
190
 
164
191
                        // Add listeners to handle more break
165
192
                        t._handleMoreBreak(ed, url);
166
193
 
188
215
                                ed.addShortcut('alt+shift+b', ed.getLang('bold_desc'), 'Bold');
189
216
                                ed.addShortcut('alt+shift+i', ed.getLang('italic_desc'), 'Italic');
190
217
                        }
 
218
 
 
219
                        ed.onInit.add(function(ed) {
 
220
                                tinymce.dom.Event.add(ed.getWin(), 'scroll', function(e) {
 
221
                                        ed.plugins.wordpress._hideButtons();
 
222
                                });
 
223
                                tinymce.dom.Event.add(ed.getBody(), 'dragstart', function(e) {
 
224
                                        ed.plugins.wordpress._hideButtons();
 
225
                                });
 
226
                        });
 
227
 
 
228
                        ed.onBeforeExecCommand.add(function(ed, cmd, ui, val) {
 
229
                                ed.plugins.wordpress._hideButtons();
 
230
                        });
 
231
 
 
232
                        ed.onSaveContent.add(function(ed, o) {
 
233
                                ed.plugins.wordpress._hideButtons();
 
234
                        });
 
235
 
 
236
                        ed.onMouseDown.add(function(ed, e) {
 
237
                                if ( e.target.nodeName != 'IMG' )
 
238
                                        ed.plugins.wordpress._hideButtons();
 
239
                        });
191
240
                },
192
241
 
193
242
                getInfo : function() {
201
250
                },
202
251
 
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+'" />';
 
256
                        });
 
257
                },
 
258
 
 
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="([^\"]+)"/);
 
263
                                        if ( u[1] )
 
264
                                                a = '[embed]' + u[1] + '[/embed]';
 
265
                                }
 
266
                                return a;
 
267
                        });
 
268
                },
 
269
 
 
270
                _showButtons : function(n, id) {
 
271
                        var ed = tinyMCE.activeEditor, p1, p2, vp, DOM = tinymce.DOM, X, Y;
 
272
 
 
273
                        vp = ed.dom.getViewPort(ed.getWin());
 
274
                        p1 = DOM.getPos(ed.getContentAreaContainer());
 
275
                        p2 = ed.dom.getPos(n);
 
276
 
 
277
                        X = Math.max(p2.x - vp.x, 0) + p1.x;
 
278
                        Y = Math.max(p2.y - vp.y, 0) + p1.y;
 
279
 
 
280
                        DOM.setStyles(id, {
 
281
                                'top' : Y+5+'px',
 
282
                                'left' : X+5+'px',
 
283
                                'display' : 'block'
 
284
                        });
 
285
 
 
286
                        if ( this.mceTout )
 
287
                                clearTimeout(this.mceTout);
 
288
 
 
289
                        this.mceTout = setTimeout( function(){ed.plugins.wordpress._hideButtons();}, 5000 );
 
290
                },
 
291
 
 
292
                _hideButtons : function() {
 
293
                        if ( !this.mceTout )
 
294
                                return;
 
295
 
 
296
                        if ( document.getElementById('wp_editbtns') )
 
297
                                tinymce.DOM.hide('wp_editbtns');
 
298
 
 
299
                        if ( document.getElementById('wp_gallerybtns') )
 
300
                                tinymce.DOM.hide('wp_gallerybtns');
 
301
 
 
302
                        clearTimeout(this.mceTout);
 
303
                        this.mceTout = 0;
 
304
                },
 
305
 
204
306
                do_align : function(n, a) {
205
307
                        var P, DL, DIV, cls, c, ed = tinyMCE.activeEditor;
206
308
 
239
341
 
240
342
                _handleMoreBreak : function(ed, url) {
241
343
                        var moreHTML, nextpageHTML;
242
 
                        
 
344
 
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')+'" />';
245
347