1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 12:03:21 +01:00

[feature/ajax] Stylistic JavaScript adjustments

PHPBB3-10270
This commit is contained in:
Igor Wiedler 2012-02-08 19:02:16 +01:00
parent b100bb9a69
commit 628074bf70
3 changed files with 35 additions and 17 deletions

View File

@ -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('<a href="' + tr.attr('data-up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
@ -23,9 +24,12 @@ phpbb.add_ajax_callback('forum_down', function() {
tr.prev().find('.down').html('<a href="' + tr.attr('data-down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
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('<a href="' + tr.attr('data-down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
@ -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);
}
});

View File

@ -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
{

View File

@ -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);
}
});