Fixes for the translation statistics script - HTML, organisation, etc.
[mediawiki.git] / skins / common / metadata.js
blob9f7a8e01b7cd0f956a268fc273049d016db89ff4
1 // Exif metadata display for MediaWiki file uploads
2 //
3 // Add an expand/collapse link and collapse by default if set to
4 // (with JS disabled, user will see all items)
5 //
6 // attachMetadataToggle("mw_metadata", "More...", "Fewer...");
9 function attachMetadataToggle(tableId, showText, hideText) {
10         if (document.createTextNode) {
11                 var box = document.getElementById(tableId);
12                 if (!box)
13                         return false;
14                 
15                 var tbody = box.getElementsByTagName('tbody')[0];
16                 
17                 var row = document.createElement('tr');
18                 
19                 var col = document.createElement('td');
20                 col.colSpan = 2;
21                 
22                 var link = document.createElement('a');
23                 link.href = '#';
24                 
25                 link.onclick = function() {
26                         if (box.className == 'mw_metadata collapsed') {
27                                 changeText(link, hideText);
28                                 box.className = 'mw_metadata expanded';
29                         } else {
30                                 changeText(link, showText);
31                                 box.className = 'mw_metadata collapsed';
32                         }
33                         return false;
34                 }
35                 
36                 var text = document.createTextNode(hideText);
37                 
38                 link.appendChild(text);
39                 col.appendChild(link);
40                 row.appendChild(col);
41                 tbody.appendChild(row);
42                 
43                 // And collapse!
44                 link.onclick();
45                 
46                 return true;
47         }
48         return false;