pos-gis/public/js/filepond-validate.min.js

6 lines
2.7 KiB
JavaScript
Raw Normal View History

2024-10-07 06:13:42 +00:00
/*!
* FilePondPluginFileValidateSize 2.2.1
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*/
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?module.exports=factory():"function"==typeof define&&define.amd?define(factory):(global=global||self).FilePondPluginFileValidateSize=factory()}(this,(function(){"use strict";var plugin=function plugin(_ref){var addFilter=_ref.addFilter,utils=_ref.utils,Type=utils.Type,replaceInString=utils.replaceInString,toNaturalFileSize=utils.toNaturalFileSize;return addFilter("ALLOW_HOPPER_ITEM",(function(file,_ref2){var query=_ref2.query;if(!query("GET_ALLOW_FILE_SIZE_VALIDATION"))return!0;var sizeMax=query("GET_MAX_FILE_SIZE");if(null!==sizeMax&&file.size>=sizeMax)return!1;var sizeMin=query("GET_MIN_FILE_SIZE");return!(null!==sizeMin&&file.size<=sizeMin)})),addFilter("LOAD_FILE",(function(file,_ref3){var query=_ref3.query;return new Promise((function(resolve,reject){if(!query("GET_ALLOW_FILE_SIZE_VALIDATION"))return resolve(file);var fileFilter=query("GET_FILE_VALIDATE_SIZE_FILTER");if(fileFilter&&!fileFilter(file))return resolve(file);var sizeMax=query("GET_MAX_FILE_SIZE");if(null!==sizeMax&&file.size>=sizeMax)reject({status:{main:query("GET_LABEL_MAX_FILE_SIZE_EXCEEDED"),sub:replaceInString(query("GET_LABEL_MAX_FILE_SIZE"),{filesize:toNaturalFileSize(sizeMax)})}});else{var sizeMin=query("GET_MIN_FILE_SIZE");if(null!==sizeMin&&file.size<=sizeMin)reject({status:{main:query("GET_LABEL_MIN_FILE_SIZE_EXCEEDED"),sub:replaceInString(query("GET_LABEL_MIN_FILE_SIZE"),{filesize:toNaturalFileSize(sizeMin)})}});else{var totalSizeMax=query("GET_MAX_TOTAL_FILE_SIZE"),currentTotalSize;if(null!==totalSizeMax)if(query("GET_ACTIVE_ITEMS").reduce((function(total,item){return total+item.fileSize}),0)>totalSizeMax)return void reject({status:{main:query("GET_LABEL_MAX_TOTAL_FILE_SIZE_EXCEEDED"),sub:replaceInString(query("GET_LABEL_MAX_TOTAL_FILE_SIZE"),{filesize:toNaturalFileSize(totalSizeMax)})}});resolve(file)}}}))})),{options:{allowFileSizeValidation:[!0,Type.BOOLEAN],maxFileSize:[null,Type.INT],minFileSize:[null,Type.INT],maxTotalFileSize:[null,Type.INT],fileValidateSizeFilter:[null,Type.FUNCTION],labelMinFileSizeExceeded:["File is too small",Type.STRING],labelMinFileSize:["Minimum file size is {filesize}",Type.STRING],labelMaxFileSizeExceeded:["File is too large",Type.STRING],labelMaxFileSize:["Maximum file size is {filesize}",Type.STRING],labelMaxTotalFileSizeExceeded:["Maximum total size exceeded",Type.STRING],labelMaxTotalFileSize:["Maximum total file size is {filesize}",Type.STRING]}}},isBrowser;return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:plugin})),plugin}));