diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 50477eef90..2725d9fa0a 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -8,8 +8,9 @@ * activates any up / down icons that require it (the ones at the top or bottom). */ phpbb.add_ajax_callback('forum_down', function() { - el = $(this); - var tr = el.parents('tr'); + var el = $(this), + tr = el.parents('tr'); + if (tr.is(':first-child')) { el.parents('span').siblings('.up').html('Move up'); @@ -23,9 +24,12 @@ phpbb.add_ajax_callback('forum_down', function() { tr.prev().find('.down').html('Move down'); phpbb.ajaxify({selector: tr.prev().find('.down').children('a')}, false, 'forum_down'); } -}).add_ajax_callback('forum_up', function() { - el = $(this); - var tr = el.parents('tr'); +}); + +phpbb.add_ajax_callback('forum_up', function() { + var el = $(this), + tr = el.parents('tr'); + if (tr.is(':last-child')) { el.parents('span').siblings('.down').html('Move down'); @@ -47,9 +51,9 @@ phpbb.add_ajax_callback('forum_down', function() { * in the href with "deactivate", and vice versa. */ phpbb.add_ajax_callback('activate_deactivate', function(res) { - el = $(this); + var el = $(this), + new_href = el.attr('href'); el.text(res.text); - var new_href = el.attr('href'); if (new_href.indexOf('deactivate') !== -1) { new_href = new_href.replace('deactivate', 'activate') @@ -72,10 +76,13 @@ phpbb.add_ajax_callback('row_delete', function() { $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.attr('data-ajax'); + var $this = $(this), + ajax = $this.attr('data-ajax'), + fn; + if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; + fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } }); diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index 68f7cf4ed8..9c5f507bb8 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -61,8 +61,10 @@ phpbb.alert = function(title, msg, fadedark) { e.stopPropagation(); }); dark.one('click', function(e) { + var fade; + div.find('.alert_close').unbind('click'); - var fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; + fade = (typeof fadedark !== 'undefined' && !fadedark) ? div : dark; fade.fadeOut(phpbb.alert_time, function() { div.hide(); }); @@ -261,6 +263,8 @@ phpbb.ajaxify = function(options, refresh, callback) { */ function return_handler(res) { + var alert; + // Is a confirmation required? if (typeof res.S_CONFIRM_ACTION === 'undefined') { @@ -268,7 +272,7 @@ phpbb.ajaxify = function(options, refresh, callback) { // callbacks. if (typeof res.MESSAGE_TITLE !== 'undefined') { - var alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); + alert = phpbb.alert(res.MESSAGE_TITLE, res.MESSAGE_TEXT); } else { diff --git a/phpBB/styles/prosilver/template/ajax.js b/phpBB/styles/prosilver/template/ajax.js index a0f0c820ba..bf7551b8b8 100644 --- a/phpBB/styles/prosilver/template/ajax.js +++ b/phpBB/styles/prosilver/template/ajax.js @@ -3,10 +3,12 @@ // This callback finds the post from the delete link, and removes it. phpbb.add_ajax_callback('post_delete', function() { - var el = $(this); + var el = $(this), + post_id; + if (el.attr('data-refresh') === undefined) { - var post_id = el[0].href.split('&p=')[1]; + post_id = el[0].href.split('&p=')[1]; el.parents('#p' + post_id).fadeOut(function() { $(this).remove(); }); @@ -34,20 +36,25 @@ phpbb.add_ajax_callback('row_delete', function() { // This handles friend / foe additions removals. phpbb.add_ajax_callback('zebra', function(res) { + var zebra; + if (res.success) { - var zebra = $('.zebra'); + zebra = $('.zebra'); zebra.html(res.MESSAGE_TEXT); $(zebra.get(1)).remove(); } -});; +}); $('[data-ajax]').each(function() { - var $this = $(this), ajax = $this.attr('data-ajax'); + var $this = $(this), + ajax = $this.attr('data-ajax'), + fn; + if (ajax !== 'false') { - var fn = (ajax !== 'true') ? ajax : null; + fn = (ajax !== 'true') ? ajax : null; phpbb.ajaxify({selector: this}, $this.attr('data-refresh') !== undefined, fn); } });