aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/styles/prosilver/template/ajax.js
blob: b24ab6d4d7d045cdf0373b5fff2c2be41d2bfbe2 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(function($) {  // Avoid conflicts with other libraries


//This callback finds the post from the delete link, and removes it.
phpbb.add_ajax_callback('post_delete', function(el) {
	if ($(this).data('refresh') === undefined)
	{
		var pid = el.href.split('&p=')[1];
		$(el).parents('div #p' + pid).fadeOut(function() {
			$(this).remove();
		});
	}
});

// This callback removes the approve / disapprove div or link.
phpbb.add_ajax_callback('post_approve', function(el, res, act) {
	$(el).parents((act === 'approve') ? '.rules' : '.post').fadeOut(function() {
		$(this).remove();
	});
});

// This callback handles the removal of the quick reply form.
phpbb.add_ajax_callback('qr-submit', function(el) {
	$(el).parents('form').fadeOut(function() {
		$(this).remove();
	});
});

// This removes the parent row of the link or form that fired the callback.
phpbb.add_ajax_callback('row_delete', function(el) {
	var tr = $(el).parents('tr');
	tr.remove();
});

// This handles friend / foe additions removals.
phpbb.add_ajax_callback('zebra', function(el, res) {
	if (res.success) {
		var zebra = $('.zebra');
		zebra.html(res.MESSAGE_TEXT);
		$(zebra.get(1)).remove();
	}
});;



$('[data-ajax]').each(function() {
	var $this = $(this);
	if ($this.data('ajax') !== 'false')
	{
		var fn = ($this.data('ajax') !== 'true') ? $this.data('ajax') : null;
		phpbb.ajaxify({selector: this}, $this.data('refresh') !== undefined, fn);
	}
});



/**
 * This AJAXifies the quick-mod tools. The reason it cannot be a standard
 * callback / data attribute is that it requires exceptions - some of the options
 * can be ajaxified, while others cannot.
 */
phpbb.ajaxify({
	selector: '#quickmodform',
	exception: function(el, act, data) {
		var action = phpbb.parse_querystring(data).action;
		if (action === 'make_normal')
		{
			return !(el.find('select option[value="make_global"]').length);
		}
		else if (action.slice(-4) === 'lock')
		{
			return false;
		}
		return !(action === 'delete_topic' || action.slice(0, 5) === 'make_');
	}
}, true);



})(jQuery); // Avoid conflicts with other libraries