Revisions: Reduce points where IDs are cast in JS. See #24425.
git-svn-id: https://develop.svn.wordpress.org/trunk@24605 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5917fcb621
commit
15df489ecd
@ -101,6 +101,6 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id ) {
|
|||||||
'postId' => $post->ID,
|
'postId' => $post->ID,
|
||||||
'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ),
|
'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ),
|
||||||
'revisionData' => array_values( $revisions ),
|
'revisionData' => array_values( $revisions ),
|
||||||
'selectedRevision' => $selected_revision_id,
|
'selectedRevision' => (int) $selected_revision_id,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ window.wp = window.wp || {};
|
|||||||
// Find the initially selected revision
|
// Find the initially selected revision
|
||||||
var initiallySelectedRevisionIndex =
|
var initiallySelectedRevisionIndex =
|
||||||
this.model.revisions.indexOf(
|
this.model.revisions.indexOf(
|
||||||
this.model.revisions.findWhere({ id: Number( revisions.settings.selectedRevision ) }) );
|
this.model.revisions.findWhere({ id: revisions.settings.selectedRevision }) );
|
||||||
|
|
||||||
this.settings = new revisions.model.Slider({
|
this.settings = new revisions.model.Slider({
|
||||||
max: latestRevisionIndex,
|
max: latestRevisionIndex,
|
||||||
@ -568,7 +568,7 @@ window.wp = window.wp || {};
|
|||||||
ready: function() {
|
ready: function() {
|
||||||
// Refresh the currently selected revision position in case router has set it.
|
// Refresh the currently selected revision position in case router has set it.
|
||||||
this.settings.attributes.value = this.model.revisions.indexOf(
|
this.settings.attributes.value = this.model.revisions.indexOf(
|
||||||
this.model.revisions.findWhere({ id: Number( revisions.settings.selectedRevision ) }) );
|
this.model.revisions.findWhere({ id: revisions.settings.selectedRevision }) );
|
||||||
|
|
||||||
// And update the slider in case the route has set it.
|
// And update the slider in case the route has set it.
|
||||||
this.updateSliderSettings();
|
this.updateSliderSettings();
|
||||||
@ -819,11 +819,14 @@ window.wp = window.wp || {};
|
|||||||
}, 250 ),
|
}, 250 ),
|
||||||
|
|
||||||
gotoRevisionId: function( from, to, handles ) {
|
gotoRevisionId: function( from, to, handles ) {
|
||||||
this.model.set( { compareTwoMode: ( '2' === handles ) } );
|
from = parseInt( from, 10 );
|
||||||
|
to = parseInt( to, 10 );
|
||||||
|
|
||||||
|
this.model.set({ compareTwoMode: ( '2' === handles ) });
|
||||||
|
|
||||||
if ( 'undefined' !== typeof this.model ) {
|
if ( 'undefined' !== typeof this.model ) {
|
||||||
var selectedToRevision = this.model.revisions.findWhere({ 'id': Number( to ) }),
|
var selectedToRevision = this.model.revisions.findWhere({ id: to }),
|
||||||
selectedFromRevision = this.model.revisions.findWhere({ 'id': Number( from ) });
|
selectedFromRevision = this.model.revisions.findWhere({ id: from });
|
||||||
|
|
||||||
this.model.set({
|
this.model.set({
|
||||||
to: selectedToRevision,
|
to: selectedToRevision,
|
||||||
|
Loading…
Reference in New Issue
Block a user