Commits (119)
......@@ -1833,11 +1833,13 @@
"modules/ve-mw/ui/widgets/ve.ui.MWMediaInfoFieldWidget.js",
"modules/ve-mw/ui/datatransferhandlers/ve.ui.MWMediaTransferHandler.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWNameOnlyMediaDialog.js",
"modules/ve-mw/ui/tools/ve.ui.MWMediaDialogTool.js",
"modules/ve-mw/ui/contextitems/ve.ui.MWMediaContextItem.js"
],
"styles": [
"modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css",
"modules/ve-mw/ui/styles/dialogs/ve.ui.MWNameOnlyMediaDialog.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWMediaInfoFieldWidget.css"
],
"dependencies": [
......@@ -1995,6 +1997,7 @@
"modules/ve-mw/ui/styles/widgets/ve.ui.MWCategoryItemWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWCategoryPopupWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWCategoryWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWFileChooserInputWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWTocWidget.css",
"modules/ve-mw/ui/styles/dialogs/ve.ui.MWMetaDialog.css"
],
......@@ -2097,6 +2100,7 @@
"modules/ve-mw/dm/models/ve.dm.MWTemplateModel.js",
"modules/ve-mw/dm/models/ve.dm.MWTemplatePlaceholderModel.js",
"modules/ve-mw/dm/models/ve.dm.MWParameterModel.js",
"modules/ve-mw/ui/widgets/ve.ui.MWFileChooserInputWidget.js",
"modules/ve-mw/ui/widgets/ve.ui.MWParameterCheckboxInputWidget.js",
"modules/ve-mw/ui/widgets/ve.ui.MWParameterSearchWidget.js",
"modules/ve-mw/ui/widgets/ve.ui.MWParameterResultWidget.js",
......@@ -2109,20 +2113,24 @@
"modules/ve-mw/ui/pages/ve.ui.MWTemplatePlaceholderPage.js",
"modules/ve-mw/ui/pages/ve.ui.MWTransclusionContentPage.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWRequiredParamBlankConfirmDialog.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWResetConfirmationDialog.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js",
"modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js",
"modules/ve-mw/ui/layouts/ve.ui.MWTemplateBookletLayout.js",
"modules/ve-mw/ui/tools/ve.ui.MWTransclusionDialogTool.js",
"modules/ve-mw/ui/contextitems/ve.ui.MWTransclusionContextItem.js",
"modules/ve-mw/ui/contextitems/ve.ui.MWDefinedTransclusionContextItem.js"
],
"styles": [
"modules/ve-mw/ce/styles/nodes/ve.ce.MWTransclusionNode.css",
"modules/ve-mw/ui/styles/layouts/ve.ui.MWTemplateBookletLayout.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWParameterResultWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWMoreParametersResultWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWNoParametersResultWidget.css",
"modules/ve-mw/ui/styles/widgets/ve.ui.MWParameterSearchWidget.css",
"modules/ve-mw/ui/styles/pages/ve.ui.MWTransclusionContentPage.css",
"modules/ve-mw/ui/styles/pages/ve.ui.MWParameterPage.css",
"modules/ve-mw/ui/styles/dialogs/ve.ui.MWResetConfirmationDialog.css",
"modules/ve-mw/ui/styles/dialogs/ve.ui.MWTransclusionDialog.css"
],
"skinStyles": {
......@@ -2136,6 +2144,7 @@
},
"dependencies": [
"ext.visualEditor.mwcore",
"ext.visualEditor.jqueryCollapser",
"mediawiki.jqueryMsg",
"mediawiki.language",
"mediawiki.widgets.UserInputWidget"
......@@ -2144,17 +2153,38 @@
"quotation-marks",
"templatedata-doc-subpage",
"visualeditor-changedesc-mwtransclusion",
"visualeditor-dialog-reset-confirmation-cancel",
"visualeditor-dialog-reset-confirmation-remove",
"visualeditor-dialog-reset-confirmation-text",
"visualeditor-dialog-reset-confirmation-title",
"visualeditor-dialog-template-title",
"visualeditor-dialog-transclusion-add-content",
"visualeditor-dialog-transclusion-add-param",
"visualeditor-dialog-transclusion-add-param-sidebar",
"visualeditor-dialog-transclusion-add-param-placeholder",
"visualeditor-dialog-transclusion-add-param-description",
"visualeditor-dialog-transclusion-add-param-button",
"visualeditor-dialog-transclusion-add-template",
"visualeditor-dialog-transclusion-add-content-button",
"visualeditor-dialog-transclusion-content",
"visualeditor-dialog-transclusion-contextitem-description",
"visualeditor-dialog-transclusion-unknown-param-warning",
"visualeditor-dialog-transclusion-datalist-warning",
"visualeditor-dialog-transclusion-date-warning",
"visualeditor-dialog-transclusion-number-warning",
"visualeditor-dialog-transclusion-deprecated-parameter",
"visualeditor-dialog-transclusion-deprecated-parameter-description",
"visualeditor-dialog-transclusion-deprecated-template",
"visualeditor-dialog-transclusion-deprecated-template-guidance",
"visualeditor-dialog-transclusion-find-parameter",
"visualeditor-dialog-transclusion-loading",
"visualeditor-dialog-transclusion-more-template-description",
"visualeditor-dialog-transclusion-more-template-help",
"visualeditor-dialog-transclusion-move-down",
"visualeditor-dialog-transclusion-move-up",
"visualeditor-dialog-transclusion-multiple-mode",
"visualeditor-dialog-transclusion-no-parameters",
"visualeditor-dialog-transclusion-no-parameters-matched",
"visualeditor-dialog-transclusion-no-template-description",
"visualeditor-dialog-transclusion-absent-template",
"visualeditor-dialog-transclusion-options",
......@@ -2174,10 +2204,14 @@
"visualeditor-dialog-transclusion-required-parameter-dialog-title",
"visualeditor-dialog-transclusion-required-parameter-is-blank",
"visualeditor-dialog-transclusion-single-mode",
"visualeditor-dialog-transclusion-title",
"visualeditor-dialog-transclusion-title-insert",
"visualeditor-dialog-transclusion-title-edit",
"visualeditor-dialog-transclusion-templates-menu-aria-label",
"visualeditor-dialogbutton-template-tooltip",
"visualeditor-dialogbutton-transclusion-tooltip",
"visualeditor-mwfileinput-add",
"visualeditor-mwfileinput-change",
"visualeditor-mwfileinput-no-file",
"visualeditor-parameter-input-placeholder",
"visualeditor-parameter-search-more",
"visualeditor-parameter-search-no-unused",
......@@ -2188,6 +2222,15 @@
"mobile"
]
},
"ext.visualEditor.jqueryCollapser": {
"scripts": [
"modules/ve-mw/plugins/jquery.collapser.js"
],
"targets": [
"desktop",
"mobile"
]
},
"treeDiffer": {
"scripts": [
"lib/ve/lib/treeDiffer/treeDiffer-dist.js"
......
......@@ -169,13 +169,23 @@
"visualeditor-dialog-transclusion-absent-template": "Die Vorlage „$1“ ist noch nicht vorhanden.",
"visualeditor-dialog-transclusion-add-content": "Inhalt hinzufügen",
"visualeditor-dialog-transclusion-add-param": "Weitere Informationen hinzufügen",
"visualeditor-dialog-transclusion-add-param-description": "Füge bei Bedarf einen undokumentierten Parameter hinzu. Gebe einen Namen ein und klicke darauf um ihn der Vorlage hinzuzufügen.",
"visualeditor-dialog-transclusion-add-param-button": "Parameter",
"visualeditor-dialog-transclusion-add-template": "Vorlage hinzufügen",
"visualeditor-dialog-transclusion-add-content-button": "Inhalt hinzufügen",
"visualeditor-dialog-transclusion-content": "Inhalt",
"visualeditor-dialog-transclusion-unknown-param-warning": "Dieser vom Benutzer hinzugefügte Parameter wird von der Vorlage möglicherweise nicht unterstützt.",
"visualeditor-dialog-transclusion-datalist-warning": "Dies gehört nicht zu den vorgeschlagenen Werten und funktioniert möglicherweise nicht mit der Vorlage.",
"visualeditor-dialog-transclusion-date-warning": "Dieser Parameter erwartet Datumsformate in ISO 8601.",
"visualeditor-dialog-transclusion-number-warning": "Dieser Parameter erwartet nur numerische Werte, 0-9.",
"visualeditor-dialog-transclusion-contextitem-description": "Erzeugt von: $1",
"visualeditor-dialog-transclusion-deprecated-parameter": "Veraltetes Feld",
"visualeditor-dialog-transclusion-deprecated-parameter-description": "Feld ist veraltet. $1",
"visualeditor-dialog-transclusion-loading": "Laden …",
"visualeditor-dialog-transclusion-more-template-description": "Es könnten einige zusätzliche Informationen über die Vorlage „$1“ auf [[{{ns:template}}:$1|ihrer Seite]] vorhanden sein.",
"visualeditor-dialog-transclusion-more-template-help": "Weitere Informationen zum Ausfüllen dieser Vorlage sind auf [[{{ns:template}}:$1|der entsprechenden Seite]] zu finden.",
"visualeditor-dialog-transclusion-move-down": "Nach unten",
"visualeditor-dialog-transclusion-move-up": "Nach oben",
"visualeditor-dialog-transclusion-multiple-mode": "Optionen anzeigen",
"visualeditor-dialog-transclusion-no-template-description": "Die Vorlage „$1“ hat noch keine Beschreibung, aber vielleicht gibt es einige Informationen auf der [[$1|Vorlagenseite]].",
"visualeditor-dialog-transclusion-options": "Optionen",
......
......@@ -163,23 +163,44 @@
"visualeditor-dialog-meta-settings-toc-label": "Show the Table of Contents",
"visualeditor-dialog-meta-templatesused-noresults": "No templates found.",
"visualeditor-dialog-meta-title": "Options",
"visualeditor-dialog-reset-confirmation-cancel": "Cancel",
"visualeditor-dialog-reset-confirmation-remove": "Remove template",
"visualeditor-dialog-reset-confirmation-text": "Going back will remove this template and any data you have input. You can then choose a different template. This action is not reversible.",
"visualeditor-dialog-reset-confirmation-title": "Remove template?",
"visualeditor-dialog-table-collapsed": "Collapsed initially",
"visualeditor-dialog-table-collapsible": "Collapsible",
"visualeditor-dialog-table-sortable": "Sortable",
"visualeditor-dialog-table-wikitable": "Styled (wikitable)",
"visualeditor-dialog-template-title": "Template",
"visualeditor-dialog-transclusion-absent-template": "The \"$1\" template doesn't yet exist.",
"visualeditor-dialog-transclusion-add-content": "Add content",
"visualeditor-dialog-transclusion-add-param": "Add more information",
"visualeditor-dialog-transclusion-add-template": "Add template",
"visualeditor-dialog-transclusion-content": "Content",
"visualeditor-dialog-transclusion-add-content": "Wikitext block",
"visualeditor-dialog-transclusion-add-param": "Add undocumented parameter",
"visualeditor-dialog-transclusion-add-param-sidebar": "Add parameter",
"visualeditor-dialog-transclusion-add-param-placeholder": "Type name of parameter",
"visualeditor-dialog-transclusion-add-param-description": "Add an undocumented parameter by typing the name below and clicking to add it to the template.",
"visualeditor-dialog-transclusion-add-param-button": "Parameter",
"visualeditor-dialog-transclusion-add-template": "Template",
"visualeditor-dialog-transclusion-add-content-button": "Add content",
"visualeditor-dialog-transclusion-content": "Wikitext block",
"visualeditor-dialog-transclusion-unknown-param-warning": "This user-added parameter may not be supported by the template.",
"visualeditor-dialog-transclusion-datalist-warning": "This is not one of the suggested values and may not work with the template.",
"visualeditor-dialog-transclusion-date-warning": "This parameter expects dates formatted in [https://en.wikipedia.org/wiki/ISO_8601#Date ISO 8601].",
"visualeditor-dialog-transclusion-number-warning": "This parameter expects only numerical values, 0-9.",
"visualeditor-dialog-transclusion-contextitem-description": "Generated from: $1",
"visualeditor-dialog-transclusion-deprecated-template": "Warning: This template is marked as deprecated.",
"visualeditor-dialog-transclusion-deprecated-template-guidance": "Warning: This template is marked as deprecated. $1",
"visualeditor-dialog-transclusion-deprecated-parameter": "Deprecated field",
"visualeditor-dialog-transclusion-deprecated-parameter-description": "Field is deprecated. $1",
"visualeditor-dialog-transclusion-loading": "Loading...",
"visualeditor-dialog-transclusion-more-template-description": "There might be some additional information about the \"$1\" template on [[{{ns:template}}:$1|its page]].",
"visualeditor-dialog-transclusion-more-template-help": "For help filling in this template, find additional information on [[{{ns:template}}:$1|its page]].",
"visualeditor-dialog-transclusion-move-down": "Move down",
"visualeditor-dialog-transclusion-move-up": "Move up",
"visualeditor-dialog-transclusion-multiple-mode": "Show options",
"visualeditor-dialog-transclusion-no-template-description": "The \"$1\" template doesn't yet have a description, but there might be some information on the [[$1|template's page]].",
"visualeditor-dialog-transclusion-find-parameter": "Find parameter",
"visualeditor-dialog-transclusion-no-parameters": "No parameters",
"visualeditor-dialog-transclusion-no-parameters-matched": "No matches found",
"visualeditor-dialog-transclusion-no-template-description": "The \"$1\" template doesn't yet have a description.",
"visualeditor-dialog-transclusion-options": "Options",
"visualeditor-dialog-transclusion-param-default": "Default: $1",
"visualeditor-dialog-transclusion-param-example": "e.g. $1",
......@@ -197,7 +218,8 @@
"visualeditor-dialog-transclusion-required-parameter-dialog-title": "Required {{PLURAL:$1|field|fields}} missing",
"visualeditor-dialog-transclusion-required-parameter-is-blank": "Are you sure you want to continue without filling the $1 {{PLURAL:$2|field|fields}}?",
"visualeditor-dialog-transclusion-single-mode": "Hide options",
"visualeditor-dialog-transclusion-title": "Transclusion",
"visualeditor-dialog-transclusion-title-insert": "Insert a template",
"visualeditor-dialog-transclusion-title-edit": "Edit template",
"visualeditor-dialog-transclusion-templates-menu-aria-label": "Template fields setup menu",
"visualeditor-dialogbutton-media-tooltip": "Images and media",
"visualeditor-dialogbutton-meta-tooltip": "Page settings",
......@@ -267,6 +289,9 @@
"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-mwfileinput-add": "Add file",
"visualeditor-mwfileinput-change": "Change file",
"visualeditor-mwfileinput-no-file": "No file is selected",
"visualeditor-mwgallerycontext-description": "$1 {{PLURAL:$1|image|images}}",
"visualeditor-mwgallerydialog-caption-field-label": "Gallery caption",
"visualeditor-mwgallerydialog-caption-input-placeholder": "Caption for the whole gallery",
......
......@@ -181,6 +181,10 @@
"visualeditor-dialog-meta-settings-toc-label": "Prompt to let the user set the Table Of Contents (TOC) behaviour.",
"visualeditor-dialog-meta-templatesused-noresults": "Message displayed when no existing templates found on the page.",
"visualeditor-dialog-meta-title": "Text of the title for the meta dialog to set categories, language links and other page settings.\n{{Identical|Options}}",
"visualeditor-dialog-reset-confirmation-cancel": "Label for the button which cancels the reset.",
"visualeditor-dialog-reset-confirmation-remove": "Label for the button which proceeds with the reset.",
"visualeditor-dialog-reset-confirmation-text": "Label for the warning displayed to the user informing them of the reset.",
"visualeditor-dialog-reset-confirmation-title": "Title for the dialog used to confirm that the user wants to reset the template dialog.",
"visualeditor-dialog-table-collapsed": "Label for toggle to make a table collapsed initially",
"visualeditor-dialog-table-collapsible": "Label for toggle to make a table collapsible\n{{Identical|Collapsible}}",
"visualeditor-dialog-table-sortable": "Label for toggle to make a table sortable",
......@@ -192,6 +196,7 @@
"visualeditor-dialog-transclusion-add-template": "Label for button that adds the specified template to the page.\n{{Identical|Add template}}",
"visualeditor-dialog-transclusion-content": "Label for editor of content between transclusion parts.\n{{Identical|Content}}",
"visualeditor-dialog-transclusion-contextitem-description": "Message shown to an editor when they click on a template or group of templates that form a transclusion, listing the template(s) from which the transclusion is constructed.\n\n* $1 – the name of the template, or a list of the names of the templates if there are multiple.\n* $2 - number of templates for PLURAL support.",
"visualeditor-dialog-transclusion-datalist-warning": "See [[phab:T260157]].",
"visualeditor-dialog-transclusion-deprecated-parameter": "Tooltip for deprecated parameter indicator",
"visualeditor-dialog-transclusion-deprecated-parameter-description": "Label describing that a parameter is deprecated.\n\nParameters:\n* $1 - Description given in TemplateData for why parameter is deprecated, which may be empty.",
"visualeditor-dialog-transclusion-loading": "Title for the transclusion dialog while its contents are loading.\n{{Identical|Loading}}",
......@@ -215,7 +220,8 @@
"visualeditor-dialog-transclusion-required-parameter-dialog-title": "Title for the confirmation dialog opened if the user tries to insert/edit a template without filling all required fields.\n\nParameters:\n* $1 - Number of parameters missing, for PLURAL support.",
"visualeditor-dialog-transclusion-required-parameter-is-blank": "Label for the confirmation dialog opened if the user tries to insert/edit a template without filling all required fields.\n\nParameters:\n* $1 - Parameters missing, as a list using {{msg-mw|and}}, {{msg-mw|comma-separator}} and {{msg-mw|word-separator}}.\n* $2 - Number of parameters missing, for PLURAL support.",
"visualeditor-dialog-transclusion-single-mode": "Label for button that hides advanced options in transclusion dialog",
"visualeditor-dialog-transclusion-title": "{{Identical|Transclusion}}",
"visualeditor-dialog-transclusion-title-insert": "Title for the dialog used to insert a new template.",
"visualeditor-dialog-transclusion-title-edit": "Title for the dialog used to edit an existing template.",
"visualeditor-dialog-transclusion-templates-menu-aria-label": "ARIA label for screen readers on template fields setup menu.",
"visualeditor-dialogbutton-media-tooltip": "Tooltip for adding images and media on page",
"visualeditor-dialogbutton-meta-tooltip": "{{Identical|Page settings}}",
......@@ -285,6 +291,9 @@
"visualeditor-mweditmodeve-warning": "Warning message shown before changing edit mode to visual editing. Depending on site configuration, it may allow the user to keep the changes using the message {{msg-mw|visualeditor-mweditmodesource-warning-switch}}, or only 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-mwfileinput-add": "Button label for adding an image when the parameter value is empty.",
"visualeditor-mwfileinput-change": "Button label for changing the image when a parameter value already exists.",
"visualeditor-mwfileinput-no-file": "Placeholder for a file input when no value exists.",
"visualeditor-mwgallerycontext-description": "Description of the gallery in the context",
"visualeditor-mwgallerydialog-caption-field-label": "Label for the caption field of the gallery dialog",
"visualeditor-mwgallerydialog-caption-input-placeholder": "Placeholder for the caption input of the gallery dialog",
......
......@@ -184,13 +184,23 @@
"visualeditor-dialog-transclusion-absent-template": "\"$1\" şablonu henüz yoktur.",
"visualeditor-dialog-transclusion-add-content": "İçerik ekle",
"visualeditor-dialog-transclusion-add-param": "Daha fazla bilgi ekleyin",
"visualeditor-dialog-transclusion-add-param-description": "Belgelenmemiş bir parametre eklemek için adını aşağıya yazınız ve bunu şablona ekleye tıklayınız.",
"visualeditor-dialog-transclusion-add-param-button": "Parametre",
"visualeditor-dialog-transclusion-add-template": "Şablon ekle",
"visualeditor-dialog-transclusion-add-content-button": "İçerik ekleyin",
"visualeditor-dialog-transclusion-content": "İçerik",
"visualeditor-dialog-transclusion-unknown-param-warning": "Kullanıcı tarafından eklenmiş olan bu parametre, şablon tarafından desteklenmeyebilir.",
"visualeditor-dialog-transclusion-datalist-warning": "Bu önerilen değerlerden biri değildir ve bu şablonla çalışmayabilir.",
"visualeditor-dialog-transclusion-date-warning": "Bu parametre, ISO 8601'e uygun biçimlendirilmiş tarihleri kabul eder.",
"visualeditor-dialog-transclusion-number-warning": "Bu parametre yalnızca sayısal değerler kabul edebilir, 0-9.",
"visualeditor-dialog-transclusion-contextitem-description": "Oluşturulan: $1",
"visualeditor-dialog-transclusion-deprecated-parameter": "Önerilmeyen alan",
"visualeditor-dialog-transclusion-deprecated-parameter-description": "Alan kullanımı önerilmemektedir.$1",
"visualeditor-dialog-transclusion-loading": "Yükleniyor...",
"visualeditor-dialog-transclusion-more-template-description": "[[{{ns:template}}:$1|Sayfası]] üzerindeki \"$1\" şablonu hakkında ek bilgi olabilir.",
"visualeditor-dialog-transclusion-more-template-help": "Bu şablonu doldururken yardım gerekirse [[{{ns:template}}:$1|sayfasından]] daha detaylı bilgi bulabilirsiniz.",
"visualeditor-dialog-transclusion-move-down": "Aşağı taşı",
"visualeditor-dialog-transclusion-move-up": "Yukarı taşı",
"visualeditor-dialog-transclusion-multiple-mode": "Seçenekleri göster",
"visualeditor-dialog-transclusion-no-template-description": "\"$1\" şablonunun henüz bir açıklaması yok, ancak [[$1|şablonun sayfası]] hakkında bazı bilgiler olabilir.",
"visualeditor-dialog-transclusion-options": "Seçenekler",
......
......@@ -114,6 +114,13 @@ ve.dm.MWParameterModel.prototype.getValue = function () {
return this.value || this.getAutoValue() || '';
};
/**
* @return {string[]}
*/
ve.dm.MWParameterModel.prototype.getDataList = function () {
return this.template.getSpec().getParameterDataList( this.name );
};
/**
* Get default parameter value.
*
......
......@@ -195,6 +195,10 @@ ve.dm.MWTemplateModel.prototype.getParameterNames = function () {
if ( !this.sequence ) {
paramOrder = this.spec.getParameterOrder();
// Same fallback as in the TemplateData extension
if ( paramOrder.length === 0 ) {
paramOrder = Object.keys( this.spec.params );
}
paramNames = Object.keys( this.params );
this.sequence = [];
......@@ -378,3 +382,23 @@ ve.dm.MWTemplateModel.prototype.getWikitext = function () {
return '{{' + wikitext + '}}';
};
/**
* @inheritDoc
*/
ve.dm.MWTemplateModel.prototype.isEmpty = function () {
var params = this.getParameters();
return Object.getOwnPropertyNames( params ).every( function ( name ) {
var param, value;
// There is always an unnamed placeholder at the start
if ( !name ) {
return true;
}
param = params[ name ];
value = param.getValue();
return value === '' || value === param.getAutoValue();
} );
};
......@@ -22,3 +22,12 @@ ve.dm.MWTemplatePlaceholderModel = function VeDmMWTemplatePlaceholderModel() {
/* Inheritance */
OO.inheritClass( ve.dm.MWTemplatePlaceholderModel, ve.dm.MWTransclusionPartModel );
/* Methods */
/**
* @inheritDoc
*/
ve.dm.MWTemplatePlaceholderModel.prototype.isEmpty = function () {
return true;
};
......@@ -20,7 +20,9 @@ ve.dm.MWTemplateSpecModel = function VeDmMWTemplateSpecModel( template ) {
// Properties
this.template = template;
this.description = null;
this.deprecated = null;
this.params = {};
this.rawParams = {};
this.paramOrder = [];
this.sets = [];
this.maps = {};
......@@ -60,10 +62,16 @@ ve.dm.MWTemplateSpecModel.prototype.extend = function ( data ) {
if ( data.description !== null ) {
this.description = data.description;
}
if ( data.deprecated !== null ) {
this.deprecated = data.deprecated;
}
if ( Array.isArray( data.paramOrder ) ) {
this.paramOrder = data.paramOrder.slice();
}
if ( data.params ) {
this.rawParams = data.params;
for ( key in data.params ) {
// Pre-fill spec
if ( !this.params[ key ] ) {
......@@ -72,6 +80,7 @@ ve.dm.MWTemplateSpecModel.prototype.extend = function ( data ) {
param = this.params[ key ];
// Extend existing spec
ve.extendObject( true, this.params[ key ], data.params[ key ] );
this.params[ key ].undocumented = false;
// Add aliased references
if ( param.aliases.length ) {
for ( i = 0, len = param.aliases.length; i < len; i++ ) {
......@@ -119,7 +128,8 @@ ve.dm.MWTemplateSpecModel.prototype.getDefaultParameterSpec = function ( name )
name: name,
required: false,
suggested: false,
deprecated: false
deprecated: false,
undocumented: true
};
};
......@@ -154,6 +164,10 @@ ve.dm.MWTemplateSpecModel.prototype.getDescription = function ( lang ) {
return this.constructor.static.getLocalValue( this.description, lang );
};
ve.dm.MWTemplateSpecModel.prototype.getDeprecated = function () {
return this.deprecated;
};
/**
* Get parameter order.
*
......@@ -207,6 +221,14 @@ ve.dm.MWTemplateSpecModel.prototype.getParameterDescription = function ( name, l
return this.constructor.static.getLocalValue( this.params[ name ].description, lang );
};
/**
* @param {string} name
* @return {string[]}
*/
ve.dm.MWTemplateSpecModel.prototype.getParameterDataList = function ( name ) {
return this.params[ name ].datalist || [];
};
/**
* Get a parameter value.
*
......@@ -214,7 +236,8 @@ ve.dm.MWTemplateSpecModel.prototype.getParameterDescription = function ( name, l
* @return {string} Default parameter value
*/
ve.dm.MWTemplateSpecModel.prototype.getParameterDefaultValue = function ( name ) {
return this.params[ name ].default;
var param = this.params[ name ];
return param ? param.default : '';
};
/**
......@@ -235,7 +258,8 @@ ve.dm.MWTemplateSpecModel.prototype.getParameterExampleValue = function ( name,
* @return {string} Auto-value for the parameter
*/
ve.dm.MWTemplateSpecModel.prototype.getParameterAutoValue = function ( name ) {
return this.params[ name ].autovalue;
var param = this.params[ name ];
return param ? param.autovalue : '';
};
/**
......@@ -300,6 +324,16 @@ ve.dm.MWTemplateSpecModel.prototype.isParameterDeprecated = function ( name ) {
return this.params[ name ].deprecated !== false;
};
/**
* Check if parameter is undocumented.
*
* @param {string} name Parameter name
* @return {boolean} Parameter is undocumented
*/
ve.dm.MWTemplateSpecModel.prototype.isParameterUndocumented = function ( name ) {
return this.params[ name ].undocumented;
};
/**
* Get parameter deprecation description.
*
......
......@@ -67,3 +67,10 @@ ve.dm.MWTransclusionContentModel.prototype.serialize = function () {
ve.dm.MWTransclusionContentModel.prototype.getWikitext = function () {
return this.value;
};
/**
* @inheritDoc
*/
ve.dm.MWTransclusionContentModel.prototype.isEmpty = function () {
return this.value === '';
};
......@@ -50,6 +50,16 @@
/* Methods */
/**
* Clears the model's state
*/
ve.dm.MWTransclusionModel.prototype.reset = function () {
this.parts = [];
this.uid = 0;
this.requests = [];
this.queue = [];
};
/**
* Insert transclusion at the end of a surface fragment.
*
......@@ -546,6 +556,7 @@
}
index++;
if ( part instanceof ve.dm.MWTemplateModel ) {
// Note these are only the parameters that are currently added
names = part.getParameterNames();
for ( j = 0, jLen = names.length; j < jLen; j++ ) {
if ( part.getParameter( names[ j ] ) === model ) {
......
......@@ -86,3 +86,11 @@ ve.dm.MWTransclusionPartModel.prototype.getWikitext = function () {
ve.dm.MWTransclusionPartModel.prototype.addPromptedParameters = function () {
return 0;
};
/**
* @return {boolean} True if there is no user input (i.e. there is no input, or only an autovalue),
* false otherwise
*/
ve.dm.MWTransclusionPartModel.prototype.isEmpty = function () {
return true;
};
/*
* jQuery - Collapser plugin v3.0.1
* https://www.aakashweb.com/
* Copyright 2020, Aakash Chakravarthy
* Released under the MIT License.
*/
;(function ($, window, document, undefined) {
var name = "collapser",
defaults = {
mode: 'words',
speed: 'slow',
truncate: 10,
grace: null,
ellipsis: ' ... ',
controlBtn: null,
showText: 'Show more',
hideText: 'Hide text',
showClass: 'show-class',
hideClass: 'hide-class',
atStart: 'hide',
blockTarget: 'next',
blockEffect: 'fade',
lockHide: false,
changeText: false,
beforeShow: null,
afterShow: null,
beforeHide: null,
afterHide: null
};
// Constructor
function Collapser(el, options) {
var s = this; // The collapser class object
s.o = $.extend({}, defaults, options);
s.e = $(el); // The element to collapse
s.init();
}
Collapser.prototype = {
init: function(){
var s = this;
s.mode = s.o.mode;
s.remaining = null;
s.ctrlButton = $.isFunction(s.o.controlBtn) ? s.o.controlBtn.call(s.e) : $('<a href="#" data-ctrl></a>');
if(s.mode == 'lines'){
s.e.wrapInner('<div>');
}
// Get the start type of the target element and activate the collapse
var atStart = $.isFunction(s.o.atStart) ? s.o.atStart.call(s.e) : s.o.atStart;
atStart = (typeof s.e.attr('data-start') !== 'undefined') ? s.e.attr('data-start') : atStart;
if(atStart == 'hide'){
s.hide(0);
}else{
s.show(0);
}
},
// SHOW METHOD
show: function(speed){
var s = this;
var e = s.e;
s.collapsed = false;
if(typeof speed === 'undefined') speed = s.o.speed;
if($.isFunction(s.o.beforeShow))
s.o.beforeShow.call(s.e, s);
var afterShow = function(){
if($.isFunction(s.o.afterShow))
s.o.afterShow.call(s.e, s);
};
e.find('[data-ctrl]').remove();
// Modes chars, words and lines follow the same sequence to show the collapsed data.
if(s.mode == 'block'){
s.blockMode(e, 'show', speed, afterShow);
}else{
/*
1. Get the current height when collapsed.
2. Set the expanded content and get the height.
3. Animate the element height from collapsed height to the expanded height.
*/
var target = (s.mode == 'lines') ? e.children('div') : e; // For lines mode, the element to collapse is the inner wrapper div
var oldHeight = target.height();
if(s.mode == 'lines'){
target.height('auto');
}else{
var backupHTML = target.data('collHTML');
if(typeof backupHTML !== 'undefined'){
target.html(backupHTML);
}
}
var newHeight = target.height();
target.height(oldHeight);
target.animate({
'height': newHeight
}, speed, function(){
target.height('auto');
afterShow();
});
e.removeClass(s.o.hideClass).addClass(s.o.showClass);
// Add the control button and set the display text
if(!$.isFunction(s.o.controlBtn)){
e.append(s.ctrlButton);
}
s.ctrlButton.html(s.o.hideText);
}
// Bind the click event for all the modes
s.bindEvent();
// Remove the control button if option is to hide it
if(s.o.lockHide){
s.ctrlButton.remove();
}
},
// HIDE METHOD
hide: function(speed){
var s = this;
var e = s.e;
s.collapsed = true;
if(typeof speed === 'undefined') speed = s.o.speed;
if($.isFunction(s.o.beforeHide)){
s.o.beforeHide.call(s.e, s);
}
var afterHide = function(){
if($.isFunction(s.o.afterHide))
s.o.afterHide.call(s.e, s);
};
e.find('[data-ctrl]').remove();
// Mode - chars & words
if(s.mode == 'chars' || s.mode == 'words'){
var fullHTML = e.html();
var collapsedHTML = s.getCollapsedHTML(fullHTML, s.mode, s.o.truncate, s.o.grace) // returns false if content is very small and cannot collapse.
if(collapsedHTML){
var plainText = e.text();
s.remaining = plainText.split(s.mode == 'words' ? ' ' : '').length - s.o.truncate;
e.data('collHTML', fullHTML);
e.html(collapsedHTML);
}else{
s.remaining = 0;
}
}
// Mode - lines
if(s.mode == 'lines'){
var $wrapElement = e.children('div');
var originalHeight = $wrapElement.outerHeight();
var $lhChar = $wrapElement.find('[data-col-char]');
if($lhChar.length == 0){
var $lhChar = $('<span style="display:none" data-col-char>.</span>');
$wrapElement.prepend($lhChar);
}
var lineHeight = $lhChar.height();
var newHeight = (lineHeight * s.o.truncate) + lineHeight/4; // Adding quarter of line height to avoid cutting the line.
// If content is already small and criteria is already met then no need to collapse.
if(newHeight >= originalHeight){
newHeight = 'auto';
s.remaining = 0;
}else{
s.remaining = parseInt(Math.ceil((originalHeight - newHeight)/lineHeight));
}
$wrapElement.css({
'overflow': 'hidden',
'height': newHeight
});
}
// Mode - block
if(s.mode == 'block'){
s.blockMode(e, 'hide', speed, afterHide);
}
afterHide();
if(s.mode != 'block'){
e.removeClass(s.o.showClass).addClass(s.o.hideClass);
// Add the control button and set the display text
if(!$.isFunction(s.o.controlBtn) && s.remaining > 0){
e.append(s.ctrlButton);
}
s.ctrlButton.html(s.o.showText);
}
// Bind the click event for all the modes
s.bindEvent();
},
blockMode: function(e, type, speed, callback){
var s = this
var effects = ['fadeOut', 'slideUp', 'fadeIn', 'slideDown'];
var inc = (s.o.blockEffect == 'fade') ? 0 : 1;
var effect = (type == 'hide') ? effects[inc] : effects [inc + 2];
if(!$.isFunction(s.o.blockTarget)){
if($.fn[s.o.blockTarget])
$(e)[s.o.blockTarget]()[effect](speed, callback);
}else{
s.o.blockTarget.call(s.e)[effect](speed, callback);
}
if(type == 'show'){
e.removeClass(s.o.showClass).addClass(s.o.hideClass);
if(s.o.changeText)
e.text(s.o.hideText);
}else{
e.removeClass(s.o.hideClass).addClass(s.o.showClass);
if(s.o.changeText)
e.text(s.o.showText);
}
},
getCollapsedHTML: function(fullHTML, mode, truncateAt, grace){
var inTag = false;
var itemsFound = 0;
var slicePoint = 0;
var hasLessItems = true;
if ( !grace ) {
grace = truncateAt;
}
// Iterate over the full HTML and find the point to break the HTML.
for(var i = 0; i <= fullHTML.length; i++){
char = fullHTML.charAt(i);
if(char == '<') inTag = true;
if(char == '>') inTag = false;
if(itemsFound == truncateAt){
slicePoint = i;
}
if ( itemsFound == grace ) {
hasLessItems = false;
break;
}
if(!inTag){
if(mode == 'words' && char == ' '){
itemsFound++;
}
if(mode == 'chars'){
itemsFound++;
}
}
}
if(hasLessItems)
return false;
var slicedHTML = fullHTML.slice(0, slicePoint);
var balancedHTML = this.balanceTags(slicedHTML);
return balancedHTML + '<span class="coll-ellipsis">' + this.o.ellipsis + '</span>';
},
balanceTags: function(string){
// Thanks to https://osric.com/chris/javascript/balance-tags.html
if (string.lastIndexOf("<") > string.lastIndexOf(">")) {
string = string.substring(0, string.lastIndexOf("<"));
}
var tags = string.match(/<[^>]+>/g);
var stack = new Array();
for (tag in tags) {
if (tags[tag].search("/") <= 0) {
stack.push(tags[tag]);
} else if (tags[tag].search("/") == 1) {
stack.pop();
} else {
}
}
while (stack.length > 0) {
var endTag = stack.pop();
endTag = endTag.substring(1,endTag.search(/[>]/));
string += "</" + endTag + ">";
}
return(string);
},
bindEvent: function(){
var s = this;
var target = (s.mode == 'block') ? s.e : s.ctrlButton; // If mode is block, then the selector itself is the target not the control button
target.off('click').on('click', function(event){
event.preventDefault();
if(s.collapsed){
s.show();
}else{
s.hide();
}
});
}
};
// Attach the object to the DOM
$.fn[name] = function (options) {
return this.each(function () {
if (!$.data(this, name)) {
$.data(this, name, new Collapser(this, options));
}
});
};
})(jQuery, window, document);
\ No newline at end of file
This diff is collapsed.
/*!
* VisualEditor UserInterface MWResetConfirmationDialog class.
*
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Dialog to confirm a destructive action.
*
* @class
* @extends OO.ui.Dialog
*
* @constructor
* @param {Object} [config] Configuration options
*/
ve.ui.MWResetConfirmationDialog = function VeUiMWResetConfirmationDialog( config ) {
// Parent constructor
ve.ui.MWResetConfirmationDialog.super.call( this, config );
// Initialization
this.$element.addClass( 've-ui-mwResetConfirmationDialog' );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWResetConfirmationDialog, OO.ui.Dialog );
/* Static properties */
ve.ui.MWResetConfirmationDialog.static.name = 'reset-confirmation-dialog';
ve.ui.MWResetConfirmationDialog.static.size = 'medium';
/* Registration */
ve.ui.windowFactory.register( ve.ui.MWResetConfirmationDialog );
/* Methods */
/**
* Adjust this dialogs dimensions to match those of the parent dialog
*
* @param {OO.ui.Dialog} parent Parent dialog
*/
ve.ui.MWResetConfirmationDialog.prototype.matchSize = function ( parent ) {
ve.ui.MWResetConfirmationDialog.prototype.getBodyHeight = function () {
return parent.getContentHeight();
};
this.setSize( parent.getSize() );
this.updateSize();
};
/**
* @inheritdoc
*/
ve.ui.MWResetConfirmationDialog.prototype.initialize = function () {
var warning, cancelButton, continueButton, buttonLayout, fieldset;
// Parent method
ve.ui.MWResetConfirmationDialog.super.prototype.initialize.call( this );
// Properties
warning = new OO.ui.MessageWidget( {
type: 'error',
label: ve.msg( 'visualeditor-dialog-reset-confirmation-text' )
} );
cancelButton = new OO.ui.ButtonWidget( {
label: ve.msg( 'visualeditor-dialog-reset-confirmation-cancel' )
} );
continueButton = new OO.ui.ButtonWidget( {
label: ve.msg( 'visualeditor-dialog-reset-confirmation-remove' ),
flags: [ 'primary', 'destructive' ]
} );
buttonLayout = new OO.ui.HorizontalLayout( {
items: [ cancelButton, continueButton ]
} );
fieldset = new OO.ui.FieldsetLayout( {
label: ve.msg( 'visualeditor-dialog-reset-confirmation-title' )
} );
// Initialization
fieldset.addItems( [ warning, buttonLayout ] );
this.$body.append( fieldset.$element );
cancelButton.on( 'click', this.onClick.bind( this, 'cancel' ) );
continueButton.on( 'click', this.onClick.bind( this, 'continue' ) );
};
/**
* @param {string} action
*/
ve.ui.MWResetConfirmationDialog.prototype.onClick = function ( action ) {
this.close( { action: action } );
};
......@@ -87,24 +87,29 @@ ve.ui.MWTemplateDialog.prototype.onReplacePart = function ( removed, added ) {
if ( removed ) {
// Remove parameter pages of removed templates
partPage = this.bookletLayout.getPage( removed.getId() );
if ( partPage ) {
if ( removed instanceof ve.dm.MWTemplateModel ) {
params = removed.getParameters();
for ( name in params ) {
removePages.push( this.bookletLayout.getPage( params[ name ].getId() ) );
delete this.expandedParamList[ params[ name ].getId() ];
var item = this.bookletLayout.outlineSelectWidget.findItemFromData( removed.getId() + '_search' );
if ( item ) {
this.bookletLayout.outlineSelectWidget.removeItems( [ item ] );
}
removed.disconnect( this );
}
if ( this.loaded && !this.preventReselection && partPage.isActive() ) {
if ( this.loaded && !this.preventReselection && partPage.isActive && partPage.isActive() ) {
reselect = this.bookletLayout.findClosestPage( partPage );
}
removePages.push( partPage );
this.bookletLayout.removePages( removePages );
}
}
if ( added ) {
page = this.getPageFromPart( added );
if ( page ) {
// The idea here is that a new parameter was already added to the model, so it's
// guaranteed to be found, but searching for its index will consider the preferred
// paramOrder.
this.bookletLayout.addPages( [ page ], this.transclusionModel.getIndex( added ) );
if ( reselect ) {
// Use added page instead of closest page
......@@ -212,8 +217,9 @@ ve.ui.MWTemplateDialog.prototype.onRemoveParameter = function ( param ) {
// Select the desired page first. Otherwise, if the page we are removing is selected,
// OOUI will try to select the first page after it is removed, and scroll to the top.
if ( this.loaded && !this.preventReselection ) {
this.setPageByName( reselect.getName() );
if ( this.loaded && !this.preventReselection && reselect ) {
// FIXME: disabled reselection for now, it's hard to control scrolling.
//this.setPageByName( reselect.getName() );
}
this.bookletLayout.removePages( [ page ] );
......@@ -245,7 +251,7 @@ ve.ui.MWTemplateDialog.prototype.setApplicableStatus = function () {
* @inheritdoc
*/
ve.ui.MWTemplateDialog.prototype.getBodyHeight = function () {
return 400;
return 560;
};
/**
......@@ -303,11 +309,7 @@ ve.ui.MWTemplateDialog.prototype.getSelectedNode = function ( data ) {
* @param {string} name Page name
*/
ve.ui.MWTemplateDialog.prototype.setPageByName = function ( name ) {
if ( this.bookletLayout.isOutlined() ) {
this.bookletLayout.getOutline().selectItemByData( name );
} else {
this.bookletLayout.setPage( name );
}
};
/**
......@@ -331,7 +333,7 @@ ve.ui.MWTemplateDialog.prototype.initialize = function () {
ve.ui.MWTemplateDialog.super.prototype.initialize.call( this );
// Properties
this.bookletLayout = new OO.ui.BookletLayout( this.constructor.static.bookletLayoutConfig );
this.bookletLayout = new ve.ui.MWTemplateBookletLayout( this.constructor.static.bookletLayoutConfig );
// Initialization
this.$content.addClass( 've-ui-mwTemplateDialog' );
......@@ -445,7 +447,7 @@ ve.ui.MWTemplateDialog.prototype.getSetupProcess = function ( data ) {
// Detach the form while building for performance
this.bookletLayout.$element.detach();
// HACK: Prevent any setPage() calls (from #onReplacePart) from focussing stuff, it messes
// HACK: Prevent any setPage() calls (from #onReplacePart) from focusing stuff, it messes
// with OOUI logic for marking fields as invalid (T199838). We set it back to true below.
this.bookletLayout.autoFocus = false;
......
......@@ -20,6 +20,11 @@ ve.ui.MWTransclusionDialog = function VeUiMWTransclusionDialog( config ) {
// Properties
this.mode = null;
this.backButton = null;
this.closeButton = null;
// Initialization
this.$content.addClass( 've-ui-mwTransclusionDialog-multiple' );
};
/* Inheritance */
......@@ -30,31 +35,22 @@ OO.inheritClass( ve.ui.MWTransclusionDialog, ve.ui.MWTemplateDialog );
ve.ui.MWTransclusionDialog.static.name = 'transclusion';
ve.ui.MWTransclusionDialog.static.title =
OO.ui.deferMsg( 'visualeditor-dialog-transclusion-title' );
ve.ui.MWTransclusionDialog.static.size = 'large';
ve.ui.MWTransclusionDialog.static.titleInsert =
OO.ui.deferMsg( 'visualeditor-dialog-transclusion-title-insert' );
ve.ui.MWTransclusionDialog.static.titleEdit =
OO.ui.deferMsg( 'visualeditor-dialog-transclusion-title-edit' );
ve.ui.MWTransclusionDialog.static.actions = ve.ui.MWTemplateDialog.static.actions.concat( [
{
action: 'mode',
action: 'back',
modes: [ 'edit', 'insert' ],
// HACK: Will be set later, but we want measurements to be accurate in the mean time, this
// will not be needed when T93290 is resolved
label: $( document.createTextNode( '\u00a0' ) )
flags: [ 'safe', 'back' ]
}
] );
/**
* Map of symbolic mode names and CSS classes.
*
* @static
* @property {Object}
* @inheritable
*/
ve.ui.MWTransclusionDialog.static.modeCssClasses = {
single: 've-ui-mwTransclusionDialog-single',
multiple: 've-ui-mwTransclusionDialog-multiple'
};
ve.ui.MWTransclusionDialog.static.bookletLayoutConfig = ve.extendObject(
{},
ve.ui.MWTemplateDialog.static.bookletLayoutConfig,
......@@ -86,12 +82,11 @@ ve.ui.MWTransclusionDialog.prototype.onOutlineControlsMove = function ( places )
/**
* Handle outline controls remove events.
*/
ve.ui.MWTransclusionDialog.prototype.onOutlineControlsRemove = function () {
ve.ui.MWTransclusionDialog.prototype.onRemoveParameterClick = function ( id ) {
var id, part, param,
item = this.bookletLayout.getOutline().findSelectedItem();
item = this.bookletLayout.getOutline().findItemFromData( id );
if ( item ) {
id = item.getData();
part = this.transclusionModel.getPartFromId( id );
// Check if the part is the actual template, or one of its parameters
if ( part instanceof ve.dm.MWTemplateModel && id !== part.getId() ) {
......@@ -105,6 +100,19 @@ ve.ui.MWTransclusionDialog.prototype.onOutlineControlsRemove = function () {
}
};
ve.ui.MWTransclusionDialog.prototype.onAddNamedParameter = function ( data ) {
var item = this.bookletLayout.getOutline().findItemFromData( data );
if ( item ) {
part = this.transclusionModel.getPartFromId( item.getData() );
// FIXME: get name from the proper object
var name = data.replace( /^.*\//, '' );
if ( part instanceof ve.dm.MWTemplateModel ) {
param = new ve.dm.MWParameterModel( part, name, null );
part.addParameter( param );
}
}
};
/**
* Handle add template button click events.
*/
......@@ -145,46 +153,19 @@ ve.ui.MWTransclusionDialog.prototype.onBookletLayoutSet = function ( page ) {
!( page instanceof ve.ui.MWTemplatePage || page instanceof ve.ui.MWParameterPage ) ||
this.isReadOnly()
);
this.bookletLayout.getOutlineControls().removeButton.toggle( !(
(
page instanceof ve.ui.MWParameterPage &&
page.parameter.isRequired()
) || (
this.transclusionModel.getParts().length === 1 &&
page instanceof ve.ui.MWTemplatePlaceholderPage
)
) );
};
/**
* @inheritdoc
*/
ve.ui.MWTransclusionDialog.prototype.onReplacePart = function ( removed, added ) {
var single;
ve.ui.MWTransclusionDialog.super.prototype.onReplacePart.call( this, removed, added );
if ( this.transclusionModel.getParts().length === 0 ) {
this.addParameterButton.setDisabled( true );
this.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ) );
}
single = this.isSingleTemplateTransclusion();
this.actions.setAbilities( { mode: single } );
};
/**
* Checks if transclusion only contains a single template or template placeholder.
*
* @return {boolean} Transclusion only contains a single template or template placeholder
*/
ve.ui.MWTransclusionDialog.prototype.isSingleTemplateTransclusion = function () {
var parts = this.transclusionModel && this.transclusionModel.getParts();
return parts && parts.length === 1 && (
parts[ 0 ] instanceof ve.dm.MWTemplateModel ||
parts[ 0 ] instanceof ve.dm.MWTemplatePlaceholderModel
);
this.updateActionSet();
};
/**
......@@ -193,104 +174,197 @@ ve.ui.MWTransclusionDialog.prototype.isSingleTemplateTransclusion = function ()
ve.ui.MWTransclusionDialog.prototype.getPageFromPart = function ( part ) {
var page = ve.ui.MWTransclusionDialog.super.prototype.getPageFromPart.call( this, part );
if ( !page && part instanceof ve.dm.MWTransclusionContentModel ) {
return new ve.ui.MWTransclusionContentPage( part, part.getId(), { $overlay: this.$overlay, isReadOnly: this.isReadOnly() } );
page = new ve.ui.MWTransclusionContentPage( part, part.getId(), { $overlay: this.$overlay, isReadOnly: this.isReadOnly() } );
}
return page;
};
/**
* Set dialog mode.
*
* Auto mode will choose single if possible.
*
* @param {string} [mode='multiple'] Symbolic name of dialog mode, `multiple`, `single` or 'auto'
*/
ve.ui.MWTransclusionDialog.prototype.setMode = function ( mode ) {
var name, single,
modeCssClasses = ve.ui.MWTransclusionDialog.static.modeCssClasses;
if ( !page.menu ) {
// We do this here because the three possible MWTemplatePage, MWTemplatePlaceholderPage, and
// MWTransclusionContentPage don't share a common base class.
var upButton = new OO.ui.MenuOptionWidget( {
data: 'upButton',
icon: 'upTriangle',
label: ve.msg( 'visualeditor-dialog-transclusion-move-up' )
} ),
downButton = new OO.ui.MenuOptionWidget( {
data: 'downButton',
icon: 'downTriangle',
label: ve.msg( 'visualeditor-dialog-transclusion-move-down' )
} ),
removeButton = new OO.ui.MenuOptionWidget( {
data: 'removeButton',
icon: 'trash',
label: page instanceof ve.ui.MWTransclusionContentPage
? ve.msg( 'visualeditor-dialog-transclusion-remove-content' )
: ve.msg( 'visualeditor-dialog-transclusion-remove-template' ),
flags: [ 'destructive' ]
} );
page.menu = new OO.ui.ButtonMenuSelectWidget( {
icon: 'ellipsis',
// TODO: Should this button have a title?
// TODO: We can still assign a label. Does this even have an effect?
invisibleLabel: true,
framed: false,
flags: [ 'progressive' ],
menu: {
horizontalPosition: 'end',
// This is redundant, we toggle the move buttons below
items: page instanceof ve.ui.MWTemplatePlaceholderPage ? [ removeButton ] : [ upButton, downButton, removeButton ]
}
} );
page.menu.toggleClipping = function () {
// Hack
};
var self = this;
function movePart( page, dir ) {
if ( page.name.indexOf( '/' ) !== -1 ) {
console.log( 'I refuse to move sub-pages: ' + page.name );
return;
}
if ( this.transclusionModel ) {
if ( mode === 'auto' ) {
mode = this.isSingleTemplateTransclusion() ? 'single' : 'multiple';
var i = 0,
moveTargets = [],
currentMoveTarget = false;
for ( var partName in self.bookletLayout.pages ) {
var p = self.bookletLayout.pages[ partName ];
if ( !p ) {
continue;
}
if ( p instanceof ve.ui.MWTemplatePlaceholderPage ||
p instanceof ve.ui.MWTemplatePage ||
p instanceof ve.ui.MWTransclusionContentPage
) {
moveTargets.push( i );
}
if ( !modeCssClasses[ mode ] ) {
mode = 'multiple';
if ( p === page ) {
currentMoveTarget = moveTargets.length - 1;
}
i++;
}
var moveTarget = currentMoveTarget + dir;
if ( currentMoveTarget === false || !( moveTarget in moveTargets ) ) {
console.log( 'Can\'t move to ' + moveTarget + ' in', moveTargets );
return;
}
if ( this.mode !== mode ) {
this.mode = mode;
single = mode === 'single';
if ( this.$content ) {
for ( name in modeCssClasses ) {
// See static.modeCssClasses
// eslint-disable-next-line mediawiki/class-doc
this.$content.toggleClass( modeCssClasses[ name ], name === mode );
var pagesToMove = [];
i = 0;
for ( partName in self.bookletLayout.pages ) {
p = self.bookletLayout.pages[ partName ];
if ( !p ) {
continue;
}
if ( i >= moveTargets[ moveTarget ] &&
( !( moveTarget + 1 in moveTargets ) || i < moveTargets[ moveTarget + 1 ] )