(function ($) { var handleFiles, ProgressBar, FileList, FileListInline; $.fileTypeIcon = function (fileId, file) { if (typeof file.type == 'undefined') { return $(''+ file.type +''); } else if(file.type.substring(0,6) == 'image/') { return $(''); } else if(file.type == 'application/pdf') { return $('application/pdf'); } else if(file.type.indexOf("sheet") != -1) { return $(''+ file.type +''); } else if(file.type.indexOf("zip") != -1) { return $(''+ file.type +''); } else if (file.type.substring(0,6) == 'video/') { return $(''+ file.type +''); } else if (file.type.indexOf("word") != -1) { return $(''+ file.type +''); } else { return $(''+ file.type +''); } }; ProgressBar = function (options) { var bar = this; this.segments = []; this.updateSegment = function (number, current, total) { bar.segments[number] = [current, total]; bar.update(); }; this.update = function () { var total = 0, current = 0; $.each(bar.segments, function (k, item) { current += item[0]; total += item[1]; }); options.progress(current, total); if (current === total) { options.done(); } }; }; FileList = function (options) { var $list = $(options.list); this.clearErrors = function () { $list.find('.text-danger').remove(); }; this.addError = function (file, message) { var $li = $('
  • ').appendTo($list); $li.text(file.name); $li.addClass('text-danger'); $li.append(' (' + (message ? message : tr('uploading failed')) + ')'); }; this.addFile = function (fileId, file, title) { // called for "upload in modal" tracker Files fields when file dropped or picked from the file dialog var $li = $('
  • ').addClass("row mb-4").appendTo($list); var label = file.name; if (title) { label = title; } $("
    ").addClass("col-sm-12").text(label) .prepend($.fileTypeIcon(fileId, file).css("margin-right", "1em")) .appendTo($li); if ($list.parents(".inline").length) { var $fileInput = $list.parents(".files-field").find("> input"); var val = $fileInput.val(); val = val ? val + "," + fileId : fileId; $fileInput.val(val); } else { $('') .attr('value', fileId) .appendTo($li); if ($list.data("adddescription")) { $("