mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Move custom buttons into outline controls
Bug: T311296 Change-Id: I5cc45f6a05ca029e319e04e76f6e35bfd5b506a6
This commit is contained in:
parent
3018a57a10
commit
2ff0f6d5f2
|
@ -144,7 +144,7 @@ ve.ui.MWTransclusionDialog.prototype.addTemplatePlaceholder = function () {
|
|||
*
|
||||
* @private
|
||||
*/
|
||||
ve.ui.MWTransclusionDialog.prototype.addContent = function () {
|
||||
ve.ui.MWTransclusionDialog.prototype.addWikitext = function () {
|
||||
this.addPart( new ve.dm.MWTransclusionContentModel( this.transclusionModel ) );
|
||||
};
|
||||
|
||||
|
@ -211,7 +211,7 @@ ve.ui.MWTransclusionDialog.prototype.setupHotkeyTriggers = function () {
|
|||
|
||||
var notInTextFields = /^(?!INPUT|TEXTAREA)/i;
|
||||
this.connectHotKeyBinding( hotkeys.addTemplate, this.addTemplatePlaceholder.bind( this ) );
|
||||
this.connectHotKeyBinding( hotkeys.addWikitext, this.addContent.bind( this ) );
|
||||
this.connectHotKeyBinding( hotkeys.addWikitext, this.addWikitext.bind( this ) );
|
||||
this.connectHotKeyBinding( hotkeys.addParameter, this.addParameter.bind( this ) );
|
||||
this.connectHotKeyBinding( hotkeys.moveUp, this.onOutlineControlsMove.bind( this, -1 ), notInTextFields );
|
||||
this.connectHotKeyBinding( hotkeys.moveDown, this.onOutlineControlsMove.bind( this, 1 ), notInTextFields );
|
||||
|
@ -220,10 +220,9 @@ ve.ui.MWTransclusionDialog.prototype.setupHotkeyTriggers = function () {
|
|||
this.connectHotKeyBinding( hotkeys.removeBackspace, this.onOutlineControlsRemove.bind( this ), notInTextFields );
|
||||
}
|
||||
|
||||
this.addHotkeyToTitle( this.addTemplateButton, hotkeys.addTemplate );
|
||||
this.addHotkeyToTitle( this.addContentButton, hotkeys.addWikitext );
|
||||
|
||||
var controls = this.bookletLayout.getOutlineControls();
|
||||
this.addHotkeyToTitle( controls.addTemplateButton, hotkeys.addTemplate );
|
||||
this.addHotkeyToTitle( controls.addWikitextButton, hotkeys.addWikitext );
|
||||
this.addHotkeyToTitle( controls.upButton, hotkeys.moveUp );
|
||||
this.addHotkeyToTitle( controls.downButton, hotkeys.moveDown );
|
||||
this.addHotkeyToTitle( controls.removeButton, hotkeys.remove );
|
||||
|
@ -516,20 +515,6 @@ ve.ui.MWTransclusionDialog.prototype.initialize = function () {
|
|||
// Parent method
|
||||
ve.ui.MWTransclusionDialog.super.prototype.initialize.call( this );
|
||||
|
||||
// Properties
|
||||
this.addTemplateButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'puzzle',
|
||||
title: ve.msg( 'visualeditor-dialog-transclusion-add-template' )
|
||||
} );
|
||||
this.addContentButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'wikiText',
|
||||
title: ve.msg( 'visualeditor-dialog-transclusion-add-wikitext' )
|
||||
} );
|
||||
|
||||
this.bookletLayout.getOutlineControls().addItems( [ this.addTemplateButton, this.addContentButton ] );
|
||||
|
||||
this.setupHotkeyTriggers();
|
||||
|
||||
// multipart message gets attached in onReplacePart()
|
||||
|
@ -558,9 +543,9 @@ ve.ui.MWTransclusionDialog.prototype.initialize = function () {
|
|||
|
||||
// Events
|
||||
this.getManager().connect( this, { resize: ve.debounce( this.onWindowResize.bind( this ) ) } );
|
||||
this.addTemplateButton.connect( this, { click: 'addTemplatePlaceholder' } );
|
||||
this.addContentButton.connect( this, { click: 'addContent' } );
|
||||
this.bookletLayout.getOutlineControls().connect( this, {
|
||||
addTemplate: 'addTemplatePlaceholder',
|
||||
addWikitext: 'addWikitext',
|
||||
move: 'onOutlineControlsMove',
|
||||
remove: 'onOutlineControlsRemove'
|
||||
} );
|
||||
|
@ -574,9 +559,6 @@ ve.ui.MWTransclusionDialog.prototype.getSetupProcess = function ( data ) {
|
|||
|
||||
return ve.ui.MWTransclusionDialog.super.prototype.getSetupProcess.call( this, data )
|
||||
.next( function () {
|
||||
var isReadOnly = this.isReadOnly();
|
||||
this.addTemplateButton.setDisabled( isReadOnly );
|
||||
this.addContentButton.setDisabled( isReadOnly );
|
||||
this.bookletLayout.getOutlineControls().toggle( !this.transclusionModel.isSingleTemplate() );
|
||||
this.$element.toggleClass(
|
||||
've-ui-mwTransclusionDialog-single-transclusion',
|
||||
|
|
|
@ -18,6 +18,16 @@ ve.ui.MWTransclusionOutlineControlsWidget = function OoUiOutlineControlsWidget(
|
|||
|
||||
// Properties
|
||||
this.$movers = $( '<div>' );
|
||||
this.addTemplateButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'puzzle',
|
||||
title: ve.msg( 'visualeditor-dialog-transclusion-add-template' )
|
||||
} );
|
||||
this.addWikitextButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'wikiText',
|
||||
title: ve.msg( 'visualeditor-dialog-transclusion-add-wikitext' )
|
||||
} );
|
||||
this.upButton = new OO.ui.ButtonWidget( {
|
||||
framed: false,
|
||||
icon: 'upTriangle',
|
||||
|
@ -35,6 +45,12 @@ ve.ui.MWTransclusionOutlineControlsWidget = function OoUiOutlineControlsWidget(
|
|||
} );
|
||||
|
||||
// Events
|
||||
this.addTemplateButton.connect( this, {
|
||||
click: [ 'emit', 'addTemplate' ]
|
||||
} );
|
||||
this.addWikitextButton.connect( this, {
|
||||
click: [ 'emit', 'addWikitext' ]
|
||||
} );
|
||||
this.upButton.connect( this, {
|
||||
click: [ 'emit', 'move', -1 ]
|
||||
} );
|
||||
|
@ -47,10 +63,17 @@ ve.ui.MWTransclusionOutlineControlsWidget = function OoUiOutlineControlsWidget(
|
|||
|
||||
// Initialization
|
||||
this.$element.addClass( 've-ui-mwTransclusionOutlineControlsWidget' );
|
||||
this.$group.addClass( 've-ui-mwTransclusionOutlineControlsWidget-items' );
|
||||
this.$movers
|
||||
.addClass( 've-ui-mwTransclusionOutlineControlsWidget-movers' )
|
||||
.append( this.upButton.$element, this.downButton.$element, this.removeButton.$element );
|
||||
this.$group.addClass( 've-ui-mwTransclusionOutlineControlsWidget-items' )
|
||||
.append(
|
||||
this.addTemplateButton.$element,
|
||||
this.addWikitextButton.$element
|
||||
);
|
||||
this.$movers.addClass( 've-ui-mwTransclusionOutlineControlsWidget-movers' )
|
||||
.append(
|
||||
this.upButton.$element,
|
||||
this.downButton.$element,
|
||||
this.removeButton.$element
|
||||
);
|
||||
this.$element.append( this.$icon, this.$group, this.$movers );
|
||||
};
|
||||
|
||||
|
@ -62,11 +85,23 @@ OO.mixinClass( ve.ui.MWTransclusionOutlineControlsWidget, OO.ui.mixin.GroupEleme
|
|||
/* Events */
|
||||
|
||||
/**
|
||||
* @event move
|
||||
* @param {number} places Number of places to move
|
||||
* Emitted when the "Add template" button in the toolbar is clicked
|
||||
* @event addTemplate
|
||||
*/
|
||||
|
||||
/**
|
||||
* Emitted when the "Add wikitext" button in the toolbar is clicked
|
||||
* @event addWikitext
|
||||
*/
|
||||
|
||||
/**
|
||||
* Emitted when one of the two "Move item up/down" buttons in the toolbar is clicked
|
||||
* @event move
|
||||
* @param {number} places Number of places to move, typically -1 or 1
|
||||
*/
|
||||
|
||||
/**
|
||||
* Emitted when the "Remove item" button in the toolbar is clicked
|
||||
* @event remove
|
||||
*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue