mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 15:50:09 +00:00
Editor scrolling:
- Add a Screen Option to turn it on/off, and on()/off() methods from JS. Store the user preference. - Fix delayed calls to resize() in the TinyMCE autoresize plugin. See #28328. git-svn-id: https://develop.svn.wordpress.org/trunk@29336 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -21,7 +21,9 @@
|
||||
* it's initialized.
|
||||
*/
|
||||
tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
var settings = editor.settings, oldSize = 0;
|
||||
var settings = editor.settings,
|
||||
oldSize = 0,
|
||||
isActive = false;
|
||||
|
||||
function isFullscreen() {
|
||||
return editor.plugins.fullscreen && editor.plugins.fullscreen.isFullscreen();
|
||||
@@ -37,8 +39,12 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
function resize( e ) {
|
||||
var deltaSize, doc, body, docElm, DOM = tinymce.DOM, resizeHeight, myHeight, marginTop, marginBottom;
|
||||
|
||||
if ( ! isActive ) {
|
||||
return;
|
||||
}
|
||||
|
||||
doc = editor.getDoc();
|
||||
if (!doc) {
|
||||
if ( ! doc ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,6 +134,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
|
||||
function on() {
|
||||
if ( ! editor.dom.hasClass( editor.getBody(), 'wp-autoresize' ) ) {
|
||||
isActive = true;
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
// Add appropriate listeners for resizing the content area
|
||||
editor.on( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
@@ -140,6 +147,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
|
||||
// Don't turn off if the setting is 'on'
|
||||
if ( ! settings.wp_autoresize_on ) {
|
||||
isActive = false;
|
||||
doc = editor.getDoc();
|
||||
editor.dom.removeClass( editor.getBody(), 'wp-autoresize' );
|
||||
editor.off( 'nodechange setcontent keyup FullscreenStateChanged', resize );
|
||||
@@ -151,6 +159,8 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
|
||||
if ( settings.wp_autoresize_on ) {
|
||||
// Turn resizing on when the editor loads
|
||||
isActive = true;
|
||||
|
||||
editor.on( 'init', function() {
|
||||
editor.dom.addClass( editor.getBody(), 'wp-autoresize' );
|
||||
});
|
||||
@@ -163,7 +173,7 @@ tinymce.PluginManager.add( 'wpautoresize', function( editor ) {
|
||||
|
||||
if ( editor.getParam( 'autoresize_on_init', true ) ) {
|
||||
editor.on( 'init', function() {
|
||||
// Hit it 20 times in 100 ms intervals
|
||||
// Hit it 10 times in 200 ms intervals
|
||||
wait( 10, 200, function() {
|
||||
// Hit it 5 times in 1 sec intervals
|
||||
wait( 5, 1000 );
|
||||
|
||||
Reference in New Issue
Block a user