summaryrefslogtreecommitdiff
path: root/skins/common/metadata.js
blob: a73b6937212e7b60d9d362074a9717cf07f2ab56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// 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)
//
// attachMetadataToggle("mw_metadata", "More...", "Fewer...");


function attachMetadataToggle(tableId, showText, hideText) {
	if (document.createTextNode) {
		var box = document.getElementById(tableId);
		if (!box)
			return false;

		var tbody = box.getElementsByTagName('tbody')[0];

		var row = document.createElement('tr');

		var col = document.createElement('td');
		col.colSpan = 2;

		var link = document.createElement('a');
		link.href = '#';

		link.onclick = function() {
			if (box.className == 'mw_metadata collapsed') {
				changeText(link, hideText);
				box.className = 'mw_metadata expanded';
			} else {
				changeText(link, showText);
				box.className = 'mw_metadata collapsed';
			}
			return false;
		}

		var text = document.createTextNode(hideText);

		link.appendChild(text);
		col.appendChild(link);
		row.appendChild(col);
		tbody.appendChild(row);

		// And collapse!
		link.onclick();

		return true;
	}
	return false;
}