aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/comments/frontend/postcomment.js
blob: 9934af9cedd398cd16787e61cde0484e45fc9086 (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
// For posting comments, both traditionally and via AJAX (postcomment.js)
HashOver.prototype.postComment = function (destination, form, button, callback, type, permalink, close, isReply, isEdit)
{
	type = type || 'main';
	permalink = permalink || '';
	isReply = isReply || false;
	isEdit = isEdit || false;

	// Return false if comment is invalid
	if (this.validateComment (false, form, type, permalink, isReply, isEdit) === false) {
		return false;
	}

	// Disable button
	setTimeout (function () {
		button.disabled = true;
	}, 500);

	// Post by sending an AJAX request if enabled
	if (this.postRequest) {
		return this.postRequest.apply (this, arguments);
	}

	// Re-enable button after 20 seconds
	setTimeout (function () {
		button.disabled = false;
	}, 20000);

	return true;
};