// fix image positions when adding or deleting images
This commit is contained in:
@@ -3055,6 +3055,7 @@ class AdminProducts extends AdminTab
|
||||
<script type="text/javascript">var upbutton = "'.$this->l('Upload a file').'"; </script>
|
||||
<script src="../js/fileuploader.js" type="text/javascript"></script>
|
||||
<script src="../js/jquery/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
|
||||
<script type="text/javascript" src="../js/admin.js"></script>
|
||||
<script type="text/javascript">
|
||||
function deleteImg(id)
|
||||
{
|
||||
@@ -3072,21 +3073,17 @@ class AdminProducts extends AdminTab
|
||||
function (data) {
|
||||
if (data)
|
||||
{
|
||||
position = parseInt($("#" + id + " .positionImage").html());
|
||||
cover = 0;
|
||||
if ($("#" + id).find(".covered").attr("src") == "../img/admin/enabled.gif")
|
||||
if ($("#tr_" + id).find(".covered").attr("src") == "../img/admin/enabled.gif")
|
||||
cover = 1;
|
||||
$("#" + id).remove();
|
||||
$("#tr_" + id).remove();
|
||||
|
||||
if (cover)
|
||||
$("#imageTable tr").eq(1).find(".covered").attr("src", "../img/admin/enabled.gif");
|
||||
$("#imageTable tr").eq(1).find(".up").html("[ <img src=\"../img/admin/up_d.gif\" alt=\"\" border=\"0\"> ]");
|
||||
|
||||
$("#countImage").html(parseInt($("#countImage").html()) - 1);
|
||||
$("#imageTable .positionImage").each( function(index){
|
||||
if (parseInt($(this).html()) > position)
|
||||
$(this).html(parseInt($(this).html()) - 1);
|
||||
$("#imageTable tr:last .down").html("[ <img src=\"../img/admin/down_d.gif\" alt=\"\" border=\"0\"> ]");
|
||||
|
||||
});
|
||||
refreshImagePositions($("#imageTable"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -3102,9 +3099,9 @@ class AdminProducts extends AdminTab
|
||||
action: \'ajax-tab.php\',
|
||||
debug: false,
|
||||
onComplete: function(id, fileName, responseJSON){
|
||||
var purcent = ((filecheck * 100) / nbfile);
|
||||
$("#progressBarImage").progressbar({value: purcent });
|
||||
if (purcent != 100)
|
||||
var percent = ((filecheck * 100) / nbfile);
|
||||
$("#progressBarImage").progressbar({value: percent });
|
||||
if (percent != 100)
|
||||
{
|
||||
$("#imageUpload").html(parseInt(filecheck));
|
||||
$("#imageTotal").html(" / " + parseInt(nbfile) + " '.$this->l('Images').'");
|
||||
@@ -3132,8 +3129,10 @@ class AdminProducts extends AdminTab
|
||||
$("#img" + id + " .errorImg").show();
|
||||
|
||||
}
|
||||
if (purcent >= 100)
|
||||
$("#imageTable tr:last .down").html("[ <img src=\"../img/admin/down_d.gif\" alt=\"\" border=\"0\"> ]");
|
||||
if (percent >= 100)
|
||||
{
|
||||
refreshImagePositions($("#imageTable"));
|
||||
}
|
||||
filecheck++;
|
||||
},
|
||||
onSubmit: function(id, filename){
|
||||
|
||||
+23
@@ -863,4 +863,27 @@ function checkMultishopDefaultValue(obj, key)
|
||||
$('#conf_id_'+key+' label.conf_title').removeClass('isDisabled');
|
||||
}
|
||||
$('#conf_id_'+key+' .preference_default_multishop input').attr('disabled', false);
|
||||
}
|
||||
/**
|
||||
* Update the product image list position buttons
|
||||
*
|
||||
* @param DOM table imageTable
|
||||
*/
|
||||
function refreshImagePositions(imageTable)
|
||||
{
|
||||
var reg = /_[0-9]$/g;
|
||||
var up_reg = new RegExp("imgPosition=[0-9]+&");
|
||||
|
||||
imageTable.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);
|
||||
});
|
||||
imageTable.find("tr td.dragHandle a:hidden").show();
|
||||
imageTable.find("tr td.dragHandle:first a:first").hide();
|
||||
imageTable.find("tr td.dragHandle:last a:last").hide();
|
||||
}
|
||||
Reference in New Issue
Block a user