From 57fa45b0c43ba732886ada24dbd6a590fd55d717 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Sun, 24 Jul 2011 18:11:14 +0100 Subject: [PATCH] [ticket/10271] AJAXified Quick-mod tools. Also made some improvements to the exceptions. PHPBB3-10271 --- phpBB/styles/script.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/phpBB/styles/script.js b/phpBB/styles/script.js index 99a73769b4..b73c392312 100644 --- a/phpBB/styles/script.js +++ b/phpBB/styles/script.js @@ -103,14 +103,6 @@ phpbb.ajaxify = function(options, refresh, callback) { $(selector).click(function() { var act, data, path, that = this; - if (typeof options.exception !== 'undefined') - { - if (options.exception(this)) - { - return true; - } - } - function return_handler(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) { act = /action\[([a-z]+)\]/.exec(this.name); @@ -165,10 +158,18 @@ phpbb.ajaxify = function(options, refresh, callback) { data += '&action=' + act; } + if (run_exception && options.exception($(this).parents('form'), act, data)) + { + return true; + } $.post(path, data, return_handler); } else { + if (run_exception && options.exception($(this).parents('form'))) + { + return true; + } $.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);