jenkins-bot has submitted this change and it was merged.
Change subject: Show welcome dialog on mobile too
......................................................................
Show welcome dialog on mobile too
Bug: T112599
Change-Id: Ie04aab468c80dabc84e1386e7529138e1101450e
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
M modules/ve-mw/init/ve.init.mw.ArticleTarget.js
M modules/ve-mw/ui/dialogs/ve.ui.MWWelcomeDialog.js
M modules/ve-mw/ui/styles/dialogs/ve.ui.MWWelcomeDialog.css
4 files changed, 102 insertions(+), 86 deletions(-)
Approvals:
Jforrester: Looks good to me, approved
Florianschmidtwelzow: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
index 3eb4f64..a940f3e 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
@@ -41,8 +41,6 @@
this.recreating = false;
this.activatingDeferred = null;
this.toolbarSetupDeferred = null;
- this.welcomeDialog = null;
- this.welcomeDialogPromise = null;
this.checkboxFields = null;
this.checkboxesByName = null;
this.$otherFields = null;
@@ -386,8 +384,6 @@
this.activatingDeferred = $.Deferred();
this.toolbarSetupDeferred = $.Deferred();
- this.maybeShowWelcomeDialog();
-
$( 'html' ).removeClass( 've-loading' ).addClass(
've-activating' );
$.when( this.activatingDeferred, this.toolbarSetupDeferred
).done( function () {
$( 'html' ).removeClass( 've-activating' ).addClass(
've-active' );
@@ -633,6 +629,7 @@
ve.init.mw.DesktopArticleTarget.super.prototype.surfaceReady.apply(
this, arguments );
this.setupUnloadHandlers();
+ this.maybeShowWelcomeDialog();
this.maybeShowMetaDialog();
this.activatingDeferred.resolve();
@@ -1216,88 +1213,6 @@
window.onbeforeunload = this.onBeforeUnloadFallback;
this.onBeforeUnloadFallback = null;
window.removeEventListener( 'unload', this.onUnloadHandler );
-};
-
-/**
- * Show the beta dialog as needed
- */
-ve.init.mw.DesktopArticleTarget.prototype.maybeShowWelcomeDialog = function ()
{
- var usePrefs, prefSaysShow, urlSaysHide, windowManager,
- target = this;
-
- this.welcomeDialogPromise = $.Deferred();
-
- if ( mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome ) {
- // Set up a temporary window manager
- windowManager = new OO.ui.WindowManager( {
- classes: [
- 've-init-mw-desktopArticleTarget-windowManager',
-
've-init-mw-desktopArticleTarget-windowManager-welcome'
- ]
- } );
- $( 'body' ).append( windowManager.$element );
- this.welcomeDialog = new ve.ui.MWWelcomeDialog();
- windowManager.addWindows( [ this.welcomeDialog ] );
-
- // Only use the preference value if the user is logged-in.
- // If the user is anonymous, we can't save the preference
- // after showing the dialog. And we don't intend to use this
- // preference to influence anonymous users (use the config
- // variable for that; besides the pref value would be stale if
- // the wiki uses static html caching).
- usePrefs = !mw.user.isAnon();
- prefSaysShow = usePrefs && !mw.user.options.get(
'visualeditor-hidebetawelcome' );
- urlSaysHide = 'vehidebetadialog' in this.currentUri.query;
-
- if (
- !urlSaysHide &&
- (
- prefSaysShow ||
- (
- !usePrefs &&
- localStorage.getItem(
've-beta-welcome-dialog' ) === null &&
- $.cookie( 've-beta-welcome-dialog' )
=== null
- )
- )
- ) {
- windowManager.openWindow( this.welcomeDialog )
- .then( function ( opened ) {
- return opened;
- } )
- .then( function ( closing ) {
- return closing;
- } )
- .then( function ( data ) {
- // Detach the temporary window manager
- windowManager.destroy();
- target.welcomeDialogPromise.resolve();
- if ( data && data.action === 'switch' )
{
- target.switchToWikitextEditor(
true, true );
- }
- } );
- } else {
- this.welcomeDialogPromise.resolve();
- }
-
- if ( prefSaysShow ) {
- new mw.Api().postWithToken( 'options', {
- action: 'options',
- change: 'visualeditor-hidebetawelcome=1'
- } );
-
- // No need to set a cookie every time for logged-in users that
have already
- // set the hidebetawelcome=1 preference, but only if this isn't
a one-off
- // view of the page via the hiding GET parameter.
- } else if ( !usePrefs && !urlSaysHide ) {
- try {
- localStorage.setItem( 've-beta-welcome-dialog',
1 );
- } catch ( e ) {
- $.cookie( 've-beta-welcome-dialog', 1, { path:
'/', expires: 30 } );
- }
- }
- } else {
- this.welcomeDialogPromise.reject();
- }
};
/**
diff --git a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
index fd77e0c..9ae8b31 100644
--- a/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
+++ b/modules/ve-mw/init/ve.init.mw.ArticleTarget.js
@@ -55,6 +55,9 @@
} );
this.events = { track: $.noop, trackActivationStart: $.noop,
trackActivationComplete: $.noop };
+ this.welcomeDialog = null;
+ this.welcomeDialogPromise = null;
+
this.preparedCacheKeyPromise = null;
this.clearState();
@@ -1624,3 +1627,78 @@
$window.scrollTop( headingNode.$element.offset().top -
this.getToolbar().$element.height() );
};
+
+/**
+ * Show the beta dialog as needed
+ */
+ve.init.mw.ArticleTarget.prototype.maybeShowWelcomeDialog = function () {
+ var usePrefs, prefSaysShow, urlSaysHide,
+ windowManager = this.getSurface().dialogs,
+ target = this;
+
+ this.welcomeDialogPromise = $.Deferred();
+
+ if ( mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome ) {
+ // Only use the preference value if the user is logged-in.
+ // If the user is anonymous, we can't save the preference
+ // after showing the dialog. And we don't intend to use this
+ // preference to influence anonymous users (use the config
+ // variable for that; besides the pref value would be stale if
+ // the wiki uses static html caching).
+ usePrefs = !mw.user.isAnon();
+ prefSaysShow = usePrefs && !mw.user.options.get(
'visualeditor-hidebetawelcome' );
+ urlSaysHide = 'vehidebetadialog' in new mw.Uri( location.href
).query;
+
+ if (
+ !urlSaysHide &&
+ (
+ prefSaysShow ||
+ (
+ !usePrefs &&
+ localStorage.getItem(
've-beta-welcome-dialog' ) === null &&
+ $.cookie( 've-beta-welcome-dialog' )
=== null
+ )
+ )
+ ) {
+ windowManager.openWindow(
+ 'welcome',
+ { targetName: this.constructor.static.name }
+ )
+ .then( function ( opened ) {
+ return opened;
+ } )
+ .then( function ( closing ) {
+ return closing;
+ } )
+ .then( function ( data ) {
+ target.welcomeDialogPromise.resolve();
+ target.welcomeDialog = null;
+ if ( data && data.action === 'switch' )
{
+ // TODO: Make this work on
mobile - right now we can only
+ // get away with it because the
button which triggers this
+ // action is hidden on mobile
+ target.switchToWikitextEditor(
true, true );
+ }
+ } );
+ this.welcomeDialog = windowManager.windows.welcome; //
ew :/
+ } else {
+ this.welcomeDialogPromise.resolve();
+ }
+
+ if ( prefSaysShow ) {
+ new mw.Api().saveOption(
'visualeditor-hidebetawelcome', '1' );
+
+ // No need to set a cookie every time for logged-in users that
have already
+ // set the hidebetawelcome=1 preference, but only if this isn't
a one-off
+ // view of the page via the hiding GET parameter.
+ } else if ( !usePrefs && !urlSaysHide ) {
+ try {
+ localStorage.setItem( 've-beta-welcome-dialog',
1 );
+ } catch ( e ) {
+ $.cookie( 've-beta-welcome-dialog', 1, { path:
'/', expires: 30 } );
+ }
+ }
+ } else {
+ this.welcomeDialogPromise.reject();
+ }
+};
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWWelcomeDialog.js
b/modules/ve-mw/ui/dialogs/ve.ui.MWWelcomeDialog.js
index 0d61551..c1dad9f 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWWelcomeDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWWelcomeDialog.js
@@ -17,6 +17,10 @@
ve.ui.MWWelcomeDialog = function VeUiMWWelcomeDialog( config ) {
// Parent constructor
ve.ui.MWWelcomeDialog.super.call( this, config );
+
+ this.$element
+ .addClass( 've-init-mw-desktopArticleTarget-windowManager' )
+ .addClass(
've-init-mw-desktopArticleTarget-windowManager-welcome' );
};
/* Inheritance */
@@ -64,12 +68,27 @@
)
}, data );
+ if ( data.targetName === 'mobile' ) {
+ this.mobile = true;
+ }
+
return ve.ui.MWWelcomeDialog.super.prototype.getSetupProcess.call(
this, data );
};
/**
* @inheritdoc
*/
+ve.ui.MWWelcomeDialog.prototype.getReadyProcess = function () {
+ if ( this.mobile ) {
+ this.actions.remove( this.actions.get( { actions: 'switch' } )
); // ew
+ }
+
+ return ve.ui.MWWelcomeDialog.super.prototype.getReadyProcess.apply(
this, arguments );
+};
+
+/**
+ * @inheritdoc
+ */
ve.ui.MWWelcomeDialog.prototype.getActionProcess = function ( action ) {
if ( action === 'switch' ) {
return new OO.ui.Process( function () {
diff --git a/modules/ve-mw/ui/styles/dialogs/ve.ui.MWWelcomeDialog.css
b/modules/ve-mw/ui/styles/dialogs/ve.ui.MWWelcomeDialog.css
index 9ac13d9..c38fa7a 100644
--- a/modules/ve-mw/ui/styles/dialogs/ve.ui.MWWelcomeDialog.css
+++ b/modules/ve-mw/ui/styles/dialogs/ve.ui.MWWelcomeDialog.css
@@ -11,6 +11,10 @@
text-align: center;
}
+.ve-ui-mobileWindowManager .visualeditor-welcomedialog-content {
+ background-size: 11em;
+}
+
.visualeditor-welcomedialog-content-text {
display: inline-block;
margin-top: 12em;
--
To view, visit https://gerrit.wikimedia.org/r/271994
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie04aab468c80dabc84e1386e7529138e1101450e
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Florianschmidtwelzow <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits