diff --git a/classes/Module.php b/classes/Module.php index bd6a9cdf0..3d8ab7c99 100644 --- a/classes/Module.php +++ b/classes/Module.php @@ -1309,6 +1309,7 @@ abstract class ModuleCore } if (!isset($k) || !isset($res[$k]) || !isset($res[$k + 1])) return false; + $from = $res[$k]; $to = $res[$k + 1]; @@ -1329,6 +1330,7 @@ abstract class ModuleCore if (!Db::getInstance()->execute($sql)) return false; } + return true; } /* diff --git a/controllers/admin/AdminModulesPositionsController.php b/controllers/admin/AdminModulesPositionsController.php index 073fab439..d7b01f52a 100644 --- a/controllers/admin/AdminModulesPositionsController.php +++ b/controllers/admin/AdminModulesPositionsController.php @@ -213,6 +213,8 @@ class AdminModulesPositionsControllerCore extends AdminController Tools::redirectAdmin(self::$currentIndex.'&conf=17'.($this->display_key ? '&show_modules='.$this->display_key : '').'&token='.$this->token); } } + else + parent::postProcess(); } public function initContent() diff --git a/js/admin-dnd.js b/js/admin-dnd.js index 24346b531..6d7b226e5 100644 --- a/js/admin-dnd.js +++ b/js/admin-dnd.js @@ -135,16 +135,13 @@ function initTableDnD(table) url: currentIndex + '&token=' + token + '&' + $.tableDnD.serialize(), data: params, success: function(data) { - if (come_from == 'AdminModulesPositions') + var nodrag_lines = $(tableDrag).find('tr:not(".nodrag")'); + + if (come_from == 'AdminModulesPositions') { - tableDrag.find('tr').removeClass('alt_row'); - tableDrag.find('tr' + reOrder).addClass('alt_row'); - tableDrag.find('td.positions').each(function(i) { - $(this).html(i+1); - }); - tableDrag.find('td.dragHandle a:hidden').show(); - tableDrag.find('td.dragHandle:first a:even').hide(); - tableDrag.find('td.dragHandle:last a:odd').hide(); + nodrag_lines.each(function(i) { + $(this).find('.positions').html(i+1); + }); } else { @@ -156,31 +153,30 @@ function initTableDnD(table) { var reg = /_[0-9]$/g; } - + var up_reg = new RegExp('position=[-]?[0-9]+&'); - $(tableDrag).children('tbody').children('tr').each(function(i) { + nodrag_lines.each(function(i) { $(this).attr('id', $(this).attr('id').replace(reg, '_' + i)); // Update link position // Up links $(this).children('td.dragHandle a:odd').attr('href', $(this).children('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&')); - // Down links $(this).children('td.dragHandle a:even').attr('href', $(this).children('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&')); - }); - $(tableDrag).children('tbody').children('tr').not('.nodrag').removeClass('alt_row').removeClass('not_alt_row'); - $(tableDrag).children('tbody').children('tr:not(".nodrag"):odd').addClass('alt_row'); - $(tableDrag).children('tbody').children('tr:not(".nodrag"):even').addClass('not_alt_row'); - $(tableDrag).children('tbody').children('tr').children('td.dragHandle').children('a:hidden').show(); + } - if (alternate) { - $(tableDrag).children('tbody').children('tr').children('td.dragHandle:first').children('a:odd').hide(); - $(tableDrag).children('tbody').children('tr').children('td.dragHandle:last').children('a:even').hide(); - } - else { - $(tableDrag).children('tbody').children('tr').children('td.dragHandle:first').children('a:even').hide(); - $(tableDrag).children('tbody').children('tr').children('td.dragHandle:last').children('a:odd').hide(); - } + nodrag_lines.removeClass('alt_row').removeClass('not_alt_row'); + nodrag_lines.filter(':odd').addClass('alt_row'); + nodrag_lines.filter(':even').addClass('not_alt_row'); + nodrag_lines.children('td.dragHandle').children('a:hidden').show(); + + if (typeof alternate !== 'undefined' && alternate) { + nodrag_lines.children('td.dragHandle:first').children('a:odd').hide(); + nodrag_lines.children('td.dragHandle:last').children('a:even').hide(); + } + else { + nodrag_lines.children('td.dragHandle:first').children('a:even').hide(); + nodrag_lines.children('td.dragHandle:last').children('a:odd').hide(); } } });