Ticket #28328: 28328.30.patch
File 28328.30.patch, 10.5 KB (added by , 10 years ago) |
---|
-
src/wp-admin/css/edit.css
405 405 } 406 406 /* end editor-expand.js override */ 407 407 408 #poststuff #post-body.columns-2 #side-sortables { 409 width: 280px; 410 } 411 408 412 #timestampdiv select { 409 413 height: 21px; 410 414 line-height: 14px; … … 1229 1233 1230 1234 #poststuff #post-body.columns-2 #side-sortables { 1231 1235 min-height: 0; 1236 width: auto; 1232 1237 } 1233 1238 1234 1239 /* hide the radio buttons for column prefs */ -
src/wp-admin/js/editor-expand.js
6 6 var $window = $( window ), 7 7 $document = $( document ), 8 8 $adminBar = $( '#wpadminbar' ), 9 $footer = $( '#wpfooter' ), 9 10 $wrap = $( '#postdivrich' ), 10 11 $contentWrap = $( '#wp-content-wrap' ), 11 12 $tools = $( '#wp-content-editor-tools' ), … … 16 17 $textEditorClone = $( '<div id="content-textarea-clone"></div>' ), 17 18 $bottom = $( '#post-status-info' ), 18 19 $statusBar, 20 $sideSortables = $( '#side-sortables' ), 21 $postboxContainer = $( '#postbox-container-1' ), 22 $postBody = $('#post-body'), 19 23 fullscreen = window.wp.editor && window.wp.editor.fullscreen, 20 24 mceEditor, 21 25 mceBind = function(){}, … … 22 26 mceUnbind = function(){}, 23 27 fixedTop = false, 24 28 fixedBottom = false, 25 scrollTimer; 29 fixedSideTop = false, 30 fixedSideBottom = false, 31 scrollTimer, 32 lastScrollPosition = 0, 33 pageYOffsetAtTop = 130, 34 pinnedToolsTop = 56, // also used in CSS for the "#poststuff #post-body #postbox-container-1.pinned" selector 35 textEditorClonePaddingTop = 37, 36 autoresizeMinHeight = 300; // $window.height() - 310; 26 37 27 38 $textEditorClone.insertAfter( $textEditor ); 28 39 … … 31 42 'font-size': $textEditor.css( 'font-size' ), 32 43 'line-height': $textEditor.css( 'line-height' ), 33 44 'padding': $textEditor.css( 'padding' ), 34 'padding-top': 37,45 'padding-top': textEditorClonePaddingTop, 35 46 'white-space': 'pre-wrap', 36 47 'word-wrap': 'break-word' 37 48 } ); … … 88 99 89 100 hiddenHeight = $textEditorClone.height(); 90 101 91 if ( hiddenHeight < 300) {92 hiddenHeight = 300;102 if ( hiddenHeight < autoresizeMinHeight ) { 103 hiddenHeight = autoresizeMinHeight; 93 104 } 94 105 95 106 if ( hiddenHeight === textEditorHeight ) { … … 112 123 mceEditor = editor; 113 124 114 125 // Set the minimum height to the initial viewport height. 115 editor.settings.autoresize_min_height = 300;126 editor.settings.autoresize_min_height = autoresizeMinHeight; 116 127 117 128 // Get the necessary UI elements. 118 129 $visualTop = $contentWrap.find( '.mce-toolbar-grp' ); … … 218 229 adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, 219 230 resize = type !== 'scroll', 220 231 visual = ( mceEditor && ! mceEditor.isHidden() ), 221 buffer = 200, 222 $top, $editor, 232 buffer = autoresizeMinHeight + adminBarHeight, 233 postBodyTop = $postBody.offset().top, 234 borderWidth = 1, 235 contentWrapWidth = $contentWrap.width(), 236 sideSortablesHeight = $sideSortables.height(), 237 $top, $editor, sidebarTop, footerTop, 223 238 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight; 224 239 225 240 if ( visual ) { … … 238 253 editorWidth = $editor.outerWidth(); 239 254 statusBarHeight = visual ? $statusBar.outerHeight() : 0; 240 255 256 241 257 // Maybe pin the top. 242 258 if ( ( ! fixedTop || resize ) && 243 // Handle scrolling down. 244 ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) && 245 // Handle scrolling up. 246 windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) { 259 // Handle scrolling down. 260 ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) && 261 // Handle scrolling up. 262 windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) { 263 247 264 fixedTop = true; 248 265 249 266 $top.css( { 250 267 position: 'fixed', 251 268 top: adminBarHeight + toolsHeight, 252 width: $editor.parent().width() - ( $top.outerWidth() - $top.width() ),269 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ), 253 270 borderTop: '1px solid #e5e5e5' 254 271 } ); 255 272 … … 256 273 $tools.css( { 257 274 position: 'fixed', 258 275 top: adminBarHeight, 259 width: editorWidth + 2276 width: contentWrapWidth 260 277 } ); 261 278 // Maybe unpin the top. 262 279 } else if ( fixedTop || resize ) { … … 268 285 position: 'absolute', 269 286 top: 0, 270 287 borderTop: 'none', 271 width: $editor.parent().width() - ( $top.outerWidth() - $top.width() )288 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) 272 289 } ); 273 290 274 291 $tools.css( { 275 292 position: 'absolute', 276 293 top: 0, 277 width: $contentWrap.width()294 width: contentWrapWidth 278 295 } ); 279 296 // Handle scrolling down. 280 297 } else if ( windowPos >= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) { … … 282 299 283 300 $top.css( { 284 301 position: 'absolute', 285 top: editorHeight - buffer 302 top: editorHeight - buffer, 303 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) 286 304 } ); 287 305 288 306 $tools.css( { 289 307 position: 'absolute', 290 top: editorHeight - buffer + 1, // border291 width: $contentWrap.width()308 top: editorHeight - buffer + borderWidth, // border 309 width: contentWrapWidth 292 310 } ); 293 311 } 294 312 } … … 295 313 296 314 // Maybe adjust the bottom bar. 297 315 if ( ( ! fixedBottom || resize ) && 298 // + 1 for the border around the .wp-editor-container. 299 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1 ) ) { 316 // +[n] for the border around the .wp-editor-container. 317 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 318 300 319 fixedBottom = true; 301 320 302 321 $bottom.css( { 303 322 position: 'fixed', 304 323 bottom: 0, 305 width: editorWidth + 2,324 width: editorWidth + ( borderWidth * 2 ), 306 325 borderTop: '1px solid #dedede' 307 326 } ); 308 327 } else if ( ( fixedBottom || resize ) && 309 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1) ) {328 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 310 329 fixedBottom = false; 311 330 312 331 $bottom.css( { … … 317 336 } ); 318 337 } 319 338 339 // Sidebar pinning 340 if ( $postboxContainer.width() < 300 && windowWidth > 600 && // sidebar position is changed with @media from CSS, make sure it is on the side 341 $document.height() > ( $sideSortables.height() + postBodyTop + 120 ) && // the sidebar is not the tallest element 342 windowHeight < editorHeight * 0.7 ) { // the editor is taller than the viewport 343 344 if ( sideSortablesHeight > windowHeight || fixedSideTop || fixedSideBottom ) { 345 // Reset when scrolling to the top 346 if ( windowPos + pinnedToolsTop <= postBodyTop ) { 347 $sideSortables.attr( 'style', '' ); 348 fixedSideTop = fixedSideBottom = false; 349 } else { 350 if ( windowPos > lastScrollPosition ) { 351 // Scrolling down 352 if ( fixedSideTop ) { 353 // let it scroll 354 fixedSideTop = false; 355 sidebarTop = $sideSortables.offset().top - adminBarHeight; 356 footerTop = $footer.offset().top; 357 358 // don't get over the footer 359 if ( footerTop < sidebarTop + sideSortablesHeight + 20 ) { 360 sidebarTop = footerTop - sideSortablesHeight - 20; 361 } 362 363 $sideSortables.css({ 364 position: 'absolute', 365 top: sidebarTop, 366 bottom: '' 367 }); 368 } else if ( ! fixedSideBottom && sideSortablesHeight + $sideSortables.offset().top + 20 < windowPos + windowHeight ) { 369 // pin the bottom 370 fixedSideBottom = true; 371 372 $sideSortables.css({ 373 position: 'fixed', 374 top: 'auto', 375 bottom: '20px' 376 }); 377 } 378 } else if ( windowPos < lastScrollPosition ) { 379 // Scrolling up 380 if ( fixedSideBottom ) { 381 // let it scroll 382 fixedSideBottom = false; 383 sidebarTop = $sideSortables.offset().top - 20; 384 footerTop = $footer.offset().top; 385 386 // don't get over the footer 387 if ( footerTop < sidebarTop + sideSortablesHeight + 20 ) { 388 sidebarTop = footerTop - sideSortablesHeight - 20; 389 } 390 391 $sideSortables.css({ 392 position: 'absolute', 393 top: sidebarTop, 394 bottom: '' 395 }); 396 } else if ( ! fixedSideTop && $sideSortables.offset().top >= windowPos + pinnedToolsTop ) { 397 // pin the top 398 fixedSideTop = true; 399 400 $sideSortables.css({ 401 position: 'fixed', 402 top: pinnedToolsTop, 403 bottom: '' 404 }); 405 } 406 } 407 } 408 } else { 409 // if the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling 410 if ( windowPos >= ( postBodyTop - pinnedToolsTop ) ) { 411 $sideSortables.css( { 412 position: 'fixed', 413 top: pinnedToolsTop 414 } ); 415 } else { 416 $sideSortables.attr( 'style', '' ); 417 } 418 419 fixedSideTop = fixedSideBottom = false; 420 } 421 422 lastScrollPosition = windowPos; 423 } else { 424 $sideSortables.attr( 'style', '' ); 425 fixedSideTop = fixedSideBottom = false; 426 } 427 320 428 if ( resize ) { 321 429 $contentWrap.css( { 322 430 paddingTop: $tools.outerHeight() … … 354 462 function on() { 355 463 // Scroll to the top when triggering this from JS. 356 464 // Ensures toolbars are pinned properly. 357 if ( window.pageYOffset && window.pageYOffset > 130) {465 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 358 466 window.scrollTo( window.pageXOffset, 0 ); 359 467 } 360 468 … … 397 505 398 506 // Scroll to the top when triggering this from JS. 399 507 // Ensures toolbars are reset properly. 400 if ( window.pageYOffset && window.pageYOffset > 130) {508 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 401 509 window.scrollTo( window.pageXOffset, 0 ); 402 510 } 403 511 … … 417 525 fullscreen && fullscreen.pubsub.unsubscribe( 'hidden', fullscreenHide ); 418 526 419 527 // Reset all css 420 $.each( [ $visualTop, $textTop, $tools, $bottom, $contentWrap, $visualEditor, $textEditor ], function( i, element ) {528 $.each( [ $visualTop, $textTop, $tools, $bottom, $contentWrap, $visualEditor, $textEditor, $sideSortables ], function( i, element ) { 421 529 element && element.attr( 'style', '' ); 422 530 }); 423 531 532 fixedTop = fixedBottom = fixedSideTop = fixedSideBottom = false; 533 424 534 if ( mceEditor ) { 425 535 mceEditor.settings.wp_autoresize_on = false; 426 536 mceEditor.execCommand( 'wpAutoResizeOff' );