|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var temp = { |
|
|
|
|
|
upload: [ ], |
|
|
|
|
|
documentid: null |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
$(document).ready(function () { |
|
|
$(document).ready(function () { |
|
|
|
|
|
|
|
|
change_page(); |
|
|
change_page(); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function isvisible(obj) { |
|
|
function isvisible(obj) { |
|
|
var top_of_element = $(obj).offset().top; |
|
|
|
|
|
var bottom_of_element = $(obj).offset().top + $(obj).outerHeight(); |
|
|
|
|
|
|
|
|
var top_of_fileent = $(obj).offset().top; |
|
|
|
|
|
var bottom_of_fileent = $(obj).offset().top + $(obj).outerHeight(); |
|
|
var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight(); |
|
|
var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight(); |
|
|
var top_of_screen = $(window).scrollTop(); |
|
|
var top_of_screen = $(window).scrollTop(); |
|
|
|
|
|
|
|
|
if (bottom_of_screen > top_of_element && top_of_screen < bottom_of_element) { |
|
|
|
|
|
|
|
|
if (bottom_of_screen > top_of_fileent && top_of_screen < bottom_of_fileent) { |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function upload_zone_init() { |
|
|
function upload_zone_init() { |
|
|
$('.autodoc_upload_zone').on('dragenter', upload_zone_highlight); |
|
|
|
|
|
$('.autodoc_upload_zone').on('dragleave', upload_zone_normal); |
|
|
|
|
|
$('.autodoc_upload_zone').on('drop', upload_zone_drop); |
|
|
|
|
|
|
|
|
$(window).on("dragover dragleave drop", function(e) { e.preventDefault() }); |
|
|
|
|
|
|
|
|
|
|
|
$('.autodoc_upload_zone').on({ |
|
|
|
|
|
dragenter: upload_zone_highlight, |
|
|
|
|
|
dragleave: upload_zone_normal, |
|
|
|
|
|
dragover: upload_zone_over, |
|
|
|
|
|
drop: upload_zone_drop |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function upload_zone_highlight(e) { |
|
|
function upload_zone_highlight(e) { |
|
|
$(e.target).addClass('autodoc_upload_zone_highlight'); |
|
|
|
|
|
|
|
|
$(e.target).addClass('autodoc_upload_zone_hover'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function upload_zone_over(e) { |
|
|
|
|
|
return true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function upload_zone_normal(e) { |
|
|
function upload_zone_normal(e) { |
|
|
$(e.target).removeClass('autodoc_upload_zone_highlight'); |
|
|
|
|
|
|
|
|
$(e.target).removeClass('autodoc_upload_zone_hover'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function upload_zone_drop(e) { |
|
|
function upload_zone_drop(e) { |
|
|
|
|
|
var ev = e.originalEvent; |
|
|
|
|
|
console.log(ev.dataTransfer.files); |
|
|
|
|
|
|
|
|
|
|
|
if ( temp.documentid == null ) { |
|
|
|
|
|
$.post(conf.openapi + "/documents", {}, function(data) { |
|
|
|
|
|
console.log(data); |
|
|
|
|
|
handle_uploads(ev); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
handle_uplaods(ev); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handle_uploads(ev) { |
|
|
|
|
|
|
|
|
e.dataTransfer.effectAllowed = "none"; |
|
|
|
|
|
e.dataTransfer.dropEffect = "none"; |
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
console.log(e); |
|
|
|
|
|
|
|
|
$.each(ev.dataTransfer.files, function(id,file) { |
|
|
|
|
|
var fileid = temp.upload.length(); |
|
|
|
|
|
temp.upload.push({ |
|
|
|
|
|
name: file.name, |
|
|
|
|
|
type: file.type, |
|
|
|
|
|
size: file.size, |
|
|
|
|
|
progress: 0, |
|
|
|
|
|
error: null |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if ( file.type != 'application/pdf' && file.type != 'image/png' && file.type != 'image/jpeg' ) { |
|
|
|
|
|
temp.upload['progress']=1; |
|
|
|
|
|
temp.upload['error']='invalid file type'; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
var reader = new FileReader(); |
|
|
|
|
|
reader.readAsBinaryString(file); |
|
|
|
|
|
reader.onloadend = function() { |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |