Tobias Gritschacher has submitted this change and it was merged. Change subject: Display copyright warning bubble above toolbar for references ......................................................................
Display copyright warning bubble above toolbar for references Change-Id: I5d942578682a1c664f9e380643bd5c1eb3dc1283 --- M lib/resources/jquery.wikibase/jquery.wikibase.entityview.js M lib/resources/wikibase.ui.Tooltip.js M repo/resources/wikibase.ui.entityViewInit.js 3 files changed, 28 insertions(+), 4 deletions(-) Approvals: Tobias Gritschacher: Verified; Looks good to me, approved diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js index bf15ccd..a309353 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityview.js @@ -116,10 +116,13 @@ // TODO: this should rather listen to 'valueviewstartediting' once implemented! $( this.element ) .on( 'statementviewafterstartediting', function( event ) { - $( wb ).trigger( 'startItemPageEditMode', [event.target, { strict: true } ] ); + $( wb ).trigger( 'startItemPageEditMode', [ event.target, { strict: true } ] ); } ) .on( 'referenceviewafterstartediting', function( event ) { - $( wb ).trigger( 'startItemPageEditMode', [event.target] ); + $( wb ).trigger( + 'startItemPageEditMode', + [ event.target, { wbCopyrightWarningGravity: 'sw' } ] + ); } ) .on( 'snakviewstopediting', function( event, dropValue ) { // snak view got already removed from the DOM on "snakviewafterstopediting" diff --git a/lib/resources/wikibase.ui.Tooltip.js b/lib/resources/wikibase.ui.Tooltip.js index 8451c5d..e085cf0 100644 --- a/lib/resources/wikibase.ui.Tooltip.js +++ b/lib/resources/wikibase.ui.Tooltip.js @@ -229,7 +229,17 @@ */ show: function( permanent ) { if ( !this._isVisible ) { + // The native Tipsy tooltip does not allow jQuery nodes to be set as content and when + // triggering Tipsy's show() method, the $tip is removed from the DOM while the $tips + // position is also set within the show() method. To work around that, we trigger + // showing the tooltip before filling it with content and cache the initial position. + // TODO: This is not the most elegant solution since the $tip might reach out of the + // viewport. this._tipsy.show(); + + var offset = this._tipsy.$tip.offset(), + height = this._tipsy.$tip.height(); + if ( this._error !== null ) { this._tipsy.tip().addClass( 'wb-error' ); @@ -246,6 +256,13 @@ } else if ( this._DomContent !== null ) { this._tipsy.tip().find( '.tipsy-inner' ).empty().append( this._DomContent ); } + + if ( this._tipsy.options.gravity.charAt( 0 ) === 's' ) { + this._tipsy.$tip.offset( + { top: offset.top - this._tipsy.$tip.height() + height, left: offset.left } + ); + } + this._isVisible = true; } if( permanent === true ) { diff --git a/repo/resources/wikibase.ui.entityViewInit.js b/repo/resources/wikibase.ui.entityViewInit.js index f00c9af..53e5880 100644 --- a/repo/resources/wikibase.ui.entityViewInit.js +++ b/repo/resources/wikibase.ui.entityViewInit.js @@ -166,7 +166,7 @@ $( wb ).triggerHandler( 'restrictEntityPageActions' ); } - $( wb ).on( 'startItemPageEditMode', function( event, origin ) { + $( wb ).on( 'startItemPageEditMode', function( event, origin, options ) { $.each( termsValueTools, function( i, termValueTool ) { if ( !origin || origin.getSubject() !== termValueTool.getSubject() ) { termValueTool.disable(); @@ -210,13 +210,17 @@ text: mw.msg( 'wikibase-copyrighttooltip-acknowledge' ) } ).appendTo( $message ); + var gravity = ( options && options.wbCopyrightWarningGravity ) + ? options.wbCopyrightWarningGravity + : 'nw'; + var tooltip = new wb.ui.Tooltip( toolbar.btnSave.getTooltipParent(), // adjust tooltip to save button {}, $message, // assuming the toolbar is used on the right side of some edit UI, we want to // point the tooltip away from that so it won't overlap with it: - { gravity: 'nw' } + { gravity: gravity } ); // Tooltip gets its own anchor since other elements might have their own tooltip. -- To view, visit https://gerrit.wikimedia.org/r/53365 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5d942578682a1c664f9e380643bd5c1eb3dc1283 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: 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