Florianschmidtwelzow has uploaded a new change for review. https://gerrit.wikimedia.org/r/303265
Change subject: [WIP] Prototype of CategoryListGateway ...................................................................... [WIP] Prototype of CategoryListGateway The CategoryListGateway provides a function to return a list of pages and subcategories, which are members of the given category. Bug: T142124 Change-Id: Icd3c7a55ddd52e69fe48e33de147ecd4085c6bcc --- M extension.json A resources/mobile.categorylist/CategoryListGateway.js 2 files changed, 65 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/65/303265/1 diff --git a/extension.json b/extension.json index 674f60d..79612f6 100644 --- a/extension.json +++ b/extension.json @@ -975,6 +975,19 @@ "mobile-frontend-categories-hidden" ] }, + "mobile.categorylist": { + "targets": [ + "mobile", + "desktop" + ], + "dependencies": [ + "mobile.search.api", + "mobile.search" + ], + "scripts": [ + "resources/mobile.categorylist/CategoryListGateway.js" + ] + }, "mobile.overlays": { "targets": [ "mobile", diff --git a/resources/mobile.categorylist/CategoryListGateway.js b/resources/mobile.categorylist/CategoryListGateway.js new file mode 100644 index 0000000..fdf5cd3 --- /dev/null +++ b/resources/mobile.categorylist/CategoryListGateway.js @@ -0,0 +1,52 @@ +( function ( M, $ ) { + var prototype, + SearchGateway = M.require( 'mobile.search.api/SearchGateway' ); + + /** + * Api for CategoryListOverlay + * @class CategoryListGateway + * @extends SearchGateway + */ + function CategoryListGateway() { + CategoryListGateway.parent.apply( this, arguments ); + } + prototype = { + continueParams: {}, + canContinue: true, + + /** + * Returns the pages and subcategories of the given category + * @param {String} title The title of the category (with the Category: namespace) + * @returns {jQuery.Deferred} + */ + getCategoryMembers: function ( title ) { + var self = this; + + if ( this.canContinue === false ) { + return false; + } + + return this.api.get( $.extend( {}, { + action: 'query', + list: 'categorymembers', + cmtitle: title, + cmtype: 'page|subcat', + cmprop: 'type|title', + cmlimit: 50 + }, this.continueParams ) ).then( function( data ) { + if ( data.hasOwnProperty( 'continue' ) ) { + self.continueParams = data.continue; + } else { + self.canContinue = false; + } + + return data; + } ); + } + }; + OO.inheritClass( CategoryListGateway, SearchGateway ); + $.extend( CategoryListGateway.prototype, prototype ); + + M.define( 'mobile.categorylist/CategoryListGateway', CategoryListGateway ); + +}( mw.mobileFrontend, jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/303265 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icd3c7a55ddd52e69fe48e33de147ecd4085c6bcc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits