/*!
* bootstrap-fileinput v4.3.6
* http://plugins.krajee.com/file-input
*
* Author: Kartik Visweswaran
* Copyright: 2014 - 2016, Kartik Visweswaran, Krajee.com
*
* Licensed under the BSD 3-Clause
* https://github.com/kartik-v/bootstrap-fileinput/blob/master/LICENSE.md
*/
(function (factory) {
"use strict";
//noinspection JSUnresolvedVariable
if (typeof define === 'function' && define.amd) { // jshint ignore:line
// AMD. Register as an anonymous module.
define(['jquery'], factory); // jshint ignore:line
} else { // noinspection JSUnresolvedVariable
if (typeof module === 'object' && module.exports) { // jshint ignore:line
// Node/CommonJS
// noinspection JSUnresolvedVariable
module.exports = factory(require('jquery')); // jshint ignore:line
} else {
// Browser globals
factory(window.jQuery);
}
}
}(function ($) {
"use strict";
$.fn.fileinputLocales = {};
$.fn.fileinputThemes = {};
var NAMESPACE, MODAL_ID, STYLE_SETTING, OBJECT_PARAMS, DEFAULT_PREVIEW, objUrl, compare, isIE, handler,
previewCache, getNum, hasFileAPISupport, hasDragDropSupport, hasFileUploadSupport, addCss, tMain1, tMain2,
tPreview, tFileIcon, tClose, tCaption, tBtnDefault, tBtnLink, tBtnBrowse, tModalMain, tModal, tProgress, tSize,
tFooter, tActions, tActionDelete, tActionUpload, tActionZoom, tActionDrag, tTagBef, tTagBef1, tTagBef2, tTagAft,
tGeneric, tHtml, tImage, tText, tVideo, tAudio, tFlash, tObject, tPdf, tOther, defaultFileActionSettings,
defaultLayoutTemplates, defaultPreviewTemplates, defaultPreviewZoomSettings, defaultPreviewTypes, getElement,
defaultPreviewSettings, defaultFileTypeSettings, isEmpty, isArray, ifSet, uniqId, htmlEncode, replaceTags,
cleanMemory, findFileName, checkFullScreen, toggleFullScreen, moveArray, FileInput;
NAMESPACE = '.fileinput';
MODAL_ID = 'kvFileinputModal';
STYLE_SETTING = 'style="width:{width};height:{height};"';
OBJECT_PARAMS = '\n' +
'\n' +
'\n' +
'\n' +
'\n' +
'\n';
DEFAULT_PREVIEW = '
\n' +
'{previewFileIcon}\n' +
'
';
//noinspection JSUnresolvedVariable
objUrl = window.URL || window.webkitURL;
compare = function (input, str, exact) {
return input !== undefined && (exact ? input === str : input.match(str));
};
isIE = function (ver) {
// check for IE versions < 11
if (navigator.appName !== 'Microsoft Internet Explorer') {
return false;
}
if (ver === 10) {
return new RegExp('msie\\s' + ver, 'i').test(navigator.userAgent);
}
var div = document.createElement("div"), status;
div.innerHTML = "";
status = div.getElementsByTagName("i").length;
document.body.appendChild(div);
div.parentNode.removeChild(div);
return status;
};
handler = function ($el, event, callback, skipNS) {
var ev = skipNS ? event : event.split(' ').join(NAMESPACE + ' ') + NAMESPACE;
$el.off(ev).on(ev, callback);
};
previewCache = {
data: {},
init: function (obj) {
var content = obj.initialPreview, id = obj.id;
if (content.length > 0 && !isArray(content)) {
content = content.split(obj.initialPreviewDelimiter);
}
previewCache.data[id] = {
content: content,
config: obj.initialPreviewConfig,
tags: obj.initialPreviewThumbTags,
delimiter: obj.initialPreviewDelimiter,
previewFileType: obj.initialPreviewFileType,
previewAsData: obj.initialPreviewAsData,
template: obj.previewGenericTemplate,
showZoom: obj.fileActionSettings.showZoom,
showDrag: obj.fileActionSettings.showDrag,
getSize: function (size) {
return obj._getSize(size);
},
parseTemplate: function (cat, data, fname, ftype, pId, ftr, ind) {
var fc = ' file-preview-initial';
return obj._generatePreviewTemplate(cat, data, fname, ftype, pId, false, null, fc, ftr, ind);
},
msg: function (n) {
return obj._getMsgSelected(n);
},
initId: obj.previewInitId,
footer: obj._getLayoutTemplate('footer').replace(/\{progress}/g, obj._renderThumbProgress()),
isDelete: obj.initialPreviewShowDelete,
caption: obj.initialCaption,
actions: function (showUpload, showDelete, showZoom, showDrag, disabled, url, key) {
return obj._renderFileActions(showUpload, showDelete, showZoom, showDrag, disabled, url, key, true);
}
};
},
fetch: function (id) {
return previewCache.data[id].content.filter(function (n) {
return n !== null;
});
},
count: function (id, all) {
return !!previewCache.data[id] && !!previewCache.data[id].content ?
(all ? previewCache.data[id].content.length : previewCache.fetch(id).length) : 0;
},
get: function (id, i, isDisabled) {
var ind = 'init_' + i, data = previewCache.data[id], config = data.config[i], content = data.content[i],
previewId = data.initId + '-' + ind, out, $tmp, frameClass = ' file-preview-initial', cat, cap, ftr,
ftype, asData = ifSet('previewAsData', config, data.previewAsData);
isDisabled = isDisabled === undefined ? true : isDisabled;
/** @namespace config.frameAttr */
/** @namespace config.frameClass */
/** @namespace config.filetype */
if (!content) {
return '';
}
if (config && config.frameClass) {
frameClass += ' ' + config.frameClass;
}
if (asData) {
cat = data.previewAsData ? ifSet('type', config, data.previewFileType || 'generic') : 'generic';
cap = ifSet('caption', config);
ftr = previewCache.footer(id, i, isDisabled, (config && config.size || null));
ftype = ifSet('filetype', config, cat);
out = data.parseTemplate(cat, content, cap, ftype, previewId, ftr, ind, null);
} else {
out = data.template
.replace(/\{previewId}/g, previewId).replace(/\{frameClass}/g, frameClass)
.replace(/\{fileindex}/g, ind).replace(/\{content}/g, data.content[i])
.replace(/\{template}/g, ifSet('type', config, data.previewFileType))
.replace(/\{footer}/g, previewCache.footer(id, i, isDisabled, (config && config.size || null)));
}
if (data.tags.length && data.tags[i]) {
out = replaceTags(out, data.tags[i]);
}
if (!isEmpty(config) && !isEmpty(config.frameAttr)) {
$tmp = $(document.createElement('div')).html(out);
$tmp.find('.file-preview-initial').attr(config.frameAttr);
out = $tmp.html();
$tmp.remove();
}
return out;
},
add: function (id, content, config, tags, append) {
var data = $.extend(true, {}, previewCache.data[id]), index;
if (!isArray(content)) {
content = content.split(data.delimiter);
}
if (append) {
index = data.content.push(content) - 1;
data.config[index] = config;
data.tags[index] = tags;
} else {
index = content.length - 1;
data.content = content;
data.config = config;
data.tags = tags;
}
previewCache.data[id] = data;
return index;
},
set: function (id, content, config, tags, append) {
var data = $.extend(true, {}, previewCache.data[id]), i, chk;
if (!content || !content.length) {
return;
}
if (!isArray(content)) {
content = content.split(data.delimiter);
}
chk = content.filter(function (n) {
return n !== null;
});
if (!chk.length) {
return;
}
if (data.content === undefined) {
data.content = [];
}
if (data.config === undefined) {
data.config = [];
}
if (data.tags === undefined) {
data.tags = [];
}
if (append) {
for (i = 0; i < content.length; i++) {
if (content[i]) {
data.content.push(content[i]);
}
}
for (i = 0; i < config.length; i++) {
if (config[i]) {
data.config.push(config[i]);
}
}
for (i = 0; i < tags.length; i++) {
if (tags[i]) {
data.tags.push(tags[i]);
}
}
} else {
data.content = content;
data.config = config;
data.tags = tags;
}
previewCache.data[id] = data;
},
unset: function (obj, index) {
var chk = previewCache.count(obj.id);
if (!chk) {
return;
}
if (chk === 1) {
previewCache.data[obj.id].content = [];
previewCache.data[obj.id].config = [];
previewCache.data[obj.id].tags = [];
obj.initialPreview = [];
obj.initialPreviewConfig = [];
obj.initialPreviewThumbTags = [];
return;
}
previewCache.data[obj.id].content[index] = null;
previewCache.data[obj.id].config[index] = null;
previewCache.data[obj.id].tags[index] = null;
},
out: function (id) {
var html = '', data = previewCache.data[id], caption, len = previewCache.count(id, true);
if (len === 0) {
return { content: '', caption: '' };
}
for (var i = 0; i < len; i++) {
html += previewCache.get(id, i);
}
caption = data.msg(previewCache.count(id));
return { content: '' + html + '
', caption: caption };
},
footer: function (id, i, isDisabled, size) {
var data = previewCache.data[id];
isDisabled = isDisabled === undefined ? true : isDisabled;
if (data.config.length === 0 || isEmpty(data.config[i])) {
return '';
}
var config = data.config[i], caption = ifSet('caption', config), width = ifSet('width', config, 'auto'),
url = ifSet('url', config, false), key = ifSet('key', config, null),
showDel = ifSet('showDelete', config, true), showZoom = ifSet('showZoom', config, data.showZoom),
showDrag = ifSet('showDrag', config, data.showDrag), disabled = (url === false) && isDisabled,
actions = data.isDelete ? data.actions(false, showDel, showZoom, showDrag, disabled, url, key) : '',
footer = data.footer.replace(/\{actions}/g, actions);
return footer.replace(/\{caption}/g, caption).replace(/\{size}/g, data.getSize(size))
.replace(/\{width}/g, width).replace(/\{indicator}/g, '').replace(/\{indicatorTitle}/g, '');
}
};
getNum = function (num, def) {
def = def || 0;
if (typeof num === "number") {
return num;
}
if (typeof num === "string") {
num = parseFloat(num);
}
return isNaN(num) ? def : num;
};
hasFileAPISupport = function () {
return !!(window.File && window.FileReader);
};
hasDragDropSupport = function () {
var div = document.createElement('div');
/** @namespace div.draggable */
/** @namespace div.ondragstart */
/** @namespace div.ondrop */
return !isIE(9) && (div.draggable !== undefined || (div.ondragstart !== undefined && div.ondrop !== undefined));
};
hasFileUploadSupport = function () {
return hasFileAPISupport() && window.FormData;
};
addCss = function ($el, css) {
$el.removeClass(css).addClass(css);
};
defaultFileActionSettings = {
showRemove: true,
showUpload: true,
showZoom: true,
showDrag: true,
removeIcon: '',
removeClass: 'btn btn-xs btn-default',
removeTitle: 'Remove file',
uploadIcon: '',
uploadClass: 'btn btn-xs btn-default',
uploadTitle: 'Upload file',
zoomIcon: '',
zoomClass: 'btn btn-xs btn-default',
zoomTitle: 'View Details',
dragIcon: '',
dragClass: 'text-info',
dragTitle: 'Move / Rearrange',
dragSettings: {},
indicatorNew: '',
indicatorSuccess: '',
indicatorError: '',
indicatorLoading: '',
indicatorNewTitle: 'Not uploaded yet',
indicatorSuccessTitle: 'Uploaded',
indicatorErrorTitle: 'Upload Error',
indicatorLoadingTitle: 'Uploading ...'
};
tMain1 = '{preview}\n' +
'\n' +
'';
tMain2 = '{preview}\n\n{remove}\n{cancel}\n{upload}\n{browse}\n';
tPreview = '\n' +
' {close}' +
'
\n' +
'
\n' +
'
\n' +
'
' +
'
\n' +
'
\n' +
'
\n' +
'
';
tClose = '×
\n';
tFileIcon = '';
tCaption = '\n';
//noinspection HtmlUnknownAttribute
tBtnDefault = '';
//noinspection HtmlUnknownAttribute
tBtnLink = '{icon} {label}';
//noinspection HtmlUnknownAttribute
tBtnBrowse = '{icon} {label}
';
tModalMain = '';
tModal = '\n' +
'
\n' +
' \n' +
'
\n' +
'
\n' +
'
\n' + '{prev} {next}\n' +
'
\n' +
'
\n' +
'
\n';
tProgress = '\n' +
'
\n' +
' {percent}%\n' +
'
\n' +
'
';
tSize = '
({sizeText})';
tFooter = '';
tActions = '\n' +
' \n' +
' {drag}\n' +
'
{indicator}
\n' +
'
\n' +
'
';
//noinspection HtmlUnknownAttribute
tActionDelete = '\n';
tActionUpload = '';
tActionZoom = '';
tActionDrag = '{dragIcon}';
tTagBef = '\n';
tTagBef2 = tTagBef + ' title="{caption}" ' + STYLE_SETTING + '>
\n';
tTagAft = '
{footer}\n
\n';
tGeneric = '{content}\n';
tHtml = '
{data}
\n';
tImage = '
\n';
tText = '
\n';
tVideo = '
\n';
tAudio = '
\n';
tFlash = '
\n';
tObject = '
\n';
tPdf = '