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",
        "visualeditor-mwgallerydialog-mode-dropdown-label-packed": "Label for 
the packed option in the mode dropdown of the gallery dialog",
        "visualeditor-mwgallerydialog-mode-dropdown-label-packed-hover": "Label 
for the packed-hover option in the mode dropdown of the gallery dialog",
@@ -301,6 +302,7 @@
        "visualeditor-mwgallerydialog-show-filename-field-label": "Label for 
the show filename field of the gallery dialog",
        "visualeditor-mwgallerydialog-title": "Title for the gallery 
dialog\n{{Identical|Gallery}}",
        "visualeditor-mwgallerydialog-widths-field-label": "Label for the 
widths field of the gallery dialog",
+       "visualeditor-mwgallerydialog-widths-input-placeholder": "Placeholder 
for the widths input",
        "visualeditor-mwsignature-tool": "Used as name of the tool for 
inserting signatures.",
        "visualeditor-pagemenu-tooltip": "Tooltip text for the page menu which 
has the following items:\n* {{msg-mw|visualeditor-meta-tool}}\n* 
{{msg-mw|visualeditor-settings-tool}}\n* 
{{msg-mw|visualeditor-advancedsettings-tool}}\n* 
{{msg-mw|visualeditor-categories-tool}}\n* 
{{msg-mw|visualeditor-languages-tool}}\n* 
{{msg-mw|visualeditor-mweditmodesource-title}}\n* 
{{msg-mw|visualeditor-dialog-command-help-title}}",
        "visualeditor-pagetranslationwarning": "Edit notice shown when 
VisualEditor loads, warning users editing a translated page that it is not 
officially supported.",
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js
index 390b5f1..71fdf3d 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js
@@ -53,6 +53,9 @@
        this.highlightedItem = null;
        this.searchPanelVisible = false;
 
+       // Default settings
+       this.defaults = mw.config.get( 'wgVisualEditorConfig' ).galleryOptions;
+
        // Images and options cards
        indexLayout = new OO.ui.IndexLayout( {
                scrollable: false,
@@ -158,11 +161,17 @@
        } );
        this.widthsInput = new OO.ui.NumberInputWidget( {
                min: 0,
-               showButtons: false
+               showButtons: false,
+               input: {
+                       placeholder: ve.msg( 
'visualeditor-mwgallerydialog-widths-input-placeholder', 
this.defaults.imageWidth )
+               }
        } );
        this.heightsInput = new OO.ui.NumberInputWidget( {
                min: 0,
-               showButtons: false
+               showButtons: false,
+               input: {
+                       placeholder: ve.msg( 
'visualeditor-mwgallerydialog-heights-input-placeholder', 
this.defaults.imageHeight )
+               }
        } );
        this.perrowInput = new OO.ui.NumberInputWidget( {
                min: 0,
@@ -307,7 +316,7 @@
                        // Options card
 
                        // Set options
-                       mode = attributes && attributes.mode || 'traditional';
+                       mode = attributes && attributes.mode || 
this.defaults.mode;
                        caption = attributes && attributes.caption || '';
                        widths = attributes && parseInt( attributes.widths ) || 
'';
                        heights = attributes && parseInt( attributes.heights ) 
|| '';
@@ -588,8 +597,6 @@
 ve.ui.MWGalleryDialog.prototype.updateMwData = function ( mwData ) {
        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;
 
@@ -604,9 +611,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 +623,15 @@
        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 mode attribute if it is the same as the default
+       mwData.attrs.mode = mode === this.defaults.mode ? undefined : mode;
 };
 
 /* Registration */

-- 
To view, visit https://gerrit.wikimedia.org/r/303103
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I1adc7987fdeb1258ee87ce46acbab469ea18116e
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Tchanders <thalia.e.c...@googlemail.com>
Gerrit-Reviewer: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Tchanders <thalia.e.c...@googlemail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to