|
@@ -196,7 +196,7 @@
|
|
return !isIE(9) && ($div.draggable !== undefined || ($div.ondragstart !== undefined && $div.ondrop !== undefined));
|
|
return !isIE(9) && ($div.draggable !== undefined || ($div.ondragstart !== undefined && $div.ondrop !== undefined));
|
|
},
|
|
},
|
|
hasFileUploadSupport = function () {
|
|
hasFileUploadSupport = function () {
|
|
- return hasFileAPISupport && window.FormData;
|
|
|
|
|
|
+ return hasFileAPISupport() && window.FormData;
|
|
},
|
|
},
|
|
addCss = function ($el, css) {
|
|
addCss = function ($el, css) {
|
|
$el.removeClass(css).addClass(css);
|
|
$el.removeClass(css).addClass(css);
|
|
@@ -445,7 +445,10 @@
|
|
if (!self.validate()) {
|
|
if (!self.validate()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (hasFileAPISupport() || isIE(9)) {
|
|
|
|
|
|
+ self.isPreviewable = hasFileAPISupport();
|
|
|
|
+ self.isIE9 = isIE(9);
|
|
|
|
+ self.isIE10 = isIE(10);
|
|
|
|
+ if (self.isPreviewable || self.isIE9) {
|
|
self.init(options);
|
|
self.init(options);
|
|
self.listen();
|
|
self.listen();
|
|
} else {
|
|
} else {
|
|
@@ -477,18 +480,19 @@
|
|
if (isEmpty(self.allowedPreviewTypes)) {
|
|
if (isEmpty(self.allowedPreviewTypes)) {
|
|
self.allowedPreviewTypes = defaultPreviewTypes;
|
|
self.allowedPreviewTypes = defaultPreviewTypes;
|
|
}
|
|
}
|
|
|
|
+ if (!self.isPreviewable) {
|
|
|
|
+ self.showPreview = false;
|
|
|
|
+ }
|
|
self.uploadFileAttr = !isEmpty($el.attr('name')) ? $el.attr('name') : 'file_data';
|
|
self.uploadFileAttr = !isEmpty($el.attr('name')) ? $el.attr('name') : 'file_data';
|
|
self.reader = null;
|
|
self.reader = null;
|
|
self.formdata = {};
|
|
self.formdata = {};
|
|
- self.isIE9 = isIE(9);
|
|
|
|
- self.isIE10 = isIE(10);
|
|
|
|
self.filestack = [];
|
|
self.filestack = [];
|
|
self.ajaxRequests = [];
|
|
self.ajaxRequests = [];
|
|
self.isError = false;
|
|
self.isError = false;
|
|
self.ajaxAborted = false;
|
|
self.ajaxAborted = false;
|
|
self.dropZoneEnabled = hasDragDropSupport() && self.dropZoneEnabled;
|
|
self.dropZoneEnabled = hasDragDropSupport() && self.dropZoneEnabled;
|
|
self.isDisabled = self.$element.attr('disabled') || self.$element.attr('readonly');
|
|
self.isDisabled = self.$element.attr('disabled') || self.$element.attr('readonly');
|
|
- self.isUploadable = hasFileUploadSupport && !isEmpty(self.uploadUrl);
|
|
|
|
|
|
+ self.isUploadable = hasFileUploadSupport() && !isEmpty(self.uploadUrl);
|
|
self.slug = typeof options.slugCallback === "function" ? options.slugCallback : self.slugDefault;
|
|
self.slug = typeof options.slugCallback === "function" ? options.slugCallback : self.slugDefault;
|
|
self.mainTemplate = self.showCaption ? self.getLayoutTemplate('main1') : self.getLayoutTemplate('main2');
|
|
self.mainTemplate = self.showCaption ? self.getLayoutTemplate('main1') : self.getLayoutTemplate('main2');
|
|
self.captionTemplate = self.getLayoutTemplate('caption');
|
|
self.captionTemplate = self.getLayoutTemplate('caption');
|
|
@@ -643,11 +647,20 @@
|
|
$form.on('submit', $.proxy(self.submitForm, self));
|
|
$form.on('submit', $.proxy(self.submitForm, self));
|
|
}
|
|
}
|
|
self.$container.find('.kv-fileinput-upload').off('click').on('click', function (e) {
|
|
self.$container.find('.kv-fileinput-upload').off('click').on('click', function (e) {
|
|
|
|
+ var $btn = $(this), $form, isEnabled = !$btn.hasClass('disabled') && isEmpty($btn.attr('disabled'));
|
|
if (!self.isUploadable) {
|
|
if (!self.isUploadable) {
|
|
|
|
+ if (isEnabled && $btn.attr('type') !== 'submit') {
|
|
|
|
+ $form = $btn.closest('form');
|
|
|
|
+ // downgrade to normal form submit if possible
|
|
|
|
+ if ($form.length) {
|
|
|
|
+ $form.trigger('submit');
|
|
|
|
+ }
|
|
|
|
+ e.preventDefault();
|
|
|
|
+ }
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
e.preventDefault();
|
|
e.preventDefault();
|
|
- if (!$(this).hasClass('disabled') && isEmpty($(this).attr('disabled'))) {
|
|
|
|
|
|
+ if (isEnabled) {
|
|
self.upload();
|
|
self.upload();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -1835,7 +1848,6 @@
|
|
}
|
|
}
|
|
self.filestack.push(file);
|
|
self.filestack.push(file);
|
|
}
|
|
}
|
|
-
|
|
|
|
readFile(0);
|
|
readFile(0);
|
|
self.updateFileDetails(numFiles, false);
|
|
self.updateFileDetails(numFiles, false);
|
|
},
|
|
},
|
|
@@ -1940,7 +1952,7 @@
|
|
self.filestack = [];
|
|
self.filestack = [];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!self.isIE9) {
|
|
|
|
|
|
+ if (self.isPreviewable) {
|
|
self.readFiles(tfiles);
|
|
self.readFiles(tfiles);
|
|
} else {
|
|
} else {
|
|
self.updateFileDetails(1);
|
|
self.updateFileDetails(1);
|