Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/199755
Change subject: Show beta welcome dialog before surface is ready ...................................................................... Show beta welcome dialog before surface is ready Split up beta and meta dialog show methods so that beta dialog is displayed as soon as possible, regardless of the surface being ready. Also make sure that we destroy the temporary window manager on destroy. Bug: T90454 Change-Id: Ib8f94518af431487ce940a74a8c268dbdbe403d2 --- M modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js 1 file changed, 38 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/55/199755/1 diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index b613f84..1fa04c7 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -40,6 +40,8 @@ this.recreating = false; this.activatingDeferred = null; this.toolbarSetupDeferred = null; + this.betaWelcomeDialog = null; + // If this is true then #transformPage / #restorePage will not call pushState // This is to avoid adding a new history entry for the url we just got from onpopstate // (which would mess up with the expected order of Back/Forwards browsing) @@ -282,6 +284,8 @@ this.activatingDeferred = $.Deferred(); this.toolbarSetupDeferred = $.Deferred(); + this.maybeShowBetaDialog(); + $( 'html' ).removeClass( 've-loading' ).addClass( 've-activating' ); $.when( this.activatingDeferred, this.toolbarSetupDeferred ).always( function () { $( 'html' ).removeClass( 've-activating' ).addClass( 've-active' ); @@ -335,6 +339,9 @@ if ( this.deactivating || ( !this.active && !this.activating ) ) { return; } + + // Just in case this wasn't closed before + this.betaWelcomeDialog.close(); if ( noDialog || this.activating || !this.edited ) { this.cancel( trackMechanism ); @@ -514,6 +521,7 @@ } ); } ); + this.maybeShowMetaDialog(); // Update UI this.changeDocumentTitle(); @@ -522,7 +530,6 @@ this.restoreScrollPosition(); this.restoreEditSection(); this.setupUnloadHandlers(); - this.maybeShowDialogs(); this.activatingDeferred.resolve(); @@ -1573,11 +1580,20 @@ }; /** - * Show dialogs as needed on load. + * Show the beta dialog as needed */ -ve.init.mw.ViewPageTarget.prototype.maybeShowDialogs = function () { - var usePrefs, prefSaysShow, urlSaysHide, target = this; +ve.init.mw.ViewPageTarget.prototype.maybeShowBetaDialog = function () { + var usePrefs, prefSaysShow, urlSaysHide, windowManager, + target = this; + if ( mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome ) { + // Set up a temporary window manager + windowManager = new OO.ui.WindowManager( { + classes: [ 've-init-mw-viewPageTarget-windowManager' ] + } ); + $( 'body' ).append( windowManager.$element ); + this.betaWelcomeDialog = new ve.ui.MWBetaWelcomeDialog(); + windowManager.addWindows( [ this.betaWelcomeDialog ] ); // Only use the preference value if the user is logged-in. // If the user is anonymous, we can't save the preference @@ -1596,18 +1612,23 @@ ( !usePrefs && localStorage.getItem( 've-beta-welcome-dialog' ) === null && - $.cookie( 've-beta-welcome-dialog' ) === null + true || $.cookie( 've-beta-welcome-dialog' ) === null ) ) ) { - this.getSurface().getDialogs().openWindow( 'betaWelcome' ).done( function ( opened ) { - opened.done( function ( closing ) { - closing.done( function () { - // Pop out the notices when the welcome dialog is closed - target.actionsToolbar.tools.notices.getPopup().toggle( true ); - } ); + windowManager.openWindow( this.betaWelcomeDialog ) + .then( function ( opened ) { + return opened; + } ) + .then( function ( closing ) { + return closing; + } ) + .then( function () { + // Pop out the notices when the welcome dialog is closed + target.actionsToolbar.tools.notices.getPopup().toggle( true ); + // Detach the temporary window manager + windowManager.destroy(); } ); - } ); } else { // Automatically open the notices immediately this.actionsToolbar.tools.notices.getPopup().toggle( true ); @@ -1630,7 +1651,12 @@ } } } +}; +/** + * Show the meta dialog as needed on load. + */ +ve.init.mw.ViewPageTarget.prototype.maybeShowMetaDialog = function () { if ( this.getSurface().getModel().metaList.getItemsInGroup( 'mwRedirect' ).length ) { this.getSurface().getDialogs().openWindow( 'meta', { page: 'settings', -- To view, visit https://gerrit.wikimedia.org/r/199755 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib8f94518af431487ce940a74a8c268dbdbe403d2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/VisualEditor Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits