Make WordPress Core

Ticket #27013: 27013.patch

File 27013.patch, 1.9 KB (added by azaozz, 11 years ago)
  • src/wp-includes/js/tinymce/plugins/wordpress/plugin.js

     
    278278        editor.on( 'init', function() {
    279279                var env = tinymce.Env,
    280280                        bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
    281                         body = editor.getBody();
     281                        doc = editor.getDoc();
    282282
    283283                if ( editor.getParam( 'directionality' ) === 'rtl' ) {
    284284                        bodyClass.push('rtl');
     
    298298
    299299                tinymce.each( bodyClass, function( cls ) {
    300300                        if ( cls ) {
    301                                 editor.dom.addClass( body, cls );
     301                                editor.dom.addClass( doc.body, cls );
    302302                        }
    303303                });
    304304
     
    314314                if ( typeof window.jQuery !== 'undefined' ) {
    315315                        window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
    316316                }
     317
     318                // When scrolling with mouse wheel or trackpad inside the editor, don't scroll the parent window
     319                editor.dom.bind( doc, 'onwheel' in doc ? 'wheel' : 'mousewheel', function( event ) {
     320                        var delta, docElement = doc.documentElement;
     321
     322                        if ( editor.settings.wp_fullscreen || 'ontouchstart' in window ) {
     323                                return;
     324                        }
     325
     326                        if ( typeof event.deltaY !== 'undefined' ) {
     327                                delta = event.deltaY;
     328
     329                                if ( typeof event.deltaMode !== 'undefined' && event.deltaMode === event.DOM_DELTA_LINE ) {
     330                                        delta *= 20;
     331                                }
     332                        } else {
     333                                delta = -event.wheelDelta;
     334                        }
     335
     336                        // Reverse direction for MacOS
     337                        if ( env.mac ) {
     338                                delta *= -1;
     339                        }
     340
     341                        event.preventDefault();
     342
     343                        if ( ( docElement.scrollTop === 0 && delta < 0 ) ||
     344                                ( docElement.clientHeight + docElement.scrollTop === docElement.scrollHeight && delta > 0 ) ) {
     345
     346                                return;
     347                        }
     348
     349                        if ( env.webkit ) {
     350                                doc.body.scrollTop += delta;
     351                        } else {
     352                                docElement.scrollTop += delta;
     353                        }
     354                });
    317355        });
    318356
    319357        // Word count