summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/wp-list-revisions.js
blob: db0485ef97a08720f41fe5036521dc00c6089bcc (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
/**
 * @output wp-includes/js/wp-list-revisions.js
 */

(function(w) {
	var init = function() {
		var pr = document.getElementById('post-revisions'),
		inputs = pr ? pr.getElementsByTagName('input') : [];
		pr.onclick = function() {
			var i, checkCount = 0, side;
			for ( i = 0; i < inputs.length; i++ ) {
				checkCount += inputs[i].checked ? 1 : 0;
				side = inputs[i].getAttribute('name');
				if ( ! inputs[i].checked &&
				( 'left' == side && 1 > checkCount || 'right' == side && 1 < checkCount && ( ! inputs[i-1] || ! inputs[i-1].checked ) ) &&
				! ( inputs[i+1] && inputs[i+1].checked && 'right' == inputs[i+1].getAttribute('name') ) )
					inputs[i].style.visibility = 'hidden';
				else if ( 'left' == side || 'right' == side )
					inputs[i].style.visibility = 'visible';
			}
		};
		pr.onclick();
	};
	if ( w && w.addEventListener )
		w.addEventListener('load', init, false);
	else if ( w && w.attachEvent )
		w.attachEvent('onload', init);
})(window);