summaryrefslogtreecommitdiff
path: root/resources/mediawiki.action/mediawiki.action.view.metadata.js
diff options
context:
space:
mode:
Diffstat (limited to 'resources/mediawiki.action/mediawiki.action.view.metadata.js')
-rw-r--r--resources/mediawiki.action/mediawiki.action.view.metadata.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/resources/mediawiki.action/mediawiki.action.view.metadata.js b/resources/mediawiki.action/mediawiki.action.view.metadata.js
new file mode 100644
index 00000000..378dd155
--- /dev/null
+++ b/resources/mediawiki.action/mediawiki.action.view.metadata.js
@@ -0,0 +1,39 @@
+// Exif metadata display for MediaWiki file uploads
+//
+// Add an expand/collapse link and collapse by default if set to
+// (with JS disabled, user will see all items)
+//
+
+jQuery( document ).ready( function( $ ) {
+ var showText = mw.msg( 'metadata-expand' );
+ var hideText = mw.msg( 'metadata-collapse' );
+
+ var $table = $( '#mw_metadata' );
+ var $tbody = $table.find( 'tbody' );
+ if ( !$tbody.length ) {
+ return;
+ }
+
+ var $row = $( '<tr></tr>' );
+ var $col = $( '<td colspan="2"></td>' );
+
+ var $link = $( '<a></a>', {
+ 'text': showText,
+ 'href': '#'
+ }).click(function() {
+ if ( $table.hasClass( 'collapsed' ) ) {
+ $( this ).text( hideText );
+ } else {
+ $( this ).text( showText );
+ }
+ $table.toggleClass( 'expanded collapsed' );
+ return false;
+ });
+
+ $col.append( $link );
+ $row.append( $col );
+ $tbody.append( $row );
+
+ // And collapse!
+ $table.addClass( 'collapsed' );
+} );