|
@@ -1618,7 +1618,10 @@
|
|
|
tModalMain, tModal, tProgress, tSize, tFooter, tActions, tActionDelete, tActionUpload, tActionDownload,
|
|
|
tActionZoom, tActionDrag, tIndicator, tTagBef, tTagBef1, tTagBef2, tTagAft, tGeneric, tHtml, tImage,
|
|
|
tText, tOffice, tGdocs, tVideo, tAudio, tFlash, tObject, tPdf, tOther, tStyle, tZoomCache, vDefaultDim,
|
|
|
- tStats, tModalLabel;
|
|
|
+ tStats, tModalLabel, renderObject = function (type, mime) {
|
|
|
+ return '<object class="kv-preview-data file-preview-' + type + '" title="{caption}" ' +
|
|
|
+ 'data="{data}" type="' + mime + '"' + tStyle + '>\n' + $h.DEFAULT_PREVIEW + '\n</object>\n';
|
|
|
+ };
|
|
|
tMain1 = '{preview}\n' +
|
|
|
'<div class="kv-upload-progress kv-hidden"></div><div class="clearfix"></div>\n' +
|
|
|
'<div class="input-group {class}">\n' +
|
|
@@ -1656,7 +1659,7 @@
|
|
|
tBtnLink = '<a href="{href}" tabindex="500" title="{title}" class="{css}" {status}>{icon} {label}</a>';
|
|
|
//noinspection HtmlUnknownAttribute
|
|
|
tBtnBrowse = '<div tabindex="500" class="{css}" {status}>{icon} {label}</div>';
|
|
|
- tModalLabel = $h.MODAL_ID + 'Label';
|
|
|
+ tModalLabel = $h.MODAL_ID + 'Label';
|
|
|
tModalMain = '<div id="' + $h.MODAL_ID + '" class="file-zoom-dialog modal fade" ' +
|
|
|
'tabindex="-1" aria-labelledby="' + tModalLabel + '"></div>';
|
|
|
tModal = '<div class="modal-dialog modal-lg{rtl}" role="document">\n' +
|
|
@@ -1715,11 +1718,11 @@
|
|
|
tTagAft = '</div>{footer}\n{zoomCache}</div>\n';
|
|
|
tGeneric = '{content}\n';
|
|
|
tStyle = ' {style}';
|
|
|
- tHtml = '<div class="kv-preview-data file-preview-html" title="{caption}"' + tStyle + '>{data}</div>\n';
|
|
|
- tImage = '<img src="{data}" class="file-preview-image kv-preview-data" title="{title}" ' +
|
|
|
- 'alt="{alt}"' + tStyle + '>\n';
|
|
|
- tText = '<textarea class="kv-preview-data file-preview-text" title="{caption}" readonly' + tStyle + '>' +
|
|
|
- '{data}</textarea>\n';
|
|
|
+ tHtml = renderObject('html', 'text/html');
|
|
|
+ tText = renderObject('text', 'text/plain;charset=UTF-8');
|
|
|
+ tPdf = renderObject('pdf', 'application/pdf');
|
|
|
+ tImage = '<img src="{data}" class="file-preview-image kv-preview-data" title="{title}" alt="{alt}"' +
|
|
|
+ tStyle + '>\n';
|
|
|
tOffice = '<iframe class="kv-preview-data file-preview-office" ' +
|
|
|
'src="https://view.officeapps.live.com/op/embed.aspx?src={data}"' + tStyle + '></iframe>';
|
|
|
tGdocs = '<iframe class="kv-preview-data file-preview-gdocs" ' +
|
|
@@ -1729,7 +1732,6 @@
|
|
|
tAudio = '<!--suppress ALL --><audio class="kv-preview-data file-preview-audio" controls' + tStyle + '>\n<source src="{data}" ' +
|
|
|
'type="{type}">\n' + $h.DEFAULT_PREVIEW + '\n</audio>\n';
|
|
|
tFlash = '<embed class="kv-preview-data file-preview-flash" src="{data}" type="application/x-shockwave-flash"' + tStyle + '>\n';
|
|
|
- tPdf = '<embed class="kv-preview-data file-preview-pdf" src="{data}" type="application/pdf"' + tStyle + '>\n';
|
|
|
tObject = '<object class="kv-preview-data file-preview-object file-object {typeCss}" ' +
|
|
|
'data="{data}" type="{type}"' + tStyle + '>\n' + '<param name="movie" value="{caption}" />\n' +
|
|
|
$h.OBJECT_PARAMS + ' ' + $h.DEFAULT_PREVIEW + '\n</object>\n';
|
|
@@ -1847,7 +1849,7 @@
|
|
|
},
|
|
|
text: function (vType, vName) {
|
|
|
return $h.compare(vType, 'text.*') || $h.compare(vName, /\.(xml|javascript)$/i) ||
|
|
|
- $h.compare(vName, /\.(txt|md|csv|nfo|ini|json|php|js|css)$/i);
|
|
|
+ $h.compare(vName, /\.(txt|md|nfo|ini|json|php|js|css)$/i);
|
|
|
},
|
|
|
video: function (vType, vName) {
|
|
|
return $h.compare(vType, 'video.*') && ($h.compare(vType, /(ogg|mp4|mp?g|mov|webm|3gp)$/i) ||
|
|
@@ -1924,7 +1926,7 @@
|
|
|
$.each(self.previewContentTemplates, function (key, value) {
|
|
|
if ($h.isEmpty(self.previewTemplates[key])) {
|
|
|
tagBef = tags.tagBefore2;
|
|
|
- if (key === 'generic' || key === 'image' || key === 'html' || key === 'text') {
|
|
|
+ if (key === 'generic' || key === 'image') {
|
|
|
tagBef = tags.tagBefore1;
|
|
|
}
|
|
|
if (self._isPdfRendered() && key === 'pdf') {
|
|
@@ -4064,9 +4066,6 @@
|
|
|
css = css.replace(' ' + $h.SORT_CSS, '');
|
|
|
}
|
|
|
tmplt = self._parseFilePreviewIcon(tmplt, fname);
|
|
|
- if (c === 'text') {
|
|
|
- d = $h.htmlEncode(d);
|
|
|
- }
|
|
|
if (cat === 'object' && !ftype) {
|
|
|
$.each(self.defaults.fileTypeSettings, function (key, func) {
|
|
|
if (key === 'object' || key === 'other') {
|
|
@@ -4143,12 +4142,9 @@
|
|
|
}
|
|
|
var self = this, fname = $h.getFileName(file), ftype = fileInfo.type, caption = fileInfo.name,
|
|
|
cat = self._parseFileType(ftype, fname), content, $preview = self.$preview, fsize = file.size || 0,
|
|
|
- iData = (cat === 'text' || cat === 'html' || cat === 'image') ? theFile.target.result : data,
|
|
|
+ iData = cat === 'image' ? theFile.target.result : data,
|
|
|
fileId = self.fileManager.getId(file), previewId = self._getThumbId(fileId);
|
|
|
/** @namespace window.DOMPurify */
|
|
|
- if (cat === 'html' && self.purifyHtml && window.DOMPurify) {
|
|
|
- iData = window.DOMPurify.sanitize(iData);
|
|
|
- }
|
|
|
content = self._generatePreviewTemplate(cat, iData, fname, ftype, previewId, fileId, false, fsize);
|
|
|
self._clearDefaultPreview();
|
|
|
self._addToPreview($preview, content);
|
|
@@ -5204,7 +5200,7 @@
|
|
|
caption = self._getFileName(file, ''), fileSize = (file && file.size || 0) / 1000,
|
|
|
fileExtExpr = '', previewData = $h.createObjectURL(file), fileCount = 0,
|
|
|
strTypes = '', fileId, canLoad, fileReaderAborted = false,
|
|
|
- func, knownTypes = 0, isText, isHtml, isImage, txtFlag, processFileLoaded = function () {
|
|
|
+ func, knownTypes = 0, isImage, txtFlag, processFileLoaded = function () {
|
|
|
var msg = msgProgress.setTokens({
|
|
|
'index': i + 1,
|
|
|
'files': numFiles,
|
|
@@ -5322,8 +5318,6 @@
|
|
|
}, 10);
|
|
|
return;
|
|
|
}
|
|
|
- isText = fnText(file.type, caption);
|
|
|
- isHtml = fnHtml(file.type, caption);
|
|
|
isImage = fnImage(file.type, caption);
|
|
|
$status.html(msgLoading.replace('{index}', i + 1).replace('{files}', numFiles));
|
|
|
$container.addClass('file-thumb-loading');
|
|
@@ -5331,7 +5325,7 @@
|
|
|
self._errorHandler(evt, caption);
|
|
|
};
|
|
|
reader.onload = function (theFile) {
|
|
|
- var hex, fileInfo, uint, byte, bytes = [], contents, mime, readTextImage = function (textFlag) {
|
|
|
+ var hex, fileInfo, uint, byte, bytes = [], contents, mime, readImage = function () {
|
|
|
var newReader = new FileReader();
|
|
|
newReader.onerror = function (theFileNew) {
|
|
|
self._errorHandler(theFileNew, caption);
|
|
@@ -5350,11 +5344,7 @@
|
|
|
self._initFileActions();
|
|
|
processFileLoaded();
|
|
|
};
|
|
|
- if (textFlag) {
|
|
|
- newReader.readAsText(file, self.textEncoding);
|
|
|
- } else {
|
|
|
- newReader.readAsDataURL(file);
|
|
|
- }
|
|
|
+ newReader.readAsDataURL(file);
|
|
|
};
|
|
|
fileInfo = {'name': caption, 'type': file.type};
|
|
|
$.each(settings, function (k, f) {
|
|
@@ -5375,12 +5365,9 @@
|
|
|
mime = $h.isSvg(contents) ? 'image/svg+xml' : $h.getMimeType(hex, contents, file.type);
|
|
|
}
|
|
|
fileInfo = {'name': caption, 'type': mime};
|
|
|
- isText = fnText(mime, '');
|
|
|
- isHtml = fnHtml(mime, '');
|
|
|
isImage = fnImage(mime, '');
|
|
|
- txtFlag = isText || isHtml;
|
|
|
- if (txtFlag || isImage) {
|
|
|
- readTextImage(txtFlag);
|
|
|
+ if (isImage) {
|
|
|
+ readImage(txtFlag);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
@@ -5413,14 +5400,10 @@
|
|
|
}, self.processDelay);
|
|
|
}
|
|
|
};
|
|
|
- if (isText || isHtml) {
|
|
|
- reader.readAsText(file, self.textEncoding);
|
|
|
+ if (isImage) {
|
|
|
+ reader.readAsDataURL(file);
|
|
|
} else {
|
|
|
- if (isImage) {
|
|
|
- reader.readAsDataURL(file);
|
|
|
- } else {
|
|
|
- reader.readAsArrayBuffer(file);
|
|
|
- }
|
|
|
+ reader.readAsArrayBuffer(file);
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -5813,7 +5796,6 @@
|
|
|
frameClass: 'krajee-default',
|
|
|
mainClass: 'file-caption-main',
|
|
|
mainTemplate: null,
|
|
|
- purifyHtml: true,
|
|
|
fileSizeGetter: null,
|
|
|
initialCaption: '',
|
|
|
initialPreview: [],
|