diff --git a/templates/admin/default/assets/js/image-upload.js b/templates/admin/default/assets/js/image-upload.js index bbeed9ea3..92d2a651b 100644 --- a/templates/admin/default/assets/js/image-upload.js +++ b/templates/admin/default/assets/js/image-upload.js @@ -1,23 +1,26 @@ $(function($){ // Manage picture upload - var pictureUploadManager = {}; + $.imageUploadManager = {}; Dropzone.autoDiscover = false; + // Remove image on click + $.imageUploadManager.initImageDropZone = function() { + var imageDropzone = new Dropzone("#images-dropzone", { + dictDefaultMessage : $('.btn-browse').html(), + uploadMultiple: false, + maxFilesize: 8 + }); - var imageDropzone = new Dropzone("#images-dropzone", { - dictDefaultMessage : $('.btn-browse').html(), - uploadMultiple: false, - maxFilesize: 8 - }); - - imageDropzone.on("success", function(file) { - $(".image-manager .dz-file-preview").remove(); - imageDropzone.removeFile(file); - pictureUploadManager.updateImageListAjax(); - }); + imageDropzone.on("success", function(file) { + $(".image-manager .dz-file-preview").remove(); + imageDropzone.removeFile(file); + $.imageUploadManager.updateImageListAjax(); + $.imageUploadManager.onClickDeleteImage(); + }); + }; // Update picture list via AJAX call - pictureUploadManager.updateImageListAjax = function() { + $.imageUploadManager.updateImageListAjax = function() { var $imageListArea = $(".image-manager .existing-image"); $imageListArea.html('
'); $.ajax({ @@ -38,7 +41,7 @@ $(function($){ }; // Remove image on click - pictureUploadManager.onClickDeleteImage = function() { + $.imageUploadManager.onClickDeleteImage = function() { $('.image-manager .image-delete-btn').on('click', function (e) { e.preventDefault(); var $this = $(this); @@ -67,5 +70,5 @@ $(function($){ return false; }); }; - pictureUploadManager.onClickDeleteImage(); + $.imageUploadManager.onClickDeleteImage(); }); diff --git a/templates/admin/default/category-edit.html b/templates/admin/default/category-edit.html index db1e3f14f..b7e1d9ed9 100755 --- a/templates/admin/default/category-edit.html +++ b/templates/admin/default/category-edit.html @@ -326,6 +326,7 @@ }); $(function() { + $.imageUploadManager.initImageDropZone(); $('.use_default_rewriten_url').click(function(ev) { alert("Not functionnal"); diff --git a/templates/admin/default/content-edit.html b/templates/admin/default/content-edit.html index bb30328c4..f4eb063cf 100644 --- a/templates/admin/default/content-edit.html +++ b/templates/admin/default/content-edit.html @@ -295,8 +295,8 @@ form_content = {$smarty.capture.delete_content_dialog nofilter} {/javascripts} -{/javascripts} + {javascripts file='assets/js/dropzone.js'} + + {/javascripts} + {javascripts file='assets/js/image-upload.js'} + + {/javascripts} + {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} + + {/javascripts} - - + + - + $.each(json, function(idx, value) { + $('#attribute_value_id').append($('