Tobias Gritschacher has submitted this change and it was merged. Change subject: Input extender: Listening to "animationstep" event ......................................................................
Input extender: Listening to "animationstep" event (bug 48677) Requires change Ie6717ccece619b7cb8a096f016a690cda3b9ed80 in the Wikibase extension. Change-Id: I90c806aa730949bfce1d5b21f1b3c0429ba962ff --- M ValueView/resources/jquery.ui/jquery.ui.inputextender.js 1 file changed, 30 insertions(+), 3 deletions(-) Approvals: Tobias Gritschacher: Looks good to me, approved jenkins-bot: Verified diff --git a/ValueView/resources/jquery.ui/jquery.ui.inputextender.js b/ValueView/resources/jquery.ui/jquery.ui.inputextender.js index 0ce49fe..8064753 100644 --- a/ValueView/resources/jquery.ui/jquery.ui.inputextender.js +++ b/ValueView/resources/jquery.ui/jquery.ui.inputextender.js @@ -76,6 +76,13 @@ _animationTimeout: null, /** + * Caches the element's offset to determine whether the input extension has to be + * repositioned when reacting on global "animationstep" event. + * @type {Object} + */ + _offset: null, + + /** * @see jQuery.Widget._create */ _create: function() { @@ -158,13 +165,12 @@ } ); } - // Blurring by clicking away from the widget (one handler is sufficient): $( 'html' ) .off( '.' + this.widgetName ) + // Blurring by clicking away from the widget (one handler is sufficient): .on( 'click.' + this.widgetName, function( event ) { // Loop through all widgets and hide content when having clicked out of it: - var $widgetNodes = $( ':' + self.widgetBaseClass ); - $widgetNodes.each( function( i, widgetNode ) { + $( ':' + self.widgetBaseClass ).each( function( i, widgetNode ) { var widget = $( widgetNode ).data( self.widgetName ), $target = $( event.target ); @@ -174,6 +180,16 @@ widget.hideExtension(); } + } ); + } ) + // If some other animation changes the input element's position, the input extender + // needs to be repositioned: + .on( 'animationstep.' + this.widgetName, function( event, now, tween ) { + $( ':' + self.widgetBaseClass ).each( function( i, widgetNode ) { + var widget = $( widgetNode ).data( self.widgetName ); + if( widget.$extension.is( ':visible' ) ) { + widget._reposition(); + } } ); } ); @@ -291,12 +307,23 @@ * Repositions the extension. */ _reposition: function() { + var offset = this.element.offset(); + + if( + this._offset + && offset.top === this._offset.top && offset.left === this._offset.left + ) { + return; // Position has not changed. + } + // TODO: Repositioning is not optimal in RTL context when hitting the toggler in the // extension to hide additional input. This seems to be caused by a width // miscalculation which can be debugged with "console.log( this.$extension.width() )". this.$extension.position( $.extend( { of: this.element }, this.options.position ) ); + + this._offset = offset; } } ); -- To view, visit https://gerrit.wikimedia.org/r/65664 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I90c806aa730949bfce1d5b21f1b3c0429ba962ff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DataValues Gerrit-Branch: mw1.22-wmf5 Gerrit-Owner: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: Henning Snater <henning.sna...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits