summaryrefslogtreecommitdiffstats
path: root/wp-admin/js/edit-comments.js
blob: e1fc68fe067a95f6705e02480332f87ddbd6d765 (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
50
51
52
53
54
55
56
57
58
59
addLoadEvent(function() {
	theCommentList = new listMan('the-comment-list');
	if ( !theCommentList )
		return false;

	theExtraCommentList = new listMan('the-extra-comment-list');
	if ( theExtraCommentList ) {
		theExtraCommentList.showLink = 0;
		theExtraCommentList.altOffset = 1;
		if ( theExtraCommentList.theList && theExtraCommentList.theList.childNodes )
			var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
		else
			var commentNum = 0;
		var urlQ   = document.location.href.split('?');
		var params = urlQ[1] ? urlQ[1].toQueryParams() : [];
		var search = params['s'] ? params['s'] : '';
		var page   = params['apage'] ? params['apage'] : 1;
	}

	theCommentList.dimComplete = function(what,id,dimClass) {
		var m = document.getElementById('awaitmod');
		if ( document.getElementById(what + '-' + id).className.match(dimClass) )
			m.innerHTML = parseInt(m.innerHTML,10) + 1;
		else
			m.innerHTML = parseInt(m.innerHTML,10) - 1;
	}

	theCommentList.delComplete = function(what,id) {
		var m = document.getElementById('awaitmod');
		what = what.split('-')[0];
		if ( document.getElementById(what + '-' + id).className.match('unapproved') )
			m.innerHTML = parseInt(m.innerHTML,10) - 1;
		if ( theExtraCommentList && commentNum ) {
			var theMover = theExtraCommentList.theList.childNodes[0];
			Element.removeClassName(theMover,'alternate');
			theCommentList.theList.appendChild(theMover);
			theExtraCommentList.inputData += '&page=' + page;
			if ( search )
				theExtraCommentList.inputData += '&s=' + search; // trust the URL not the search box
			theExtraCommentList.addComplete = function() {
				if ( theExtraCommentList.theList.childNodes )
					var commentNum = $A(theExtraCommentList.theList.childNodes).findAll( function(i) { return Element.visible(i) } ).length;
				else
					var commentNum = 0;
			}
			theExtraCommentList.ajaxAdder( 'comment', 'ajax-response' ); // Dummy Request
		}
	}

	if ( theList ) // the post list: edit.php
		theList.delComplete = function() {
			var comments = document.getElementById('comments');
			var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments);
			var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList);
			setTimeout(commdel,705);
			setTimeout(listdel,705);
		}
});