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