Fix scrolling inside the Visual editor on MacOS, add the same functionality to the Text editor, see #27013
Built from https://develop.svn.wordpress.org/trunk@27110 git-svn-id: http://core.svn.wordpress.org/trunk@26977 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b2e6ad7c32
commit
5ea367cfe1
|
@ -374,6 +374,7 @@ jQuery(document).ready( function($) {
|
|||
sticky = '',
|
||||
last = 0,
|
||||
co = $('#content'),
|
||||
$document = $(document),
|
||||
$editSlugWrap = $('#edit-slug-box'),
|
||||
postId = $('#post_ID').val() || 0,
|
||||
$submitpost = $('#submitpost'),
|
||||
|
@ -509,7 +510,7 @@ jQuery(document).ready( function($) {
|
|||
});
|
||||
}
|
||||
|
||||
$(document).on( 'autosave-disable-buttons.edit-post', function() {
|
||||
$document.on( 'autosave-disable-buttons.edit-post', function() {
|
||||
$submitButtons.addClass( 'disabled' );
|
||||
}).on( 'autosave-enable-buttons.edit-post', function() {
|
||||
if ( ! wp.heartbeat || ! wp.heartbeat.hasConnectionError() ) {
|
||||
|
@ -940,7 +941,7 @@ jQuery(document).ready( function($) {
|
|||
|
||||
// word count
|
||||
if ( typeof(wpWordCount) != 'undefined' ) {
|
||||
$(document).triggerHandler('wpcountwords', [ co.val() ]);
|
||||
$document.triggerHandler('wpcountwords', [ co.val() ]);
|
||||
|
||||
co.keyup( function(e) {
|
||||
var k = e.keyCode || e.charCode;
|
||||
|
@ -949,7 +950,7 @@ jQuery(document).ready( function($) {
|
|||
return true;
|
||||
|
||||
if ( 13 == k || 8 == last || 46 == last )
|
||||
$(document).triggerHandler('wpcountwords', [ co.val() ]);
|
||||
$document.triggerHandler('wpcountwords', [ co.val() ]);
|
||||
|
||||
last = k;
|
||||
return true;
|
||||
|
@ -985,7 +986,6 @@ jQuery(document).ready( function($) {
|
|||
// Resize the visual and text editors
|
||||
( function() {
|
||||
var editor, offset, mce,
|
||||
$document = $( document ),
|
||||
$textarea = $('textarea#content'),
|
||||
$handle = $('#post-status-info');
|
||||
|
||||
|
@ -1063,4 +1063,28 @@ jQuery(document).ready( function($) {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ( ! ( 'ontouchstart' in window ) ) {
|
||||
// When scrolling with mouse wheel or trackpad inside the Text editor, don't scroll the whole window
|
||||
var $content = $('#content').on( 'onwheel' in $document[0] ? 'wheel.text-editor-scroll' : 'mousewheel.text-editor-scroll', function( event ) {
|
||||
var delta, origEvent = event.originalEvent;
|
||||
|
||||
if ( wp.editor && wp.editor.fullscreen.settings.visible ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( typeof origEvent.deltaY !== 'undefined' ) {
|
||||
delta = origEvent.deltaY;
|
||||
|
||||
if ( typeof origEvent.deltaMode !== 'undefined' && origEvent.deltaMode === origEvent.DOM_DELTA_LINE ) {
|
||||
delta *= 20;
|
||||
}
|
||||
} else {
|
||||
delta = -origEvent.wheelDelta;
|
||||
}
|
||||
|
||||
$content.scrollTop( $content.scrollTop() + delta );
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -315,43 +315,34 @@ tinymce.PluginManager.add( 'wordpress', function( 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 ( ! ( 'ontouchstart' in window ) ) {
|
||||
// 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;
|
||||
if ( editor.settings.wp_fullscreen ) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
delta = -event.wheelDelta;
|
||||
}
|
||||
|
||||
// Reverse direction for MacOS
|
||||
if ( env.mac ) {
|
||||
delta *= -1;
|
||||
}
|
||||
if ( typeof event.deltaY !== 'undefined' ) {
|
||||
delta = event.deltaY;
|
||||
|
||||
event.preventDefault();
|
||||
if ( typeof event.deltaMode !== 'undefined' && event.deltaMode === event.DOM_DELTA_LINE ) {
|
||||
delta *= 20;
|
||||
}
|
||||
} else {
|
||||
delta = -event.wheelDelta;
|
||||
}
|
||||
|
||||
if ( ( docElement.scrollTop === 0 && delta < 0 ) ||
|
||||
( docElement.clientHeight + docElement.scrollTop === docElement.scrollHeight && delta > 0 ) ) {
|
||||
event.preventDefault();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( env.webkit ) {
|
||||
doc.body.scrollTop += delta;
|
||||
} else {
|
||||
docElement.scrollTop += delta;
|
||||
}
|
||||
});
|
||||
if ( env.webkit ) {
|
||||
doc.body.scrollTop += delta;
|
||||
} else {
|
||||
docElement.scrollTop += delta;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Word count
|
||||
|
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Loading…
Reference in New Issue