Ticket #28328: 28328.21.patch
File 28328.21.patch, 5.3 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/editor-expand.js
16 16 $textEditorClone = $( '<div id="content-textarea-clone"></div>' ), 17 17 $bottom = $( '#post-status-info' ), 18 18 $statusBar, 19 $sideSortables = $( '#side-sortables' ), 19 20 fullscreen = window.wp.editor && window.wp.editor.fullscreen, 20 21 mceEditor, 21 22 mceBind = function(){}, … … 22 23 mceUnbind = function(){}, 23 24 fixedTop = false, 24 25 fixedBottom = false, 25 scrollTimer; 26 scrollTimer, 27 pageYOffsetAtTop = 130, 28 textEditorClonePaddingTop = 37, 29 autoresizeMinHeight = $window.height() - 310; 26 30 27 31 $textEditorClone.insertAfter( $textEditor ); 28 32 … … 31 35 'font-size': $textEditor.css( 'font-size' ), 32 36 'line-height': $textEditor.css( 'line-height' ), 33 37 'padding': $textEditor.css( 'padding' ), 34 'padding-top': 37,38 'padding-top': textEditorClonePaddingTop, 35 39 'white-space': 'pre-wrap', 36 40 'word-wrap': 'break-word' 37 41 } ); … … 88 92 89 93 hiddenHeight = $textEditorClone.height(); 90 94 91 if ( hiddenHeight < 300) {92 hiddenHeight = 300;95 if ( hiddenHeight < autoresizeMinHeight ) { 96 hiddenHeight = autoresizeMinHeight; 93 97 } 94 98 95 99 if ( hiddenHeight === textEditorHeight ) { … … 112 116 mceEditor = editor; 113 117 114 118 // Set the minimum height to the initial viewport height. 115 editor.settings.autoresize_min_height = 300;119 editor.settings.autoresize_min_height = autoresizeMinHeight; 116 120 117 121 // Get the necessary UI elements. 118 122 $visualTop = $contentWrap.find( '.mce-toolbar-grp' ); … … 218 222 adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, 219 223 resize = type !== 'scroll', 220 224 visual = ( mceEditor && ! mceEditor.isHidden() ), 221 buffer = 200,225 buffer = autoresizeMinHeight + adminBarHeight, 222 226 $top, $editor, 223 227 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight; 224 228 … … 236 240 editorPos = $editor.offset().top; 237 241 editorHeight = $editor.outerHeight(); 238 242 editorWidth = $editor.outerWidth(); 243 borderWidth = 1; 239 244 statusBarHeight = visual ? $statusBar.outerHeight() : 0; 240 245 241 246 // Maybe pin the top. … … 256 261 $tools.css( { 257 262 position: 'fixed', 258 263 top: adminBarHeight, 259 width: editorWidth + 2264 width: editorWidth + ( borderWidth * 2 ) 260 265 } ); 261 266 // Maybe unpin the top. 262 267 } else if ( fixedTop || resize ) { … … 287 292 288 293 $tools.css( { 289 294 position: 'absolute', 290 top: editorHeight - buffer + 1, // border295 top: editorHeight - buffer + borderWidth, // border 291 296 width: $contentWrap.width() 292 297 } ); 293 298 } … … 295 300 296 301 // Maybe adjust the bottom bar. 297 302 if ( ( ! fixedBottom || resize ) && 298 // + 1for the border around the .wp-editor-container.299 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1) ) {303 // +[n] for the border around the .wp-editor-container. 304 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 300 305 fixedBottom = true; 301 306 302 307 $bottom.css( { 303 308 position: 'fixed', 304 309 bottom: 0, 305 width: editorWidth + 2,310 width: editorWidth + ( borderWidth * 2 ), 306 311 borderTop: '1px solid #dedede' 307 312 } ); 308 313 } else if ( ( fixedBottom || resize ) && 309 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1) ) {314 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 310 315 fixedBottom = false; 311 316 312 317 $bottom.css( { … … 317 322 } ); 318 323 } 319 324 325 // Handle sidebar pinning 326 if ( $sideSortables.outerHeight() > windowHeight ) { 327 // If the sidebar is taller than the viewport, pin/unpin the bottom when scrolling 328 if ( ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 329 $sideSortables.css( { 330 position: 'relative', 331 bottom: 'auto' 332 } ); 333 334 } else if ( ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 335 $sideSortables.css( { 336 position: 'fixed', 337 bottom: 0, 338 marginBottom: '20px' 339 } ); 340 } 341 } else { 342 // if the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling 343 if ( windowPos >= ( toolsHeight + adminBarHeight ) ) { 344 $sideSortables.css( { 345 position: 'fixed', 346 top: toolsHeight 347 } ); 348 } else { 349 $sideSortables.css( { 350 position: 'relative', 351 top: 'auto' 352 } ); 353 } 354 } 355 320 356 if ( resize ) { 321 357 $contentWrap.css( { 322 358 paddingTop: $tools.outerHeight() … … 354 390 function on() { 355 391 // Scroll to the top when triggering this from JS. 356 392 // Ensures toolbars are pinned properly. 357 if ( window.pageYOffset && window.pageYOffset > 130) {393 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 358 394 window.scrollTo( window.pageXOffset, 0 ); 359 395 } 360 396 … … 397 433 398 434 // Scroll to the top when triggering this from JS. 399 435 // Ensures toolbars are reset properly. 400 if ( window.pageYOffset && window.pageYOffset > 130) {436 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 401 437 window.scrollTo( window.pageXOffset, 0 ); 402 438 } 403 439