mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 00:00:49 +00:00
Add controls for wikitable and sortable to table dialog
Bug: T95189 Depends-On: Ife3f3505b845db28dd29a07e9be1533c39726ce1 Change-Id: I1672d8cd2e138df1fad19dcfd948700942e87f2c
This commit is contained in:
parent
74358498da
commit
db5ed236dd
|
@ -1066,6 +1066,7 @@
|
|||
"modules/ve-mw/ui/dialogs/ve.ui.MWCommandHelpDialog.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWCancelConfirmDialog.js",
|
||||
"modules/ve-mw/ui/dialogs/ve.ui.MWWikitextSwitchConfirmDialog.js",
|
||||
"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",
|
||||
|
@ -1122,6 +1123,8 @@
|
|||
"visualeditor-beta-label",
|
||||
"visualeditor-beta-warning",
|
||||
"visualeditor-browserwarning",
|
||||
"visualeditor-dialog-table-sortable",
|
||||
"visualeditor-dialog-table-wikitable",
|
||||
"visualeditor-diff-nochanges",
|
||||
"visualeditor-differror",
|
||||
"visualeditor-editconflict",
|
||||
|
|
|
@ -196,6 +196,8 @@
|
|||
"visualeditor-dialog-referenceslist-contextitem-description-general": "List of general references",
|
||||
"visualeditor-dialog-referenceslist-contextitem-description-named": "List of references for group \"$1\"",
|
||||
"visualeditor-dialog-referenceslist-title": "References list",
|
||||
"visualeditor-dialog-table-sortable": "Sortable",
|
||||
"visualeditor-dialog-table-wikitable": "Styled (wikitable)",
|
||||
"visualeditor-dialog-template-title": "Template",
|
||||
"visualeditor-dialog-transclusion-add-content": "Add content",
|
||||
"visualeditor-dialog-transclusion-add-param": "Add more information",
|
||||
|
|
|
@ -206,6 +206,8 @@
|
|||
"visualeditor-dialog-referenceslist-contextitem-description-general": "Message shown to an editor when they click on a reference list without a group, explaining to them that the item will list all \"general\" references on the page.",
|
||||
"visualeditor-dialog-referenceslist-contextitem-description-named": "Message shown to an editor when they click on a reference list with a group, explaining to them that the item will list all references on the page with that particular group.\n\n* $1 – the name of the group of references (user-entered)",
|
||||
"visualeditor-dialog-referenceslist-title": "{{Identical|References list}}",
|
||||
"visualeditor-dialog-table-sortable": "Label for toggle to make a table sortable",
|
||||
"visualeditor-dialog-table-wikitable": "Label for toggle to make a table a wikitable",
|
||||
"visualeditor-dialog-template-title": "{{Identical|Template}}",
|
||||
"visualeditor-dialog-transclusion-add-content": "Label for button that adds parameter content to a transclusion.",
|
||||
"visualeditor-dialog-transclusion-add-param": "Label for button that adds a parameter to a transcluded template.",
|
||||
|
|
92
modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js
Normal file
92
modules/ve-mw/ui/dialogs/ve.ui.MWTableDialog.js
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*!
|
||||
* VisualEditor UserInterface MWTableDialog class.
|
||||
*
|
||||
* @copyright 2011-2016 VisualEditor Team and others; see http://ve.mit-license.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* Dialog for table properties.
|
||||
*
|
||||
* @class
|
||||
* @extends ve.ui.TableDialog
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config] Configuration options
|
||||
*/
|
||||
ve.ui.MWTableDialog = function VeUiMWTableDialog( config ) {
|
||||
// Parent constructor
|
||||
ve.ui.MWTableDialog.super.call( this, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWTableDialog, ve.ui.TableDialog );
|
||||
|
||||
/* Static Properties */
|
||||
|
||||
ve.ui.MWTableDialog.static.actions = [
|
||||
{
|
||||
action: 'done',
|
||||
label: OO.ui.deferMsg( 'visualeditor-dialog-action-done' ),
|
||||
flags: [ 'primary', 'progressive' ]
|
||||
}
|
||||
];
|
||||
|
||||
/* Methods */
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWTableDialog.prototype.initialize = function () {
|
||||
// Parent method
|
||||
ve.ui.MWTableDialog.super.prototype.initialize.call( this );
|
||||
|
||||
this.wikitableToggle = new OO.ui.ToggleSwitchWidget();
|
||||
this.wikitableField = new OO.ui.FieldLayout( this.wikitableToggle, {
|
||||
align: 'left',
|
||||
label: ve.msg( 'visualeditor-dialog-table-wikitable' )
|
||||
} );
|
||||
|
||||
this.sortableToggle = new OO.ui.ToggleSwitchWidget();
|
||||
this.sortableField = new OO.ui.FieldLayout( this.sortableToggle, {
|
||||
align: 'left',
|
||||
label: ve.msg( 'visualeditor-dialog-table-sortable' )
|
||||
} );
|
||||
|
||||
this.panel.$element.prepend( this.wikitableField.$element, this.sortableField.$element );
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWTableDialog.prototype.getSetupProcess = function ( data ) {
|
||||
return ve.ui.MWTableDialog.super.prototype.getSetupProcess.call( this, data )
|
||||
.next( function () {
|
||||
var tableNode = this.getFragment().getSelection().getTableNode();
|
||||
|
||||
this.wikitableToggle.setValue( !!tableNode.getAttribute( 'wikitable' ) );
|
||||
this.sortableToggle.setValue( !!tableNode.getAttribute( 'sortable' ) );
|
||||
}, this );
|
||||
};
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
ve.ui.MWTableDialog.prototype.getActionProcess = function ( action ) {
|
||||
return ve.ui.MWTableDialog.super.prototype.getActionProcess.call( this, action )
|
||||
.next( function () {
|
||||
var surfaceModel, fragment;
|
||||
if ( action === 'done' ) {
|
||||
surfaceModel = this.getFragment().getSurface();
|
||||
fragment = surfaceModel.getLinearFragment( this.getFragment().getSelection().tableRange, true );
|
||||
fragment.changeAttributes( {
|
||||
wikitable: this.wikitableToggle.getValue(),
|
||||
sortable: this.sortableToggle.getValue()
|
||||
} );
|
||||
}
|
||||
}, this );
|
||||
};
|
||||
|
||||
/* Registration */
|
||||
|
||||
ve.ui.windowFactory.register( ve.ui.MWTableDialog );
|
Loading…
Reference in a new issue