mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-24 10:48:42 +00:00
Merge "Add a popup after switching into VE from WTE"
This commit is contained in:
commit
80636c235e
|
@ -572,6 +572,7 @@ class VisualEditorHooks {
|
|||
$preferences['visualeditor-hidebetawelcome'] = $api;
|
||||
$preferences['visualeditor-hidetabdialog'] = $api;
|
||||
$preferences['visualeditor-hidesourceswitchpopup'] = $api;
|
||||
$preferences['visualeditor-hidevisualswitchpopup'] = $api;
|
||||
$preferences['visualeditor-hideusered'] = $api;
|
||||
$preferences['visualeditor-findAndReplace-findText'] = $api;
|
||||
$preferences['visualeditor-findAndReplace-replaceText'] = $api;
|
||||
|
|
|
@ -1066,6 +1066,8 @@
|
|||
"visualeditor-mweditmodeve-title",
|
||||
"visualeditor-mweditmodeve-tool",
|
||||
"visualeditor-mweditmodeve-warning",
|
||||
"visualeditor-mweditmodewt-popup-body",
|
||||
"visualeditor-mweditmodewt-popup-title",
|
||||
"visualeditor-preference-tabs-multi-tab",
|
||||
"visualeditor-preference-tabs-prefer-ve",
|
||||
"visualeditor-preference-tabs-prefer-wt"
|
||||
|
@ -1106,8 +1108,8 @@
|
|||
"modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js",
|
||||
"modules/ve-mw/ui/elements/ve.ui.MWExpandableErrorElement.js",
|
||||
"modules/ve-mw/ui/elements/ve.ui.MWPreviewElement.js",
|
||||
"modules/ve-mw/ui/tools/ve.ui.MWEditModeTool.js",
|
||||
"modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js",
|
||||
"modules/ve-mw/ui/tools/ve.ui.MWEditModeTool.js",
|
||||
"modules/ve-mw/ui/inspectors/ve.ui.MWExtensionInspector.js",
|
||||
"modules/ve-mw/ui/inspectors/ve.ui.MWLiveExtensionInspector.js",
|
||||
"modules/ve-mw/ui/actions/ve.ui.MWLinkAction.js",
|
||||
|
|
|
@ -265,6 +265,8 @@
|
|||
"visualeditor-mweditmodeve-title": "Switch to visual editing?",
|
||||
"visualeditor-mweditmodeve-tool": "Switch to visual editing",
|
||||
"visualeditor-mweditmodeve-warning": "You are switching to visual editing.\nDo you want to continue?",
|
||||
"visualeditor-mweditmodewt-popup-body": "You can switch back to source editing at any time by clicking on this icon.",
|
||||
"visualeditor-mweditmodewt-popup-title": "You have switched to visual editing",
|
||||
"visualeditor-mwgalleryinspector-placeholder": "Example.jpg|Caption for image",
|
||||
"visualeditor-mwgalleryinspector-title": "Gallery",
|
||||
"visualeditor-mwsignature-tool": "Your signature",
|
||||
|
|
|
@ -272,10 +272,12 @@
|
|||
"visualeditor-mweditmodesource-warning-switch-discard": "Label for the button on the confirmation dialog for switching to source editing to continue and switch editors when doing so will throw away your changes.",
|
||||
"visualeditor-mweditmodeve-popup-body": "Body text of popup shown after switching to source mode from visual mode",
|
||||
"visualeditor-mweditmodeve-popup-title": "Title of popup shown after switching to source mode from visual mode",
|
||||
"visualeditor-mweditmodeve-showagain": "Label for checkbox to not show the 'switched to visual mode' popup again",
|
||||
"visualeditor-mweditmodeve-showagain": "Label for the checkboxes to not show one of the 'switched to visual mode' or 'switched to source mode' popups again",
|
||||
"visualeditor-mweditmodeve-title": "Title of dialog to confirm switching to visual mode.",
|
||||
"visualeditor-mweditmodeve-tool": "Label for tool that changes edit mode to visual editing.",
|
||||
"visualeditor-mweditmodeve-warning": "Warning message show before changing edit mode to visual editing. It may allow the user to keep the changes using the message {{msg-mw|Visualeditor-mweditmodesource-warning-switch}}, or instaed that they'd need to start source editing from scratch using {{msg-mw|Visualeditor-mweditmodesource-warning-switch-discard}}.",
|
||||
"visualeditor-mweditmodewt-popup-body": "Body text of popup shown after switching to visual mode from source mode",
|
||||
"visualeditor-mweditmodewt-popup-title": "Title of popup shown after switching to visual mode from source mode",
|
||||
"visualeditor-mwgalleryinspector-placeholder": "Placeholder text for the gallery inspector demonstrating how gallery syntax works.",
|
||||
"visualeditor-mwgalleryinspector-title": "Used as title for the gallery inspector.\n{{Identical|Gallery}}",
|
||||
"visualeditor-mwsignature-tool": "Used as name of the tool for inserting signatures.",
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch {
|
||||
.wikiEditor-ui-toolbar .ve-init-mw-editSwitch {
|
||||
font-size: 1.0079em;
|
||||
}
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-buttonElement-button {
|
||||
.ve-init-mw-editSwitch .oo-ui-buttonElement-button {
|
||||
padding: 0.35em;
|
||||
}
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch {
|
||||
.wikiEditor-ui-toolbar .ve-init-mw-editSwitch {
|
||||
font-size: 0.9143em;
|
||||
}
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-buttonElement-button {
|
||||
.ve-init-mw-editSwitch .oo-ui-buttonElement-button {
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
|
|
@ -5,23 +5,28 @@
|
|||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch {
|
||||
.ve-init-mw-editSwitch {
|
||||
float: right;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-iconElement-icon {
|
||||
.ve-init-mw-editSwitch .oo-ui-iconElement-icon {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-popupWidget-head {
|
||||
.ve-init-mw-editSwitch .oo-ui-popupWidget-head {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-popupWidget-body > :first-child {
|
||||
.ve-init-mw-editSwitch .oo-ui-popupWidget-body > :first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.ve-init-mw-desktopArticleTarget-editSwitch .oo-ui-popupWidget-body > :last-child {
|
||||
.ve-init-mw-editSwitch .oo-ui-popupWidget-body > :last-child {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.oo-ui-tool-name-editModeSource .ve-init-mw-editSwitch {
|
||||
padding: 0.5em 1em 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
|
|
@ -749,7 +749,10 @@
|
|||
mw.user.options.set( 'visualeditor-hidesourceswitchpopup', configValue );
|
||||
} );
|
||||
|
||||
showAgainLayout = new OO.ui.FieldLayout( showAgainCheckbox, { align: 'inline', label: mw.msg( 'visualeditor-mweditmodeve-showagain' ) } );
|
||||
showAgainLayout = new OO.ui.FieldLayout( showAgainCheckbox, {
|
||||
align: 'inline',
|
||||
label: mw.msg( 'visualeditor-mweditmodeve-showagain' )
|
||||
} );
|
||||
$content = $content.add( showAgainLayout.$element );
|
||||
}
|
||||
|
||||
|
@ -757,7 +760,7 @@
|
|||
framed: false,
|
||||
icon: 'edit',
|
||||
title: mw.msg( 'visualeditor-mweditmodeve-tool' ),
|
||||
classes: [ 've-init-mw-desktopArticleTarget-editSwitch' ],
|
||||
classes: [ 've-init-mw-editSwitch' ],
|
||||
popup: {
|
||||
label: mw.msg( 'visualeditor-mweditmodeve-popup-title' ),
|
||||
$content: $content,
|
||||
|
@ -773,7 +776,7 @@
|
|||
framed: false,
|
||||
icon: 'edit',
|
||||
title: mw.msg( 'visualeditor-mweditmodeve-tool' ),
|
||||
classes: [ 've-init-mw-desktopArticleTarget-editSwitch' ]
|
||||
classes: [ 've-init-mw-editSwitch' ]
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -1362,7 +1362,14 @@ ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () {
|
|||
this.welcomeDialogPromise
|
||||
.always( function () {
|
||||
// Pop out the notices when the welcome dialog is closed
|
||||
target.actionsToolbar.tools.notices.getPopup().toggle( true );
|
||||
if (
|
||||
target.switched &&
|
||||
!mw.user.options.get( 'visualeditor-hidevisualswitchpopup' )
|
||||
) {
|
||||
target.actionsToolbar.tools.editModeSource.getPopup().toggle( true );
|
||||
} else {
|
||||
target.actionsToolbar.tools.notices.getPopup().toggle( true );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -207,6 +207,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
|
|||
this.originalHtml = data.content;
|
||||
this.etag = data.etag;
|
||||
this.fromEditedState = data.fromEditedState;
|
||||
this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query;
|
||||
this.doc = this.parseHtml( this.originalHtml );
|
||||
|
||||
this.remoteNotices = ve.getObjectValues( data.notices );
|
||||
|
|
|
@ -102,6 +102,7 @@
|
|||
*/
|
||||
requestPageData: function ( pageName, oldid, targetName, modified ) {
|
||||
var start, apiXhr, restbaseXhr, apiPromise, restbasePromise, dataPromise, pageHtmlUrl,
|
||||
switched = false,
|
||||
fromEditedState = false,
|
||||
data = {
|
||||
action: 'visualeditor',
|
||||
|
@ -140,6 +141,7 @@
|
|||
$( '#wpTextbox1' ).val() &&
|
||||
!$( '[name=wpSection]' ).val()
|
||||
) {
|
||||
switched = true;
|
||||
fromEditedState = modified;
|
||||
window.onbeforeunload = null;
|
||||
$( window ).off( 'beforeunload' );
|
||||
|
@ -200,6 +202,7 @@
|
|||
if ( apiData.visualeditor ) {
|
||||
apiData.visualeditor.content = restbaseData[ 0 ];
|
||||
apiData.visualeditor.etag = restbaseData[ 1 ];
|
||||
apiData.visualeditor.switched = switched;
|
||||
apiData.visualeditor.fromEditedState = fromEditedState;
|
||||
}
|
||||
return apiData;
|
||||
|
|
|
@ -10,18 +10,44 @@
|
|||
*
|
||||
* @class
|
||||
* @abstract
|
||||
* @extends ve.ui.Tool
|
||||
* @extends ve.ui.MWPopupTool
|
||||
* @constructor
|
||||
* @param {OO.ui.ToolGroup} toolGroup
|
||||
* @param {Object} [config] Config options
|
||||
*/
|
||||
ve.ui.MWEditModeTool = function VeUiMWEditModeTool( toolGroup, config ) {
|
||||
ve.ui.Tool.call( this, toolGroup, config );
|
||||
var tool = this,
|
||||
$content = $( '<p>' ).text( mw.msg( 'visualeditor-mweditmodewt-popup-body' ) ),
|
||||
showAgainLayout, showAgainCheckbox;
|
||||
ve.ui.MWPopupTool.call( this, mw.msg( 'visualeditor-mweditmodewt-popup-title' ), toolGroup, config );
|
||||
|
||||
if ( !mw.user.isAnon() ) {
|
||||
showAgainCheckbox = new OO.ui.CheckboxInputWidget()
|
||||
.on( 'change', function ( value ) {
|
||||
var configValue = value ? '1' : '';
|
||||
new mw.Api().saveOption( 'visualeditor-hidevisualswitchpopup', configValue );
|
||||
mw.user.options.set( 'visualeditor-hidevisualswitchpopup', configValue );
|
||||
} );
|
||||
|
||||
showAgainLayout = new OO.ui.FieldLayout( showAgainCheckbox, {
|
||||
align: 'inline',
|
||||
label: mw.msg( 'visualeditor-mweditmodeve-showagain' )
|
||||
} );
|
||||
$content = $content.add( showAgainLayout.$element );
|
||||
}
|
||||
|
||||
this.popup.$body
|
||||
.addClass( 've-init-mw-editSwitch' )
|
||||
.append( $content );
|
||||
this.popup.$element.click( function () {
|
||||
tool.getPopup().toggle( false );
|
||||
} );
|
||||
this.$element.append( this.popup.$element );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWEditModeTool, ve.ui.Tool );
|
||||
OO.inheritClass( ve.ui.MWEditModeTool, ve.ui.MWPopupTool );
|
||||
|
||||
/* Static Properties */
|
||||
|
||||
|
@ -34,6 +60,11 @@ ve.ui.MWEditModeTool.static.autoAddToGroup = false;
|
|||
/* Methods */
|
||||
|
||||
/** */
|
||||
ve.ui.MWEditModeTool.prototype.onSelect = function () {
|
||||
// Bypass OO.ui.PopupTool.prototype.onSelect
|
||||
OO.ui.Tool.prototype.onSelect.apply( this, arguments );
|
||||
};
|
||||
|
||||
ve.ui.MWEditModeTool.prototype.onUpdateState = function () {
|
||||
// Parent method
|
||||
ve.ui.MWEditModeTool.super.prototype.onUpdateState.apply( this, arguments );
|
||||
|
|
Loading…
Reference in a new issue