Ticket #28328: 28328.23.patch
File 28328.23.patch, 5.4 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' ), 20 $footer = $( '#wpfooter' ), 19 21 fullscreen = window.wp.editor && window.wp.editor.fullscreen, 20 22 mceEditor, 21 23 mceBind = function(){}, … … 22 24 mceUnbind = function(){}, 23 25 fixedTop = false, 24 26 fixedBottom = false, 25 scrollTimer; 27 scrollTimer, 28 pageYOffsetAtTop = 130, 29 textEditorClonePaddingTop = 37, 30 autoresizeMinHeight = $window.height() - 310; 26 31 27 32 $textEditorClone.insertAfter( $textEditor ); 28 33 … … 31 36 'font-size': $textEditor.css( 'font-size' ), 32 37 'line-height': $textEditor.css( 'line-height' ), 33 38 'padding': $textEditor.css( 'padding' ), 34 'padding-top': 37,39 'padding-top': textEditorClonePaddingTop, 35 40 'white-space': 'pre-wrap', 36 41 'word-wrap': 'break-word' 37 42 } ); … … 88 93 89 94 hiddenHeight = $textEditorClone.height(); 90 95 91 if ( hiddenHeight < 300) {92 hiddenHeight = 300;96 if ( hiddenHeight < autoresizeMinHeight ) { 97 hiddenHeight = autoresizeMinHeight; 93 98 } 94 99 95 100 if ( hiddenHeight === textEditorHeight ) { … … 112 117 mceEditor = editor; 113 118 114 119 // Set the minimum height to the initial viewport height. 115 editor.settings.autoresize_min_height = 300;120 editor.settings.autoresize_min_height = autoresizeMinHeight; 116 121 117 122 // Get the necessary UI elements. 118 123 $visualTop = $contentWrap.find( '.mce-toolbar-grp' ); … … 218 223 adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, 219 224 resize = type !== 'scroll', 220 225 visual = ( mceEditor && ! mceEditor.isHidden() ), 221 buffer = 200,226 buffer = autoresizeMinHeight + adminBarHeight, 222 227 $top, $editor, 223 228 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight; 224 229 … … 236 241 editorPos = $editor.offset().top; 237 242 editorHeight = $editor.outerHeight(); 238 243 editorWidth = $editor.outerWidth(); 244 borderWidth = 1; 239 245 statusBarHeight = visual ? $statusBar.outerHeight() : 0; 246 sideSortablesHeight = $sideSortables.outerHeight(); 240 247 241 248 // Maybe pin the top. 242 249 if ( ( ! fixedTop || resize ) && … … 256 263 $tools.css( { 257 264 position: 'fixed', 258 265 top: adminBarHeight, 259 width: editorWidth + 2266 width: editorWidth + ( borderWidth * 2 ) 260 267 } ); 261 268 // Maybe unpin the top. 262 269 } else if ( fixedTop || resize ) { … … 287 294 288 295 $tools.css( { 289 296 position: 'absolute', 290 top: editorHeight - buffer + 1, // border297 top: editorHeight - buffer + borderWidth, // border 291 298 width: $contentWrap.width() 292 299 } ); 293 300 } … … 295 302 296 303 // Maybe adjust the bottom bar. 297 304 if ( ( ! fixedBottom || resize ) && 298 // + 1for the border around the .wp-editor-container.299 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1) ) {305 // +[n] for the border around the .wp-editor-container. 306 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 300 307 fixedBottom = true; 301 308 302 309 $bottom.css( { 303 310 position: 'fixed', 304 311 bottom: 0, 305 width: editorWidth + 2,312 width: editorWidth + ( borderWidth * 2 ), 306 313 borderTop: '1px solid #dedede' 307 314 } ); 308 315 } else if ( ( fixedBottom || resize ) && 309 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1) ) {316 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 310 317 fixedBottom = false; 311 318 312 319 $bottom.css( { … … 317 324 } ); 318 325 } 319 326 327 // Handle sidebar pinning 328 if ( sideSortablesHeight > windowHeight ) { 329 // If the sidebar is taller than the viewport, pin/unpin the bottom when scrolling 330 if ( sideSortablesHeight < ( editorHeight + pageYOffsetAtTop ) && ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth )) { 331 $sideSortables.css({ 332 position: 'fixed', 333 bottom: '20px' 334 }); 335 } else if (( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth )) { 336 $sideSortables.css({ 337 position: 'relative', 338 bottom: 'auto' 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