From 40738c832af93cb433f16ccc9b9029e6158d2d25 Mon Sep 17 00:00:00 2001 From: gladoscc Date: Tue, 13 Jan 2015 13:51:46 +1100 Subject: [PATCH] Display the file name in metadata panel This patch adds the file name to the metadata panel, after the license item. The namespace prefix is included and set to a static 'File:'. The Title class already converts underscore to spaces. The icon is from @Pginer-WMF. PS: This has been a frequent annoyance for me, I'm glad to be working on this patch! Bug: T76680 Change-Id: I7d1f4ce67a6776ac017f8afe49cb3102b267af5c --- resources/mmv/ui/img/file.svg | 30 +++++++++++++++++++ resources/mmv/ui/mmv.ui.metadataPanel.js | 35 ++++++++++++++++++++++ resources/mmv/ui/mmv.ui.metadataPanel.less | 10 +++++++ 3 files changed, 75 insertions(+) create mode 100644 resources/mmv/ui/img/file.svg diff --git a/resources/mmv/ui/img/file.svg b/resources/mmv/ui/img/file.svg new file mode 100644 index 000000000..f1f7a6343 --- /dev/null +++ b/resources/mmv/ui/img/file.svg @@ -0,0 +1,30 @@ + + + +image/svg+xml + + \ No newline at end of file diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.js b/resources/mmv/ui/mmv.ui.metadataPanel.js index c05b2f263..d43c61d09 100644 --- a/resources/mmv/ui/mmv.ui.metadataPanel.js +++ b/resources/mmv/ui/mmv.ui.metadataPanel.js @@ -153,6 +153,10 @@ this.$licenseLi.addClass( 'empty' ); this.$permissionLink.hide(); + this.$filename.empty(); + this.$filenamePrefix.empty(); + this.$filenameLi.addClass( 'empty' ); + this.$username.empty(); this.$usernameLi.addClass( 'empty' ); @@ -298,6 +302,7 @@ .appendTo( this.$imageLinkDiv ); this.initializeLicense(); + this.initializeFilename(); this.initializeUploader(); this.initializeDatetime(); this.initializeLocation(); @@ -337,6 +342,23 @@ } ); }; + /** + * Initializes the filename element. + */ + MPP.initializeFilename = function () { + this.$filenameLi = $( '
  • ' ) + .addClass( 'mw-mmv-filename-li empty' ) + .appendTo( this.$imageLinks ); + + this.$filenamePrefix = $( '' ) + .addClass( 'mw-mmv-filename-prefix' ) + .appendTo( this.$filenameLi ); + + this.$filename = $( '' ) + .addClass( 'mw-mmv-filename' ) + .appendTo( this.$filenameLi ); + }; + /** * Initializes the upload date/time element. */ @@ -483,6 +505,17 @@ this.$datetimeLi.removeClass( 'empty' ); }; + /** + * Sets the file name in the panel. + * @param {string} filename The file name to set, without prefix + */ + MPP.setFileName = function ( filename ) { + this.$filenamePrefix.text( 'File:' ); + this.$filename.text( filename ); + + this.$filenameLi.removeClass( 'empty' ); + }; + /** * Set source and author. * @param {string} attribution Custom attribution string @@ -716,6 +749,8 @@ this.setLicense( imageData.license, imageData.descriptionUrl ); + this.setFileName( imageData.title.getMainText() ); + // these handle text truncation and should be called when everything that can push text down // (e.g. floated buttons) has already been laid out this.setTitle( image, imageData ); diff --git a/resources/mmv/ui/mmv.ui.metadataPanel.less b/resources/mmv/ui/mmv.ui.metadataPanel.less index 215847802..6932c8977 100644 --- a/resources/mmv/ui/mmv.ui.metadataPanel.less +++ b/resources/mmv/ui/mmv.ui.metadataPanel.less @@ -201,6 +201,11 @@ background-image: url(img/pd.svg); } + &.mw-mmv-filename-li:before { + /* @embed */ + background-image: url(img/file.svg); + } + &.mw-mmv-datetime-li:before { /* @embed */ background-image: url(img/time.svg); @@ -229,6 +234,11 @@ text-align: right; } +.mw-mmv-filename-prefix { + padding-right: 4px; + cursor: text; +} + .mw-mmv-title-para, .mw-mmv-credit, .mw-mmv-image-desc {