// change image drag&drop to look like other drag&drop lists
This commit is contained in:
@@ -3103,7 +3103,6 @@ class AdminProducts extends AdminTab
|
||||
<th>'.$this->l('Action').'</th>
|
||||
</tr></thead>';
|
||||
|
||||
echo $this->_positionJS();
|
||||
foreach ($images AS $k => $image)
|
||||
echo $this->getLineTableImage($image, $imagesTotal, $token, $shops);
|
||||
|
||||
@@ -3146,32 +3145,17 @@ class AdminProducts extends AdminTab
|
||||
$image_obj = new Image($image['id_image']);
|
||||
$img_path = $image_obj->getExistingImgPath();
|
||||
$html = '
|
||||
<tr id="tr_'.$image_obj->id.'_'.$image_obj->position.'">
|
||||
<tr id="tr_'.$image_obj->id.'">
|
||||
<td style="padding: 4px;"><a href="'._THEME_PROD_DIR_.$img_path.'.jpg" target="_blank">
|
||||
<img src="'._THEME_PROD_DIR_.$img_path.'-small.jpg'.((int)(Tools::getValue('image_updated')) === (int)($image['id_image']) ? '?date='.time() : '').'"
|
||||
alt="'.htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8').'" title="'.htmlentities(stripslashes($image['legend']), ENT_COMPAT, 'UTF-8').'" /></a>
|
||||
</td>
|
||||
<td class="center positionImage">'.(int)($image['position']).'</td>
|
||||
<td id="td_'.$image_obj->id.'" class="position-cell dragHandle">';
|
||||
if ($image['position'] == 1)
|
||||
{
|
||||
$html .= '
|
||||
<span class="up">[ <img src="../img/admin/up_d.gif" alt="" border="0"> ]</span>';
|
||||
if ($image['position'] == $imagesTotal)
|
||||
$html .= '
|
||||
<span class="down">[ <img src="../img/admin/down_d.gif" alt="" border="0"> ]</span>';
|
||||
else
|
||||
$html .= '
|
||||
<span class="down">[ <a onclick="return hideLink();" href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&imgPosition='.($image['position'] + 1).'&imgDirection=1&token='.($token ? $token : $this->token).'"><img src="../img/admin/down.gif" alt="" border="0"></a> ]</span>';
|
||||
}
|
||||
elseif ($image['position'] == $imagesTotal)
|
||||
$html .= '
|
||||
<span class="up">[ <a onclick="return hideLink();" href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&imgPosition='.($image['position'] - 1).'&imgDirection=0&token='.($token ? $token : $this->token).'"><img src="../img/admin/up.gif" alt="" border="0"></a> ]</span>
|
||||
<span class="down">[ <img src="../img/admin/down_d.gif" alt="" border="0"> ]</span>';
|
||||
else
|
||||
$html .= '
|
||||
<span class="up">[ <a onclick="return hideLink();" href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&imgPosition='.($image['position'] - 1).'&imgDirection=0&token='.($token ? $token : $this->token).'"><img src="../img/admin/up.gif" alt="" border="0"></a> ]</span>
|
||||
<span class="down">[ <a onclick="return hideLink();" href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&imgPosition='.($image['position'] + 1).'&imgDirection=1&token='.($token ? $token : $this->token).'"><img src="../img/admin/down.gif" alt="" border="0"></a> ]</span>';
|
||||
<td id="td_'.$image_obj->id.'" class="pointer dragHandle center">';
|
||||
|
||||
$html .= '
|
||||
<a '.($image['position'] == 1 ? ' style="display: none;"' : '').' href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&imgPosition='.($image['position'] - 1).'&imgDirection=0&token='.($token ? $token : $this->token).'"><img src="../img/admin/up.gif" alt="" border="0"></a>
|
||||
<a '.($image['position'] == $imagesTotal ? ' style="display: none;"' : '').' href="'.self::$currentIndex.'&id_image='.$image['id_image'].'&imgPosition='.($image['position'] + 1).'&imgDirection=1&token='.($token ? $token : $this->token).'"><img src="../img/admin/down.gif" alt="" border="0"></a>';
|
||||
$html .= '
|
||||
</td>';
|
||||
if (Shop::isMultiShopActivated())
|
||||
@@ -3850,20 +3834,6 @@ class AdminProducts extends AdminTab
|
||||
}';
|
||||
}
|
||||
|
||||
private function _positionJS()
|
||||
{
|
||||
|
||||
return '<script type="text/javascript">
|
||||
|
||||
function hideLink()
|
||||
{
|
||||
$(".position-cell span").hide();
|
||||
$(".position-cell").append("<img src=\"'._PS_IMG_.'loader.gif\" alt=\"\" />");
|
||||
|
||||
}
|
||||
</script>';
|
||||
}
|
||||
|
||||
public function updatePackItems($product)
|
||||
{
|
||||
Pack::deleteItems($product->id);
|
||||
|
||||
+41
-44
@@ -99,61 +99,59 @@ $(document).ready(function() {
|
||||
url: 'ajax.php?' + $.tableDnD.serialize(),
|
||||
data: params,
|
||||
success: function(data) {
|
||||
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();
|
||||
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();
|
||||
}
|
||||
else if (table.id == 'product') {
|
||||
var reg = /_[0-9][0-9]*$/g;
|
||||
tableDrag.find('tbody tr').each(function(i) {
|
||||
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
||||
|
||||
// Update link position
|
||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
||||
|
||||
// Up links
|
||||
$(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&'));
|
||||
|
||||
// Down links
|
||||
$(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
||||
|
||||
});
|
||||
tableDrag.find('tr').not('.nodrag').removeClass('alt_row');
|
||||
tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row');
|
||||
tableDrag.find('tr td.dragHandle a:hidden').show();
|
||||
|
||||
if (alternate) {
|
||||
tableDrag.find('tr td.dragHandle:first a:odd').hide();
|
||||
tableDrag.find('tr td.dragHandle:last a:even').hide();
|
||||
}
|
||||
else {
|
||||
tableDrag.find('tr td.dragHandle:first a:even').hide();
|
||||
tableDrag.find('tr td.dragHandle:last a:odd').hide();
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (table.id == 'imageTable')
|
||||
{
|
||||
var reg = /_[0-9]$/g;
|
||||
var up_reg = new RegExp('imgPosition=[0-9]+&');
|
||||
tableDrag.find('tbody tr').each(function(i) {
|
||||
// Update link position
|
||||
// Up links
|
||||
$(this).find('td.dragHandle a:first').attr('href', $(this).find('td.dragHandle a:first').attr('href').replace(up_reg, 'imgPosition='+ i +'&'));//, 'imgPosition='+ (i - 1) +'&'));
|
||||
// Down links
|
||||
$(this).find('td.dragHandle a:last').attr('href', $(this).find('td.dragHandle a:last').attr('href').replace(up_reg, 'imgPosition='+ (i + 2) +'&'));
|
||||
// Position image cell
|
||||
$(this).find('td.positionImage').html(i + 1);
|
||||
|
||||
});
|
||||
tableDrag.find('tr td.dragHandle a:hidden').show();
|
||||
tableDrag.find('tr td.dragHandle:first a:first').hide();
|
||||
tableDrag.find('tr td.dragHandle:last a:last').hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (table.id == 'product')
|
||||
{
|
||||
var reg = /_[0-9][0-9]*$/g;
|
||||
}
|
||||
else
|
||||
{
|
||||
var reg = /_[0-9]$/g;
|
||||
}
|
||||
|
||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
||||
|
||||
tableDrag.find('tbody tr').each(function(i) {
|
||||
$(this).attr('id', $(this).attr('id').replace(reg, '_' + i));
|
||||
|
||||
// Update link position
|
||||
var up_reg = new RegExp('position=[-]?[0-9]+&');
|
||||
|
||||
// Update link position
|
||||
// Up links
|
||||
$(this).find('td.dragHandle a:odd').attr('href', $(this).find('td.dragHandle a:odd').attr('href').replace(up_reg, 'position='+ (i - 1) +'&'));
|
||||
|
||||
// Down links
|
||||
$(this).find('td.dragHandle a:even').attr('href', $(this).find('td.dragHandle a:even').attr('href').replace(up_reg, 'position='+ (i + 1) +'&'));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
tableDrag.find('tr').not('.nodrag').removeClass('alt_row');
|
||||
tableDrag.find('tr:not(".nodrag"):odd').addClass('alt_row');
|
||||
tableDrag.find('tr td.dragHandle a:hidden').show();
|
||||
@@ -166,7 +164,6 @@ $(document).ready(function() {
|
||||
tableDrag.find('tr td.dragHandle:first a:even').hide();
|
||||
tableDrag.find('tr td.dragHandle:last a:odd').hide();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user