Henning Snater has uploaded a new change for review.
https://gerrit.wikimedia.org/r/170020
Change subject: Initialize copyright tooltip on toolbar container
......................................................................
Initialize copyright tooltip on toolbar container
Change-Id: I095d9b0e0a41fb96f230639da6ee1aeb4b1e76c9
---
M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.edittoolbar.js
M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.movetoolbar.js
M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.singlebuttontoolbar.js
M lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
M lib/resources/wikibase.css
M lib/tests/qunit/jquery.wikibase/toolbar/jquery.wikibase.toolbar.tests.js
M repo/resources/wikibase.ui.entityViewInit.js
7 files changed, 60 insertions(+), 24 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/20/170020/1
diff --git
a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.edittoolbar.js
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.edittoolbar.js
index 19a07cb..9b0582b 100644
--- a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.edittoolbar.js
+++ b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.edittoolbar.js
@@ -100,7 +100,7 @@
this._buttons = {};
- var $scrapedSubToolbar = this._getContainer().children(
'.wikibase-toolbar' );
+ var $scrapedSubToolbar = this.getContainer().children(
'.wikibase-toolbar' );
this._initSubToolbar( $scrapedSubToolbar );
this._attachEventHandlers();
@@ -130,7 +130,7 @@
this._$tooltipAnchor.data( 'wikibase-toolbaritem'
).destroy();
}
- this._getContainer().off( '.' + this.widgetName );
+ this.getContainer().off( '.' + this.widgetName );
$.each( this._buttons, function( buttonName, $button ) {
$button.off( '.' + self.widgetName );
@@ -170,7 +170,7 @@
var $content = $();
if( !$subToolbar.length ) {
- $subToolbar = $( '<span/>' ).appendTo(
this._getContainer() );
+ $subToolbar = $( '<span/>' ).appendTo(
this.getContainer() );
} else {
this._scrapeButtons( $subToolbar );
$content = $subToolbar.children();
@@ -259,7 +259,7 @@
}
} );
- this._getContainer()
+ this.getContainer()
.on( 'toolbarbuttonaction.' + this.widgetName, function( event
) {
if( self._buttons.edit && event.target ===
self._buttons.edit.get( 0 ) ) {
self.options.interactionWidget.element.one(
@@ -290,7 +290,7 @@
return;
}
- var $subToolbar = this._getContainer().children(
':wikibase-toolbar' ),
+ var $subToolbar = this.getContainer().children(
':wikibase-toolbar' ),
subToolbar = $subToolbar.data( 'toolbar' );
var $buttons = this.getButton( 'save' ).element;
@@ -300,7 +300,7 @@
$buttons = $buttons.add( this.getButton( 'cancel' ).element );
subToolbar.option( '$content', $buttons );
- this._getContainer()
+ this.getContainer()
.append( this._getTooltipAnchor() )
.addClass( this.widgetBaseClass + '-ineditmode' );
},
@@ -309,7 +309,7 @@
* Forces drawing edit mode.
*/
_toEditMode: function() {
- this._getContainer().removeClass( this.widgetBaseClass +
'-ineditmode' );
+ this.getContainer().removeClass( this.widgetBaseClass +
'-ineditmode' );
this.toEditMode();
},
@@ -325,19 +325,19 @@
this._$tooltipAnchor.detach();
}
- var $subToolbar = this._getContainer().children(
':wikibase-toolbar' ),
+ var $subToolbar = this.getContainer().children(
':wikibase-toolbar' ),
subToolbar = $subToolbar.data( 'toolbar' );
subToolbar.option( '$content', this.getButton( 'edit' ).element
);
- this._getContainer().removeClass( this.widgetBaseClass +
'-ineditmode' );
+ this.getContainer().removeClass( this.widgetBaseClass +
'-ineditmode' );
},
/**
* Forces drawing non-edit mode.
*/
_toNonEditMode: function() {
- this._getContainer().addClass( this.widgetBaseClass +
'-ineditmode' );
+ this.getContainer().addClass( this.widgetBaseClass +
'-ineditmode' );
this.toNonEditMode();
},
@@ -345,7 +345,7 @@
* @return {boolean}
*/
_isInEditMode: function() {
- return this._getContainer().hasClass( this.widgetBaseClass +
'-ineditmode' );
+ return this.getContainer().hasClass( this.widgetBaseClass +
'-ineditmode' );
},
/**
@@ -412,7 +412,7 @@
*/
toggleActionMessage: function( messageOrCallback ) {
var self = this,
- $container = this._getContainer(),
+ $container = this.getContainer(),
actionMessageClass = this.widgetBaseClass +
'-actionmsg',
$actionMsg = $container.find( '.' + actionMessageClass
);
diff --git
a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.movetoolbar.js
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.movetoolbar.js
index 6d6b3a3..3a980a5 100644
--- a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.movetoolbar.js
+++ b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.movetoolbar.js
@@ -41,7 +41,7 @@
if( !this.options.$content.length ) {
this.options.$content
= this._createDefaultButton( 'up' ).add(
this._createDefaultButton( 'down' ) )
- .appendTo( this._getContainer() );
+ .appendTo( this.getContainer() );
this.draw();
}
},
diff --git
a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.singlebuttontoolbar.js
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.singlebuttontoolbar.js
index 3fc2976..6746904 100644
---
a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.singlebuttontoolbar.js
+++
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.singlebuttontoolbar.js
@@ -78,7 +78,7 @@
var self = this,
$defaultButton = null;
- this._getContainer().children( '.wikibase-toolbar-button'
).each( function() {
+ this.getContainer().children( '.wikibase-toolbar-button'
).each( function() {
var $button = $( this );
if( $button.text() === self.options.label ) {
$defaultButton = $button;
diff --git a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
index 6f2f3fa..441cc23 100644
--- a/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
+++ b/lib/resources/jquery.wikibase/toolbar/jquery.wikibase.toolbar.js
@@ -48,7 +48,7 @@
this.draw();
}
- this._getContainer()
+ this.getContainer()
.addClass( this.widgetBaseClass + '-container' )
.addClass( 'wikibase-toolbar-container' );
},
@@ -68,7 +68,7 @@
this.element.remove();
} );
- var $container = this._getContainer();
+ var $container = this.getContainer();
$container
.removeClass( this.widgetBaseClass + '-container' )
@@ -88,7 +88,7 @@
*/
_getItems: function() {
var items = [];
- this._getContainer().children().each( function() {
+ this.getContainer().children().each( function() {
var item = $( this ).data( 'wikibase-toolbar-item' );
if( item ) {
items.push( item );
@@ -98,15 +98,17 @@
},
/**
+ * Returns the node actually containing the toolbar DOM structure.
+ *
* @return {jQuery}
*/
- _getContainer: function() {
+ getContainer: function() {
return this.options.$container || this.element;
},
draw: function() {
var self = this,
- $container = this._getContainer(),
+ $container = this.getContainer(),
$children = $();
$container.children().each( function() {
@@ -159,7 +161,7 @@
* @param {string} state
*/
_setState: function( state ) {
- this._getContainer()[
+ this.getContainer()[
state === 'disable' ? 'addClass' : 'removeClass'
]( 'ui-state-disabled' );
$.each( this._getItems(), function() {
diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css
index bade4c4..cb8daef 100644
--- a/lib/resources/wikibase.css
+++ b/lib/resources/wikibase.css
@@ -41,6 +41,10 @@
color: inherit;
}
+.wb-entitypage .wikibase-wbtooltip-tip .tipsy-arrow {
+ display: none;
+}
+
/* Messages displayed while some action is performed (e.g. an API call) */
.wb-actionmsg {
font-style: italic;
diff --git
a/lib/tests/qunit/jquery.wikibase/toolbar/jquery.wikibase.toolbar.tests.js
b/lib/tests/qunit/jquery.wikibase/toolbar/jquery.wikibase.toolbar.tests.js
index 477cce9..0a6d245 100644
--- a/lib/tests/qunit/jquery.wikibase/toolbar/jquery.wikibase.toolbar.tests.js
+++ b/lib/tests/qunit/jquery.wikibase/toolbar/jquery.wikibase.toolbar.tests.js
@@ -39,6 +39,12 @@
'Instantiated widget.'
);
+ assert.equal(
+ toolbar.getContainer().get( 0 ),
+ $toolbar.get( 0 ),
+ 'Verified toolbar node getting returned by getContainer().'
+ );
+
toolbar.destroy();
assert.ok(
@@ -70,6 +76,12 @@
'Verified toolbar container containing the button.'
);
+ assert.equal(
+ toolbar.getContainer().get( 0 ),
+ $container.get( 0 ),
+ 'Verified dedicated container node getting returned by
getContainer().'
+ );
+
toolbar.destroy();
assert.strictEqual(
diff --git a/repo/resources/wikibase.ui.entityViewInit.js
b/repo/resources/wikibase.ui.entityViewInit.js
index 480ad80..b9a9893 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -73,6 +73,7 @@
$target.data( 'labelview' )
|| $target.data( 'descriptionview' )
|| $target.data( 'aliasesview' )
+ || $target.data( 'sitelinkgroupview' )
) {
gravity = 'nw';
}
@@ -151,6 +152,9 @@
} );
}
+ /**
+ * @return {string[]}
+ */
function getUserLanguages() {
var userLanguages = mw.config.get( 'wbUserSpecifiedLanguages' ),
isUlsDefined = mw.uls !== undefined
@@ -269,12 +273,13 @@
content: $message,
permanent: true,
gravity: gravity,
- $anchor: edittoolbar.getButton( 'save' ).element
+ $anchor: edittoolbar.getContainer()
} );
$hideMessage.on( 'click', function( event ) {
event.preventDefault();
$messageAnchor.data( 'wbtooltip' ).degrade( true );
+ $( window ).off( '.wbCopyrightTooltip' );
if( mw.user.isAnon() ) {
$.cookie( cookieKey, copyRightVersion, {
'expires': 365 * 3, 'path': '/' } );
} else {
@@ -291,11 +296,24 @@
// destroy tooltip after edit mode gets closed again:
$entityview
- .one( 'entityviewafterstopediting', function( event, origin ) {
- if( $messageAnchor.data( 'wbtooltip' ) !== undefined ) {
- $messageAnchor.data( 'wbtooltip' ).degrade(
true );
+ .one( 'entityviewafterstopediting.wbCopyRightTooltip',
function( event, origin ) {
+ var tooltip = $messageAnchor.data( 'wbtooltip' );
+ if( tooltip ) {
+ tooltip.degrade( true );
}
+ $( window ).off( '.wbCopyrightTooltip' );
} );
+
+ $( window ).one(
+ 'scroll.wbCopyrightTooltip touchmove.wbCopyrightTooltip
resize.wbCopyrightTooltip',
+ function() {
+ var tooltip = $messageAnchor.data( 'wbtooltip'
);
+ if( tooltip ) {
+ $messageAnchor.data( 'wbtooltip'
).hide();
+ }
+ $entityview.off( '.wbCopyRightTooltip' );
+ }
+ );
}
function evaluateRestrictions() {
--
To view, visit https://gerrit.wikimedia.org/r/170020
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I095d9b0e0a41fb96f230639da6ee1aeb4b1e76c9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits