Introduce a default for the pushState function argument

Storing a new entry in the browser history is the normal, default
thing to do. The only exception is on initialization, when the slider
is initialized from the browser history.

I hope this makes the code a little easier to read.

Change-Id: I09a3e9b4417ec3d57e86dc947ac0748f30ef0dd5
This commit is contained in:
thiemowmde 2024-02-10 16:10:47 +01:00
parent 1b49469c96
commit 52fd2e0527

View file

@ -353,7 +353,7 @@ $.extend( SliderView.prototype, {
return; return;
} }
this.updatePointersAndDiffView( newNewerPointerPos, newOlderPointerPos, true ); this.updatePointersAndDiffView( newNewerPointerPos, newOlderPointerPos );
}, },
/** /**
@ -462,7 +462,7 @@ $.extend( SliderView.prototype, {
$revisions, this.getOlderPointerPos() $revisions, this.getOlderPointerPos()
).data( 'revid' ); ).data( 'revid' );
this.lastRequest = this.refreshDiffView( diff, oldid, true ); this.lastRequest = this.refreshDiffView( diff, oldid );
this.lastRequest.then( function () { this.lastRequest.then( function () {
$pointer.trigger( 'focus' ); $pointer.trigger( 'focus' );
@ -527,7 +527,7 @@ $.extend( SliderView.prototype, {
return; return;
} }
self.refreshDiffView( diff, oldid, true ); self.refreshDiffView( diff, oldid );
self.alignPointersAndLines( 0 ); self.alignPointersAndLines( 0 );
self.resetRevisionStylesBasedOnPointerPosition( $revisions ); self.resetRevisionStylesBasedOnPointerPosition( $revisions );
}, },
@ -641,12 +641,12 @@ $.extend( SliderView.prototype, {
* @private * @private
* @param {number} diff * @param {number} diff
* @param {number} oldid * @param {number} oldid
* @param {boolean} pushState * @param {boolean} [pushState=true] False to skip manipulating the browser history
* @return {jQuery} * @return {jQuery}
*/ */
refreshDiffView: function ( diff, oldid, pushState ) { refreshDiffView: function ( diff, oldid, pushState ) {
this.diffPage.refresh( diff, oldid, this ); this.diffPage.refresh( diff, oldid, this );
if ( pushState ) { if ( pushState !== false ) {
this.diffPage.pushState( diff, oldid, this ); this.diffPage.pushState( diff, oldid, this );
} }
return this.diffPage.lastRequest; return this.diffPage.lastRequest;
@ -655,16 +655,14 @@ $.extend( SliderView.prototype, {
showNextDiff: function () { showNextDiff: function () {
this.updatePointersAndDiffView( this.updatePointersAndDiffView(
this.getNewerPointerPos() + 1, this.getNewerPointerPos() + 1,
this.getNewerPointerPos(), this.getNewerPointerPos()
true
); );
}, },
showPrevDiff: function () { showPrevDiff: function () {
this.updatePointersAndDiffView( this.updatePointersAndDiffView(
this.getOlderPointerPos(), this.getOlderPointerPos(),
this.getOlderPointerPos() - 1, this.getOlderPointerPos() - 1
true
); );
}, },
@ -673,7 +671,7 @@ $.extend( SliderView.prototype, {
* *
* @param {number} newPointerPos * @param {number} newPointerPos
* @param {number} oldPointerPos * @param {number} oldPointerPos
* @param {boolean} pushState * @param {boolean} [pushState=true] False to skip manipulating the browser history
*/ */
updatePointersAndDiffView: function ( updatePointersAndDiffView: function (
newPointerPos, newPointerPos,