From 857298e748685a6796a2ad1be4727098651c2688 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 14 Nov 2012 16:31:46 +0100 Subject: [ticket/11198] Correctly set links after an item is moved up/down with AJAX PHPBB3-11198 --- phpBB/adm/style/acp_forums.html | 8 ++++---- phpBB/adm/style/ajax.js | 36 +++++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 15 deletions(-) (limited to 'phpBB/adm') diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index cb9cae6c0d..9a3706c2f0 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -454,12 +454,12 @@ {ICON_MOVE_UP_DISABLED} - {ICON_MOVE_DOWN} + {ICON_MOVE_DOWN} - {ICON_MOVE_UP} - {ICON_MOVE_DOWN} + {ICON_MOVE_UP} + {ICON_MOVE_DOWN} - {ICON_MOVE_UP} + {ICON_MOVE_UP} {ICON_MOVE_DOWN_DISABLED} {ICON_MOVE_UP_DISABLED} diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 12541cb057..4dfe00c5dd 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -10,12 +10,12 @@ var img_templates = { }; /** - * The following callbacks are for reording forums in acp_forums. forum_down - * is triggered when a forum is moved down, and forum_up is triggered when - * a forum is moved up. It moves the row up or down, and deactivates / + * The following callbacks are for reording items. row_down + * is triggered when a forum is moved down, and row_up is triggered when + * an item is moved up. It moves the row up or down, and deactivates / * activates any up / down icons that require it (the ones at the top or bottom). */ -phpbb.add_ajax_callback('forum_down', function() { +phpbb.add_ajax_callback('row_down', function() { var el = $(this), tr = el.parents('tr'); @@ -26,16 +26,19 @@ phpbb.add_ajax_callback('forum_down', function() { tr.next().find('.up').html(img_templates.up_disabled); + var down_img = img_templates.down.clone().attr('href', tr.next().attr('data-down')); + tr.next().find('.down').html(down_img); + phpbb.ajaxify({ selector: el.parents('span').siblings('.up').children('a'), - callback: 'forum_up', + callback: 'row_up', overlay: false }); } tr.insertAfter(tr.next()); - if (tr.is(':last-child')) + if (!tr.prev().is(':first-child') && tr.is(':last-child')) { el.replaceWith(img_templates.down_disabled); @@ -44,13 +47,17 @@ phpbb.add_ajax_callback('forum_down', function() { phpbb.ajaxify({ selector: tr.prev().find('.down').children('a'), - callback: 'forum_down', + callback: 'row_down', overlay: false }); } + else if (tr.is(':last-child')) + { + el.replaceWith(img_templates.down_disabled); + } }); -phpbb.add_ajax_callback('forum_up', function() { +phpbb.add_ajax_callback('row_up', function() { var el = $(this), tr = el.parents('tr'); @@ -61,16 +68,19 @@ phpbb.add_ajax_callback('forum_up', function() { tr.prev().find('.down').html(img_templates.down_disabled); + var up_img = img_templates.down.clone().attr('href', tr.prev().attr('data-up')); + tr.prev().find('.up').html(up_img); + phpbb.ajaxify({ selector: el.parents('span').siblings('.down').children('a'), - callback: 'forum_down', + callback: 'row_down', overlay: false }); } tr.insertBefore(tr.prev()); - if (tr.is(':first-child')) + if (!tr.next().is(':last-child') && tr.is(':first-child')) { el.replaceWith(img_templates.up_disabled); @@ -79,10 +89,14 @@ phpbb.add_ajax_callback('forum_up', function() { phpbb.ajaxify({ selector: tr.next().find('.up').children('a'), - callback: 'forum_up', + callback: 'row_up', overlay: false }); } + else if (tr.is(':first-child')) + { + el.replaceWith(img_templates.up_disabled); + } }); /** -- cgit v1.2.1 From e39947e57e8b39319bb34597d2fb0a706bd1bc44 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 14 Nov 2012 23:30:29 +0100 Subject: [ticket/11198] Store the swapping partners in vars and simplify the logic PHPBB3-11198 --- phpBB/adm/style/ajax.js | 86 +++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 39 deletions(-) (limited to 'phpBB/adm') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index 4dfe00c5dd..d780196173 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -11,92 +11,100 @@ var img_templates = { /** * The following callbacks are for reording items. row_down - * is triggered when a forum is moved down, and row_up is triggered when + * is triggered when an item is moved down, and row_up is triggered when * an item is moved up. It moves the row up or down, and deactivates / * activates any up / down icons that require it (the ones at the top or bottom). */ phpbb.add_ajax_callback('row_down', function() { var el = $(this), - tr = el.parents('tr'); - + tr = el.parents('tr'), + tr_swap = tr.next(); + + /** + * If the element was the first one, we have to: + * - Add the up-link to the row we moved + * - Remove the up-link on the next row + */ if (tr.is(':first-child')) { var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); - el.parents('span').siblings('.up').html(up_img); - - tr.next().find('.up').html(img_templates.up_disabled); - - var down_img = img_templates.down.clone().attr('href', tr.next().attr('data-down')); - tr.next().find('.down').html(down_img); + tr.find('.up').html(up_img); phpbb.ajaxify({ - selector: el.parents('span').siblings('.up').children('a'), + selector: tr.find('.up').children('a'), callback: 'row_up', overlay: false }); + + tr_swap.find('.up').html(img_templates.up_disabled); } - tr.insertAfter(tr.next()); + tr.insertAfter(tr_swap); - if (!tr.prev().is(':first-child') && tr.is(':last-child')) + /** + * As well as: + * - Remove the down-link on the moved row, if it is now the last row + * - Add the down-link to the next row, if it was the last row + */ + if (tr.is(':last-child')) { - el.replaceWith(img_templates.down_disabled); + tr.find('.down').html(img_templates.down_disabled); - var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); - tr.prev().find('.down').html(down_img); + var down_img = img_templates.down.clone().attr('href', tr_swap.attr('data-down')); + tr_swap.find('.down').html(down_img); phpbb.ajaxify({ - selector: tr.prev().find('.down').children('a'), + selector: tr_swap.find('.down').children('a'), callback: 'row_down', overlay: false }); } - else if (tr.is(':last-child')) - { - el.replaceWith(img_templates.down_disabled); - } }); phpbb.add_ajax_callback('row_up', function() { var el = $(this), - tr = el.parents('tr'); - + tr = el.parents('tr'), + tr_swap = tr.prev(); + + /** + * If the element was the last one, we have to: + * - Add the down-link to the row we moved + * - Remove the down-link on the next row + */ if (tr.is(':last-child')) { var down_img = img_templates.down.clone().attr('href', tr.attr('data-down')); - el.parents('span').siblings('.down').html(down_img); - - tr.prev().find('.down').html(img_templates.down_disabled); - - var up_img = img_templates.down.clone().attr('href', tr.prev().attr('data-up')); - tr.prev().find('.up').html(up_img); + tr.find('.down').html(down_img); phpbb.ajaxify({ - selector: el.parents('span').siblings('.down').children('a'), + selector: tr.find('.down').children('a'), callback: 'row_down', overlay: false }); + + tr_swap.find('.down').html(img_templates.down_disabled); } - tr.insertBefore(tr.prev()); + tr.insertBefore(tr_swap); - if (!tr.next().is(':last-child') && tr.is(':first-child')) + /** + * As well as: + * - Remove the up-link on the moved row, if it is now the first row + * - Add the up-link to the previous row, if it was the first row + */ + if (tr.is(':first-child')) { - el.replaceWith(img_templates.up_disabled); + tr.find('.up').html(img_templates.up_disabled); - var up_img = img_templates.up.clone().attr('href', tr.attr('data-up')); - tr.next().find('.up').html(up_img); + var up_img = img_templates.up.clone().attr('href', tr_swap.attr('data-up')); + tr_swap.find('.up').html(up_img); phpbb.ajaxify({ - selector: tr.next().find('.up').children('a'), + selector: tr_swap.find('.up').children('a'), callback: 'row_up', overlay: false }); } - else if (tr.is(':first-child')) - { - el.replaceWith(img_templates.up_disabled); - } }); /** -- cgit v1.2.1 From 132163d4ec2c7758afb82071af2b3c68965e2c4d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 15 Nov 2012 16:26:36 +0100 Subject: [ticket/11198] Remove additional asterix as /** is doc-block only PHPBB3-11198 --- phpBB/adm/style/ajax.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/adm') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index d780196173..a3a77df89b 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -20,7 +20,7 @@ phpbb.add_ajax_callback('row_down', function() { tr = el.parents('tr'), tr_swap = tr.next(); - /** + /* * If the element was the first one, we have to: * - Add the up-link to the row we moved * - Remove the up-link on the next row @@ -41,7 +41,7 @@ phpbb.add_ajax_callback('row_down', function() { tr.insertAfter(tr_swap); - /** + /* * As well as: * - Remove the down-link on the moved row, if it is now the last row * - Add the down-link to the next row, if it was the last row @@ -66,7 +66,7 @@ phpbb.add_ajax_callback('row_up', function() { tr = el.parents('tr'), tr_swap = tr.prev(); - /** + /* * If the element was the last one, we have to: * - Add the down-link to the row we moved * - Remove the down-link on the next row @@ -87,7 +87,7 @@ phpbb.add_ajax_callback('row_up', function() { tr.insertBefore(tr_swap); - /** + /* * As well as: * - Remove the up-link on the moved row, if it is now the first row * - Add the up-link to the previous row, if it was the first row -- cgit v1.2.1 From c7f701c1e71caa416217b5438274785f3ab0c2af Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 16 Nov 2012 11:41:39 +0100 Subject: [ticket/11209] Clone disable moving images to allow multiple per page The disable images need to be clone rather then moved, in order to allow multiple disable images per page. We do not have such a case at the moment but it will be required for the new teampage/legend ACP section. PHPBB3-11209 --- phpBB/adm/style/ajax.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/adm') diff --git a/phpBB/adm/style/ajax.js b/phpBB/adm/style/ajax.js index a3a77df89b..3ccb368665 100644 --- a/phpBB/adm/style/ajax.js +++ b/phpBB/adm/style/ajax.js @@ -36,7 +36,7 @@ phpbb.add_ajax_callback('row_down', function() { overlay: false }); - tr_swap.find('.up').html(img_templates.up_disabled); + tr_swap.find('.up').html(img_templates.up_disabled.clone()); } tr.insertAfter(tr_swap); @@ -48,7 +48,7 @@ phpbb.add_ajax_callback('row_down', function() { */ if (tr.is(':last-child')) { - tr.find('.down').html(img_templates.down_disabled); + tr.find('.down').html(img_templates.down_disabled.clone()); var down_img = img_templates.down.clone().attr('href', tr_swap.attr('data-down')); tr_swap.find('.down').html(down_img); @@ -82,7 +82,7 @@ phpbb.add_ajax_callback('row_up', function() { overlay: false }); - tr_swap.find('.down').html(img_templates.down_disabled); + tr_swap.find('.down').html(img_templates.down_disabled.clone()); } tr.insertBefore(tr_swap); @@ -94,7 +94,7 @@ phpbb.add_ajax_callback('row_up', function() { */ if (tr.is(':first-child')) { - tr.find('.up').html(img_templates.up_disabled); + tr.find('.up').html(img_templates.up_disabled.clone()); var up_img = img_templates.up.clone().attr('href', tr_swap.attr('data-up')); tr_swap.find('.up').html(up_img); -- cgit v1.2.1