mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
DesktopArticleTarget.init: Add mw.libs.ve.disableWelcomeDialog()
This allows code in other extensions to suppress the welcome dialog temporarily (just for that one page view), without touching the user's preferences. Bug: T235566 Change-Id: Ief6545289cf59fda851aa944b059994abd90253e
This commit is contained in:
parent
e0125e3e9d
commit
ab763f37df
|
@ -34,7 +34,8 @@
|
||||||
availableModes = [],
|
availableModes = [],
|
||||||
active = false,
|
active = false,
|
||||||
targetLoaded = false,
|
targetLoaded = false,
|
||||||
plugins = [];
|
plugins = [],
|
||||||
|
welcomeDialogDisabled = false;
|
||||||
|
|
||||||
function showLoading( mode ) {
|
function showLoading( mode ) {
|
||||||
var $content, windowHeight, clientTop, top, bottom, middle;
|
var $content, windowHeight, clientTop, top, bottom, middle;
|
||||||
|
@ -994,15 +995,17 @@
|
||||||
/**
|
/**
|
||||||
* Check whether the welcome dialog should be shown.
|
* Check whether the welcome dialog should be shown.
|
||||||
*
|
*
|
||||||
* The welcome dialog can be disabled in configuration; or using a query string parameter;
|
* The welcome dialog can be disabled in configuration; or by calling disableWelcomeDialog();
|
||||||
* or if we've recorded that we've already shown it before in a user preference, local storage
|
* or using a query string parameter; or if we've recorded that we've already shown it before
|
||||||
* or a cookie.
|
* in a user preference, local storage or a cookie.
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
*/
|
*/
|
||||||
shouldShowWelcomeDialog: function () {
|
shouldShowWelcomeDialog: function () {
|
||||||
return !(
|
return !(
|
||||||
// Disabled in config?
|
// Disabled in config?
|
||||||
!mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome ||
|
!mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome ||
|
||||||
|
// Disabled by calling disableWelcomeDialog()?
|
||||||
|
welcomeDialogDisabled ||
|
||||||
// Hidden using URL parameter?
|
// Hidden using URL parameter?
|
||||||
'vehidebetadialog' in new mw.Uri().query ||
|
'vehidebetadialog' in new mw.Uri().query ||
|
||||||
// Check for deprecated hidewelcomedialog parameter (T249954)
|
// Check for deprecated hidewelcomedialog parameter (T249954)
|
||||||
|
@ -1035,6 +1038,16 @@
|
||||||
new mw.Api().saveOption( 'visualeditor-hidebetawelcome', '1' );
|
new mw.Api().saveOption( 'visualeditor-hidebetawelcome', '1' );
|
||||||
mw.user.options.set( 'visualeditor-hidebetawelcome', '1' );
|
mw.user.options.set( 'visualeditor-hidebetawelcome', '1' );
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prevent the welcome dialog from being shown on this page view only.
|
||||||
|
*
|
||||||
|
* Causes shouldShowWelcomeDialog() to return false, but doesn't save anything to preferences
|
||||||
|
* or local storage, so future page views are not affected.
|
||||||
|
*/
|
||||||
|
disableWelcomeDialog: function () {
|
||||||
|
welcomeDialogDisabled = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue