some refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-08-08 22:16:25 +03:00
parent 55c80011f5
commit f19894bf39

View File

@ -46,8 +46,7 @@ module.DragAndDrop = core.ImageGridFeatures.Feature({
for (var i = 0, f; f = files[i]; i++) { for (var i = 0, f; f = files[i]; i++) {
// only images... // only images...
if (!f.type.match('image.*')) { if (!f.type.match('image.*')) {
continue continue }
}
if(f.path){ if(f.path){
paths.push(f.path) paths.push(f.path)
@ -66,9 +65,7 @@ module.DragAndDrop = core.ImageGridFeatures.Feature({
that.ribbons.updateImage(gid) that.ribbons.updateImage(gid)
} })(f) } })(f)
reader.readAsDataURL(f) reader.readAsDataURL(f) } }
}
}
if(paths.length > 0){ if(paths.length > 0){
that.loadURLs(paths) that.loadURLs(paths)
@ -78,26 +75,24 @@ module.DragAndDrop = core.ImageGridFeatures.Feature({
// add the generated stuff to the list -- this will help us id the // add the generated stuff to the list -- this will help us id the
// images when they are loaded later... // images when they are loaded later...
that.images.forEach(function(gid, img){ that.images
lst[img.path].gid = gid .forEach(function(gid, img){
img.name = img.path.split('.').slice(0, -1).join('.') lst[img.path].gid = gid
}) img.name = img.path
} .split('.')
} .slice(0, -1)
.join('.') }) } }
function handleDragOver(evt) { function handleDragOver(evt) {
evt.stopPropagation() evt.stopPropagation()
evt.preventDefault() evt.preventDefault()
// Explicitly show this is a copy... // Explicitly show this is a copy...
evt.dataTransfer.dropEffect = 'copy' evt.dataTransfer.dropEffect = 'copy' }
}
// handle drop events... // handle drop events...
this.ribbons.viewer[0] this.ribbons.viewer[0]
.addEventListener('dragover', handleDragOver, false); .addEventListener('dragover', handleDragOver, false);
this.ribbons.viewer[0] this.ribbons.viewer[0]
.addEventListener('drop', handleDrop, false) .addEventListener('drop', handleDrop, false) }] ],
}]
],
}) })