diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2014-12-27 15:41:37 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2014-12-31 11:43:28 +0100 |
commit | c1f9b1f7b1b77776192048005dcc66dcf3df2bfb (patch) | |
tree | 2b38796e738dd74cb42ecd9bfd151803108386bc /resources/mediawiki.api/mediawiki.api.category.js | |
parent | b88ab0086858470dd1f644e64cb4e4f62bb2be9b (diff) |
Update to MediaWiki 1.24.1
Diffstat (limited to 'resources/mediawiki.api/mediawiki.api.category.js')
-rw-r--r-- | resources/mediawiki.api/mediawiki.api.category.js | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/resources/mediawiki.api/mediawiki.api.category.js b/resources/mediawiki.api/mediawiki.api.category.js deleted file mode 100644 index 98a9c54b..00000000 --- a/resources/mediawiki.api/mediawiki.api.category.js +++ /dev/null @@ -1,133 +0,0 @@ -/** - * @class mw.Api.plugin.category - */ -( function ( mw, $ ) { - - $.extend( mw.Api.prototype, { - /** - * Determine if a category exists. - * @param {mw.Title} title - * @param {Function} [ok] Success callback (deprecated) - * @param {Function} [err] Error callback (deprecated) - * @return {jQuery.Promise} - * @return {Function} return.done - * @return {boolean} return.done.isCategory Whether the category exists. - */ - isCategory: function ( title, ok, err ) { - var d = $.Deferred(), - apiPromise; - - // Backwards compatibility (< MW 1.20) - d.done( ok ).fail( err ); - - apiPromise = this.get( { - prop: 'categoryinfo', - titles: title.toString() - } ) - .done( function ( data ) { - var exists = false; - if ( data.query && data.query.pages ) { - $.each( data.query.pages, function ( id, page ) { - if ( page.categoryinfo ) { - exists = true; - } - } ); - } - d.resolve( exists ); - }) - .fail( d.reject ); - - return d.promise( { abort: apiPromise.abort } ); - }, - - /** - * Get a list of categories that match a certain prefix. - * e.g. given "Foo", return "Food", "Foolish people", "Foosball tables" ... - * @param {string} prefix Prefix to match. - * @param {Function} [ok] Success callback (deprecated) - * @param {Function} [err] Error callback (deprecated) - * @return {jQuery.Promise} - * @return {Function} return.done - * @return {String[]} return.done.categories Matched categories - */ - getCategoriesByPrefix: function ( prefix, ok, err ) { - var d = $.Deferred(), - apiPromise; - - // Backwards compatibility (< MW 1.20) - d.done( ok ).fail( err ); - - // Fetch with allpages to only get categories that have a corresponding description page. - apiPromise = this.get( { - list: 'allpages', - apprefix: prefix, - apnamespace: mw.config.get('wgNamespaceIds').category - } ) - .done( function ( data ) { - var texts = []; - if ( data.query && data.query.allpages ) { - $.each( data.query.allpages, function ( i, category ) { - texts.push( new mw.Title( category.title ).getNameText() ); - } ); - } - d.resolve( texts ); - }) - .fail( d.reject ); - - return d.promise( { abort: apiPromise.abort } ); - }, - - - /** - * Get the categories that a particular page on the wiki belongs to - * @param {mw.Title} title - * @param {Function} [ok] Success callback (deprecated) - * @param {Function} [err] Error callback (deprecated) - * @param {boolean} [async=true] Asynchronousness - * @return {jQuery.Promise} - * @return {Function} return.done - * @return {boolean|mw.Title[]} return.done.categories List of category titles or false - * if title was not found. - */ - getCategories: function ( title, ok, err, async ) { - var d = $.Deferred(), - apiPromise; - - // Backwards compatibility (< MW 1.20) - d.done( ok ).fail( err ); - - apiPromise = this.get( { - prop: 'categories', - titles: title.toString() - }, { - async: async === undefined ? true : async - } ) - .done( function ( data ) { - var ret = false; - if ( data.query && data.query.pages ) { - $.each( data.query.pages, function ( id, page ) { - if ( page.categories ) { - if ( typeof ret !== 'object' ) { - ret = []; - } - $.each( page.categories, function ( i, cat ) { - ret.push( new mw.Title( cat.title ) ); - } ); - } - } ); - } - d.resolve( ret ); - } ) - .fail( d.reject ); - - return d.promise( { abort: apiPromise.abort } ); - } - - } ); - - /** - * @class mw.Api - * @mixins mw.Api.plugin.category - */ - -}( mediaWiki, jQuery ) ); |