Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/313614
Change subject: Add an option to the title widget to exclude the current page
......................................................................
Add an option to the title widget to exclude the current page
Useful when suggesting links, as linking to the current page
is discouraged.
Bug: T147050
Change-Id: Ieade9d0ffc05b358df6af0b65d58e60f5b87577e
---
M resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/14/313614/1
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
index 1732407..b25b2d4 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
@@ -33,6 +33,7 @@
* @cfg {boolean} [showRedlink] Show red link to exact match if it
doesn't exist
* @cfg {boolean} [showImages] Show page images
* @cfg {boolean} [showDescriptions] Show page descriptions
+ * @cfg {boolean} [excludeCurrentPage] Exclude the current page from
suggestions
* @cfg {boolean} [validateTitle=true] Whether the input must be a
valid title (if set to true,
* the widget will marks itself red for invalid inputs, including an
empty query).
* @cfg {Object} [cache] Result cache which implements a 'set' method,
taking keyed values as an argument
@@ -54,6 +55,7 @@
this.showRedlink = !!config.showRedlink;
this.showImages = !!config.showImages;
this.showDescriptions = !!config.showDescriptions;
+ this.excludeCurrentPage = !!config.excludeCurrentPage;
this.validateTitle = config.validateTitle !== undefined ?
config.validateTitle : true;
this.cache = config.cache;
@@ -162,6 +164,7 @@
*/
mw.widgets.TitleWidget.prototype.getOptionsFromData = function ( data )
{
var i, len, index, pageExists, pageExistsExact, suggestionPage,
page, redirect, redirects,
+ currentPageName = new mw.Title( mw.config.get(
'wgRelevantPageName' ) ).getPrefixedText(),
items = [],
titles = [],
titleObj = mw.Title.newFromText( this.getQueryValue() ),
@@ -178,6 +181,10 @@
for ( index in data.pages ) {
suggestionPage = data.pages[ index ];
+ // When excludeCurrentPage is set, don't list the
current page unless the user has type the full title
+ if ( this.excludeCurrentPage && suggestionPage.title
=== currentPageName && suggestionPage.title !== titleObj.getPrefixedText() ) {
+ continue;
+ }
pageData[ suggestionPage.title ] = {
missing: suggestionPage.missing !== undefined,
redirect: suggestionPage.redirect !== undefined,
--
To view, visit https://gerrit.wikimedia.org/r/313614
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieade9d0ffc05b358df6af0b65d58e60f5b87577e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits