(function($){ function bytesToSize(bytes) { var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; if (bytes == 0) return '0 Byte'; var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024))); return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i]; } function getExt(filename){ return (/[.]/.exec(filename)) ? /[^.]+$/.exec(filename) : undefined; } $(document).ready(function(){ $('.ap-field-type-upload input[type="file"]').on('change', function(){ var args = $(this).data('upload'); var parent = $(this).closest('.ap-form-group'); var counter = $(this).parent().find('b'); parent.removeClass('ap-have-errors'); parent.find('.ap-field-errors').remove(); if($(this).parent().prev().is('.ap-upload-list')) $(this).parent().prev().remove(); $('
').insertBefore($(this).parent()); if(this.files.length > args.max_files){ AnsPress.trigger('snackbar', {'snackbar': {'success': false, 'message': args.label_max_added}}); parent.addClass('ap-have-errors'); $('