|
@@ -28,7 +28,7 @@
|
|
div.parentNode.removeChild(div);
|
|
div.parentNode.removeChild(div);
|
|
return status;
|
|
return status;
|
|
},
|
|
},
|
|
- getNum = function(num, def) {
|
|
|
|
|
|
+ getNum = function (num, def) {
|
|
def = def || 0;
|
|
def = def || 0;
|
|
if (typeof num === "number") {
|
|
if (typeof num === "number") {
|
|
return num;
|
|
return num;
|
|
@@ -638,7 +638,8 @@
|
|
url = isSet('url', config) ? config.url : false,
|
|
url = isSet('url', config) ? config.url : false,
|
|
key = isSet('key', config) ? config.key : null,
|
|
key = isSet('key', config) ? config.key : null,
|
|
disabled = (url === false),
|
|
disabled = (url === false),
|
|
- actions = self.initialPreviewShowDelete ? self.renderFileActions(false, true, disabled, url, key, i) : '',
|
|
|
|
|
|
+ actions = self.initialPreviewShowDelete ? self.renderFileActions(false, true, disabled, url, key,
|
|
|
|
+ i) : '',
|
|
footer = template.repl('{actions}', actions);
|
|
footer = template.repl('{actions}', actions);
|
|
return footer.repl('{caption}', caption).repl('{width}', width)
|
|
return footer.repl('{caption}', caption).repl('{width}', width)
|
|
.repl('{indicator}', '').repl('{indicatorTitle}', '');
|
|
.repl('{indicator}', '').repl('{indicatorTitle}', '');
|
|
@@ -742,69 +743,70 @@
|
|
}
|
|
}
|
|
};
|
|
};
|
|
self.$preview.find('.kv-file-remove').each(function () {
|
|
self.$preview.find('.kv-file-remove').each(function () {
|
|
- var $el = $(this), $frame = $el.closest('.file-preview-frame'), index = $el.data('index'),
|
|
|
|
|
|
+ var $el = $(this), $frame = $el.closest('.file-preview-frame'), index = $el.data('index'),
|
|
config = isEmpty(self.initialPreviewConfig[index]) ? null : self.initialPreviewConfig[index],
|
|
config = isEmpty(self.initialPreviewConfig[index]) ? null : self.initialPreviewConfig[index],
|
|
extraData = isEmpty(config) || isEmpty(config.extra) ? deleteExtraData : config.extra,
|
|
extraData = isEmpty(config) || isEmpty(config.extra) ? deleteExtraData : config.extra,
|
|
- vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'), $content;
|
|
|
|
- if (typeof extraData === "function") {
|
|
|
|
|
|
+ vUrl = $el.data('url') || self.deleteUrl, vKey = $el.data('key'), $content, settings;
|
|
|
|
+ if (typeof extraData === "function") {
|
|
extraData = extraData();
|
|
extraData = extraData();
|
|
}
|
|
}
|
|
if (vUrl === undefined || vKey === undefined) {
|
|
if (vUrl === undefined || vKey === undefined) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- $el.off('click').on('click', function () {
|
|
|
|
- $.ajax({
|
|
|
|
- url: vUrl,
|
|
|
|
- type: 'POST',
|
|
|
|
- dataType: 'json',
|
|
|
|
- data: $.extend({key: vKey}, extraData),
|
|
|
|
- beforeSend: function (jqXHR) {
|
|
|
|
- addCss($frame, 'file-uploading');
|
|
|
|
- addCss($el, 'disabled');
|
|
|
|
- self.raise('filepredelete', [vKey, jqXHR, extraData]);
|
|
|
|
- },
|
|
|
|
- success: function (data, textStatus, jqXHR) {
|
|
|
|
- if (data.error === undefined) {
|
|
|
|
- self.raise('filedeleted', [vKey, jqXHR, extraData]);
|
|
|
|
- } else {
|
|
|
|
- self.showError(data.error, extraData, $el.attr('id'), vKey, 'filedeleteerror', jqXHR);
|
|
|
|
- $frame.removeClass('file-uploading');
|
|
|
|
- $el.removeClass('disabled');
|
|
|
|
- resetProgress();
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- $frame.removeClass('file-uploading').addClass('file-deleted');
|
|
|
|
- $frame.fadeOut('slow', function () {
|
|
|
|
- self.clearObjects($frame);
|
|
|
|
- $frame.remove();
|
|
|
|
- $content = $(document.createElement('div')).html(self.original.preview);
|
|
|
|
- $content.find('.file-preview-frame').each(function () {
|
|
|
|
- $that = $(this);
|
|
|
|
- if ($that.find('.kv-file-remove').attr('data-key') == vKey) {
|
|
|
|
- $that.remove();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- self.initialPreviewContent = $content.html();
|
|
|
|
- if (self.initialPreviewCount > 0) {
|
|
|
|
- self.initialPreviewCount -= 1;
|
|
|
|
- }
|
|
|
|
- caption = self.initialCaption;
|
|
|
|
- if (self.initialCaption.length === 0) {
|
|
|
|
- caption = self.msgSelected.repl('{n}', self.initialPreviewCount);
|
|
|
|
- }
|
|
|
|
- self.original.preview = $content.html();
|
|
|
|
- self.setCaption(caption);
|
|
|
|
- self.original.caption = self.$caption.html();
|
|
|
|
- $content.remove();
|
|
|
|
- resetProgress();
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- error: function (jqXHR, textStatus, errorThrown) {
|
|
|
|
- self.showError(errorThrown, extraData, $el.attr('id'), vKey, 'filedeleteerror', jqXHR);
|
|
|
|
|
|
+ settings = $.extend({
|
|
|
|
+ url: vUrl,
|
|
|
|
+ type: 'POST',
|
|
|
|
+ dataType: 'json',
|
|
|
|
+ data: $.extend({key: vKey}, extraData),
|
|
|
|
+ beforeSend: function (jqXHR) {
|
|
|
|
+ addCss($frame, 'file-uploading');
|
|
|
|
+ addCss($el, 'disabled');
|
|
|
|
+ self.raise('filepredelete', [vKey, jqXHR, extraData]);
|
|
|
|
+ },
|
|
|
|
+ success: function (data, textStatus, jqXHR) {
|
|
|
|
+ if (data.error === undefined) {
|
|
|
|
+ self.raise('filedeleted', [vKey, jqXHR, extraData]);
|
|
|
|
+ } else {
|
|
|
|
+ self.showError(data.error, extraData, $el.attr('id'), vKey, 'filedeleteerror', jqXHR);
|
|
$frame.removeClass('file-uploading');
|
|
$frame.removeClass('file-uploading');
|
|
|
|
+ $el.removeClass('disabled');
|
|
resetProgress();
|
|
resetProgress();
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ $frame.removeClass('file-uploading').addClass('file-deleted');
|
|
|
|
+ $frame.fadeOut('slow', function () {
|
|
|
|
+ self.clearObjects($frame);
|
|
|
|
+ $frame.remove();
|
|
|
|
+ $content = $(document.createElement('div')).html(self.original.preview);
|
|
|
|
+ $content.find('.file-preview-frame').each(function () {
|
|
|
|
+ $that = $(this);
|
|
|
|
+ if ($that.find('.kv-file-remove').attr('data-key') == vKey) {
|
|
|
|
+ $that.remove();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ self.initialPreviewContent = $content.html();
|
|
|
|
+ if (self.initialPreviewCount > 0) {
|
|
|
|
+ self.initialPreviewCount -= 1;
|
|
|
|
+ }
|
|
|
|
+ caption = self.initialCaption;
|
|
|
|
+ if (self.initialCaption.length === 0) {
|
|
|
|
+ caption = self.msgSelected.repl('{n}', self.initialPreviewCount);
|
|
|
|
+ }
|
|
|
|
+ self.original.preview = $content.html();
|
|
|
|
+ self.setCaption(caption);
|
|
|
|
+ self.original.caption = self.$caption.html();
|
|
|
|
+ $content.remove();
|
|
|
|
+ resetProgress();
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ error: function (jqXHR, textStatus, errorThrown) {
|
|
|
|
+ self.showError(errorThrown, extraData, $el.attr('id'), vKey, 'filedeleteerror', jqXHR);
|
|
|
|
+ $frame.removeClass('file-uploading');
|
|
|
|
+ resetProgress();
|
|
|
|
+ }
|
|
|
|
+ }, self.ajaxDeleteSettings);
|
|
|
|
+ $el.off('click').on('click', function () {
|
|
|
|
+ $.ajax(settings);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -988,7 +990,7 @@
|
|
ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
|
|
ajaxSubmit: function (fnBefore, fnSuccess, fnComplete, fnError) {
|
|
var self = this, settings;
|
|
var self = this, settings;
|
|
self.uploadExtra();
|
|
self.uploadExtra();
|
|
- settings = $.extend(self.ajaxSettings, {
|
|
|
|
|
|
+ settings = $.extend({
|
|
xhr: function () {
|
|
xhr: function () {
|
|
var xhrobj = $.ajaxSettings.xhr();
|
|
var xhrobj = $.ajaxSettings.xhr();
|
|
return self.initXhr(xhrobj, 98);
|
|
return self.initXhr(xhrobj, 98);
|
|
@@ -1004,7 +1006,7 @@
|
|
success: fnSuccess,
|
|
success: fnSuccess,
|
|
complete: fnComplete,
|
|
complete: fnComplete,
|
|
error: fnError
|
|
error: fnError
|
|
- });
|
|
|
|
|
|
+ }, self.ajaxSettings);
|
|
self.ajaxRequests.push($.ajax(settings));
|
|
self.ajaxRequests.push($.ajax(settings));
|
|
},
|
|
},
|
|
uploadSingle: function (i, files, allFiles) {
|
|
uploadSingle: function (i, files, allFiles) {
|
|
@@ -1426,7 +1428,7 @@
|
|
$status.html('');
|
|
$status.html('');
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- var node = ctr + i, previewId = previewInitId + "-" + node, isText, file = files[i],
|
|
|
|
|
|
+ var node = ctr + i, previewId = previewInitId + "-" + node, isText, file = files[i],
|
|
caption = self.slug(file.name), fileSize = (file.size || 0) / 1000, checkFile, fileExtExpr = '',
|
|
caption = self.slug(file.name), fileSize = (file.size || 0) / 1000, checkFile, fileExtExpr = '',
|
|
previewData = objUrl.createObjectURL(file), fileCount = 0, j, msg, typ, chk,
|
|
previewData = objUrl.createObjectURL(file), fileCount = 0, j, msg, typ, chk,
|
|
fileTypes = self.allowedFileTypes, strTypes = isEmpty(fileTypes) ? '' : fileTypes.join(', '),
|
|
fileTypes = self.allowedFileTypes, strTypes = isEmpty(fileTypes) ? '' : fileTypes.join(', '),
|
|
@@ -1543,7 +1545,7 @@
|
|
self.$container.removeClass('file-input-new file-input-ajax-new');
|
|
self.$container.removeClass('file-input-new file-input-ajax-new');
|
|
if (arguments.length === 1) {
|
|
if (arguments.length === 1) {
|
|
self.raise('fileselect', [numFiles, label]);
|
|
self.raise('fileselect', [numFiles, label]);
|
|
- }
|
|
|
|
|
|
+ }
|
|
if (self.initialPreviewContent.length > 0) {
|
|
if (self.initialPreviewContent.length > 0) {
|
|
self.initPreviewDeletes();
|
|
self.initPreviewDeletes();
|
|
}
|
|
}
|
|
@@ -1566,8 +1568,10 @@
|
|
};
|
|
};
|
|
self.resetUpload();
|
|
self.resetUpload();
|
|
self.hideFileIcon();
|
|
self.hideFileIcon();
|
|
- if (isDragDrop) {
|
|
|
|
|
|
+ if (self.isUploadable) {
|
|
self.$container.find('.file-drop-zone .' + self.dropZoneTitleClass).remove();
|
|
self.$container.find('.file-drop-zone .' + self.dropZoneTitleClass).remove();
|
|
|
|
+ }
|
|
|
|
+ if (isDragDrop) {
|
|
tfiles = files;
|
|
tfiles = files;
|
|
} else {
|
|
} else {
|
|
if (e.target.files === undefined) {
|
|
if (e.target.files === undefined) {
|
|
@@ -1595,7 +1599,7 @@
|
|
} else {
|
|
} else {
|
|
$preview.html('');
|
|
$preview.html('');
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if (isSingleUpload && ctr > 0) {
|
|
if (isSingleUpload && ctr > 0) {
|
|
self.filestack = [];
|
|
self.filestack = [];
|
|
}
|
|
}
|
|
@@ -1837,7 +1841,8 @@
|
|
fileActionSettings: {},
|
|
fileActionSettings: {},
|
|
otherActionButtons: '',
|
|
otherActionButtons: '',
|
|
textEncoding: 'UTF-8',
|
|
textEncoding: 'UTF-8',
|
|
- ajaxSettings: {}
|
|
|
|
|
|
+ ajaxSettings: {},
|
|
|
|
+ ajaxDeleteSettings: {}
|
|
};
|
|
};
|
|
|
|
|
|
$.fn.fileinput.Constructor = FileInput;
|
|
$.fn.fileinput.Constructor = FileInput;
|