Daniel Werner has submitted this change and it was merged.
Change subject: (bug 44824) Renaming entity selector widget to
$.wikibase.entityselector
......................................................................
(bug 44824) Renaming entity selector widget to $.wikibase.entityselector
Fixed some documentation in addition.
Change-Id: If85b1cd0ef4d25da994cd9122a3ec474cc6b30de
---
M lib/WikibaseLib.hooks.php
M lib/resources/Resources.php
M lib/resources/jquery.ui/jquery.ui.suggester.js
R lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js
R
lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entityselector.css
M lib/tests/qunit/jquery.ui/jquery.ui.suggester.tests.js
R lib/tests/qunit/jquery.wikibase/jquery.wikibase.entityselector.tests.js
M repo/resources/Resources.php
8 files changed, 35 insertions(+), 33 deletions(-)
Approvals:
Daniel Werner: Verified; Looks good to me, approved
diff --git a/lib/WikibaseLib.hooks.php b/lib/WikibaseLib.hooks.php
index f440ec2..fe559d7 100644
--- a/lib/WikibaseLib.hooks.php
+++ b/lib/WikibaseLib.hooks.php
@@ -166,7 +166,7 @@
'tests/qunit/wikibase.utilities/wikibase.utilities.jQuery.ui.tagadata.tests.js',
'tests/qunit/jquery.ui/jquery.ui.suggester.tests.js',
-
'tests/qunit/jquery.ui/jquery.ui.entityselector.tests.js',
+
'tests/qunit/jquery.wikibase/jquery.wikibase.entityselector.tests.js',
'tests/qunit/jquery.wikibase/jquery.wikibase.siteselector.tests.js',
),
@@ -180,7 +180,7 @@
'wikibase.ui.Toolbar',
'wikibase.ui.PropertyEditTool',
'jquery.ui.suggester',
- 'jquery.ui.entityselector',
+ 'jquery.wikibase.entityselector',
'jquery.nativeEventHandler',
'jquery.client',
'jquery.eachchange',
diff --git a/lib/resources/Resources.php b/lib/resources/Resources.php
index f29de55..047811b 100644
--- a/lib/resources/Resources.php
+++ b/lib/resources/Resources.php
@@ -258,7 +258,7 @@
'jquery.inputAutoExpand',
'jquery.tablesorter',
'jquery.ui.suggester',
- 'jquery.ui.entityselector',
+ 'jquery.wikibase.entityselector',
'jquery.wikibase.siteselector',
'mediawiki.api',
'mediawiki.language',
@@ -395,7 +395,7 @@
'dependencies' => array(
'jquery.eachchange',
'jquery.nativeEventHandler',
- 'jquery.ui.entityselector',
+ 'jquery.wikibase.entityselector',
'wikibase.datamodel',
'dataTypes.jquery.valueview.views',
'wikibase.jquery.valueview.views',
@@ -487,12 +487,12 @@
)
),
- 'jquery.ui.entityselector' => $moduleTemplate + array(
+ 'jquery.wikibase.entityselector' => $moduleTemplate + array(
'scripts' => array(
- 'jquery.ui/jquery.ui.entityselector.js'
+
'jquery.wikibase/jquery.wikibase.entityselector.js'
),
'styles' => array(
-
'jquery.ui/themes/default/jquery.ui.entityselector.css'
+
'jquery.wikibase/themes/default/jquery.wikibase.entityselector.css'
),
'dependencies' => array(
'jquery.ui.suggester',
diff --git a/lib/resources/jquery.ui/jquery.ui.suggester.js
b/lib/resources/jquery.ui/jquery.ui.suggester.js
index ec3d82e..1618ac3 100644
--- a/lib/resources/jquery.ui/jquery.ui.suggester.js
+++ b/lib/resources/jquery.ui/jquery.ui.suggester.js
@@ -54,9 +54,9 @@
* Example:
* {
* content: 'custom item label',
- * action: function( entityselector ) {
- * console.log( entityselector.element.val() );
- * entityselector.close();
+ * action: function( suggestger ) {
+ * console.log( suggester.element.val() );
+ * suggester.close();
* }
* }
* @option customListItem.content {jQuery|String} The content of the
additional list item. The
diff --git a/lib/resources/jquery.ui/jquery.ui.entityselector.js
b/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js
similarity index 93%
rename from lib/resources/jquery.ui/jquery.ui.entityselector.js
rename to lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js
index 166efd0..99254a7 100644
--- a/lib/resources/jquery.ui/jquery.ui.entityselector.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.entityselector.js
@@ -77,7 +77,8 @@
* @type {Boolean}
*/
var IS_MODULE_LOADED = (
- IS_MW_CONTEXT && $.inArray( 'jquery.ui.entityselector',
mw.loader.getModuleNames() ) !== -1
+ IS_MW_CONTEXT
+ && $.inArray( 'jquery.wikibase.entityselector',
mw.loader.getModuleNames() ) !== -1
);
/**
@@ -92,7 +93,7 @@
return ( IS_MODULE_LOADED ) ? mw.msg( msgKey ) : string;
}
- $.widget( 'ui.entityselector', $.ui.suggester, {
+ $.widget( 'wikibase.entityselector', $.ui.suggester, {
/**
* Options
@@ -155,9 +156,11 @@
*/
_create: function() {
if ( this.options.url === null ) {
- throw new Error( 'ui.entityselector requires
url parameter to be specified.' );
+ throw new Error(
'jquery.wikibase.entityselector requires url parameter to be ' +
+ 'specified.' );
} else if ( this.options.language === null ) {
- throw new Error( 'ui.entityselector requires
language parameter to be specified.' );
+ throw new Error(
'jquery.wikibase.entityselector requires language parameter to ' +
+ 'be specified.' );
}
$.ui.suggester.prototype._create.call( this );
@@ -208,9 +211,11 @@
// triggered on click event will manage further
operations like replacing the input
// value but "blur" event will not trigger a redundant
"selected" event since the entity
// is set already.
- this.menu.element.on ( 'mousedown.' + this.widgetName,
function( event ) {
+ this.menu.element.on( 'mousedown.' + this.widgetName,
function( event ) {
if ( $( event.target ).closest( '.ui-menu-item'
).length ) {
- self._setEntity( $( event.target
).closest( '.ui-menu-item' ).data( 'item.autocomplete' ) );
+ var item =
+ $( event.target ).closest(
'.ui-menu-item' ).data( 'item.autocomplete' );
+ self._setEntity( item );
}
} );
@@ -468,26 +473,22 @@
_renderItem: function( ul, item ) {
/* wrap all text in <a> tags using common jquery.menu
style */
var itemLabel = ( item.label ) ? item.label : item.id,
- section =
- $( '<li/>' ).data( 'item.autocomplete', item )
- .append(
- $( '<a/>' ).addClass(
'ui-entityselector-section-container' ).append(
- $( '<span/>' ).addClass(
'ui-entityselector-itemcontent' )
- .append(
- $( '<span/>'
).addClass( 'ui-entityselector-label' ).text( itemLabel )
- )
+ $link = $( '<a/>' ).addClass(
'ui-entityselector-section-container' ).append(
+ $( '<span/>' ).addClass(
'ui-entityselector-itemcontent' ).append(
+ $( '<span/>' ).addClass(
'ui-entityselector-label' ).text( itemLabel )
)
- );
+ ),
+ $section = $( '<li/>' ).data(
'item.autocomplete', item ).append( $link );
if ( item.description !== undefined ) {
- section.find( '.ui-entityselector-itemcontent'
).append(
+ $section.find( '.ui-entityselector-itemcontent'
).append(
$( '<span/>' ).addClass(
'ui-entityselector-description' )
.text( item.description )
);
}
if ( item.aliases ) {
- section.find( '.ui-entityselector-itemcontent'
).append(
+ $section.find( '.ui-entityselector-itemcontent'
).append(
$( '<span/>' ).addClass(
'ui-entityselector-aliases' )
.text(
this.options.messages[
'aliases-label' ] + ' ' + item.aliases.join( ', ' )
@@ -495,7 +496,7 @@
);
}
- return section.appendTo( ul );
+ return $section.appendTo( ul );
},
/**
@@ -615,7 +616,8 @@
setEntity( null );
} else if ( typeof entity === 'object' ) {
if( !entity.id ) {
- throw new Error( 'entity selector:
Tried to set an entity missing an id.' );
+ throw new Error(
'jquery.wikibase.entityselector: Tried to set an entity ' +
+ 'missing an id.' );
}
setEntity( entity );
} else if ( typeof entity === 'string' ) {
diff --git
a/lib/resources/jquery.ui/themes/default/jquery.ui.entityselector.css
b/lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entityselector.css
similarity index 100%
rename from lib/resources/jquery.ui/themes/default/jquery.ui.entityselector.css
rename to
lib/resources/jquery.wikibase/themes/default/jquery.wikibase.entityselector.css
diff --git a/lib/tests/qunit/jquery.ui/jquery.ui.suggester.tests.js
b/lib/tests/qunit/jquery.ui/jquery.ui.suggester.tests.js
index 79ee0c5..aab2865 100644
--- a/lib/tests/qunit/jquery.ui/jquery.ui.suggester.tests.js
+++ b/lib/tests/qunit/jquery.ui/jquery.ui.suggester.tests.js
@@ -247,7 +247,7 @@
suggester.customListItem( {
content: $( '<span/>' ).text( 'jQuery node' ),
- action: function( entitySelector ) {
+ action: function( suggester ) {
check = true;
}
} );
diff --git a/lib/tests/qunit/jquery.ui/jquery.ui.entityselector.tests.js
b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.entityselector.tests.js
similarity index 95%
rename from lib/tests/qunit/jquery.ui/jquery.ui.entityselector.tests.js
rename to
lib/tests/qunit/jquery.wikibase/jquery.wikibase.entityselector.tests.js
index 5f68cdc..ac02b6b 100644
--- a/lib/tests/qunit/jquery.ui/jquery.ui.entityselector.tests.js
+++ b/lib/tests/qunit/jquery.wikibase/jquery.wikibase.entityselector.tests.js
@@ -13,7 +13,7 @@
'use strict';
/**
- * Factory for creating a jquery.ui.entityselector widget suitable for
testing.
+ * Factory for creating a jquery.wikibase.entityselector widget
suitable for testing.
*
* @param {Object} customOptions
*/
@@ -29,7 +29,7 @@
return $( '<input/>' ).addClass(
'test_entityselector').appendTo( 'body' ).entityselector( options );
};
- QUnit.module( 'jquery.ui.entityselector', QUnit.newMwEnvironment( {
+ QUnit.module( 'jquery.wikibase.entityselector', QUnit.newMwEnvironment(
{
teardown: function() {
$( '.test_entityselector' ).remove();
}
diff --git a/repo/resources/Resources.php b/repo/resources/Resources.php
index 147ed5f..dac0f07 100644
--- a/repo/resources/Resources.php
+++ b/repo/resources/Resources.php
@@ -61,7 +61,7 @@
'wikibase.ui.entitysearch.js',
),
'dependencies' => array(
- 'jquery.ui.entityselector',
+ 'jquery.wikibase.entityselector',
),
),
--
To view, visit https://gerrit.wikimedia.org/r/50156
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If85b1cd0ef4d25da994cd9122a3ec474cc6b30de
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Daniel Werner <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits