1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-10 19:56:52 +02:00

[ticket/10281] AJAXified reordering forums in the ACP.

PHPBB3-10281
This commit is contained in:
Callum Macrae
2011-07-27 12:57:58 +01:00
committed by Igor Wiedler
parent 22c6953c11
commit bb7a03f738
4 changed files with 49 additions and 9 deletions

View File

@ -443,7 +443,7 @@
<col class="row1" /><col class="row1" /><col class="row2" /> <col class="row1" /><col class="row1" /><col class="row2" />
<tbody> <tbody>
<!-- BEGIN forums --> <!-- BEGIN forums -->
<tr> <tr data-down="{forums.U_MOVE_DOWN}" data-up="{forums.U_MOVE_UP}">
<td style="width: 5%; text-align: center;">{forums.FOLDER_IMAGE}</td> <td style="width: 5%; text-align: center;">{forums.FOLDER_IMAGE}</td>
<td> <td>
<!-- IF forums.FORUM_IMAGE --><div style="float: {S_CONTENT_FLOW_BEGIN}; margin-right: 5px;">{forums.FORUM_IMAGE}</div><!-- ENDIF --> <!-- IF forums.FORUM_IMAGE --><div style="float: {S_CONTENT_FLOW_BEGIN}; margin-right: 5px;">{forums.FORUM_IMAGE}</div><!-- ENDIF -->
@ -453,17 +453,17 @@
</td> </td>
<td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;"> <td style="vertical-align: top; width: 100px; text-align: right; white-space: nowrap;">
<!-- IF forums.S_FIRST_ROW && not forums.S_LAST_ROW --> <!-- IF forums.S_FIRST_ROW && not forums.S_LAST_ROW -->
{ICON_MOVE_UP_DISABLED} <span class="up">{ICON_MOVE_UP_DISABLED}</span>
<a href="{forums.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down"><a href="{forums.U_MOVE_DOWN}" data-ajax="forum_down">{ICON_MOVE_DOWN}</a></span>
<!-- ELSEIF not forums.S_FIRST_ROW && not forums.S_LAST_ROW --> <!-- ELSEIF not forums.S_FIRST_ROW && not forums.S_LAST_ROW -->
<a href="{forums.U_MOVE_UP}">{ICON_MOVE_UP}</a> <span class="up"><a href="{forums.U_MOVE_UP}" data-ajax="forum_up">{ICON_MOVE_UP}</a></span>
<a href="{forums.U_MOVE_DOWN}">{ICON_MOVE_DOWN}</a> <span class="down"><a href="{forums.U_MOVE_DOWN}" data-ajax="forum_down">{ICON_MOVE_DOWN}</a></span>
<!-- ELSEIF forums.S_LAST_ROW && not forums.S_FIRST_ROW --> <!-- ELSEIF forums.S_LAST_ROW && not forums.S_FIRST_ROW -->
<a href="{forums.U_MOVE_UP}">{ICON_MOVE_UP}</a> <span class="up"><a href="{forums.U_MOVE_UP}" data-ajax="forum_up">{ICON_MOVE_UP}</a></span>
{ICON_MOVE_DOWN_DISABLED} <span class="down">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ELSE --> <!-- ELSE -->
{ICON_MOVE_UP_DISABLED} <span class="up">{ICON_MOVE_UP_DISABLED}</span>
{ICON_MOVE_DOWN_DISABLED} <span class="down">{ICON_MOVE_DOWN_DISABLED}</span>
<!-- ENDIF --> <!-- ENDIF -->
<a href="{forums.U_EDIT}">{ICON_EDIT}</a> <a href="{forums.U_EDIT}">{ICON_EDIT}</a>
<!-- IF not forums.S_FORUM_LINK --> <!-- IF not forums.S_FORUM_LINK -->

View File

@ -17,6 +17,10 @@
<!-- IF S_COPYRIGHT_HTML --><br /><!-- ENDIF --> <!-- IF S_COPYRIGHT_HTML --><br /><!-- ENDIF -->
{DEBUG_OUTPUT} {DEBUG_OUTPUT}
<!-- ENDIF --> <!-- ENDIF -->
<!-- tmp -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="../styles/script.js"></script>
</div> </div>
</div> </div>

View File

@ -256,6 +256,12 @@ class acp_forums
$cache->destroy('sql', FORUMS_TABLE); $cache->destroy('sql', FORUMS_TABLE);
} }
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest')
{
echo json_encode(array('success' => ($move_forum_name !== false)));
exit;
}
break; break;
case 'sync': case 'sync':

View File

@ -316,6 +316,36 @@ phpbb.add_ajax_callback('post_delete', function(el) {
$(el).parents('form').fadeOut(function() { $(el).parents('form').fadeOut(function() {
$(this).remove(); $(this).remove();
}); });
}).add_ajax_callback('forum_down', function(el) {
var tr = $(el).parents('tr');
if (tr.is(':first-child'))
{
$(el).parents('span').siblings('.up').html('<a href="' + tr.data('up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
tr.next().find('.up').html('<img src="./images/icon_up_disabled.gif" alt="Move up" title="Move up" />');
phpbb.ajaxify({selector: $(el).parents('span').siblings('.up').children('a')}, false, 'forum_up');
}
tr.insertAfter(tr.next());
if (tr.is(':last-child'))
{
$(el).html('<img src="./images/icon_down_disabled.gif" alt="Move down" title="Move down" />');
tr.prev().find('.down').html('<a href="' + tr.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) {
var tr = $(el).parents('tr');
if (tr.is(':last-child'))
{
$(el).parents('span').siblings('.down').html('<a href="' + tr.data('down') + '"><img src="./images/icon_down.gif" alt="Move down" title="Move down" /></a>');
tr.prev().find('.down').html('<img src="./images/icon_down_disabled.gif" alt="Move down" title="Move down" />');
phpbb.ajaxify({selector: $(el).parents('span').siblings('.down').children('a')}, false, 'forum_down');
}
tr.insertBefore(tr.prev());
if (tr.is(':first-child'))
{
$(el).html('<img src="./images/icon_up_disabled.gif" alt="Move up" title="Move up" />');
tr.next().find('.up').html('<a href="' + tr.data('up') + '"><img src="./images/icon_up.gif" alt="Move up" title="Move up" /></a>');
phpbb.ajaxify({selector: tr.next().find('.up').children('a')}, false, 'forum_up');
}
}); });