[ticket/10271] AJAXified Quick-mod tools.

Also made some improvements to the exceptions.

PHPBB3-10271
This commit is contained in:
Callum Macrae 2011-07-24 18:11:14 +01:00 committed by Igor Wiedler
parent efe872745f
commit 57fa45b0c4

View file

@ -103,14 +103,6 @@ phpbb.ajaxify = function(options, refresh, callback) {
$(selector).click(function() { $(selector).click(function() {
var act, data, path, that = this; var act, data, path, that = this;
if (typeof options.exception !== 'undefined')
{
if (options.exception(this))
{
return true;
}
}
function return_handler(res) function return_handler(res)
{ {
res = JSON.parse(res); res = JSON.parse(res);
@ -153,6 +145,7 @@ phpbb.ajaxify = function(options, refresh, callback) {
} }
} }
var run_exception = typeof options.exception === 'function';
if (is_form) if (is_form)
{ {
act = /action\[([a-z]+)\]/.exec(this.name); act = /action\[([a-z]+)\]/.exec(this.name);
@ -165,10 +158,18 @@ phpbb.ajaxify = function(options, refresh, callback) {
data += '&action=' + act; data += '&action=' + act;
} }
if (run_exception && options.exception($(this).parents('form'), act, data))
{
return true;
}
$.post(path, data, return_handler); $.post(path, data, return_handler);
} }
else else
{ {
if (run_exception && options.exception($(this).parents('form')))
{
return true;
}
$.get(this.href, return_handler); $.get(this.href, return_handler);
} }
@ -223,4 +224,14 @@ $('[data-ajax]').each(function() {
phpbb.ajaxify('#quickmodform'); phpbb.ajaxify({
selector: '#quickmodform',
exception: function(el, act, data) {
var d = data.split('=')[1];
if (d == 'make_normal')
{
return !(el.find('select option[value="make_global"]').length);
}
return !(d == 'lock' || d == 'unlock' || d == 'delete_topic' || d.slice(0, 5) == 'make_');
}
}, true);