TinyMCE: don't scroll the main window when scrolling the editor content with a mouse wheel or trackpad and reaching the end. Fixes #27013.
git-svn-id: https://develop.svn.wordpress.org/trunk@27095 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6a0251847b
commit
89b8edf8f1
|
@ -278,7 +278,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
editor.on( 'init', function() {
|
editor.on( 'init', function() {
|
||||||
var env = tinymce.Env,
|
var env = tinymce.Env,
|
||||||
bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
|
bodyClass = ['mceContentBody'], // back-compat for themes that use this in editor-style.css...
|
||||||
body = editor.getBody();
|
doc = editor.getDoc();
|
||||||
|
|
||||||
if ( editor.getParam( 'directionality' ) === 'rtl' ) {
|
if ( editor.getParam( 'directionality' ) === 'rtl' ) {
|
||||||
bodyClass.push('rtl');
|
bodyClass.push('rtl');
|
||||||
|
@ -298,7 +298,7 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
|
|
||||||
tinymce.each( bodyClass, function( cls ) {
|
tinymce.each( bodyClass, function( cls ) {
|
||||||
if ( cls ) {
|
if ( cls ) {
|
||||||
editor.dom.addClass( body, cls );
|
editor.dom.addClass( doc.body, cls );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -314,6 +314,44 @@ tinymce.PluginManager.add( 'wordpress', function( editor ) {
|
||||||
if ( typeof window.jQuery !== 'undefined' ) {
|
if ( typeof window.jQuery !== 'undefined' ) {
|
||||||
window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
window.jQuery( document ).triggerHandler( 'tinymce-editor-init', [editor] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When scrolling with mouse wheel or trackpad inside the editor, don't scroll the parent window
|
||||||
|
editor.dom.bind( doc, 'onwheel' in doc ? 'wheel' : 'mousewheel', function( event ) {
|
||||||
|
var delta, docElement = doc.documentElement;
|
||||||
|
|
||||||
|
if ( editor.settings.wp_fullscreen || 'ontouchstart' in window ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( typeof event.deltaY !== 'undefined' ) {
|
||||||
|
delta = event.deltaY;
|
||||||
|
|
||||||
|
if ( typeof event.deltaMode !== 'undefined' && event.deltaMode === event.DOM_DELTA_LINE ) {
|
||||||
|
delta *= 20;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
delta = -event.wheelDelta;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverse direction for MacOS
|
||||||
|
if ( env.mac ) {
|
||||||
|
delta *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
if ( ( docElement.scrollTop === 0 && delta < 0 ) ||
|
||||||
|
( docElement.clientHeight + docElement.scrollTop === docElement.scrollHeight && delta > 0 ) ) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( env.webkit ) {
|
||||||
|
doc.body.scrollTop += delta;
|
||||||
|
} else {
|
||||||
|
docElement.scrollTop += delta;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Word count
|
// Word count
|
||||||
|
|
Loading…
Reference in New Issue