$(document).ready(function() { // editor save function var saveEditedImageLogo = function(item) { // if still uploading // pend and exit if (item.upload && item.upload.status == 'loading') return item.editor.isUploadPending = true; // if not appended or not uploaded if (!item.appended && !item.uploaded) return; // if no editor if (!item.editor || !item.reader.width) return; // if uploaded // resend upload if (item.upload && item.upload.resend) { item.editor._namee = item.name; item.upload.resend(); } if (item.appended) { item.imageIsUploading = true; item.image.addClass('fileuploader-loading').html(''); item.html.find('.fileuploader-action-popup').hide(); $.post('/ajax/uploader-resize-logo.php', { _file: item.file, _editor: JSON.stringify(item.editor), fileuploader: 1 }, function () { item.reader.read(function () { delete item.imageIsUploading; item.html.find('.fileuploader-action-popup').show(); item.popup.html = item.popup.editor = item.editor.crop = item.editor.rotation = null; item.renderThumbnail(); }, null, true); }); } }; // enable fileuploader plugin $('input[name="photoAg"]').fileuploader({ extensions: ['jpg', 'jpeg', 'png', 'gif', 'bmp'], changeInput: ' ', theme: 'thumbnails', enableApi: true, addMore: false, fileMaxSize: 5, thumbnails: { box: '
' + '' + '
', item: '
  • ' + '
    ' + '
    ${image}
    ' + '
    ' + ''+ '' + '
    ' + '
    ${progressBar}
    ' + '
    ' + '
  • ', item2: '
  • ' + '
    ' + '
    ${image}
    ' + '
    ' + ''+ '' + '
    ' + '
    ' + '
  • ', startImageRenderer: true, canvasImage: false, _selectors: { list: '.fileuploader-items-list', item: '.fileuploader-item', start: '.fileuploader-action-start', retry: '.fileuploader-action-retry', remove: '.fileuploader-action-remove', sorter: '.fileuploader-action-sort' }, onItemShow: function(item, listEl) { var plusInput = listEl.find('.fileuploader-thumbnails-input'); plusInput.hide(); if(item.format == 'image') { item.html.find('.fileuploader-item-icon').hide(); } } }, afterRender: function(listEl, parentEl, newInputEl, inputEl) { var plusInput = listEl.find('.fileuploader-thumbnails-input'), api = $.fileuploader.getInstance(inputEl.get(0)); plusInput.on('click', function() { api.open(); }); }, upload : { // upload URL {String} url: '/ajax/uploader-logo.php', data: null, type: 'POST', enctype: 'multipart/form-data', start: true, synchron: true, chunk: false, onSuccess: function(data, item, listEl, parentEl, newInputEl, inputEl, textStatus, jqXHR) { //todo setTimeout(function() { item.html.find('.progress-holder').remove(); }, 400); }, onComplete: function(listEl, parentEl, newInputEl, inputEl, jqXHR, textStatus) { // callback will go here } }, dragDrop: { container: '.company-ph' }, onRemove: function(item, listEl) { $.ajax({ url: '/ajax/delete-logo.php', success:function(data) { } }); var plusInput = listEl.find('.fileuploader-thumbnails-input'); plusInput.show(); }, editor: { cropper: { ratio: '1:1', showGrid: true }, onSave: function(dataURL, item) { saveEditedImageLogo(item); } }, captions: { feedback: 'Drag and drop files here', feedback2: 'Drag and drop files here', drop: 'Drag and drop files here', removeConfirmation: "Удалить выбранный файл?", errors: { filesLimit: 'Только ${limit} файлов можно загрузить.', filesType: 'Только ${extensions} файлы можно загрузить.', fileSize: 'Превышение допустимого размера файла. Выберите файл размером не более ${fileMaxSize}MB.', fileName: 'Файл с именем ${name} уже выбран.' } }, sorter: { selectorExclude: null, placeholder: '
  • ', scrollContainer: window, onSort: function(list, listEl, parentEl, newInputEl, inputEl) { var api = $.fileuploader.getInstance(inputEl.get(0)), fileList = api.getFileList(), _list = []; $.each(fileList, function(i, item) { _list.push({ name: item.name, index: item.index }); }); } } }); $('input[name="avatar"]').fileuploader({ extensions: ['jpg', 'jpeg', 'png', 'gif', 'bmp'], changeInput: ' ', theme: 'thumbnails', enableApi: true, addMore: false, fileMaxSize: 5, thumbnails: { box: '
    ' + '' + '
    ', item: '
  • ' + '
    ' + '
    ${image}
    ' + '
    ' + '' + '' + '
    ' + '
    ${progressBar}
    ' + '
    ' + '
  • ', item2: '
  • ' + '
    ' + '
    ${image}
    ' + '
    ' + ''+ '' + '
    ' + '
    ' + '
  • ', startImageRenderer: true, canvasImage: false, _selectors: { list: '.fileuploader-items-list', item: '.fileuploader-item', start: '.fileuploader-action-start', retry: '.fileuploader-action-retry', remove: '.fileuploader-action-remove', sorter: '.fileuploader-action-sort' }, onItemShow: function(item, listEl) { var plusInput = listEl.find('.fileuploader-thumbnails-input'); plusInput.hide(); if(item.format == 'image') { item.html.find('.fileuploader-item-icon').hide(); } } }, afterRender: function(listEl, parentEl, newInputEl, inputEl) { var plusInput = listEl.find('.fileuploader-thumbnails-input'), api = $.fileuploader.getInstance(inputEl.get(0)); plusInput.on('click', function() { api.open(); }); }, upload : { // upload URL {String} url: '/ajax/uploader-avatar.php', data: null, type: 'POST', enctype: 'multipart/form-data', start: true, synchron: true, chunk: false, onSuccess: function(data, item, listEl, parentEl, newInputEl, inputEl, textStatus, jqXHR) { //todo setTimeout(function() { item.html.find('.progress-holder').remove(); }, 400); }, onComplete: function(listEl, parentEl, newInputEl, inputEl, jqXHR, textStatus) { // callback will go here } }, dragDrop: { container: '.avatar-ph' }, onRemove: function(item, listEl) { $.ajax({ url: '/ajax/delete-avatar.php', success:function(data) { } }); var plusInput = listEl.find('.fileuploader-thumbnails-input'); plusInput.show(); }, editor: { cropper: { showGrid: true }, onSave: function(dataURL, item) { saveEditedImageLogo(item); } }, captions: { feedback: 'Drag and drop files here', feedback2: 'Drag and drop files here', drop: 'Drag and drop files here', removeConfirmation: "Удалить выбранный файл?", errors: { filesLimit: 'Только ${limit} файлов можно загрузить.', filesType: 'Только ${extensions} файлы можно загрузить.', fileSize: '${name} очень большой! Выберите файл размером не больше ${fileMaxSize}MB.', fileName: 'Файл с именем ${name} уже выбран.' } }, sorter: { selectorExclude: null, placeholder: '
  • ', scrollContainer: window, onSort: function(list, listEl, parentEl, newInputEl, inputEl) { var api = $.fileuploader.getInstance(inputEl.get(0)), fileList = api.getFileList(), _list = []; $.each(fileList, function(i, item) { _list.push({ name: item.name, index: item.index }); }); } } }); $('input[name="watermark"]').fileuploader({ extensions: ['jpg', 'jpeg', 'png', 'gif', 'bmp'], changeInput: ' ', theme: 'thumbnails', enableApi: true, addMore: false, fileMaxSize: 5, thumbnails: { box: '
    ' + '' + '
    ', item: '
  • ' + '
    ' + '
    ${image}
    ' + '
    ' + '' + '' + '
    ' + '
    ${progressBar}
    ' + '
    ' + '
  • ', item2: '
  • ' + '
    ' + '
    ${image}
    ' + '
    ' + ''+ '' + '
    ' + '
    ' + '
  • ', startImageRenderer: true, canvasImage: false, _selectors: { list: '.fileuploader-items-list', item: '.fileuploader-item', start: '.fileuploader-action-start', retry: '.fileuploader-action-retry', remove: '.fileuploader-action-remove', sorter: '.fileuploader-action-sort' }, onItemShow: function(item, listEl) { var plusInput = listEl.find('.fileuploader-thumbnails-input'); plusInput.hide(); if(item.format == 'image') { item.html.find('.fileuploader-item-icon').hide(); } } }, afterRender: function(listEl, parentEl, newInputEl, inputEl) { var plusInput = listEl.find('.fileuploader-thumbnails-input'), api = $.fileuploader.getInstance(inputEl.get(0)); plusInput.on('click', function() { api.open(); }); }, upload : { // upload URL {String} url: '/ajax/uploader-watermark.php', data: null, type: 'POST', enctype: 'multipart/form-data', start: true, synchron: true, chunk: false, onSuccess: function(data, item, listEl, parentEl, newInputEl, inputEl, textStatus, jqXHR) { //todo setTimeout(function() { item.html.find('.progress-holder').remove(); }, 400); }, onComplete: function(listEl, parentEl, newInputEl, inputEl, jqXHR, textStatus) { // callback will go here } }, dragDrop: { container: '.watermark-ph' }, onRemove: function(item, listEl) { $.ajax({ url: '/ajax/delete-watermark.php', success:function(data) { } }); var plusInput = listEl.find('.fileuploader-thumbnails-input'); plusInput.show(); }, editor: { cropper: { showGrid: true }, onSave: function(dataURL, item) { saveEditedImageLogo(item); } }, captions: { feedback: 'Drag and drop files here', feedback2: 'Drag and drop files here', drop: 'Drag and drop files here', removeConfirmation: "Удалить выбранный файл?", errors: { filesLimit: 'Только ${limit} файлов можно загрузить.', filesType: 'Только ${extensions} файлы можно загрузить.', fileSize: '${name} очень большой! Выберите файл размером не больше ${fileMaxSize}MB.', fileName: 'Файл с именем ${name} уже выбран.' } }, sorter: { selectorExclude: null, placeholder: '
  • ', scrollContainer: window, onSort: function(list, listEl, parentEl, newInputEl, inputEl) { var api = $.fileuploader.getInstance(inputEl.get(0)), fileList = api.getFileList(), _list = []; $.each(fileList, function(i, item) { _list.push({ name: item.name, index: item.index }); }); } } }); });