Working : Upload image : set product image form loaded via ajax, fix category, folder, content
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
$(function($){
|
$(function($){
|
||||||
// Manage picture upload
|
// Manage picture upload
|
||||||
var pictureUploadManager = {};
|
$.imageUploadManager = {};
|
||||||
|
|
||||||
Dropzone.autoDiscover = false;
|
Dropzone.autoDiscover = false;
|
||||||
|
// Remove image on click
|
||||||
|
$.imageUploadManager.initImageDropZone = function() {
|
||||||
var imageDropzone = new Dropzone("#images-dropzone", {
|
var imageDropzone = new Dropzone("#images-dropzone", {
|
||||||
dictDefaultMessage : $('.btn-browse').html(),
|
dictDefaultMessage : $('.btn-browse').html(),
|
||||||
uploadMultiple: false,
|
uploadMultiple: false,
|
||||||
@@ -13,11 +14,13 @@ $(function($){
|
|||||||
imageDropzone.on("success", function(file) {
|
imageDropzone.on("success", function(file) {
|
||||||
$(".image-manager .dz-file-preview").remove();
|
$(".image-manager .dz-file-preview").remove();
|
||||||
imageDropzone.removeFile(file);
|
imageDropzone.removeFile(file);
|
||||||
pictureUploadManager.updateImageListAjax();
|
$.imageUploadManager.updateImageListAjax();
|
||||||
|
$.imageUploadManager.onClickDeleteImage();
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Update picture list via AJAX call
|
// Update picture list via AJAX call
|
||||||
pictureUploadManager.updateImageListAjax = function() {
|
$.imageUploadManager.updateImageListAjax = function() {
|
||||||
var $imageListArea = $(".image-manager .existing-image");
|
var $imageListArea = $(".image-manager .existing-image");
|
||||||
$imageListArea.html('<div class="loading" ></div>');
|
$imageListArea.html('<div class="loading" ></div>');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -38,7 +41,7 @@ $(function($){
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Remove image on click
|
// Remove image on click
|
||||||
pictureUploadManager.onClickDeleteImage = function() {
|
$.imageUploadManager.onClickDeleteImage = function() {
|
||||||
$('.image-manager .image-delete-btn').on('click', function (e) {
|
$('.image-manager .image-delete-btn').on('click', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
@@ -67,5 +70,5 @@ $(function($){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
pictureUploadManager.onClickDeleteImage();
|
$.imageUploadManager.onClickDeleteImage();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -326,6 +326,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
$.imageUploadManager.initImageDropZone();
|
||||||
|
|
||||||
$('.use_default_rewriten_url').click(function(ev) {
|
$('.use_default_rewriten_url').click(function(ev) {
|
||||||
alert("Not functionnal");
|
alert("Not functionnal");
|
||||||
|
|||||||
@@ -295,8 +295,8 @@ form_content = {$smarty.capture.delete_content_dialog nofilter}
|
|||||||
{/javascripts}
|
{/javascripts}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
$.imageUploadManager.initImageDropZone();
|
||||||
|
|
||||||
$('.use_default_rewriten_url').click(function(ev) {
|
$('.use_default_rewriten_url').click(function(ev) {
|
||||||
alert("Not functionnal");
|
alert("Not functionnal");
|
||||||
|
|||||||
@@ -295,6 +295,7 @@
|
|||||||
{/javascripts}
|
{/javascripts}
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
|
$.imageUploadManager.initImageDropZone();
|
||||||
|
|
||||||
$('.use_default_rewriten_url').click(function(ev) {
|
$('.use_default_rewriten_url').click(function(ev) {
|
||||||
alert("Not functionnal");
|
alert("Not functionnal");
|
||||||
|
|||||||
@@ -65,7 +65,8 @@
|
|||||||
<li>
|
<li>
|
||||||
<a href="#images"
|
<a href="#images"
|
||||||
data-toggle="tab"
|
data-toggle="tab"
|
||||||
data-href="{url path="/admin/image/type/product/{$product_id}/form-ajax"}">
|
data-href="{url path="/admin/image/type/product/{$product_id}/form-ajax"}"
|
||||||
|
data-callback="$.imageUploadManager.initImageDropZone">
|
||||||
{intl l="Images"}
|
{intl l="Images"}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -115,6 +116,12 @@
|
|||||||
|
|
||||||
{block name="javascript-initialization"}
|
{block name="javascript-initialization"}
|
||||||
|
|
||||||
|
{javascripts file='assets/js/dropzone.js'}
|
||||||
|
<script src="{$asset_url}"></script>
|
||||||
|
{/javascripts}
|
||||||
|
{javascripts file='assets/js/image-upload.js'}
|
||||||
|
<script src="{$asset_url}"></script>
|
||||||
|
{/javascripts}
|
||||||
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
|
{javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'}
|
||||||
<script src="{$asset_url}"></script>
|
<script src="{$asset_url}"></script>
|
||||||
{/javascripts}
|
{/javascripts}
|
||||||
@@ -144,8 +151,10 @@ $(function() {
|
|||||||
|
|
||||||
// Atomatic ajax tab load, if data-href is defined.
|
// Atomatic ajax tab load, if data-href is defined.
|
||||||
$('.nav-tabs a[data-href]').on('shown.bs.tab', function(ev) {
|
$('.nav-tabs a[data-href]').on('shown.bs.tab', function(ev) {
|
||||||
var zis = $(this);
|
var $this = $(this);
|
||||||
$(zis.attr('href')).load(zis.data('href'));
|
$($this.attr('href')).load($this.data('href'), function(ev) {
|
||||||
|
eval($this.data('callback') + '();');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load active tab
|
// Load active tab
|
||||||
@@ -237,6 +246,4 @@ $(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user