MarkTraceur has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/89128


Change subject: Add source and authour to the title div
......................................................................

Add source and authour to the title div

May have some bugs w/r/t more complex formatting, needs moar testing.

Change-Id: Id835fd8133b9762e7bec10783f4fa4b983177aed
---
M MultimediaViewer.i18n.php
M MultimediaViewer.php
M css/ext.multimediaViewer.css
M js/ext.multimediaViewer.js
4 files changed, 65 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MultimediaViewer 
refs/changes/28/89128/1

diff --git a/MultimediaViewer.i18n.php b/MultimediaViewer.i18n.php
index e5defdb..1df85e4 100644
--- a/MultimediaViewer.i18n.php
+++ b/MultimediaViewer.i18n.php
@@ -31,6 +31,7 @@
        'multimediaviewer-pref-desc' => 'Enables a nicer-looking multimedia 
viewer for images on pages that have thumbnails. Uses a third party lightbox 
library and JavaScript.',
        'multimediaviewer-file-page' => 'Go to corresponding file page',
        'multimediaviewer-userpage-link' => '{{GENDER|$1|Uploaded}} by $1',
+       'multimediaviewer-credit' => '$1 - $2',
 );
 
 /** Message documentation (Message documentation)
@@ -42,6 +43,7 @@
        'multimediaviewer-pref-desc' => 'Description of preference',
        'multimediaviewer-file-page' => 'Text for a link to the file page for 
an image.',
        'multimediaviewer-userpage-link' => 'Link to the user page for the 
uploader of the image. $1 is the username of the uploader.',
+       'multimediaviewer-credit' => 'Credit line for images - $1 is HTML 
describing the authour, $2 is HTML describing the source. Neither are 
usernames, so GENDER is useless.',
 );
 
 /** German (Deutsch)
diff --git a/MultimediaViewer.php b/MultimediaViewer.php
index 5554191..d90f6fa 100644
--- a/MultimediaViewer.php
+++ b/MultimediaViewer.php
@@ -72,6 +72,7 @@
        'messages' => array(
                'multimediaviewer-file-page',
                'multimediaviewer-userpage-link',
+               'multimediaviewer-credit',
        ),
 ), $moduleInfo );
 
diff --git a/css/ext.multimediaViewer.css b/css/ext.multimediaViewer.css
index 4d65aa5..50747fb 100644
--- a/css/ext.multimediaViewer.css
+++ b/css/ext.multimediaViewer.css
@@ -89,6 +89,10 @@
        padding: 0px;
 }
 
+.mw-mlb-author {
+       font-weight: bold;
+}
+
 .mw-mlb-image-metadata {
        margin-top: 30px;
        width: 100%;
diff --git a/js/ext.multimediaViewer.js b/js/ext.multimediaViewer.js
index 95dbdd7..cdb2a56 100644
--- a/js/ext.multimediaViewer.js
+++ b/js/ext.multimediaViewer.js
@@ -63,7 +63,7 @@
                                viewer.lightbox.open();
 
                                viewer.fetchImageInfo( fileTitle, function ( 
imageInfo ) {
-                                       var username;
+                                       var username, extmeta, source, author;
 
                                        viewer.lightbox.images[index].src = 
imageInfo.imageinfo[0].url;
                                        viewer.lightbox.open();
@@ -81,6 +81,42 @@
                                        }
 
                                        
viewer.lightbox.iface.$usernameLi.toggleClass( 'empty', username );
+
+                                       extmeta = 
imageInfo.imageinfo[0].extendedmetadata;
+
+                                       if ( extmeta ) {
+                                               source = extmeta.Credit;
+                                               author = extmeta.Artist;
+
+                                               if ( source ) {
+                                                       source = source['*'];
+                                                       
viewer.lightbox.iface.$source.html( source );
+                                               }
+
+                                               if ( author ) {
+                                                       author = author['*'];
+                                                       
viewer.lightbox.iface.$author.html( author );
+                                               }
+
+                                               if ( source && author ) {
+                                                       
viewer.lightbox.iface.$credit.html(
+                                                               mw.message(
+                                                                       
'multimediaviewer-credit',
+                                                                       
viewer.lightbox.iface.$author.get( 0 ).outerHTML,
+                                                                       
viewer.lightbox.iface.$source.get( 0 ).outerHTML
+                                                               ).plain()
+                                                       );
+                                               } else {
+                                                       // Clobber the contents 
and only have one of the fields
+                                                       if ( source ) {
+                                                               
viewer.lightbox.iface.$credit.html( viewer.lightbox.iface.$source );
+                                                       } else if ( author ) {
+                                                               
viewer.lightbox.iface.$credit.html( viewer.lightbox.iface.$author );
+                                                       }
+                                               }
+
+                                               
viewer.lightbox.iface.$credit.toggleClass( 'empty', source || author );
+                                       }
                                } );
 
                                return false;
@@ -134,9 +170,29 @@
                        this.$title = $( '<p>' )
                                .addClass( 'mw-mlb-title' );
 
+                       this.$source = $( '<span>' )
+                               .addClass( 'mw-mlb-source' );
+
+                       this.$author = $( '<span>' )
+                               .addClass( 'mw-mlb-author' );
+
+                       this.$credit = $( '<p>' )
+                               .addClass( 'mw-mlb-credit' )
+                               .addClass( 'empty' )
+                               .html(
+                                       mw.message(
+                                               'multimediaviewer-credit',
+                                               this.$author.get( 0 ).outerHTML,
+                                               this.$source.get( 0 ).outerHTML
+                                       ).plain()
+                               );
+
                        this.$titleDiv = $( '<div>' )
                                .addClass( 'mw-mlb-title-div' )
-                               .html( this.$title );
+                               .append(
+                                       this.$title,
+                                       this.$credit
+                               );
 
                        this.$controlBar.append( this.$titleDiv );
                } );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id835fd8133b9762e7bec10783f4fa4b983177aed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MultimediaViewer
Gerrit-Branch: master
Gerrit-Owner: MarkTraceur <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to