diff --git src/wp-includes/js/customize-selective-refresh.js src/wp-includes/js/customize-selective-refresh.js
index d3b81db6d7..32f5b2f6df 100644
|
|
wp.customize.selectiveRefresh = ( function( $, api ) { |
334 | 334 | * @param {Placement} placement |
335 | 335 | */ |
336 | 336 | preparePlacement: function( placement ) { |
| 337 | var partial = this; |
337 | 338 | $( placement.container ).addClass( 'customize-partial-refreshing' ); |
| 339 | partial.scrollIntoView( placement ); |
| 340 | }, |
| 341 | |
| 342 | /** |
| 343 | * Scroll a placement container into view. |
| 344 | * |
| 345 | * @since 4.8.0 |
| 346 | * |
| 347 | * @param {Placement} [placement] Placement, if not provided then the first found placement will be used. |
| 348 | * @returns {void} |
| 349 | */ |
| 350 | scrollIntoView: function( placement ) { |
| 351 | var partial = this, container, docViewTop, docViewBottom, elemTop, elemBottom, selectedPlacement; |
| 352 | selectedPlacement = placement || partial.placements()[0]; |
| 353 | if ( ! selectedPlacement ) { |
| 354 | return; |
| 355 | } |
| 356 | container = $( selectedPlacement.container ); |
| 357 | if ( ! container[0] ) { |
| 358 | return; |
| 359 | } |
| 360 | if ( container[0].scrollIntoViewIfNeeded ) { |
| 361 | container[0].scrollIntoViewIfNeeded(); |
| 362 | } else { |
| 363 | // Props http://stackoverflow.com/a/488073/93579 |
| 364 | docViewTop = $( window ).scrollTop(); |
| 365 | docViewBottom = docViewTop + $( window ).height(); |
| 366 | elemTop = container.offset().top; |
| 367 | elemBottom = elemTop + container.height(); |
| 368 | if ( ( elemBottom > docViewBottom ) || ( elemTop < docViewTop ) ) { |
| 369 | container[0].scrollIntoView( elemTop < docViewTop ); |
| 370 | } |
| 371 | } |
338 | 372 | }, |
339 | 373 | |
340 | 374 | /** |
… |
… |
wp.customize.selectiveRefresh = ( function( $, api ) { |
469 | 503 | // Prevent placement container from being being re-triggered as being rendered among nested partials. |
470 | 504 | placement.container.data( 'customize-partial-content-rendered', true ); |
471 | 505 | |
| 506 | // Make sure partial is in view. |
| 507 | partial.scrollIntoView( placement ); |
| 508 | |
472 | 509 | /** |
473 | 510 | * Announce when a partial's placement has been rendered so that dynamic elements can be re-built. |
474 | 511 | */ |
diff --git src/wp-includes/js/wp-api.js src/wp-includes/js/wp-api.js
index 717ebf8e06..42583cc99a 100644
|
|
|
1154 | 1154 | // Include the array of route methods for easy reference. |
1155 | 1155 | methods: modelRoute.route.methods, |
1156 | 1156 | |
1157 | | initialize: function() { |
| 1157 | initialize: function( attributes, options ) { |
| 1158 | wp.api.WPApiBaseModel.prototype.initialize.call( this, attributes, options ); |
1158 | 1159 | |
1159 | 1160 | /** |
1160 | 1161 | * Posts and pages support trashing, other types don't support a trash |