Changeset 29523
- Timestamp:
- 08/18/2014 12:34:45 AM (10 years ago)
- Location:
- trunk/src/wp-admin/js
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/editor-expand.js
r29522 r29523 227 227 resize = type !== 'scroll', 228 228 visual = ( mceEditor && ! mceEditor.isHidden() ), 229 buffer = autoresizeMinHeight + adminBarHeight,229 buffer = autoresizeMinHeight, 230 230 postBodyTop = $postBody.offset().top, 231 231 borderWidth = 1, 232 232 contentWrapWidth = $contentWrap.width(), 233 233 sideSortablesHeight = $sideSortables.height(), 234 $top, $editor, sidebarTop, footerTop, 235 toolsHeight, topPos, topHeight, editorPos, editorHeight, editorWidth,statusBarHeight;234 $top, $editor, sidebarTop, footerTop, canPin, 235 toolsHeight, topPos, topHeight, editorPos, editorHeight, statusBarHeight; 236 236 237 237 if ( visual ) { … … 248 248 editorPos = $editor.offset().top; 249 249 editorHeight = $editor.outerHeight(); 250 editorWidth = $editor.outerWidth();251 250 statusBarHeight = visual ? $statusBar.outerHeight() : 0; 252 251 253 254 // Maybe pin the top. 255 if ( ( ! fixedTop || resize ) && 256 // Handle scrolling down. 257 ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) && 258 // Handle scrolling up. 259 windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) { 260 261 fixedTop = true; 262 263 $top.css( { 264 position: 'fixed', 265 top: adminBarHeight + toolsHeight, 266 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ), 267 borderTop: '1px solid #e5e5e5' 268 } ); 269 270 $tools.css( { 271 position: 'fixed', 272 top: adminBarHeight, 273 width: contentWrapWidth 274 } ); 275 // Maybe unpin the top. 276 } else if ( fixedTop || resize ) { 277 // Handle scrolling up. 278 if ( windowPos <= ( topPos - toolsHeight - adminBarHeight ) ) { 279 fixedTop = false; 280 252 // Should we pin? 253 canPin = visual ? autoresizeMinHeight + topHeight : autoresizeMinHeight + 20; // 20px from textarea padding 254 canPin = editorHeight > ( canPin + 5 ); 255 256 if ( ! canPin ) { 257 if ( resize ) { 281 258 $top.css( { 282 259 position: 'absolute', … … 291 268 width: contentWrapWidth 292 269 } ); 293 // Handle scrolling down. 294 } else if ( windowPos >= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) { 295 fixedTop = false; 270 271 $bottom.css( { 272 position: 'relative', 273 bottom: 'auto', 274 width: '100%', 275 borderTop: 'none' 276 } ); 277 } 278 } else { 279 // Maybe pin the top. 280 if ( ( ! fixedTop || resize ) && 281 // Handle scrolling down. 282 ( windowPos >= ( topPos - toolsHeight - adminBarHeight ) && 283 // Handle scrolling up. 284 windowPos <= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) ) { 285 286 fixedTop = true; 296 287 297 288 $top.css( { 298 position: 'absolute', 299 top: editorHeight - buffer, 300 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) 289 position: 'fixed', 290 top: adminBarHeight + toolsHeight, 291 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ), 292 borderTop: '1px solid #e5e5e5' 301 293 } ); 302 294 303 295 $tools.css( { 304 position: ' absolute',305 top: editorHeight - buffer + borderWidth, // border296 position: 'fixed', 297 top: adminBarHeight, 306 298 width: contentWrapWidth 307 299 } ); 308 } 309 } 310 311 // Maybe adjust the bottom bar. 312 if ( ( ! fixedBottom || resize ) && 313 // +[n] for the border around the .wp-editor-container. 314 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 315 316 fixedBottom = true; 317 318 $bottom.css( { 319 position: 'fixed', 320 bottom: 0, 321 width: editorWidth + ( borderWidth * 2 ), 322 borderTop: '1px solid #dedede' 323 } ); 324 } else if ( ( fixedBottom || resize ) && 325 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 326 fixedBottom = false; 327 328 $bottom.css( { 329 position: 'relative', 330 bottom: 'auto', 331 width: '100%', 332 borderTop: 'none' 333 } ); 300 // Maybe unpin the top. 301 } else if ( fixedTop || resize ) { 302 // Handle scrolling up. 303 if ( windowPos <= ( topPos - toolsHeight - adminBarHeight ) ) { 304 fixedTop = false; 305 306 $top.css( { 307 position: 'absolute', 308 top: 0, 309 borderTop: 'none', 310 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) 311 } ); 312 313 $tools.css( { 314 position: 'absolute', 315 top: 0, 316 width: contentWrapWidth 317 } ); 318 // Handle scrolling down. 319 } else if ( windowPos >= ( topPos - toolsHeight - adminBarHeight + editorHeight - buffer ) ) { 320 fixedTop = false; 321 322 $top.css( { 323 position: 'absolute', 324 top: editorHeight - buffer, 325 width: contentWrapWidth - ( borderWidth * 2 ) - ( visual ? 0 : ( $top.outerWidth() - $top.width() ) ) 326 } ); 327 328 $tools.css( { 329 position: 'absolute', 330 top: editorHeight - buffer + borderWidth, // border 331 width: contentWrapWidth 332 } ); 333 } 334 } 335 336 // Maybe adjust the bottom bar. 337 if ( ( ! fixedBottom || resize ) && 338 // +[n] for the border around the .wp-editor-container. 339 ( windowPos + windowHeight ) <= ( editorPos + editorHeight + bottomHeight + statusBarHeight + borderWidth ) ) { 340 341 fixedBottom = true; 342 343 $bottom.css( { 344 position: 'fixed', 345 bottom: 0, 346 width: contentWrapWidth, 347 borderTop: '1px solid #dedede' 348 } ); 349 } else if ( ( fixedBottom || resize ) && 350 ( windowPos + windowHeight ) > ( editorPos + editorHeight + bottomHeight + statusBarHeight - borderWidth ) ) { 351 fixedBottom = false; 352 353 $bottom.css( { 354 position: 'relative', 355 bottom: 'auto', 356 width: '100%', 357 borderTop: 'none' 358 } ); 359 } 334 360 } 335 361 … … 337 363 if ( $postboxContainer.width() < 300 && windowWidth > 600 && // sidebar position is changed with @media from CSS, make sure it is on the side 338 364 $document.height() > ( $sideSortables.height() + postBodyTop + 120 ) && // the sidebar is not the tallest element 339 windowHeight < editorHeight * 0.7) { // the editor is taller than the viewport365 windowHeight < editorHeight ) { // the editor is taller than the viewport 340 366 341 367 if ( sideSortablesHeight > windowHeight || fixedSideTop || fixedSideBottom ) { … … 455 481 function afterScroll() { 456 482 clearTimeout( scrollTimer ); 457 scrollTimer = setTimeout( adjust, 200 );483 scrollTimer = setTimeout( adjust, 100 ); 458 484 } 459 485 … … 474 500 475 501 // Adjust when collapsing the menu, changing the columns, changing the body class. 476 $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); 502 $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ) 503 .on( 'postbox-toggled.editor-expand', function() { 504 if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > 20 ) { 505 fixedSideBottom = true; 506 window.scrollBy( 0, -1 ); 507 adjust(); 508 window.scrollBy( 0, 1 ); 509 } 510 511 adjust(); 512 }); 477 513 478 514 $textEditor.on( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); … … 510 546 $wrap.removeClass( 'wp-editor-expand' ); 511 547 512 // Adjust when the window is scrolled or resized. 513 $window.off( 'scroll.editor-expand resize.editor-expand' ); 514 515 // Adjust when collapsing the menu, changing the columns, changing the body class. 516 $document.off( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust ); 517 518 $textEditor.off( 'focus.editor-expand input.editor-expand propertychange.editor-expand', textEditorResize ); 519 $textEditor.off( 'keyup.editor-expand', textEditorKeyup ); 548 $window.off( '.editor-expand' ); 549 $document.off( '.editor-expand' ); 550 $textEditor.off( '.editor-expand' ); 520 551 mceUnbind(); 521 552 -
trunk/src/wp-admin/js/postbox.js
r29049 r29523 4 4 5 5 (function($) { 6 var $document = $( document ); 7 6 8 postboxes = { 7 9 add_postbox_toggles : function(page, args) { … … 27 29 self.pbhide(id); 28 30 } 31 32 $document.trigger( 'postbox-toggled', p ); 29 33 }); 30 34 … … 40 44 41 45 $('.hide-postbox-tog').bind('click.postboxes', function() { 42 var box = $(this).val(); 46 var boxId = $(this).val(), 47 $postbox = $( '#' + boxId ); 43 48 44 49 if ( $(this).prop('checked') ) { 45 $ ('#' + box).show();50 $postbox.show(); 46 51 if ( $.isFunction( postboxes.pbshow ) ) 47 52 self.pbshow( box ); 48 53 } else { 49 $ ('#' + box).hide();54 $postbox.hide(); 50 55 if ( $.isFunction( postboxes.pbhide ) ) 51 56 self.pbhide( box ); … … 53 58 self.save_state(page); 54 59 self._mark_area(); 60 $document.trigger( 'postbox-toggled', $postbox ); 55 61 }); 56 62
Note: See TracChangeset
for help on using the changeset viewer.