Merge "Tooltips when hovering slider lines in the SliderViewTwo"

This commit is contained in:
jenkins-bot 2017-04-19 12:02:55 +00:00 committed by Gerrit Code Review
commit bf4cd0da02
2 changed files with 32 additions and 2 deletions

View file

@ -78,6 +78,11 @@
*/
dir: null,
/**
* @type {boolean}
*/
isDragged: false,
render: function ( $container ) {
var containerWidth = this.calculateSliderContainerWidth(),
$revisions = this.slider.getRevisions().getView().render( this.revisionWidth ),
@ -210,6 +215,7 @@
grid: [ this.revisionWidth, null ],
containment: containmentClass,
start: function() {
self.isDragged = true;
self.setPointerDragCursor();
self.fadeOutPointerLines();
escapePressed = false;
@ -220,6 +226,7 @@
pointer = self.whichPointer( $p ),
revId1, revId2;
self.isDragged = false;
self.removePointerDragCursor();
if ( escapePressed ) {

View file

@ -22,7 +22,8 @@
renderPointerContainer: function( containerWidth ) {
var pointerContainerPosition = 53,
pointerContainerWidth = containerWidth + this.revisionWidth - 1,
pointerContainerStyle;
pointerContainerStyle, lastMouseMoveRevisionPos,
self = this;
pointerContainerStyle = { left: pointerContainerPosition + 'px', width: pointerContainerWidth + 'px' };
if ( this.dir === 'rtl' ) {
@ -37,7 +38,15 @@
return $( '<div>' )
.addClass( 'mw-revslider-pointer-container' )
.css( pointerContainerStyle )
.append( this.renderPointerContainers() );
.append( this.renderPointerContainers() )
.mousemove( function( event ) {
if ( !self.isDragged ) {
lastMouseMoveRevisionPos = self.showTooltipsOnMouseMoveHandler(
event,
lastMouseMoveRevisionPos
);
}
} );
},
renderPointerContainers: function() {
@ -135,6 +144,20 @@
.removeClass( 'mw-revslider-pointer-grabbing' );
},
showTooltipsOnMouseMoveHandler: function( event, lastValidPosition ) {
var pos = this.getRevisionPositionFromLeftOffset( event.pageX ),
$hoveredRevisionWrapper;
if ( pos === lastValidPosition ) {
return pos;
}
$hoveredRevisionWrapper = this.getRevElementAtPosition( this.getRevisionsElement(), pos ).parent();
this.slider.getRevisions().getView().showTooltip( $hoveredRevisionWrapper );
return pos;
},
sliderLineClickHandler: function( event, $line ) {
var pos = this.getRevisionPositionFromLeftOffset( event.pageX ),
$clickedRev, pointerMoved, pointerOther, $revisions;