Mooeypoo has uploaded a new change for review.
https://gerrit.wikimedia.org/r/183729
Change subject: Add filename to the media dialog
......................................................................
Add filename to the media dialog
Show the currently used filename at the top of the media dialog so
it can be copied and used in other pages if needed.
Bug: T54459
Change-Id: Ib1844c997189f7ead0656c5a811d3cab70030f89
---
M VisualEditor.php
M modules/ve-mw/dm/models/ve.dm.MWImageModel.js
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
M modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
M modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
6 files changed, 46 insertions(+), 6 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/29/183729/1
diff --git a/VisualEditor.php b/VisualEditor.php
index 5e10605..635ee81 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -1007,6 +1007,7 @@
'visualeditor-dialog-media-alttext-section',
'visualeditor-dialog-media-change-image',
'visualeditor-dialog-media-choose-image',
+ 'visualeditor-dialog-media-content-filename',
'visualeditor-dialog-media-content-section',
'visualeditor-dialog-media-dimensionseparator',
'visualeditor-dialog-media-info-artist',
diff --git a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
index ee4cfe4..a241a63 100644
--- a/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
+++ b/modules/ve-mw/dm/models/ve.dm.MWImageModel.js
@@ -176,6 +176,8 @@
imgModel.cacheOriginalImageAttributes( attrs );
imgModel.setImageSource( attrs.src );
+ imgModel.setFilename( attrs.resource.replace( /^(\.+\/)File:*/, '' ) );
+
imgModel.setImageHref( attrs.href );
// Collect all the information
@@ -219,7 +221,7 @@
*/
ve.dm.MWImageModel.prototype.getHashObject = function () {
var hash = {
- normalizedSource: this.getNormalizedImageSource(),
+ filename: this.getFilename(),
altText: this.getAltText(),
type: this.getType(),
alignment: this.getAlignment(),
@@ -259,7 +261,7 @@
* @param {Object} [dimensions] New dimensions of the image
*/
ve.dm.MWImageModel.prototype.changeImageSource = function ( attrs, dimensions
) {
- var newDimensions, remoteFilename,
+ var newDimensions,
imageModel = this;
if ( attrs.mediaType ) {
@@ -270,7 +272,7 @@
}
if ( attrs.resource ) {
this.setImageResourceName( attrs.resource );
- remoteFilename = attrs.resource.replace( /^(\.+\/)*/, '' );
+ this.setFilename( attrs.resource.replace( /^(\.+\/)File:*/, ''
) );
}
if ( attrs.src ) {
@@ -284,8 +286,8 @@
this.scalable.clearMinDimensions();
// Call for updated scalable
- if ( remoteFilename ) {
- ve.dm.MWImageNode.static.getScalablePromise( remoteFilename
).done( function ( info ) {
+ if ( this.getFilename() ) {
+ ve.dm.MWImageNode.static.getScalablePromise( this.getFilename()
).done( function ( info ) {
imageModel.scalable.setOriginalDimensions( {
width: info.width,
height: info.height
@@ -1111,6 +1113,22 @@
};
/**
+ * Set the filename of the current image
+ * @param {string} filename Image filename
+ */
+ve.dm.MWImageModel.prototype.setFilename = function ( filename ) {
+ this.filename = filename;
+};
+
+/**
+ * Get the filename of the current image
+ * @returns {string} filename Image filename
+ */
+ve.dm.MWImageModel.prototype.getFilename = function () {
+ return this.filename;
+};
+
+/**
* Set image caption document.
*
* @param {ve.dm.Document} Image caption document
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index ac4a303..7ffe91a 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -74,6 +74,7 @@
"visualeditor-dialog-media-change-image": "Change image",
"visualeditor-dialog-media-choose-image": "Use this image",
"visualeditor-dialog-media-content-section": "Caption",
+ "visualeditor-dialog-media-content-filename": "File name",
"visualeditor-dialog-media-dimensionseparator": " × ",
"visualeditor-dialog-media-goback": "Back",
"visualeditor-dialog-media-info-artist": "Uploaded by $1",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index bee94a5..c9aa53f 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -84,6 +84,7 @@
"visualeditor-dialog-media-change-image": "Label for the button to
change the current image in the media edit dialog.",
"visualeditor-dialog-media-choose-image": "Label for the button to use
the selected image in the media edit dialog.",
"visualeditor-dialog-media-content-section": "Label for the image
content sub-section.\n{{Identical|Caption}}",
+ "visualeditor-dialog-media-content-filename": "Label for the image
filename.\n",
"visualeditor-dialog-media-dimensionseparator": "Label dimensions
separator in the image size display.{{Optional}}",
"visualeditor-dialog-media-goback": "Label for the button to go back to
edit settings in the media dialog.\n{{Identical|Go back}}",
"visualeditor-dialog-media-info-artist": "Label for the author
information for the image in the media dialog. $1 - Author name.",
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
index 4dd075c..c212939 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js
@@ -205,11 +205,19 @@
// Define fieldsets for image settings
+ // Filename
+ this.filenameFieldset = new OO.ui.FieldsetLayout( {
+ $: this.$,
+ label: ve.msg( 'visualeditor-dialog-media-content-filename' ),
+ icon: 'picture'
+ } );
+
// Caption
this.captionFieldset = new OO.ui.FieldsetLayout( {
$: this.$,
label: ve.msg( 'visualeditor-dialog-media-content-section' ),
- icon: 'parameter'
+ icon: 'parameter',
+ classes: [ 've-ui-mwMediaDialog-caption-fielset']
} );
// Alt text
@@ -374,6 +382,7 @@
// Initialization
this.mediaSearchPanel.$element.append( this.search.$element );
this.generalSettingsPage.$element.append(
+ this.filenameFieldset.$element,
this.captionFieldset.$element,
altTextFieldset.$element
);
@@ -1211,6 +1220,11 @@
// setting up the initial tools according to the model state
this.isSettingUpModel = true;
+ // Filename
+ this.filenameFieldset.setLabel(
+ this.imageModel.getFilename()
+ );
+
// Size widget
this.sizeErrorLabel.$element.hide();
this.sizeWidget.setScalable( this.imageModel.getScalable() );
diff --git a/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
b/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
index e02e461..2d0c404 100644
--- a/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
+++ b/modules/ve-mw/ui/styles/dialogs/ve.ui.MWMediaDialog.css
@@ -137,3 +137,8 @@
.ve-ui-mwMediaSearchWidget .oo-ui-searchWidget-results {
padding-right: 0;
}
+
+/* HACK: Override ooui specific 2em top margin */
+.ve-ui-mwMediaDialog-caption-fielset.oo-ui-labelElement.oo-ui-fieldsetLayout {
+ margin-top: 0;
+}
--
To view, visit https://gerrit.wikimedia.org/r/183729
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib1844c997189f7ead0656c5a811d3cab70030f89
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits