[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: Fetch default options for gallery dialog
jenkins-bot has submitted this change and it was merged. Change subject: Fetch default options for gallery dialog .. Fetch default options for gallery dialog Fetch default options for mode, image heights and image widths rather than hard-coding them. Bug: T139632 Change-Id: I1adc7987fdeb1258ee87ce46acbab469ea18116e --- M VisualEditor.hooks.php M extension.json M modules/ve-mw/i18n/en.json M modules/ve-mw/i18n/qqq.json M modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js 5 files changed, 25 insertions(+), 11 deletions(-) Approvals: Esanders: Looks good to me, approved jenkins-bot: Verified diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index f7c3e86..9b1a8e7 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -697,6 +697,7 @@ 'defaultUserOptions' => [ 'defaultthumbsize' => $thumbLimits[ $defaultUserOptions['thumbsize'] ] ], + 'galleryOptions' => $coreConfig->get( 'GalleryOptions' ), 'blacklist' => $veConfig->get( 'VisualEditorBrowserBlacklist' ), 'skins' => $veConfig->get( 'VisualEditorSupportedSkins' ), 'tabPosition' => $veConfig->get( 'VisualEditorTabPosition' ), diff --git a/extension.json b/extension.json index a3916d2..8311316 100644 --- a/extension.json +++ b/extension.json @@ -1753,6 +1753,7 @@ "visualeditor-mwgallerydialog-classes-input-placeholder", "visualeditor-mwgallerydialog-empty-gallery-message", "visualeditor-mwgallerydialog-heights-field-label", + "visualeditor-mwgallerydialog-heights-input-placeholder", "visualeditor-mwgallerydialog-mode-dropdown-label-nolines", "visualeditor-mwgallerydialog-mode-dropdown-label-packed", "visualeditor-mwgallerydialog-mode-dropdown-label-packed-hover", @@ -1767,7 +1768,8 @@ "visualeditor-mwgallerydialog-styles-input-placeholder", "visualeditor-mwgallerydialog-show-filename-field-label", "visualeditor-mwgallerydialog-title", - "visualeditor-mwgallerydialog-widths-field-label" + "visualeditor-mwgallerydialog-widths-field-label", + "visualeditor-mwgallerydialog-widths-input-placeholder" ], "targets": [ "desktop", diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json index acbeb92..5d85af9 100644 --- a/modules/ve-mw/i18n/en.json +++ b/modules/ve-mw/i18n/en.json @@ -275,6 +275,7 @@ "visualeditor-mwgallerydialog-classes-input-placeholder": "Class names, space-separated", "visualeditor-mwgallerydialog-empty-gallery-message": "The gallery is empty.", "visualeditor-mwgallerydialog-heights-field-label": "Image height", + "visualeditor-mwgallerydialog-heights-input-placeholder": "Default height: $1 px", "visualeditor-mwgallerydialog-mode-dropdown-label-nolines": "Traditional with no outlines", "visualeditor-mwgallerydialog-mode-dropdown-label-packed": "Packed", "visualeditor-mwgallerydialog-mode-dropdown-label-packed-hover": "Packed with captions on hover", @@ -290,6 +291,7 @@ "visualeditor-mwgallerydialog-show-filename-field-label": "Show filenames", "visualeditor-mwgallerydialog-title": "Gallery", "visualeditor-mwgallerydialog-widths-field-label": "Image width", + "visualeditor-mwgallerydialog-widths-input-placeholder": "Default width: $1 px", "visualeditor-mwsignature-tool": "Your signature", "visualeditor-pagemenu-tooltip": "Page options", "visualeditor-pagetranslationwarning": "You are editing a translatable page. Editing these in this editor is not yet officially supported.", diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json index 050ce1d..7cbf275 100644 --- a/modules/ve-mw/i18n/qqq.json +++ b/modules/ve-mw/i18n/qqq.json @@ -286,6 +286,7 @@ "visualeditor-mwgallerydialog-classes-input-placeholder": "Placeholder for the classes input of the gallery dialog", "visualeditor-mwgallerydialog-empty-gallery-message": "Empty gallery message for the gallery dialog", "visualeditor-mwgallerydialog-heights-field-label": "Label for the heights field of the gallery dialog", + "visualeditor-mwgallerydialog-heights-input-placeholder": "Placeholder for the heights input", "visualeditor-mwgallerydialog-mode-dropdown-label-nolines": "Label for the nolines option in the mode dropdown of the gallery dialog", "vis
[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: Fetch default options for gallery dialog
Tchanders has uploaded a new change for review. https://gerrit.wikimedia.org/r/303103 Change subject: Fetch default options for gallery dialog .. Fetch default options for gallery dialog Fetch default options for mode, image heights and image widths rather than hard-coding them. Bug: T139632 Change-Id: I1adc7987fdeb1258ee87ce46acbab469ea18116e --- M VisualEditor.hooks.php M modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js 2 files changed, 15 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/03/303103/1 diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php index f7c3e86..9b1a8e7 100644 --- a/VisualEditor.hooks.php +++ b/VisualEditor.hooks.php @@ -697,6 +697,7 @@ 'defaultUserOptions' => [ 'defaultthumbsize' => $thumbLimits[ $defaultUserOptions['thumbsize'] ] ], + 'galleryOptions' => $coreConfig->get( 'GalleryOptions' ), 'blacklist' => $veConfig->get( 'VisualEditorBrowserBlacklist' ), 'skins' => $veConfig->get( 'VisualEditorSupportedSkins' ), 'tabPosition' => $veConfig->get( 'VisualEditorTabPosition' ), diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js index 390b5f1..285a74e 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js @@ -252,7 +252,8 @@ caption, widths, heights, perrow, showFilename, classes, styles, dialog = this, - attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs; + attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs, + defaults = mw.config.get( 'wgVisualEditorConfig' ).galleryOptions; // Images card @@ -307,10 +308,10 @@ // Options card // Set options - mode = attributes && attributes.mode || 'traditional'; + mode = attributes && attributes.mode || defaults.mode; caption = attributes && attributes.caption || ''; - widths = attributes && parseInt( attributes.widths ) || ''; - heights = attributes && parseInt( attributes.heights ) || ''; + widths = attributes && parseInt( attributes.widths ) || defaults.imageWidth; + heights = attributes && parseInt( attributes.heights ) || defaults.imageHeight; perrow = attributes && attributes.perrow || ''; showFilename = attributes && attributes.showfilename === 'yes'; classes = attributes && attributes.class || ''; @@ -589,9 +590,9 @@ var i, ilen, mode, caption, widths, heights, perrow, showFilename, classes, styles, selectedNode = this.selectedNode, - oldMode = selectedNode && selectedNode.getAttribute( 'mw' ).attrs.mode, extsrc = '', - items = this.galleryGroup.items; + items = this.galleryGroup.items, + defaults = mw.config.get( 'wgVisualEditorConfig' ).galleryOptions; // Parent method ve.ui.MWGalleryDialog.super.prototype.updateMwData.call( this, mwData ); @@ -604,9 +605,6 @@ // Get data from options card mode = this.modeDropdown.getMenu().getSelectedItem().getData(); - if ( oldMode === undefined && mode === 'traditional' ) { - mode = undefined; - } caption = this.captionInput.getValue(); widths = this.widthsInput.getValue(); heights = this.heightsInput.getValue(); @@ -619,12 +617,17 @@ mwData.body.extsrc = extsrc + '\n'; mwData.attrs.mode = mode || undefined; mwData.attrs.caption = caption || undefined; - mwData.attrs.widths = widths ? widths + 'px' : undefined; - mwData.attrs.heights = heights ? heights + 'px' : undefined; + mwData.attrs.widths = widths || undefined; + mwData.attrs.heights = heights || undefined; mwData.attrs.perrow = perrow || undefined; mwData.attrs.showfilename = showFilename ? 'yes' : undefined; mwData.attrs.classes = classes || undefined; mwData.attrs.styles = styles || undefined; + + // Unset attributes with defaults if they are the same as the default + mwData.attrs.mode = mode === defaults.mode ? undefined : mode; + mwData.attrs.widths = widths === defaults.imageWidth.toString() ? undefined : widths + 'px'; + mwData.attrs.he