mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Add template outline widgets for all content types"
This commit is contained in:
commit
f92d85604c
|
@ -2149,9 +2149,11 @@
|
|||
"modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js",
|
||||
"modules/ve-mw/ui/contextitems/ve.ui.MWDefinedTransclusionContextItem.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlineParameterCheckboxLayout.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlinePartWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTemplateOutlineTemplateWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js"
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePartWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineContainerWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlinePlaceholderWidget.js",
|
||||
"modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineWikitextWidget.js"
|
||||
],
|
||||
"styles": [
|
||||
"modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css",
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
font-style: italic;
|
||||
}
|
||||
|
||||
.ve-ui-mwTemplateOutlinePartWidget-header {
|
||||
.ve-ui-mwTransclusionOutlinePartWidget-header {
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
overflow: hidden;
|
||||
|
@ -59,11 +59,11 @@
|
|||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.ve-ui-mwTemplateOutlinePartWidget-header:hover {
|
||||
.ve-ui-mwTransclusionOutlinePartWidget-header:hover {
|
||||
background-color: #eaecf0;
|
||||
}
|
||||
|
||||
.ve-ui-mwTemplateOutlinePartWidget-header .oo-ui-iconElement-icon {
|
||||
.ve-ui-mwTransclusionOutlinePartWidget-header .oo-ui-iconElement-icon {
|
||||
left: 11px;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,13 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.onReplacePart = function (
|
|||
|
||||
if ( added instanceof ve.dm.MWTemplateModel ) {
|
||||
this.addTemplate( added );
|
||||
} else if ( added instanceof ve.dm.MWTemplatePlaceholderModel ) {
|
||||
var placeholder = new ve.ui.MWTransclusionOutlinePlaceholderWidget();
|
||||
this.$element.append( placeholder.$element );
|
||||
} else if ( added instanceof ve.dm.MWTransclusionContentModel ) {
|
||||
var wikitextItem = new ve.ui.MWTransclusionOutlineWikitextWidget();
|
||||
this.$element.append( wikitextItem.$element );
|
||||
}
|
||||
// TODO: and for wikitext snippets?
|
||||
};
|
||||
|
||||
/* Methods */
|
||||
|
@ -63,7 +68,7 @@ ve.ui.MWTransclusionOutlineContainerWidget.prototype.onReplacePart = function (
|
|||
*/
|
||||
ve.ui.MWTransclusionOutlineContainerWidget.prototype.addTemplate = function ( template ) {
|
||||
// FIXME: Respect order
|
||||
var container = new ve.ui.MWTemplateOutlineTemplateWidget( {
|
||||
var container = new ve.ui.MWTransclusionOutlineTemplateWidget( {
|
||||
templateModel: template
|
||||
} );
|
||||
|
||||
|
|
|
@ -17,26 +17,26 @@
|
|||
* @cfg {string} [icon='']
|
||||
* @cfg {string} [label]
|
||||
*/
|
||||
ve.ui.MWTemplateOutlinePartWidget = function VeUiMWTemplateOutlinePartWidget( config ) {
|
||||
ve.ui.MWTransclusionOutlinePartWidget = function VeUiMWTransclusionOutlinePartWidget( config ) {
|
||||
// Parent constructor
|
||||
ve.ui.MWTemplateOutlinePartWidget.super.call( this, config );
|
||||
ve.ui.MWTransclusionOutlinePartWidget.super.call( this, config );
|
||||
|
||||
// Mixin constructors
|
||||
OO.ui.mixin.IconElement.call( this, config );
|
||||
OO.ui.mixin.LabelElement.call( this, config );
|
||||
|
||||
this.$header = $( '<div>' )
|
||||
.addClass( 've-ui-mwTemplateOutlinePartWidget-header' )
|
||||
.addClass( 've-ui-mwTransclusionOutlinePartWidget-header' )
|
||||
.prepend( this.$icon, this.$label );
|
||||
this.$element
|
||||
.addClass( 've-ui-mwTemplateOutlinePartWidget' )
|
||||
.addClass( 've-ui-mwTransclusionOutlinePartWidget' )
|
||||
.prepend( this.$header );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWTemplateOutlinePartWidget, OO.ui.Widget );
|
||||
OO.mixinClass( ve.ui.MWTemplateOutlinePartWidget, OO.ui.mixin.IconElement );
|
||||
OO.mixinClass( ve.ui.MWTemplateOutlinePartWidget, OO.ui.mixin.LabelElement );
|
||||
OO.inheritClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.Widget );
|
||||
OO.mixinClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.mixin.IconElement );
|
||||
OO.mixinClass( ve.ui.MWTransclusionOutlinePartWidget, OO.ui.mixin.LabelElement );
|
||||
// TODO: Add OO.ui.mixin.AccessKeyedElement?
|
||||
// TODO: Add OO.ui.mixin.TitledElement?
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* @class
|
||||
* @extends ve.ui.MWTransclusionOutlinePartWidget
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config]
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlinePlaceholderWidget = function VeUiMWTransclusionOutlinePlaceholderWidget( config ) {
|
||||
// Initialize config
|
||||
config = $.extend( {
|
||||
icon: 'puzzle',
|
||||
label: ve.msg( 'visualeditor-dialog-transclusion-add-template' )
|
||||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTransclusionOutlinePlaceholderWidget.super.call( this, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWTransclusionOutlinePlaceholderWidget, ve.ui.MWTransclusionOutlinePartWidget );
|
|
@ -1,6 +1,4 @@
|
|||
/*!
|
||||
* VisualEditor user interface MWTemplateOutlineTemplateWidget class.
|
||||
*
|
||||
* @license The MIT License (MIT); see LICENSE.txt
|
||||
*/
|
||||
|
||||
|
@ -8,13 +6,13 @@
|
|||
* Container for template, as rendered in the template dialog sidebar.
|
||||
*
|
||||
* @class
|
||||
* @extends ve.ui.MWTemplateOutlinePartWidget
|
||||
* @extends ve.ui.MWTransclusionOutlinePartWidget
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} config
|
||||
* @param {ve.dm.MWTemplateModel} config.templateModel
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineTemplateWidget = function VeUiMWTemplateOutlineTemplateWidget( config ) {
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget = function VeUiMWTransclusionOutlineTemplateWidget( config ) {
|
||||
// Initialize config
|
||||
config = $.extend( {
|
||||
icon: 'puzzle',
|
||||
|
@ -22,7 +20,7 @@ ve.ui.MWTemplateOutlineTemplateWidget = function VeUiMWTemplateOutlineTemplateWi
|
|||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTemplateOutlineTemplateWidget.super.call( this, config );
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.super.call( this, config );
|
||||
|
||||
// Initialization
|
||||
this.templateModel = config.templateModel.connect( this, {
|
||||
|
@ -57,13 +55,13 @@ ve.ui.MWTemplateOutlineTemplateWidget = function VeUiMWTemplateOutlineTemplateWi
|
|||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWTemplateOutlineTemplateWidget, ve.ui.MWTemplateOutlinePartWidget );
|
||||
OO.inheritClass( ve.ui.MWTransclusionOutlineTemplateWidget, ve.ui.MWTransclusionOutlinePartWidget );
|
||||
|
||||
/**
|
||||
* @param {string|ve.dm.MWParameterModel} parameter
|
||||
* @return {ve.ui.MWTemplateOutlineParameterCheckboxLayout}
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineTemplateWidget.prototype.createCheckbox = function ( parameter ) {
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.createCheckbox = function ( parameter ) {
|
||||
var templateSpec = this.templateModel.getSpec(),
|
||||
parameterModel = ( parameter instanceof ve.dm.MWParameterModel ) ?
|
||||
parameter : this.templateModel.getParameter( parameter ),
|
||||
|
@ -89,7 +87,7 @@ ve.ui.MWTemplateOutlineTemplateWidget.prototype.createCheckbox = function ( para
|
|||
*
|
||||
* @param {ve.dm.MWParameterModel} parameter
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineTemplateWidget.prototype.onAddParameter = function ( parameter ) {
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onAddParameter = function ( parameter ) {
|
||||
var paramName = parameter.getName(),
|
||||
paramCheckbox = this.parameters.findItemFromData( paramName );
|
||||
|
||||
|
@ -114,7 +112,7 @@ ve.ui.MWTemplateOutlineTemplateWidget.prototype.onAddParameter = function ( para
|
|||
*
|
||||
* @param {ve.dm.MWParameterModel} parameter
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineTemplateWidget.prototype.onRemoveParameter = function ( parameter ) {
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onRemoveParameter = function ( parameter ) {
|
||||
var paramCheckbox = this.parameters.findItemFromData( parameter.getName() );
|
||||
if ( paramCheckbox ) {
|
||||
paramCheckbox.setSelected( false, true );
|
||||
|
@ -127,7 +125,7 @@ ve.ui.MWTemplateOutlineTemplateWidget.prototype.onRemoveParameter = function ( p
|
|||
* @param {string} data Parameter name
|
||||
* @param {boolean} checked New checkbox state
|
||||
*/
|
||||
ve.ui.MWTemplateOutlineTemplateWidget.prototype.onCheckboxChange = function ( data, checked ) {
|
||||
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onCheckboxChange = function ( data, checked ) {
|
||||
var parameter = this.templateModel.getParameter( data );
|
||||
|
||||
if ( checked ) {
|
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* @class
|
||||
* @extends ve.ui.MWTransclusionOutlinePartWidget
|
||||
*
|
||||
* @constructor
|
||||
* @param {Object} [config]
|
||||
*/
|
||||
ve.ui.MWTransclusionOutlineWikitextWidget = function VeUiMWTransclusionOutlineWikitextWidget( config ) {
|
||||
// Initialize config
|
||||
config = $.extend( {
|
||||
icon: 'wikiText',
|
||||
label: ve.msg( 'visualeditor-dialog-transclusion-content' )
|
||||
}, config );
|
||||
|
||||
// Parent constructor
|
||||
ve.ui.MWTransclusionOutlineWikitextWidget.super.call( this, config );
|
||||
};
|
||||
|
||||
/* Inheritance */
|
||||
|
||||
OO.inheritClass( ve.ui.MWTransclusionOutlineWikitextWidget, ve.ui.MWTransclusionOutlinePartWidget );
|
Loading…
Reference in a new issue