inital commit
This commit is contained in:
46
webroot/js/inventory.js
Normal file
46
webroot/js/inventory.js
Normal file
@@ -0,0 +1,46 @@
|
||||
$(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
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user