Ticket #28328: 28328.25.patch
File 28328.25.patch, 6.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 #postbox-container-1.pinned { 409 position: fixed; 410 margin: 0; 411 top: 56px; 412 bottom: 0; 413 right: 20px; 414 transition: top 200ms; 415 } 416 417 #postbox-container-1 #side-sortables { 418 padding-bottom: 1px; 419 } 420 408 421 #timestampdiv select { 409 422 height: 21px; 410 423 line-height: 14px; -
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 $postboxContainer = $('#postbox-container-1'), 21 $postBodyContent = $('#post-body-content'), 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 fixedSide = false, 30 scrolledSide = false, 31 scrollTimer, 32 lastScrollPosition = 0, 33 pageYOffsetAtTop = 130, 34 textEditorClonePaddingTop = 37, 35 autoresizeMinHeight = $window.height() - 310; 26 36 27 37 $textEditorClone.insertAfter( $textEditor ); 28 38 … … 31 41 'font-size': $textEditor.css( 'font-size' ), 32 42 'line-height': $textEditor.css( 'line-height' ), 33 43 'padding': $textEditor.css( 'padding' ), 34 'padding-top': 37,44 'padding-top': textEditorClonePaddingTop, 35 45 'white-space': 'pre-wrap', 36 46 'word-wrap': 'break-word' 37 47 } ); … … 88 98 89 99 hiddenHeight = $textEditorClone.height(); 90 100 91 if ( hiddenHeight < 300) {92 hiddenHeight = 300;101 if ( hiddenHeight < autoresizeMinHeight ) { 102 hiddenHeight = autoresizeMinHeight; 93 103 } 94 104 95 105 if ( hiddenHeight === textEditorHeight ) { … … 112 122 mceEditor = editor; 113 123 114 124 // Set the minimum height to the initial viewport height. 115 editor.settings.autoresize_min_height = 300;125 editor.settings.autoresize_min_height = autoresizeMinHeight; 116 126 117 127 // Get the necessary UI elements. 118 128 $visualTop = $contentWrap.find( '.mce-toolbar-grp' ); … … 218 228 adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, 219 229 resize = type !== 'scroll', 220 230 visual = ( mceEditor && ! mceEditor.isHidden() ), 221 buffer = 200, 231 buffer = autoresizeMinHeight + adminBarHeight, 232 postBodyTop = $postBody.offset().top, 222 233 $top, $editor, 223 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight ;234 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight, sideScrollTrigger; 224 235 225 236 if ( visual ) { 226 237 $top = $visualTop; … … 236 247 editorPos = $editor.offset().top; 237 248 editorHeight = $editor.outerHeight(); 238 249 editorWidth = $editor.outerWidth(); 250 borderWidth = 1; 239 251 statusBarHeight = visual ? $statusBar.outerHeight() : 0; 240 252 241 253 // Maybe pin the top. … … 256 268 $tools.css( { 257 269 position: 'fixed', 258 270 top: adminBarHeight, 259 width: editorWidth + 2271 width: editorWidth + ( borderWidth * 2 ) 260 272 } ); 261 273 // Maybe unpin the top. 262 274 } else if ( fixedTop || resize ) { … … 287 299 288 300 $tools.css( { 289 301 position: 'absolute', 290 top: editorHeight - buffer + 1, // border302 top: editorHeight - buffer + borderWidth, // border 291 303 width: $contentWrap.width() 292 304 } ); 293 305 } … … 295 307 296 308 // Maybe adjust the bottom bar. 297 309 if ( ( ! fixedBottom || resize ) && 298 // + 1for the border around the .wp-editor-container.299 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1) ) {310 // +[n] for the border around the .wp-editor-container. 311 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 300 312 fixedBottom = true; 301 313 302 314 $bottom.css( { 303 315 position: 'fixed', 304 316 bottom: 0, 305 width: editorWidth + 2,317 width: editorWidth + ( borderWidth * 2 ), 306 318 borderTop: '1px solid #dedede' 307 319 } ); 308 320 } else if ( ( fixedBottom || resize ) && 309 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1) ) {321 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 310 322 fixedBottom = false; 311 323 312 324 $bottom.css( { … … 317 329 } ); 318 330 } 319 331 332 // The sidebar is on the left and the scrolling height is large enough, pin it. 333 if ( $postboxContainer.width() < 300 && windowWidth > 600 && 334 $document.height() > ( $sideSortables.height() + postBodyTop + 120 ) ) { 335 336 if ( ! fixedSide && ( postBodyTop - 56 ) < windowPos ) { 337 fixedSide = true; 338 $postboxContainer.addClass( 'pinned' ); 339 } else if ( fixedSide ) { 340 if ( ( postBodyTop - 56 ) >= windowPos ) { 341 fixedSide = false; 342 $postboxContainer.removeClass( 'pinned' ); 343 } 344 } 345 346 if ( fixedSide && windowPos > lastScrollPosition ) { 347 // Scrolling down 348 sideScrollTrigger = ( $sideSortables.height() - ( windowHeight - 56 ) ); 349 350 if ( ! scrolledSide && sideScrollTrigger > 1 && windowPos > sideScrollTrigger && windowPos > $wrap.offset().top ) { 351 scrolledSide = true; 352 $postboxContainer.css( 'top', -( sideScrollTrigger - 36 ) ); 353 } 354 } else if ( scrolledSide && windowPos < lastScrollPosition ) { 355 scrolledSide = false; 356 $postboxContainer.css( 'top', '' ); 357 } 358 359 lastScrollPosition = windowPos; 360 } else { 361 // Unpin 362 $postboxContainer.removeClass( 'pinned' ); 363 $postboxContainer.css( 'top', '' ); 364 scrolledSide = fixedSide = false; 365 } 366 320 367 if ( resize ) { 321 368 $contentWrap.css( { 322 369 paddingTop: $tools.outerHeight() … … 354 401 function on() { 355 402 // Scroll to the top when triggering this from JS. 356 403 // Ensures toolbars are pinned properly. 357 if ( window.pageYOffset && window.pageYOffset > 130) {404 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 358 405 window.scrollTo( window.pageXOffset, 0 ); 359 406 } 360 407 … … 397 444 398 445 // Scroll to the top when triggering this from JS. 399 446 // Ensures toolbars are reset properly. 400 if ( window.pageYOffset && window.pageYOffset > 130) {447 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 401 448 window.scrollTo( window.pageXOffset, 0 ); 402 449 } 403 450