summaryrefslogtreecommitdiff
path: root/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js')
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js66
1 files changed, 36 insertions, 30 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
index ca8af558..0d769164 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
@@ -188,40 +188,40 @@ $.wikiEditor.modules.dialogs.config = {
// Show loading spinner while waiting for the API to respond
updateWidget( 'loading' );
// Call the API to check page status, saving the request object so it can be aborted if
- // necessary
+ // necessary.
+ // This used to request a page that would show whether or not the target exists, but we can
+ // also check whether it has the disambiguation property and still get existence information.
+ // If the Disambiguator extension is not installed then such a property won't be set.
$( '#wikieditor-toolbar-link-int-target-status' ).data(
'request',
- $.ajax( {
- url: mw.util.wikiScript( 'api' ),
- dataType: 'json',
- data: {
- action: 'query',
- indexpageids: '',
- titles: target,
- converttitles: '',
- format: 'json'
- },
- success: function ( data ) {
- var status;
- if ( !data || !data.query ) {
- // This happens in some weird cases
- status = false;
- } else {
- var page = data.query.pages[data.query.pageids[0]];
- status = 'exists';
- if ( page.missing !== undefined ) {
- status = 'notexists';
- } else if ( page.invalid !== undefined ) {
- status = 'invalid';
- }
- }
- // Cache the status of the link target if the force internal
- // parameter was not passed
- if ( !internal ) {
- cache[target] = status;
+ ( new mw.Api() ).get( {
+ action: 'query',
+ prop: 'pageprops',
+ titles: target,
+ ppprop: 'disambiguation',
+ indexpageids: true
+ } ).done( function ( data ) {
+ var status;
+ if ( !data.query ) {
+ // This happens in some weird cases
+ status = false;
+ } else {
+ var page = data.query.pages[data.query.pageids[0]];
+ status = 'exists';
+ if ( page.missing !== undefined ) {
+ status = 'notexists';
+ } else if ( page.invalid !== undefined ) {
+ status = 'invalid';
+ } else if ( page.pageprops !== undefined ) {
+ status = 'disambig';
}
- updateWidget( status );
}
+ // Cache the status of the link target if the force internal
+ // parameter was not passed
+ if ( !internal ) {
+ cache[target] = status;
+ }
+ updateWidget( status );
} )
);
}
@@ -324,6 +324,7 @@ $.wikiEditor.modules.dialogs.config = {
var invalidMsg = mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-invalid' );
var externalMsg = mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-external' );
var loadingMsg = mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-loading' );
+ var disambigMsg = mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-disambig' );
$( '#wikieditor-toolbar-link-int-target-status' )
.append( $( '<div>' )
.attr( 'id', 'wikieditor-toolbar-link-int-target-status-exists' )
@@ -349,6 +350,10 @@ $.wikiEditor.modules.dialogs.config = {
'title': loadingMsg
} ) )
)
+ .append( $( '<div>' )
+ .attr( 'id', 'wikieditor-toolbar-link-int-target-status-disambig' )
+ .append( disambigMsg )
+ )
.data( 'existencecache', {} )
.children().hide();
@@ -1000,6 +1005,7 @@ $.wikiEditor.modules.dialogs.config = {
return;
}
if ( ( rows * cols ) > 1000 ) {
+ // 1000 is in the English message. The parameter replacement is kept for BC.
alert( mw.msg( 'wikieditor-toolbar-tool-table-toomany', 1000 ) );
return;
}