blob: 0f16c6fdde36fcf6e6cf73ca233b3722cdecdaa2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
define('drag_n_drop', ['jquery', 'jquery-ui', 'rhizicore'], function($, __unused_jqueryui, RZ) {
function init() {
console.log('rhizi: init drag-n-drop');
$(document).on('drop', function(e) {
e.stopPropagation();
e.preventDefault();
var files = e.originalEvent.dataTransfer.files;
var file = files[files.length - 1];
var fr = new FileReader();
fr.onload = function() {
if (fr.readyState != 2) {
console.log('drop: error: reading from file failed');
} else {
console.log('loading dropped file');
RZ.load_from_json(fr.result);
}
}
fr.readAsText(file);
return false;
});
$(document).on('dragover', function (e)
{
e.stopPropagation();
e.preventDefault();
return false;
});
};
return {'init': init };
}); // define
|