Ticket #28328: 28328.24.patch
File 28328.24.patch, 6.1 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 408 417 #timestampdiv select { 409 418 height: 21px; 410 419 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 scrollTimer, 31 lastScrollPosition = 0, 32 pageYOffsetAtTop = 130, 33 textEditorClonePaddingTop = 37, 34 autoresizeMinHeight = $window.height() - 310; 26 35 27 36 $textEditorClone.insertAfter( $textEditor ); 28 37 … … 31 40 'font-size': $textEditor.css( 'font-size' ), 32 41 'line-height': $textEditor.css( 'line-height' ), 33 42 'padding': $textEditor.css( 'padding' ), 34 'padding-top': 37,43 'padding-top': textEditorClonePaddingTop, 35 44 'white-space': 'pre-wrap', 36 45 'word-wrap': 'break-word' 37 46 } ); … … 88 97 89 98 hiddenHeight = $textEditorClone.height(); 90 99 91 if ( hiddenHeight < 300) {92 hiddenHeight = 300;100 if ( hiddenHeight < autoresizeMinHeight ) { 101 hiddenHeight = autoresizeMinHeight; 93 102 } 94 103 95 104 if ( hiddenHeight === textEditorHeight ) { … … 112 121 mceEditor = editor; 113 122 114 123 // Set the minimum height to the initial viewport height. 115 editor.settings.autoresize_min_height = 300;124 editor.settings.autoresize_min_height = autoresizeMinHeight; 116 125 117 126 // Get the necessary UI elements. 118 127 $visualTop = $contentWrap.find( '.mce-toolbar-grp' ); … … 218 227 adminBarHeight = windowWidth > 600 ? $adminBar.height() : 0, 219 228 resize = type !== 'scroll', 220 229 visual = ( mceEditor && ! mceEditor.isHidden() ), 221 buffer = 200,230 buffer = autoresizeMinHeight + adminBarHeight, 222 231 $top, $editor, 223 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight ;232 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth, statusBarHeight, sideScrollTrigger; 224 233 225 234 if ( visual ) { 226 235 $top = $visualTop; … … 236 245 editorPos = $editor.offset().top; 237 246 editorHeight = $editor.outerHeight(); 238 247 editorWidth = $editor.outerWidth(); 248 borderWidth = 1; 239 249 statusBarHeight = visual ? $statusBar.outerHeight() : 0; 240 250 241 251 // Maybe pin the top. … … 256 266 $tools.css( { 257 267 position: 'fixed', 258 268 top: adminBarHeight, 259 width: editorWidth + 2269 width: editorWidth + ( borderWidth * 2 ) 260 270 } ); 261 271 // Maybe unpin the top. 262 272 } else if ( fixedTop || resize ) { … … 287 297 288 298 $tools.css( { 289 299 position: 'absolute', 290 top: editorHeight - buffer + 1, // border300 top: editorHeight - buffer + borderWidth, // border 291 301 width: $contentWrap.width() 292 302 } ); 293 303 } … … 295 305 296 306 // Maybe adjust the bottom bar. 297 307 if ( ( ! fixedBottom || resize ) && 298 // + 1for the border around the .wp-editor-container.299 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + 1) ) {308 // +[n] for the border around the .wp-editor-container. 309 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 300 310 fixedBottom = true; 301 311 302 312 $bottom.css( { 303 313 position: 'fixed', 304 314 bottom: 0, 305 width: editorWidth + 2,315 width: editorWidth + ( borderWidth * 2 ), 306 316 borderTop: '1px solid #dedede' 307 317 } ); 308 318 } else if ( ( fixedBottom || resize ) && 309 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - 1) ) {319 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 310 320 fixedBottom = false; 311 321 312 322 $bottom.css( { … … 317 327 } ); 318 328 } 319 329 330 // The sidebar is on the left, pin it 331 if ( ( $postboxContainer.position().top - 10 ) < $postBodyContent.position().top ) { 332 sideScrollTrigger = ( $sideSortables.height() - ( windowHeight - 56 ) ); 333 334 if ( ! fixedSide && ( $postBody.offset().top - 56 ) < windowPos ) { 335 fixedSide = true; 336 $postboxContainer.addClass('pinned'); 337 } else if ( fixedSide ) { 338 if ( ( $postBody.offset().top - 56 ) >= windowPos ) { 339 fixedSide = false; 340 $postboxContainer.removeClass('pinned scroll-down'); 341 } 342 } 343 344 if ( fixedSide && windowPos > lastScrollPosition ) { 345 // Scrolling down 346 if ( sideScrollTrigger > 1 && sideScrollTrigger < windowPos ) { 347 $postboxContainer.css( 'top', -( sideScrollTrigger -36 ) ); 348 } 349 } else if ( windowPos < lastScrollPosition ) { 350 $postboxContainer.css( 'top', '' ); 351 } 352 353 lastScrollPosition = windowPos; 354 } 355 320 356 if ( resize ) { 321 357 $contentWrap.css( { 322 358 paddingTop: $tools.outerHeight() … … 350 386 clearTimeout( scrollTimer ); 351 387 scrollTimer = setTimeout( adjust, 200 ); 352 388 } 353 354 389 function on() { 355 390 // Scroll to the top when triggering this from JS. 356 391 // Ensures toolbars are pinned properly. 357 if ( window.pageYOffset && window.pageYOffset > 130) {392 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 358 393 window.scrollTo( window.pageXOffset, 0 ); 359 394 } 360 395 … … 397 432 398 433 // Scroll to the top when triggering this from JS. 399 434 // Ensures toolbars are reset properly. 400 if ( window.pageYOffset && window.pageYOffset > 130) {435 if ( window.pageYOffset && window.pageYOffset > pageYOffsetAtTop ) { 401 436 window.scrollTo( window.pageXOffset, 0 ); 402 437 } 403 438