Phuedx has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/192805

Change subject: Remove the PageImagesBannerImageRepository class
......................................................................

Remove the PageImagesBannerImageRepository class

Change-Id: I992d7a2c4bd6d2a8cae78802e65753e5b02c7e23
---
M includes/Resources.php
D javascripts/modules/bannerImage/PageImagesBannerImageRepository.js
D tests/qunit/modules/bannerImage/test_PageImagesBannerImageRepository.js
3 files changed, 0 insertions(+), 198 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/05/192805/1

diff --git a/includes/Resources.php b/includes/Resources.php
index 3c4b55a..492a2e9 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -1244,7 +1244,6 @@
                ),
                'scripts' => array(
                        'javascripts/modules/bannerImage/Image.js',
-                       
'javascripts/modules/bannerImage/PageImagesBannerImageRepository.js',
                        
'javascripts/modules/bannerImage/MobileViewBannerImageRepository.js',
                        'javascripts/modules/bannerImage/BannerImage.js',
                ),
diff --git a/javascripts/modules/bannerImage/PageImagesBannerImageRepository.js 
b/javascripts/modules/bannerImage/PageImagesBannerImageRepository.js
deleted file mode 100644
index 84f0cea..0000000
--- a/javascripts/modules/bannerImage/PageImagesBannerImageRepository.js
+++ /dev/null
@@ -1,92 +0,0 @@
- ( function ( M, $ ) {
-
-       var Class = M.require( 'Class' ),
-               Image = M.require( 'modules/bannerImage/Image' ),
-               PageImagesBannerImageRepository;
-
-       /**
-        * Uses the PageImages API to get images that can be used as banner 
images
-        * for a page.
-        *
-        * @class
-        */
-       PageImagesBannerImageRepository = Class.extend( {
-
-               /**
-                * @constructor
-                * @param {mw.Api} api A MediaWiki API client
-                * @param {String} title The title of the page
-                */
-               initialize: function ( api, title ) {
-                       this.api = api;
-                       this.title = title;
-                       this.cache = {};
-               },
-
-               /**
-                * Gets images that can be used as banner images.
-                *
-                * @param {Number} targetWidth The target width of the image
-                * @return {$.Promise} A promise that resolves with an array of 
Image objects if the
-                *  MediaWiki API request was successful or rejects otherwise.
-                */
-               getImages: function ( targetWidth ) {
-                       var deferred = $.Deferred(),
-                               promise = deferred.promise(),
-                               self = this;
-
-                       if ( self.cache.hasOwnProperty( targetWidth ) ) {
-                               deferred.resolve( self.cache[targetWidth] );
-
-                               return promise;
-                       }
-
-                       self.api.get( {
-                               prop: 'pageimages',
-                               titles: self.title,
-                               pithumbsize: targetWidth
-                       } )
-                       .then( function ( data ) {
-                               var image;
-
-                               // Page doesn't exist.
-                               if ( data.query.pages.hasOwnProperty( '-1' ) ) {
-                                       deferred.reject();
-
-                                       return;
-                               }
-
-                               // TODO: Do we have an IE8 Object.keys polyfill 
available?
-                               // If so, then get rid of this iterator.
-                               $.each( data.query.pages, function ( key, value 
) {
-                                       var thumbnail = value.thumbnail;
-
-                                       // Page exists but doesn't have 
thumbnail.
-                                       if ( !thumbnail ) {
-                                               deferred.reject();
-
-                                               return false;
-                                       }
-
-                                       image = new Image(
-                                               thumbnail.source,
-                                               thumbnail.width,
-                                               thumbnail.height
-                                       );
-
-                                       return false;
-                               } );
-
-                               self.cache[targetWidth] = image;
-
-                               deferred.resolve( image );
-                       } )
-                       .fail( deferred.reject );
-
-                       return promise;
-               }
-       } );
-
-       M.define( 'modules/bannerImage/PageImagesBannerImageRepository', 
PageImagesBannerImageRepository );
-
-} ( mw.mobileFrontend, jQuery ) );
diff --git 
a/tests/qunit/modules/bannerImage/test_PageImagesBannerImageRepository.js 
b/tests/qunit/modules/bannerImage/test_PageImagesBannerImageRepository.js
deleted file mode 100644
index 0a81b88..0000000
--- a/tests/qunit/modules/bannerImage/test_PageImagesBannerImageRepository.js
+++ /dev/null
@@ -1,105 +0,0 @@
-( function ( M, mw, $ ) {
-
-       var PageImagesBannerImageRepository = M.require( 
'modules/bannerImage/PageImagesBannerImageRepository' ),
-               Image = M.require( 'modules/bannerImage/Image' );
-
-       QUnit.module( 'MobileFrontend 
modules/bannerImage/PageImagesBannerImageRepository', {
-               setup: function () {
-                       var api = new mw.Api();
-                       this.getDeferred = $.Deferred();
-                       this.getSpy = this.stub( api, 'get' ).returns( 
this.getDeferred.promise() );
-                       this.title = 'Samurai';
-                       this.repository = new PageImagesBannerImageRepository( 
api, this.title );
-               }
-       } );
-
-       QUnit.test( 'it should try to get the images at the target width', 1, 
function ( assert ) {
-               this.repository.getImages( 1234 );
-
-               assert.deepEqual( this.getSpy.lastCall.args[0], {
-                       prop: 'pageimages',
-                       titles: this.title,
-                       pithumbsize: 1234
-               } );
-       } );
-
-       QUnit.test( 'it should reject if the page doesn\'t exist', 1, function 
( assert ) {
-               this.getDeferred.resolve( {
-                       query: {
-                               pages: {
-                                       '-1': {}
-                               }
-                       }
-               } );
-
-               this.repository.getImages( 1234 ).fail( function () {
-                       assert.strictEqual( true, true );
-               } );
-       } );
-
-       QUnit.test( 'it should reject if there\'s an error getting the image', 
1, function ( assert ) {
-               var error = 'ERR0R!!!';
-
-               this.getDeferred.reject( error );
-
-               this.repository.getImages( 1234 ).fail( function ( actualError 
) {
-                       assert.deepEqual( error, actualError );
-               } );
-       } );
-
-       QUnit.test( 'it should return an image if there is one', 1, function ( 
assert ) {
-               this.getDeferred.resolve( {
-                       query: {
-                               pages: {
-                                       1234: {
-                                               thumbnail: {
-                                                       source: 
'http://foo/bar/baz',
-                                                       width: 1,
-                                                       height: 1
-                                               }
-                                       }
-                               }
-                       }
-               } );
-
-               this.repository.getImages( 1234 ).then( function ( image ) {
-                       assert.deepEqual( image, new Image( 
'http://foo/bar/baz', 1, 1 ) );
-               } );
-       } );
-
-       QUnit.test( 'it shouldn reject image if there isn\'t a thumbnail', 1, 
function ( assert ) {
-               this.getDeferred.resolve( {
-                       query: {
-                               pages: {
-                                       1234: {}
-                               }
-                       }
-               } );
-
-               this.repository.getImages( 1234 ).fail( function () {
-                       assert.strictEqual( true, true );
-               } );
-       } );
-
-       QUnit.test( 'it shouldn\'t try to get an image at the target width more 
than once', 1, function ( assert ) {
-               this.getDeferred.resolve( {
-                       query: {
-                               pages: {
-                                       1234: {
-                                               thumbnail: {
-                                                       source: 
'http://foo/bar/baz',
-                                                       width: 1,
-                                                       height: 1
-                                               }
-                                       }
-                               }
-                       }
-               } );
-
-               this.repository.getImages( 1234 );
-               this.repository.getImages( 1234 );
-
-               assert.strictEqual( this.getSpy.callCount, 1 );
-       } );
-
-} ( mw.mobileFrontend, mw, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/192805
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I992d7a2c4bd6d2a8cae78802e65753e5b02c7e23
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to