* @private
*/
PageExistenceCache.prototype.processExistenceCheckQueue = function () {
- var queue, titles;
+ var queue, titles,
+ cache = this;
if ( this.currentRequest ) {
// Don't fire off a million requests at the same time
this.currentRequest.always( function () {
- this.currentRequest = null;
- this.processExistenceCheckQueueDebounced();
- }.bind( this ) );
+ cache.currentRequest = null;
+ cache.processExistenceCheckQueueDebounced();
+ } );
return;
}
queue = this.existenceCheckQueue;
this.existenceCheckQueue = {};
titles = Object.keys( queue ).filter( function ( title ) {
- if ( this.existenceCache.hasOwnProperty( title ) ) {
- queue[ title ].resolve( this.existenceCache[ title ] );
+ if ( cache.existenceCache.hasOwnProperty( title ) ) {
+ queue[ title ].resolve( cache.existenceCache[ title ] );
}
- return !this.existenceCache.hasOwnProperty( title );
- }.bind( this ) );
+ return !cache.existenceCache.hasOwnProperty( title );
+ } );
if ( !titles.length ) {
return;
}
} ).done( function ( response ) {
$.each( response.query.pages, function ( index, page ) {
var title = new ForeignTitle( page.title ).getPrefixedText();
- this.existenceCache[ title ] = !page.missing;
- queue[ title ].resolve( this.existenceCache[ title ] );
+ cache.existenceCache[ title ] = !page.missing;
+ queue[ title ].resolve( cache.existenceCache[ title ] );
} );
- }.bind( this ) );
+ } );
};
/**
* @constructor
* @inheritdoc
*/
- function ForeignTitle() {
- ForeignTitle.parent.apply( this, arguments );
+ function ForeignTitle( title, namespace ) {
+ // We only need to handle categories here... but we don't know the target language.
+ // So assume that any namespace-like prefix is the 'Category' namespace...
+ title = title.replace( /^(.+?)_*:_*(.*)$/, 'Category:$2' ); // HACK
+ ForeignTitle.parent.call( this, title, namespace );
}
OO.inheritClass( ForeignTitle, mw.Title );
ForeignTitle.prototype.getNamespacePrefix = function () {
* @cfg {string} [apiUrl] API URL, if not the current wiki's API
*/
mw.widgets.CategoryCapsuleItemWidget = function MWWCategoryCapsuleItemWidget( config ) {
+ var widget = this;
// Parent constructor
mw.widgets.CategoryCapsuleItemWidget.parent.call( this, $.extend( {
data: config.title.getMainText(),
.text( this.label )
.attr( 'target', '_blank' )
.on( 'click', function ( e ) {
- // CapsuleMultiSelectWidget really wants to prevent you from clicking the link, don't let it
+ // CapsuleMultiselectWidget really wants to prevent you from clicking the link, don't let it
e.stopPropagation();
} );
this.constructor.static.pageExistenceCaches[ this.apiUrl ]
.checkPageExistence( new ForeignTitle( this.title.getPrefixedText() ) )
.done( function ( exists ) {
- this.setMissing( !exists );
- }.bind( this ) );
+ widget.setMissing( !exists );
+ } );
/*jshint +W024*/
};