Edit File by line
/home/barbar84/public_h.../wp-admin/js
File: editor-expand.js
/**
[0] Fix | Delete
* @output wp-admin/js/editor-expand.js
[1] Fix | Delete
*/
[2] Fix | Delete
[3] Fix | Delete
( function( window, $, undefined ) {
[4] Fix | Delete
'use strict';
[5] Fix | Delete
[6] Fix | Delete
var $window = $( window ),
[7] Fix | Delete
$document = $( document ),
[8] Fix | Delete
$adminBar = $( '#wpadminbar' ),
[9] Fix | Delete
$footer = $( '#wpfooter' );
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Handles the resizing of the editor.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 4.0.0
[15] Fix | Delete
*
[16] Fix | Delete
* @return {void}
[17] Fix | Delete
*/
[18] Fix | Delete
$( function() {
[19] Fix | Delete
var $wrap = $( '#postdivrich' ),
[20] Fix | Delete
$contentWrap = $( '#wp-content-wrap' ),
[21] Fix | Delete
$tools = $( '#wp-content-editor-tools' ),
[22] Fix | Delete
$visualTop = $(),
[23] Fix | Delete
$visualEditor = $(),
[24] Fix | Delete
$textTop = $( '#ed_toolbar' ),
[25] Fix | Delete
$textEditor = $( '#content' ),
[26] Fix | Delete
textEditor = $textEditor[0],
[27] Fix | Delete
oldTextLength = 0,
[28] Fix | Delete
$bottom = $( '#post-status-info' ),
[29] Fix | Delete
$menuBar = $(),
[30] Fix | Delete
$statusBar = $(),
[31] Fix | Delete
$sideSortables = $( '#side-sortables' ),
[32] Fix | Delete
$postboxContainer = $( '#postbox-container-1' ),
[33] Fix | Delete
$postBody = $('#post-body'),
[34] Fix | Delete
fullscreen = window.wp.editor && window.wp.editor.fullscreen,
[35] Fix | Delete
mceEditor,
[36] Fix | Delete
mceBind = function(){},
[37] Fix | Delete
mceUnbind = function(){},
[38] Fix | Delete
fixedTop = false,
[39] Fix | Delete
fixedBottom = false,
[40] Fix | Delete
fixedSideTop = false,
[41] Fix | Delete
fixedSideBottom = false,
[42] Fix | Delete
scrollTimer,
[43] Fix | Delete
lastScrollPosition = 0,
[44] Fix | Delete
pageYOffsetAtTop = 130,
[45] Fix | Delete
pinnedToolsTop = 56,
[46] Fix | Delete
sidebarBottom = 20,
[47] Fix | Delete
autoresizeMinHeight = 300,
[48] Fix | Delete
initialMode = $contentWrap.hasClass( 'tmce-active' ) ? 'tinymce' : 'html',
[49] Fix | Delete
advanced = !! parseInt( window.getUserSetting( 'hidetb' ), 10 ),
[50] Fix | Delete
// These are corrected when adjust() runs, except on scrolling if already set.
[51] Fix | Delete
heights = {
[52] Fix | Delete
windowHeight: 0,
[53] Fix | Delete
windowWidth: 0,
[54] Fix | Delete
adminBarHeight: 0,
[55] Fix | Delete
toolsHeight: 0,
[56] Fix | Delete
menuBarHeight: 0,
[57] Fix | Delete
visualTopHeight: 0,
[58] Fix | Delete
textTopHeight: 0,
[59] Fix | Delete
bottomHeight: 0,
[60] Fix | Delete
statusBarHeight: 0,
[61] Fix | Delete
sideSortablesHeight: 0
[62] Fix | Delete
};
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* Resizes textarea based on scroll height and width.
[66] Fix | Delete
*
[67] Fix | Delete
* Doesn't shrink the editor size below the 300px auto resize minimum height.
[68] Fix | Delete
*
[69] Fix | Delete
* @since 4.6.1
[70] Fix | Delete
*
[71] Fix | Delete
* @return {void}
[72] Fix | Delete
*/
[73] Fix | Delete
var shrinkTextarea = window._.throttle( function() {
[74] Fix | Delete
var x = window.scrollX || document.documentElement.scrollLeft;
[75] Fix | Delete
var y = window.scrollY || document.documentElement.scrollTop;
[76] Fix | Delete
var height = parseInt( textEditor.style.height, 10 );
[77] Fix | Delete
[78] Fix | Delete
textEditor.style.height = autoresizeMinHeight + 'px';
[79] Fix | Delete
[80] Fix | Delete
if ( textEditor.scrollHeight > autoresizeMinHeight ) {
[81] Fix | Delete
textEditor.style.height = textEditor.scrollHeight + 'px';
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
if ( typeof x !== 'undefined' ) {
[85] Fix | Delete
window.scrollTo( x, y );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
if ( textEditor.scrollHeight < height ) {
[89] Fix | Delete
adjust();
[90] Fix | Delete
}
[91] Fix | Delete
}, 300 );
[92] Fix | Delete
[93] Fix | Delete
/**
[94] Fix | Delete
* Resizes the text editor depending on the old text length.
[95] Fix | Delete
*
[96] Fix | Delete
* If there is an mceEditor and it is hidden, it resizes the editor depending
[97] Fix | Delete
* on the old text length. If the current length of the text is smaller than
[98] Fix | Delete
* the old text length, it shrinks the text area. Otherwise it resizes the editor to
[99] Fix | Delete
* the scroll height.
[100] Fix | Delete
*
[101] Fix | Delete
* @since 4.6.1
[102] Fix | Delete
*
[103] Fix | Delete
* @return {void}
[104] Fix | Delete
*/
[105] Fix | Delete
function textEditorResize() {
[106] Fix | Delete
var length = textEditor.value.length;
[107] Fix | Delete
[108] Fix | Delete
if ( mceEditor && ! mceEditor.isHidden() ) {
[109] Fix | Delete
return;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
if ( ! mceEditor && initialMode === 'tinymce' ) {
[113] Fix | Delete
return;
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
if ( length < oldTextLength ) {
[117] Fix | Delete
shrinkTextarea();
[118] Fix | Delete
} else if ( parseInt( textEditor.style.height, 10 ) < textEditor.scrollHeight ) {
[119] Fix | Delete
textEditor.style.height = Math.ceil( textEditor.scrollHeight ) + 'px';
[120] Fix | Delete
adjust();
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
oldTextLength = length;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Gets the height and widths of elements.
[128] Fix | Delete
*
[129] Fix | Delete
* Gets the heights of the window, the adminbar, the tools, the menu,
[130] Fix | Delete
* the visualTop, the textTop, the bottom, the statusbar and sideSortables
[131] Fix | Delete
* and stores these in the heights object. Defaults to 0.
[132] Fix | Delete
* Gets the width of the window and stores this in the heights object.
[133] Fix | Delete
*
[134] Fix | Delete
* @since 4.0.0
[135] Fix | Delete
*
[136] Fix | Delete
* @return {void}
[137] Fix | Delete
*/
[138] Fix | Delete
function getHeights() {
[139] Fix | Delete
var windowWidth = $window.width();
[140] Fix | Delete
[141] Fix | Delete
heights = {
[142] Fix | Delete
windowHeight: $window.height(),
[143] Fix | Delete
windowWidth: windowWidth,
[144] Fix | Delete
adminBarHeight: ( windowWidth > 600 ? $adminBar.outerHeight() : 0 ),
[145] Fix | Delete
toolsHeight: $tools.outerHeight() || 0,
[146] Fix | Delete
menuBarHeight: $menuBar.outerHeight() || 0,
[147] Fix | Delete
visualTopHeight: $visualTop.outerHeight() || 0,
[148] Fix | Delete
textTopHeight: $textTop.outerHeight() || 0,
[149] Fix | Delete
bottomHeight: $bottom.outerHeight() || 0,
[150] Fix | Delete
statusBarHeight: $statusBar.outerHeight() || 0,
[151] Fix | Delete
sideSortablesHeight: $sideSortables.height() || 0
[152] Fix | Delete
};
[153] Fix | Delete
[154] Fix | Delete
// Adjust for hidden menubar.
[155] Fix | Delete
if ( heights.menuBarHeight < 3 ) {
[156] Fix | Delete
heights.menuBarHeight = 0;
[157] Fix | Delete
}
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
// We need to wait for TinyMCE to initialize.
[161] Fix | Delete
/**
[162] Fix | Delete
* Binds all necessary functions for editor expand to the editor when the editor
[163] Fix | Delete
* is initialized.
[164] Fix | Delete
*
[165] Fix | Delete
* @since 4.0.0
[166] Fix | Delete
*
[167] Fix | Delete
* @param {event} event The TinyMCE editor init event.
[168] Fix | Delete
* @param {object} editor The editor to bind the vents on.
[169] Fix | Delete
*
[170] Fix | Delete
* @return {void}
[171] Fix | Delete
*/
[172] Fix | Delete
$document.on( 'tinymce-editor-init.editor-expand', function( event, editor ) {
[173] Fix | Delete
// VK contains the type of key pressed. VK = virtual keyboard.
[174] Fix | Delete
var VK = window.tinymce.util.VK,
[175] Fix | Delete
/**
[176] Fix | Delete
* Hides any float panel with a hover state. Additionally hides tooltips.
[177] Fix | Delete
*
[178] Fix | Delete
* @return {void}
[179] Fix | Delete
*/
[180] Fix | Delete
hideFloatPanels = _.debounce( function() {
[181] Fix | Delete
! $( '.mce-floatpanel:hover' ).length && window.tinymce.ui.FloatPanel.hideAll();
[182] Fix | Delete
$( '.mce-tooltip' ).hide();
[183] Fix | Delete
}, 1000, true );
[184] Fix | Delete
[185] Fix | Delete
// Make sure it's the main editor.
[186] Fix | Delete
if ( editor.id !== 'content' ) {
[187] Fix | Delete
return;
[188] Fix | Delete
}
[189] Fix | Delete
[190] Fix | Delete
// Copy the editor instance.
[191] Fix | Delete
mceEditor = editor;
[192] Fix | Delete
[193] Fix | Delete
// Set the minimum height to the initial viewport height.
[194] Fix | Delete
editor.settings.autoresize_min_height = autoresizeMinHeight;
[195] Fix | Delete
[196] Fix | Delete
// Get the necessary UI elements.
[197] Fix | Delete
$visualTop = $contentWrap.find( '.mce-toolbar-grp' );
[198] Fix | Delete
$visualEditor = $contentWrap.find( '.mce-edit-area' );
[199] Fix | Delete
$statusBar = $contentWrap.find( '.mce-statusbar' );
[200] Fix | Delete
$menuBar = $contentWrap.find( '.mce-menubar' );
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* Gets the offset of the editor.
[204] Fix | Delete
*
[205] Fix | Delete
* @return {number|boolean} Returns the offset of the editor
[206] Fix | Delete
* or false if there is no offset height.
[207] Fix | Delete
*/
[208] Fix | Delete
function mceGetCursorOffset() {
[209] Fix | Delete
var node = editor.selection.getNode(),
[210] Fix | Delete
range, view, offset;
[211] Fix | Delete
[212] Fix | Delete
/*
[213] Fix | Delete
* If editor.wp.getView and the selection node from the editor selection
[214] Fix | Delete
* are defined, use this as a view for the offset.
[215] Fix | Delete
*/
[216] Fix | Delete
if ( editor.wp && editor.wp.getView && ( view = editor.wp.getView( node ) ) ) {
[217] Fix | Delete
offset = view.getBoundingClientRect();
[218] Fix | Delete
} else {
[219] Fix | Delete
range = editor.selection.getRng();
[220] Fix | Delete
[221] Fix | Delete
// Try to get the offset from a range.
[222] Fix | Delete
try {
[223] Fix | Delete
offset = range.getClientRects()[0];
[224] Fix | Delete
} catch( er ) {}
[225] Fix | Delete
[226] Fix | Delete
// Get the offset from the bounding client rectangle of the node.
[227] Fix | Delete
if ( ! offset ) {
[228] Fix | Delete
offset = node.getBoundingClientRect();
[229] Fix | Delete
}
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
return offset.height ? offset : false;
[233] Fix | Delete
}
[234] Fix | Delete
[235] Fix | Delete
/**
[236] Fix | Delete
* Filters the special keys that should not be used for scrolling.
[237] Fix | Delete
*
[238] Fix | Delete
* @since 4.0.0
[239] Fix | Delete
*
[240] Fix | Delete
* @param {event} event The event to get the key code from.
[241] Fix | Delete
*
[242] Fix | Delete
* @return {void}
[243] Fix | Delete
*/
[244] Fix | Delete
function mceKeyup( event ) {
[245] Fix | Delete
var key = event.keyCode;
[246] Fix | Delete
[247] Fix | Delete
// Bail on special keys. Key code 47 is a '/'.
[248] Fix | Delete
if ( key <= 47 && ! ( key === VK.SPACEBAR || key === VK.ENTER || key === VK.DELETE || key === VK.BACKSPACE || key === VK.UP || key === VK.LEFT || key === VK.DOWN || key === VK.UP ) ) {
[249] Fix | Delete
return;
[250] Fix | Delete
// OS keys, function keys, num lock, scroll lock. Key code 91-93 are OS keys.
[251] Fix | Delete
// Key code 112-123 are F1 to F12. Key code 144 is num lock. Key code 145 is scroll lock.
[252] Fix | Delete
} else if ( ( key >= 91 && key <= 93 ) || ( key >= 112 && key <= 123 ) || key === 144 || key === 145 ) {
[253] Fix | Delete
return;
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
mceScroll( key );
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
/**
[260] Fix | Delete
* Makes sure the cursor is always visible in the editor.
[261] Fix | Delete
*
[262] Fix | Delete
* Makes sure the cursor is kept between the toolbars of the editor and scrolls
[263] Fix | Delete
* the window when the cursor moves out of the viewport to a wpview.
[264] Fix | Delete
* Setting a buffer > 0 will prevent the browser default.
[265] Fix | Delete
* Some browsers will scroll to the middle,
[266] Fix | Delete
* others to the top/bottom of the *window* when moving the cursor out of the viewport.
[267] Fix | Delete
*
[268] Fix | Delete
* @since 4.1.0
[269] Fix | Delete
*
[270] Fix | Delete
* @param {string} key The key code of the pressed key.
[271] Fix | Delete
*
[272] Fix | Delete
* @return {void}
[273] Fix | Delete
*/
[274] Fix | Delete
function mceScroll( key ) {
[275] Fix | Delete
var offset = mceGetCursorOffset(),
[276] Fix | Delete
buffer = 50,
[277] Fix | Delete
cursorTop, cursorBottom, editorTop, editorBottom;
[278] Fix | Delete
[279] Fix | Delete
// Don't scroll if there is no offset.
[280] Fix | Delete
if ( ! offset ) {
[281] Fix | Delete
return;
[282] Fix | Delete
}
[283] Fix | Delete
[284] Fix | Delete
// Determine the cursorTop based on the offset and the top of the editor iframe.
[285] Fix | Delete
cursorTop = offset.top + editor.iframeElement.getBoundingClientRect().top;
[286] Fix | Delete
[287] Fix | Delete
// Determine the cursorBottom based on the cursorTop and offset height.
[288] Fix | Delete
cursorBottom = cursorTop + offset.height;
[289] Fix | Delete
[290] Fix | Delete
// Subtract the buffer from the cursorTop.
[291] Fix | Delete
cursorTop = cursorTop - buffer;
[292] Fix | Delete
[293] Fix | Delete
// Add the buffer to the cursorBottom.
[294] Fix | Delete
cursorBottom = cursorBottom + buffer;
[295] Fix | Delete
editorTop = heights.adminBarHeight + heights.toolsHeight + heights.menuBarHeight + heights.visualTopHeight;
[296] Fix | Delete
[297] Fix | Delete
/*
[298] Fix | Delete
* Set the editorBottom based on the window Height, and add the bottomHeight and statusBarHeight if the
[299] Fix | Delete
* advanced editor is enabled.
[300] Fix | Delete
*/
[301] Fix | Delete
editorBottom = heights.windowHeight - ( advanced ? heights.bottomHeight + heights.statusBarHeight : 0 );
[302] Fix | Delete
[303] Fix | Delete
// Don't scroll if the node is taller than the visible part of the editor.
[304] Fix | Delete
if ( editorBottom - editorTop < offset.height ) {
[305] Fix | Delete
return;
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
/*
[309] Fix | Delete
* If the cursorTop is smaller than the editorTop and the up, left
[310] Fix | Delete
* or backspace key is pressed, scroll the editor to the position defined
[311] Fix | Delete
* by the cursorTop, pageYOffset and editorTop.
[312] Fix | Delete
*/
[313] Fix | Delete
if ( cursorTop < editorTop && ( key === VK.UP || key === VK.LEFT || key === VK.BACKSPACE ) ) {
[314] Fix | Delete
window.scrollTo( window.pageXOffset, cursorTop + window.pageYOffset - editorTop );
[315] Fix | Delete
[316] Fix | Delete
/*
[317] Fix | Delete
* If any other key is pressed or the cursorTop is bigger than the editorTop,
[318] Fix | Delete
* scroll the editor to the position defined by the cursorBottom,
[319] Fix | Delete
* pageYOffset and editorBottom.
[320] Fix | Delete
*/
[321] Fix | Delete
} else if ( cursorBottom > editorBottom ) {
[322] Fix | Delete
window.scrollTo( window.pageXOffset, cursorBottom + window.pageYOffset - editorBottom );
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
/**
[327] Fix | Delete
* If the editor is fullscreen, calls adjust.
[328] Fix | Delete
*
[329] Fix | Delete
* @since 4.1.0
[330] Fix | Delete
*
[331] Fix | Delete
* @param {event} event The FullscreenStateChanged event.
[332] Fix | Delete
*
[333] Fix | Delete
* @return {void}
[334] Fix | Delete
*/
[335] Fix | Delete
function mceFullscreenToggled( event ) {
[336] Fix | Delete
// event.state is true if the editor is fullscreen.
[337] Fix | Delete
if ( ! event.state ) {
[338] Fix | Delete
adjust();
[339] Fix | Delete
}
[340] Fix | Delete
}
[341] Fix | Delete
[342] Fix | Delete
/**
[343] Fix | Delete
* Shows the editor when scrolled.
[344] Fix | Delete
*
[345] Fix | Delete
* Binds the hideFloatPanels function on the window scroll.mce-float-panels event.
[346] Fix | Delete
* Executes the wpAutoResize on the active editor.
[347] Fix | Delete
*
[348] Fix | Delete
* @since 4.0.0
[349] Fix | Delete
*
[350] Fix | Delete
* @return {void}
[351] Fix | Delete
*/
[352] Fix | Delete
function mceShow() {
[353] Fix | Delete
$window.on( 'scroll.mce-float-panels', hideFloatPanels );
[354] Fix | Delete
[355] Fix | Delete
setTimeout( function() {
[356] Fix | Delete
editor.execCommand( 'wpAutoResize' );
[357] Fix | Delete
adjust();
[358] Fix | Delete
}, 300 );
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
/**
[362] Fix | Delete
* Resizes the editor.
[363] Fix | Delete
*
[364] Fix | Delete
* Removes all functions from the window scroll.mce-float-panels event.
[365] Fix | Delete
* Resizes the text editor and scrolls to a position based on the pageXOffset and adminBarHeight.
[366] Fix | Delete
*
[367] Fix | Delete
* @since 4.0.0
[368] Fix | Delete
*
[369] Fix | Delete
* @return {void}
[370] Fix | Delete
*/
[371] Fix | Delete
function mceHide() {
[372] Fix | Delete
$window.off( 'scroll.mce-float-panels' );
[373] Fix | Delete
[374] Fix | Delete
setTimeout( function() {
[375] Fix | Delete
var top = $contentWrap.offset().top;
[376] Fix | Delete
[377] Fix | Delete
if ( window.pageYOffset > top ) {
[378] Fix | Delete
window.scrollTo( window.pageXOffset, top - heights.adminBarHeight );
[379] Fix | Delete
}
[380] Fix | Delete
[381] Fix | Delete
textEditorResize();
[382] Fix | Delete
adjust();
[383] Fix | Delete
}, 100 );
[384] Fix | Delete
[385] Fix | Delete
adjust();
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
/**
[389] Fix | Delete
* Toggles advanced states.
[390] Fix | Delete
*
[391] Fix | Delete
* @since 4.1.0
[392] Fix | Delete
*
[393] Fix | Delete
* @return {void}
[394] Fix | Delete
*/
[395] Fix | Delete
function toggleAdvanced() {
[396] Fix | Delete
advanced = ! advanced;
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
/**
[400] Fix | Delete
* Binds events of the editor and window.
[401] Fix | Delete
*
[402] Fix | Delete
* @since 4.0.0
[403] Fix | Delete
*
[404] Fix | Delete
* @return {void}
[405] Fix | Delete
*/
[406] Fix | Delete
mceBind = function() {
[407] Fix | Delete
editor.on( 'keyup', mceKeyup );
[408] Fix | Delete
editor.on( 'show', mceShow );
[409] Fix | Delete
editor.on( 'hide', mceHide );
[410] Fix | Delete
editor.on( 'wp-toolbar-toggle', toggleAdvanced );
[411] Fix | Delete
[412] Fix | Delete
// Adjust when the editor resizes.
[413] Fix | Delete
editor.on( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
[414] Fix | Delete
[415] Fix | Delete
// Don't hide the caret after undo/redo.
[416] Fix | Delete
editor.on( 'undo redo', mceScroll );
[417] Fix | Delete
[418] Fix | Delete
// Adjust when exiting TinyMCE's fullscreen mode.
[419] Fix | Delete
editor.on( 'FullscreenStateChanged', mceFullscreenToggled );
[420] Fix | Delete
[421] Fix | Delete
$window.off( 'scroll.mce-float-panels' ).on( 'scroll.mce-float-panels', hideFloatPanels );
[422] Fix | Delete
};
[423] Fix | Delete
[424] Fix | Delete
/**
[425] Fix | Delete
* Unbinds the events of the editor and window.
[426] Fix | Delete
*
[427] Fix | Delete
* @since 4.0.0
[428] Fix | Delete
*
[429] Fix | Delete
* @return {void}
[430] Fix | Delete
*/
[431] Fix | Delete
mceUnbind = function() {
[432] Fix | Delete
editor.off( 'keyup', mceKeyup );
[433] Fix | Delete
editor.off( 'show', mceShow );
[434] Fix | Delete
editor.off( 'hide', mceHide );
[435] Fix | Delete
editor.off( 'wp-toolbar-toggle', toggleAdvanced );
[436] Fix | Delete
editor.off( 'setcontent wp-autoresize wp-toolbar-toggle', adjust );
[437] Fix | Delete
editor.off( 'undo redo', mceScroll );
[438] Fix | Delete
editor.off( 'FullscreenStateChanged', mceFullscreenToggled );
[439] Fix | Delete
[440] Fix | Delete
$window.off( 'scroll.mce-float-panels' );
[441] Fix | Delete
};
[442] Fix | Delete
[443] Fix | Delete
if ( $wrap.hasClass( 'wp-editor-expand' ) ) {
[444] Fix | Delete
[445] Fix | Delete
// Adjust "immediately".
[446] Fix | Delete
mceBind();
[447] Fix | Delete
initialResize( adjust );
[448] Fix | Delete
}
[449] Fix | Delete
} );
[450] Fix | Delete
[451] Fix | Delete
/**
[452] Fix | Delete
* Adjusts the toolbars heights and positions.
[453] Fix | Delete
*
[454] Fix | Delete
* Adjusts the toolbars heights and positions based on the scroll position on
[455] Fix | Delete
* the page, the active editor mode and the heights of the editor, admin bar and
[456] Fix | Delete
* side bar.
[457] Fix | Delete
*
[458] Fix | Delete
* @since 4.0.0
[459] Fix | Delete
*
[460] Fix | Delete
* @param {event} event The event that calls this function.
[461] Fix | Delete
*
[462] Fix | Delete
* @return {void}
[463] Fix | Delete
*/
[464] Fix | Delete
function adjust( event ) {
[465] Fix | Delete
[466] Fix | Delete
// Makes sure we're not in fullscreen mode.
[467] Fix | Delete
if ( fullscreen && fullscreen.settings.visible ) {
[468] Fix | Delete
return;
[469] Fix | Delete
}
[470] Fix | Delete
[471] Fix | Delete
var windowPos = $window.scrollTop(),
[472] Fix | Delete
type = event && event.type,
[473] Fix | Delete
resize = type !== 'scroll',
[474] Fix | Delete
visual = mceEditor && ! mceEditor.isHidden(),
[475] Fix | Delete
buffer = autoresizeMinHeight,
[476] Fix | Delete
postBodyTop = $postBody.offset().top,
[477] Fix | Delete
borderWidth = 1,
[478] Fix | Delete
contentWrapWidth = $contentWrap.width(),
[479] Fix | Delete
$top, $editor, sidebarTop, footerTop, canPin,
[480] Fix | Delete
topPos, topHeight, editorPos, editorHeight;
[481] Fix | Delete
[482] Fix | Delete
/*
[483] Fix | Delete
* Refresh the heights if type isn't 'scroll'
[484] Fix | Delete
* or heights.windowHeight isn't set.
[485] Fix | Delete
*/
[486] Fix | Delete
if ( resize || ! heights.windowHeight ) {
[487] Fix | Delete
getHeights();
[488] Fix | Delete
}
[489] Fix | Delete
[490] Fix | Delete
// Resize on resize event when the editor is in text mode.
[491] Fix | Delete
if ( ! visual && type === 'resize' ) {
[492] Fix | Delete
textEditorResize();
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
if ( visual ) {
[496] Fix | Delete
$top = $visualTop;
[497] Fix | Delete
$editor = $visualEditor;
[498] Fix | Delete
topHeight = heights.visualTopHeight;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function