diff --git a/resources/skins.minerva.categories/init.js b/resources/skins.minerva.categories/init.js index 4ec24918f..aa7d59f3e 100644 --- a/resources/skins.minerva.categories/init.js +++ b/resources/skins.minerva.categories/init.js @@ -6,40 +6,34 @@ // categories overlay overlayManager.add( /^\/categories$/, function () { - var result = $.Deferred(); - - loader.loadModule( 'mobile.categories.overlays', true ).done( function ( loadingOverlay ) { + return loader.loadModule( 'mobile.categories.overlays', true ).then( function ( loadingOverlay ) { var CategoryOverlay = M.require( 'mobile.categories.overlays/CategoryOverlay' ); M.on( 'category-added', function () { window.location.hash = '#/categories'; } ); loadingOverlay.hide(); - result.resolve( new CategoryOverlay( { + return new CategoryOverlay( { api: new mw.Api(), isAnon: user.isAnon(), title: M.getCurrentPage().title - } ) ); + } ); } ); - return result; } ); // add categories overlay overlayManager.add( /^\/categories\/add$/, function () { - var result = $.Deferred(); - - loader.loadModule( 'mobile.categories.overlays' ).done( function ( loadingOverlay ) { + return loader.loadModule( 'mobile.categories.overlays' ).then( function ( loadingOverlay ) { var CategoryAddOverlay = M.require( 'mobile.categories.overlays/CategoryAddOverlay' ); loadingOverlay.hide(); - result.resolve( new CategoryAddOverlay( { + return new CategoryAddOverlay( { api: new mw.Api(), categories: mw.config.get( 'wgCategories' ), isAnon: user.isAnon(), title: M.getCurrentPage().title - } ) ); + } ); } ); - return result; } ); /** diff --git a/resources/skins.minerva.editor/init.js b/resources/skins.minerva.editor/init.js index 59f56fb2d..0831923a5 100644 --- a/resources/skins.minerva.editor/init.js +++ b/resources/skins.minerva.editor/init.js @@ -171,7 +171,6 @@ overlayManager.add( /^\/editor\/(\d+|all)$/, function ( sectionId ) { var $content = $( '#mw-content-text' ), - result = $.Deferred(), preferredEditor = getPreferredEditor(), editorOptions = { overlayManager: overlayManager, @@ -201,7 +200,7 @@ function logInit( editor ) { // If MobileFrontend is not available this will not be possible so // check first. - mw.loader.using( 'mobile.loggingSchemas.edit' ).done( function () { + mw.loader.using( 'mobile.loggingSchemas.edit' ).then( function () { mw.track( 'mf.schemaEdit', { action: 'init', type: 'section', @@ -217,13 +216,14 @@ * @private * @ignore * @method + * @returns {JQuery.Promise} */ function loadSourceEditor() { logInit( 'wikitext' ); - loader.loadModule( 'mobile.editor.overlay' ).done( function () { + return loader.loadModule( 'mobile.editor.overlay' ).then( function () { var EditorOverlay = M.require( 'mobile.editor.overlay/EditorOverlay' ); - result.resolve( new EditorOverlay( editorOptions ) ); + return new EditorOverlay( editorOptions ); } ); } @@ -254,15 +254,13 @@ editorOverride !== 'SourceEditor' ) { logInit( 'visualeditor' ); - loader.loadModule( 'mobile.editor.ve' ).done( function () { + return loader.loadModule( 'mobile.editor.ve' ).then( function () { var VisualEditorOverlay = M.require( 'mobile.editor.ve/VisualEditorOverlay' ); - result.resolve( new VisualEditorOverlay( editorOptions ) ); - } ).fail( loadSourceEditor ); + return new VisualEditorOverlay( editorOptions ); + }, loadSourceEditor ); } else { - loadSourceEditor(); + return loadSourceEditor(); } - - return result; } ); updateEditPageButton( true ); // reveal edit links on user pages diff --git a/resources/skins.minerva.notifications.badge/NotificationBadge.js b/resources/skins.minerva.notifications.badge/NotificationBadge.js index 7b2ca7be9..ec9143da4 100644 --- a/resources/skins.minerva.notifications.badge/NotificationBadge.js +++ b/resources/skins.minerva.notifications.badge/NotificationBadge.js @@ -61,13 +61,13 @@ * @memberof NotificationBadge * @instance * @param {string} moduleName Name of a module to fetch - * @return {JQuery.Deferred} + * @return {JQuery.Promise} */ _loadModuleScript: function ( moduleName ) { var self = this; this.$el.html( this.options.loadingIconHtml ); - return mw.loader.using( moduleName ).done( function () { + return mw.loader.using( moduleName ).then( function () { // trigger a re-render once one to remove loading icon self.render(); } ); @@ -105,7 +105,7 @@ this.$el.on( 'click', $.proxy( this.onClickBadge, this ) ); this.options.overlayManager.add( /^\/notifications$/, function () { - return self._loadNotificationOverlay().done( function ( overlay ) { + return self._loadNotificationOverlay().then( function ( overlay ) { mainMenu.openNavigationDrawer( 'secondary' ); overlay.on( 'hide', function () { mainMenu.closeNavigationDrawers(); @@ -115,6 +115,7 @@ $( '#mw-mf-page-center' ).one( 'click.secondary', function () { self.options.router.back(); } ); + return overlay; } ); } ); }, diff --git a/resources/skins.minerva.notifications/init.js b/resources/skins.minerva.notifications/init.js index a503d385a..baa0c946b 100644 --- a/resources/skins.minerva.notifications/init.js +++ b/resources/skins.minerva.notifications/init.js @@ -55,7 +55,7 @@ } // Load the notification filter overlay - mw.loader.using( 'mobile.notifications.filter.overlay' ).done( function () { + mw.loader.using( 'mobile.notifications.filter.overlay' ).then( function () { var $crossWikiUnreadFilter = $( '.mw-echo-ui-crossWikiUnreadFilterWidget' ), $notifReadState = $( '.mw-echo-ui-notificationsInboxWidget-main-toolbar-readState' ), NotificationsFilterOverlay = M.require( 'mobile.notifications.filter.overlay/NotificationsFilterOverlay' ); diff --git a/resources/skins.minerva.scripts/DownloadIcon.js b/resources/skins.minerva.scripts/DownloadIcon.js index 863b814fa..29156ea49 100644 --- a/resources/skins.minerva.scripts/DownloadIcon.js +++ b/resources/skins.minerva.scripts/DownloadIcon.js @@ -124,6 +124,12 @@ window.print(); hideSpinner(); } + + function doPrintBeforeTimeout() { + if ( self.timeout ) { + doPrint(); + } + } // The click handler may be invoked multiple times so if a pending print is occurring // do nothing. if ( !this.timeout ) { @@ -134,11 +140,7 @@ // If all image downloads are taking longer to load then the MAX_PRINT_TIMEOUT // abort the spinner and print regardless. this.timeout = setTimeout( doPrint, MAX_PRINT_TIMEOUT ); - this.skin.loadImagesList().always( function () { - if ( self.timeout ) { - doPrint(); - } - } ); + this.skin.loadImagesList().then( doPrintBeforeTimeout, doPrintBeforeTimeout ); } }, events: { diff --git a/resources/skins.minerva.scripts/init.js b/resources/skins.minerva.scripts/init.js index 4a047515a..327b06118 100644 --- a/resources/skins.minerva.scripts/init.js +++ b/resources/skins.minerva.scripts/init.js @@ -130,25 +130,23 @@ // Routes overlayManager.add( /^\/media\/(.+)$/, loadImageOverlay ); overlayManager.add( /^\/languages$/, function () { - var result = $.Deferred(), - lang = mw.config.get( 'wgUserLanguage' ); + var lang = mw.config.get( 'wgUserLanguage' ); - loader.loadModule( 'mobile.languages.structured', true ).done( function ( loadingOverlay ) { + return loader.loadModule( 'mobile.languages.structured', true ).then( function ( loadingOverlay ) { var PageGateway = M.require( 'mobile.startup/PageGateway' ), gateway = new PageGateway( new mw.Api() ), LanguageOverlay = M.require( 'mobile.languages.structured/LanguageOverlay' ); - gateway.getPageLanguages( mw.config.get( 'wgPageName' ), lang ).done( function ( data ) { + return gateway.getPageLanguages( mw.config.get( 'wgPageName' ), lang ).then( function ( data ) { loadingOverlay.hide(); - result.resolve( new LanguageOverlay( { + return new LanguageOverlay( { currentLanguage: mw.config.get( 'wgContentLanguage' ), languages: data.languages, variants: data.variants, deviceLanguage: getDeviceLanguage() - } ) ); + } ); } ); } ); - return result; } ); // Setup diff --git a/resources/skins.minerva.talk/init.js b/resources/skins.minerva.talk/init.js index 5114a87ee..e1838aae7 100644 --- a/resources/skins.minerva.talk/init.js +++ b/resources/skins.minerva.talk/init.js @@ -36,16 +36,15 @@ } overlayManager.add( /^\/talk\/?(.*)$/, function ( id ) { - var result = $.Deferred(), - talkOptions = { - api: new mw.Api(), - title: title, - // T184273 using `getCurrentPage` because 'wgPageName' contains underscores instead of spaces. - currentPageTitle: M.getCurrentPage().title, - licenseMsg: skin.getLicenseMsg() - }; + var talkOptions = { + api: new mw.Api(), + title: title, + // T184273 using `getCurrentPage` because 'wgPageName' contains underscores instead of spaces. + currentPageTitle: M.getCurrentPage().title, + licenseMsg: skin.getLicenseMsg() + }; - loader.loadModule( 'mobile.talk.overlays' ).done( function () { + return loader.loadModule( 'mobile.talk.overlays' ).then( function () { var Overlay; if ( id === 'new' ) { Overlay = M.require( 'mobile.talk.overlays/TalkSectionAddOverlay' ); @@ -55,9 +54,8 @@ } else { Overlay = M.require( 'mobile.talk.overlays/TalkOverlay' ); } - result.resolve( new Overlay( talkOptions ) ); + return new Overlay( talkOptions ); } ); - return result; } ); /**