Files
RTG/webroot/js/inventory.js
2026-06-19 20:08:01 +06:00

46 lines
1.1 KiB
JavaScript

$(function () {
$('#dropzone').on('dragover', function () {
$(this).addClass('hover');
});
$('#dropzone').on('dragleave', function () {
$(this).removeClass('hover');
});
$('#dropzone input').on('change', function (e) {
var file = this.files[0];
$('#dropzone').removeClass('hover');
if (this.accept && $.inArray(file.type, this.accept.split(/, ?/)) == -1) {
return alert('File type not allowed.');
}
$('#dropzone').addClass('dropped');
$('#dropzone img').remove();
if ((/^image\/(gif|png|jpeg)$/i).test(file.type)) {
var reader = new FileReader(file);
reader.readAsDataURL(file);
reader.onload = function (e) {
var data = e.target.result,
$img = $('<img />').attr('src', data).fadeIn();
$('#dropzone div').html($img);
};
} else {
var ext = file.name.split('.').pop();
$('#dropzone div').html(ext);
}
});
$('[data-toggle="tooltip"]').tooltip(); //this js is for tooltip option show
});