mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RevisionSlider
synced 2024-11-15 11:40:43 +00:00
Simplify tooltip and hover effect removal
There's no need and probably just minimal gain to use these methods with a revision as input. We could always just cleanup all tooltips or wrapper highlighting before we set a new one. Makes the code much simpler. Change-Id: I34594843ccafa83372c796ff8cca68c4d6b58e06
This commit is contained in:
parent
23b2f811a2
commit
3140576347
|
@ -118,7 +118,8 @@ $.extend( RevisionListView.prototype, {
|
||||||
}
|
}
|
||||||
} )
|
} )
|
||||||
.on( 'mouseleave', function () {
|
.on( 'mouseleave', function () {
|
||||||
self.unsetRevisionHovered( $( this ) );
|
self.unsetAllHovered();
|
||||||
|
self.hideCurrentTooltipWithDelay();
|
||||||
} )
|
} )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -177,14 +178,6 @@ $.extend( RevisionListView.prototype, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {jQuery} $revisionWrapper
|
|
||||||
* @return {number}
|
|
||||||
*/
|
|
||||||
getRevisionWrapperPos: function ( $revisionWrapper ) {
|
|
||||||
return +$revisionWrapper.find( '.mw-revslider-revision' ).attr( 'data-pos' );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {jQuery} $revisionWrapper
|
* @param {jQuery} $revisionWrapper
|
||||||
*/
|
*/
|
||||||
|
@ -192,29 +185,11 @@ $.extend( RevisionListView.prototype, {
|
||||||
$revisionWrapper.addClass( 'mw-revslider-revision-hovered' );
|
$revisionWrapper.addClass( 'mw-revslider-revision-hovered' );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {jQuery} $revisionWrapper
|
|
||||||
*/
|
|
||||||
unsetRevisionHovered: function ( $revisionWrapper ) {
|
|
||||||
this.unsetRevisionGhosts( $revisionWrapper );
|
|
||||||
this.hideTooltip( $revisionWrapper );
|
|
||||||
},
|
|
||||||
|
|
||||||
unsetAllHovered: function () {
|
unsetAllHovered: function () {
|
||||||
$( '.mw-revslider-revision-wrapper-up, .mw-revslider-revision-wrapper-down' )
|
$( '.mw-revslider-revision-wrapper-up, .mw-revslider-revision-wrapper-down' )
|
||||||
.removeClass( 'mw-revslider-revision-hovered' );
|
.removeClass( 'mw-revslider-revision-hovered' );
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {jQuery} $revisionWrapper
|
|
||||||
*/
|
|
||||||
unsetRevisionGhosts: function ( $revisionWrapper ) {
|
|
||||||
$revisionWrapper.children()
|
|
||||||
.add( $revisionWrapper.prev().children() )
|
|
||||||
.add( $revisionWrapper.next().children() )
|
|
||||||
.removeClass( 'mw-revslider-revision-hovered' );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {jQuery} $renderedList
|
* @param {jQuery} $renderedList
|
||||||
*/
|
*/
|
||||||
|
@ -254,15 +229,10 @@ $.extend( RevisionListView.prototype, {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hides the tooltip after 500ms
|
* Hides the current tooltip after 500ms
|
||||||
*
|
|
||||||
* @param {jQuery} $revisionWrapper
|
|
||||||
*/
|
*/
|
||||||
hideTooltip: function ( $revisionWrapper ) {
|
hideCurrentTooltipWithDelay: function () {
|
||||||
this.tooltipTimeout = window.setTimeout( function () {
|
this.tooltipTimeout = window.setTimeout( this.hideCurrentTooltip.bind( this ), 500 );
|
||||||
$revisionWrapper.removeClass( 'mw-revslider-revision-wrapper-hovered' );
|
|
||||||
$( '.mw-revslider-revision-tooltip' ).remove();
|
|
||||||
}, 500 );
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,7 +312,7 @@ $.extend( RevisionListView.prototype, {
|
||||||
window.clearTimeout( self.tooltipTimeout );
|
window.clearTimeout( self.tooltipTimeout );
|
||||||
} )
|
} )
|
||||||
.on( 'mouseleave', '.mw-revslider-revision-tooltip', function () {
|
.on( 'mouseleave', '.mw-revslider-revision-tooltip', function () {
|
||||||
self.hideTooltip( $( '.mw-revslider-revision-wrapper-hovered' ) );
|
self.hideCurrentTooltipWithDelay();
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -280,8 +280,7 @@ $.extend( SliderView.prototype, {
|
||||||
}
|
}
|
||||||
|
|
||||||
const $hoveredRevisionWrapper = this.getRevElementAtPosition( this.getRevisionsElement(), pos ).parent();
|
const $hoveredRevisionWrapper = this.getRevElementAtPosition( this.getRevisionsElement(), pos ).parent();
|
||||||
const $lastRevisionWrapper = this.getRevElementAtPosition( this.getRevisionsElement(), lastValidPosition ).parent();
|
this.getRevisionListView().unsetAllHovered();
|
||||||
this.getRevisionListView().unsetRevisionGhosts( $lastRevisionWrapper );
|
|
||||||
this.getRevisionListView().setRevisionHoveredFromMouseEvent( $hoveredRevisionWrapper, event );
|
this.getRevisionListView().setRevisionHoveredFromMouseEvent( $hoveredRevisionWrapper, event );
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
|
|
Loading…
Reference in a new issue