[MediaWiki-commits] [Gerrit] Display copyright warning bubble above toolbar for references - change (mediawiki...Wikibase)

2013-03-12 Thread Henning Snater (Code Review)
Henning Snater has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/53365


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(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/65/53365/1

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
+ 

[MediaWiki-commits] [Gerrit] Display copyright warning bubble above toolbar for references - change (mediawiki...Wikibase)

2013-03-12 Thread Tobias Gritschacher (Code Review)
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';
+