Make WordPress Core

Ticket #31576: 31576.patch

File 31576.patch, 2.3 KB (added by iseulde, 12 years ago)
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    433433                }
    434434        });
    435435
    436         // popup buttons for the gallery, etc.
    437         editor.on( 'init', function() {
    438                 editor.dom.bind( editor.getWin(), 'scroll', function() {
    439                         _hideButtons();
    440                 });
    441 
    442                 editor.dom.bind( editor.getBody(), 'dragstart', function() {
    443                         _hideButtons();
    444                 });
    445         });
    446 
    447         editor.on( 'BeforeExecCommand', function() {
    448                 _hideButtons();
    449         });
    450 
    451         editor.on( 'SaveContent', function() {
    452                 _hideButtons();
    453         });
    454 
    455         editor.on( 'MouseDown', function( e ) {
    456                 if ( e.target.nodeName !== 'IMG' ) {
    457                         _hideButtons();
    458                 }
    459         });
    460 
    461         editor.on( 'keydown', function( e ) {
    462                 if ( e.which === tinymce.util.VK.DELETE || e.which === tinymce.util.VK.BACKSPACE ) {
    463                         _hideButtons();
    464                 }
    465         });
    466 
    467         // Internal functions
    468         function _setEmbed( c ) {
    469                 return c.replace( /\[embed\]([\s\S]+?)\[\/embed\][\s\u00a0]*/g, function( a, b ) {
    470                         return '<img width="300" height="200" src="' + tinymce.Env.transparentSrc + '" class="wp-oembed" ' +
    471                                 'alt="'+ b +'" title="'+ b +'" data-mce-resize="false" data-mce-placeholder="1" />';
    472                 });
    473         }
    474 
    475         function _getEmbed( c ) {
    476                 return c.replace( /<img[^>]+>/g, function( a ) {
    477                         if ( a.indexOf('class="wp-oembed') !== -1 ) {
    478                                 var u = a.match( /alt="([^\"]+)"/ );
    479 
    480                                 if ( u[1] ) {
    481                                         a = '[embed]' + u[1] + '[/embed]';
    482                                 }
    483                         }
    484 
    485                         return a;
    486                 });
    487         }
    488 
    489         function _showButtons( n, id ) {
    490                 var p1, p2, vp, X, Y;
    491 
    492                 vp = editor.dom.getViewPort( editor.getWin() );
    493                 p1 = DOM.getPos( editor.getContentAreaContainer() );
    494                 p2 = editor.dom.getPos( n );
    495 
    496                 X = Math.max( p2.x - vp.x, 0 ) + p1.x;
    497                 Y = Math.max( p2.y - vp.y, 0 ) + p1.y;
    498 
    499                 DOM.setStyles( id, {
    500                         'top' : Y + 5 + 'px',
    501                         'left' : X + 5 + 'px',
    502                         'display': 'block'
    503                 });
    504         }
    505 
    506         function _hideButtons() {
    507                 DOM.hide( DOM.select( '#wp_editbtns, #wp_gallerybtns' ) );
    508         }
     436        function noop() {}
    509437
    510438        // Expose some functions (back-compat)
    511439        return {
    512                 _showButtons: _showButtons,
    513                 _hideButtons: _hideButtons,
    514                 _setEmbed: _setEmbed,
    515                 _getEmbed: _getEmbed
     440                _showButtons: noop,
     441                _hideButtons: noop,
     442                _setEmbed: noop,
     443                _getEmbed: noop
    516444        };
    517445});