|
@@ -21,7 +21,7 @@
|
|
$.fn.fileinputLocales = {};
|
|
$.fn.fileinputLocales = {};
|
|
|
|
|
|
var isIE, isEdge, handler, previewCache, getNum, hasFileAPISupport, hasDragDropSupport, hasFileUploadSupport, addCss,
|
|
var isIE, isEdge, handler, previewCache, getNum, hasFileAPISupport, hasDragDropSupport, hasFileUploadSupport, addCss,
|
|
- STYLE_SETTING, OBJECT_PARAMS, DEFAULT_PREVIEW, defaultFileActionSettings, tMain1, tMain2, tPreview, tIcon,
|
|
|
|
|
|
+ STYLE_SETTING, OBJECT_PARAMS, DEFAULT_PREVIEW, defaultFileActionSettings, tMain1, tMain2, tPreview, tIcon, tClose,
|
|
tCaption, tBtnDefault, tBtnLink, tBtnBrowse, tModal, tProgress, tFooter, tActions, tActionDelete, tActionUpload,
|
|
tCaption, tBtnDefault, tBtnLink, tBtnBrowse, tModal, tProgress, tFooter, tActions, tActionDelete, tActionUpload,
|
|
tZoom, tGeneric, tHtml, tImage, tText, tVideo, tAudio, tFlash, tObject, tOther, defaultLayoutTemplates,
|
|
tZoom, tGeneric, tHtml, tImage, tText, tVideo, tAudio, tFlash, tObject, tOther, defaultLayoutTemplates,
|
|
defaultPreviewTemplates, defaultPreviewTypes, defaultPreviewSettings, defaultFileTypeSettings, isEmpty, isArray,
|
|
defaultPreviewTemplates, defaultPreviewTypes, defaultPreviewSettings, defaultFileTypeSettings, isEmpty, isArray,
|
|
@@ -286,7 +286,7 @@
|
|
'</div>';
|
|
'</div>';
|
|
tMain2 = '{preview}\n<div class="kv-upload-progress hide"></div>\n{remove}\n{cancel}\n{upload}\n{browse}\n';
|
|
tMain2 = '{preview}\n<div class="kv-upload-progress hide"></div>\n{remove}\n{cancel}\n{upload}\n{browse}\n';
|
|
tPreview = '<div class="file-preview {class}">\n' +
|
|
tPreview = '<div class="file-preview {class}">\n' +
|
|
- ' <div class="close fileinput-remove">×</div>\n' +
|
|
|
|
|
|
+ ' {close}' +
|
|
' <div class="{dropClass}">\n' +
|
|
' <div class="{dropClass}">\n' +
|
|
' <div class="file-preview-thumbnails">\n' +
|
|
' <div class="file-preview-thumbnails">\n' +
|
|
' </div>\n' +
|
|
' </div>\n' +
|
|
@@ -295,6 +295,7 @@
|
|
' <div class="kv-fileinput-error"></div>\n' +
|
|
' <div class="kv-fileinput-error"></div>\n' +
|
|
' </div>\n' +
|
|
' </div>\n' +
|
|
'</div>';
|
|
'</div>';
|
|
|
|
+ tClose = '<div class="close fileinput-remove">×</div>\n';
|
|
tIcon = '<span class="glyphicon glyphicon-file kv-caption-icon"></span>';
|
|
tIcon = '<span class="glyphicon glyphicon-file kv-caption-icon"></span>';
|
|
tCaption = '<div tabindex="500" class="form-control file-caption {class}">\n' +
|
|
tCaption = '<div tabindex="500" class="form-control file-caption {class}">\n' +
|
|
' <div class="file-caption-name"></div>\n' +
|
|
' <div class="file-caption-name"></div>\n' +
|
|
@@ -400,6 +401,7 @@
|
|
main1: tMain1,
|
|
main1: tMain1,
|
|
main2: tMain2,
|
|
main2: tMain2,
|
|
preview: tPreview,
|
|
preview: tPreview,
|
|
|
|
+ close: tClose,
|
|
zoom: tZoom,
|
|
zoom: tZoom,
|
|
icon: tIcon,
|
|
icon: tIcon,
|
|
caption: tCaption,
|
|
caption: tCaption,
|
|
@@ -908,7 +910,7 @@
|
|
if (!self.isUploadable || !self.showPreview || $zone.length === 0 || self.getFileStack().length > 0 || !self.dropZoneEnabled) {
|
|
if (!self.isUploadable || !self.showPreview || $zone.length === 0 || self.getFileStack().length > 0 || !self.dropZoneEnabled) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if ($zone.find('.file-preview-frame').length === 0) {
|
|
|
|
|
|
+ if ($zone.find('.file-preview-frame').length === 0 && isEmpty(self.defaultPreviewContent)) {
|
|
$zone.prepend('<div class="' + self.dropZoneTitleClass + '">' + self.dropZoneTitle + '</div>');
|
|
$zone.prepend('<div class="' + self.dropZoneTitleClass + '">' + self.dropZoneTitle + '</div>');
|
|
}
|
|
}
|
|
self.$container.removeClass('file-input-new');
|
|
self.$container.removeClass('file-input-new');
|
|
@@ -1005,6 +1007,7 @@
|
|
if (!self.$preview.find('.file-preview-frame').length || !self.showPreview) {
|
|
if (!self.$preview.find('.file-preview-frame').length || !self.showPreview) {
|
|
self.resetUpload();
|
|
self.resetUpload();
|
|
}
|
|
}
|
|
|
|
+ self.validateDefaultPreview();
|
|
},
|
|
},
|
|
initPreview: function (isInit) {
|
|
initPreview: function (isInit) {
|
|
var self = this, cap = self.initialCaption || '', out;
|
|
var self = this, cap = self.initialCaption || '', out;
|
|
@@ -1222,6 +1225,7 @@
|
|
self.setCaption(cap);
|
|
self.setCaption(cap);
|
|
self.$caption.attr('title', '');
|
|
self.$caption.attr('title', '');
|
|
addCss(self.$container, 'file-input-new');
|
|
addCss(self.$container, 'file-input-new');
|
|
|
|
+ self.validateDefaultPreview();
|
|
}
|
|
}
|
|
if (self.$container.find('.file-preview-frame').length === 0) {
|
|
if (self.$container.find('.file-preview-frame').length === 0) {
|
|
if (!self.initCaption()) {
|
|
if (!self.initCaption()) {
|
|
@@ -1245,6 +1249,18 @@
|
|
self.initCaption();
|
|
self.initCaption();
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ clearDefaultPreview: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ self.$preview.find('.file-default-preview').remove();
|
|
|
|
+ },
|
|
|
|
+ validateDefaultPreview: function() {
|
|
|
|
+ var self = this;
|
|
|
|
+ if (!self.showPreview || isEmpty(self.defaultPreviewContent)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ self.$preview.html('<div class="file-default-preview">' + self.defaultPreviewContent + '</div>');
|
|
|
|
+ self.$container.removeClass('file-input-new');
|
|
|
|
+ },
|
|
resetPreviewThumbs: function (isAjax) {
|
|
resetPreviewThumbs: function (isAjax) {
|
|
var self = this, out;
|
|
var self = this, out;
|
|
if (isAjax) {
|
|
if (isAjax) {
|
|
@@ -1926,6 +1942,7 @@
|
|
'">' + self.fileActionSettings.indicatorError + '</div>';
|
|
'">' + self.fileActionSettings.indicatorError + '</div>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ self.clearDefaultPreview();
|
|
self.$preview.append("\n" + previewOtherTemplate
|
|
self.$preview.append("\n" + previewOtherTemplate
|
|
.replace(/\{previewId}/g, previewId)
|
|
.replace(/\{previewId}/g, previewId)
|
|
.replace(/\{frameClass}/g, frameClass)
|
|
.replace(/\{frameClass}/g, frameClass)
|
|
@@ -1973,6 +1990,7 @@
|
|
.replace(/\{width}/g, config.width).replace(/\{height}/g, config.height)
|
|
.replace(/\{width}/g, config.width).replace(/\{height}/g, config.height)
|
|
.replace(/\{footer}/g, footer).replace(/\{data}/g, data);
|
|
.replace(/\{footer}/g, footer).replace(/\{data}/g, data);
|
|
}
|
|
}
|
|
|
|
+ self.clearDefaultPreview();
|
|
self.$preview.append("\n" + content);
|
|
self.$preview.append("\n" + content);
|
|
self.validateImage(i, previewId, caption, file.type);
|
|
self.validateImage(i, previewId, caption, file.type);
|
|
} else {
|
|
} else {
|
|
@@ -2408,12 +2426,15 @@
|
|
},
|
|
},
|
|
renderMain: function () {
|
|
renderMain: function () {
|
|
var self = this, dropCss = (self.isUploadable && self.dropZoneEnabled) ? ' file-drop-zone' : '',
|
|
var self = this, dropCss = (self.isUploadable && self.dropZoneEnabled) ? ' file-drop-zone' : '',
|
|
- preview = self.showPreview ? self.getLayoutTemplate('preview').replace(/\{class}/g, self.previewClass)
|
|
|
|
- .replace(/\{dropClass}/g, dropCss) : '',
|
|
|
|
|
|
+ close = !self.showClose ? '' : self.getLayoutTemplate('close'),
|
|
|
|
+ preview = !self.showPreview ? '' : self.getLayoutTemplate('preview')
|
|
|
|
+ .replace(/\{class}/g, self.previewClass)
|
|
|
|
+ .replace(/\{dropClass}/g, dropCss),
|
|
css = self.isDisabled ? self.captionClass + ' file-caption-disabled' : self.captionClass,
|
|
css = self.isDisabled ? self.captionClass + ' file-caption-disabled' : self.captionClass,
|
|
caption = self.captionTemplate.replace(/\{class}/g, css + ' kv-fileinput-caption');
|
|
caption = self.captionTemplate.replace(/\{class}/g, css + ' kv-fileinput-caption');
|
|
return self.mainTemplate.replace(/\{class}/g, self.mainClass)
|
|
return self.mainTemplate.replace(/\{class}/g, self.mainClass)
|
|
.replace(/\{preview}/g, preview)
|
|
.replace(/\{preview}/g, preview)
|
|
|
|
+ .replace(/\{close}/g, close)
|
|
.replace(/\{caption}/g, caption)
|
|
.replace(/\{caption}/g, caption)
|
|
.replace(/\{upload}/g, self.renderButton('upload'))
|
|
.replace(/\{upload}/g, self.renderButton('upload'))
|
|
.replace(/\{remove}/g, self.renderButton('remove'))
|
|
.replace(/\{remove}/g, self.renderButton('remove'))
|
|
@@ -2505,6 +2526,7 @@
|
|
showRemove: true,
|
|
showRemove: true,
|
|
showUpload: true,
|
|
showUpload: true,
|
|
showCancel: true,
|
|
showCancel: true,
|
|
|
|
+ showClose: true,
|
|
showUploadedThumbs: true,
|
|
showUploadedThumbs: true,
|
|
autoReplace: false,
|
|
autoReplace: false,
|
|
mainClass: '',
|
|
mainClass: '',
|
|
@@ -2527,6 +2549,7 @@
|
|
allowedPreviewMimeTypes: null,
|
|
allowedPreviewMimeTypes: null,
|
|
allowedFileTypes: null,
|
|
allowedFileTypes: null,
|
|
allowedFileExtensions: null,
|
|
allowedFileExtensions: null,
|
|
|
|
+ defaultPreviewContent: null,
|
|
customLayoutTags: {},
|
|
customLayoutTags: {},
|
|
customPreviewTags: {},
|
|
customPreviewTags: {},
|
|
previewSettings: defaultPreviewSettings,
|
|
previewSettings: defaultPreviewSettings,
|