create confirmation message before deleting an image
This commit is contained in:
@@ -8,6 +8,8 @@ $(function($){
|
||||
$.imageUploadManager.initImageDropZone = function() {
|
||||
|
||||
$.imageUploadManager.onClickDeleteImage();
|
||||
$.imageUploadManager.onClickModal();
|
||||
$.imageUploadManager.onModalHidden();
|
||||
$.imageUploadManager.sortImage();
|
||||
|
||||
var imageDropzone = new Dropzone("#images-dropzone", {
|
||||
@@ -73,7 +75,26 @@ $(function($){
|
||||
$.imageUploadManager.onClickDeleteImage = function() {
|
||||
$('.image-manager .image-delete-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
$("#submit-delete-image").data("element-id", $(this).attr("id"));
|
||||
$('#image_delete_dialog').modal("show");
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
$.imageUploadManager.onModalHidden = function() {
|
||||
$("#image_delete_dialog").on('hidden.bs.modal', function (e) {
|
||||
$("#submit-delete-image").data("element-id", "");
|
||||
});
|
||||
};
|
||||
|
||||
$.imageUploadManager.onClickModal = function() {
|
||||
$("#submit-delete-image").on('click', function(e){
|
||||
|
||||
var $id= $(this).data("element-id");
|
||||
var $this = $("#"+$id);
|
||||
var $parent = $this.parent();
|
||||
var $greatParent = $parent.parent();
|
||||
|
||||
@@ -92,6 +113,8 @@ $(function($){
|
||||
}
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#image_delete_dialog').modal("hide");
|
||||
$("#submit-delete-image").data("element-id", "");
|
||||
$greatParent.remove();
|
||||
$(".image-manager .message").html(
|
||||
data
|
||||
@@ -101,8 +124,12 @@ $(function($){
|
||||
$( "#js-sort-image").children('li').each(function(position, element) {
|
||||
$(element).find('.js-sorted-position').html(position + 1);
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}).fail(function(){
|
||||
$('#image_delete_dialog').modal("hide");
|
||||
$("#submit-delete-image").data("element-id", "");
|
||||
})
|
||||
|
||||
;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -36,3 +36,21 @@ Parameters:
|
||||
var imageListErrorMessage = "{intl l='Can\'t load images, please refresh this page.'}";
|
||||
var imageReorderErrorMessage = "{intl l='Can\'t reorder images, please refresh this page.'}";
|
||||
</script>
|
||||
|
||||
<div class="modal fade" id="image_delete_dialog" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3>{intl l="delete image"}</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{intl l="Do you really want to delete this image ?"}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span>{intl l="No"}</button>
|
||||
<button type="button" id="submit-delete-image" data-element-id="" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span>{intl l="Yes"}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,7 @@ Parameters:
|
||||
<a class="image-update-btn btn btn-default btn-xs" href="{url path="/admin/image/type/$imageType/$ID/update"}" data-error-message="{intl l='Please retry'}">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
</a>
|
||||
<a class="image-delete-btn btn btn-default btn-xs" href="{url path="/admin/image/type/$imageType/delete/$ID"}" data-error-message="{intl l='Please retry'}">
|
||||
<a class="image-delete-btn btn btn-default btn-xs" id="image-{$ID}" href="{url path="/admin/image/type/$imageType/delete/$ID"}" data-error-message="{intl l='Please retry'}">
|
||||
<span class="glyphicon glyphicon-trash"></span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user