mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
drag and drop now working, still a prototype...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a45fa6d20b
commit
82fa9d290b
@ -270,6 +270,16 @@ actions.Actions({
|
|||||||
return res
|
return res
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
getImagePath: ['- System/',
|
||||||
|
function(gid, type){
|
||||||
|
gid = this.data.getImage(gid)
|
||||||
|
|
||||||
|
var img = this.images[gid]
|
||||||
|
|
||||||
|
return img == null ?
|
||||||
|
null
|
||||||
|
: this.images.getImagePath(gid, this.location.path)
|
||||||
|
}],
|
||||||
replaceGid: ['- System/Replace image gid',
|
replaceGid: ['- System/Replace image gid',
|
||||||
{journal: true},
|
{journal: true},
|
||||||
function(from, to){
|
function(from, to){
|
||||||
|
|||||||
@ -196,14 +196,6 @@ module.IndexFormat = core.ImageGridFeatures.Feature({
|
|||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
var FileSystemInfoActions = actions.Actions({
|
var FileSystemInfoActions = actions.Actions({
|
||||||
getImagePath: ['- System/',
|
|
||||||
function(gid, type){
|
|
||||||
gid = this.data.getImage(gid)
|
|
||||||
|
|
||||||
var img = this.images[gid]
|
|
||||||
|
|
||||||
return pathlib.join(img.base_path || this.location.path, img.path)
|
|
||||||
}],
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,8 @@ var MetadataReaderActions = actions.Actions({
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var full_path = path.normalize(img.base_path +'/'+ img.path)
|
//var full_path = path.normalize(img.base_path +'/'+ img.path)
|
||||||
|
var full_path = this.getImagePath(gid)
|
||||||
|
|
||||||
return new Promise(function(resolve, reject){
|
return new Promise(function(resolve, reject){
|
||||||
if(!force && img.metadata){
|
if(!force && img.metadata){
|
||||||
@ -207,6 +208,7 @@ module.MetadataReader = core.ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
tag: 'fs-metadata',
|
tag: 'fs-metadata',
|
||||||
depends: [
|
depends: [
|
||||||
|
'fs-info',
|
||||||
'metadata',
|
'metadata',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
var sha1 = require('ext-lib/sha1')
|
var sha1 = require('ext-lib/sha1')
|
||||||
|
|
||||||
var object = require('lib/object')
|
var object = require('lib/object')
|
||||||
|
var util = require('lib/util')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -457,7 +458,15 @@ module.ImagesPrototype = {
|
|||||||
|
|
||||||
// Image data helpers...
|
// Image data helpers...
|
||||||
|
|
||||||
|
getImagePath: function(gid, path){
|
||||||
|
var img = this[gid] || IMAGE_DATA
|
||||||
|
|
||||||
|
return (img.base_path || path) ?
|
||||||
|
[img.base_path || path, img.path].join('/')
|
||||||
|
: util.path2url(img.path)
|
||||||
|
},
|
||||||
// XXX see: ribbons.js for details...
|
// XXX see: ribbons.js for details...
|
||||||
|
// XXX this is the same (in part) as .getImagePath(..)
|
||||||
getBestPreview: function(gid, size, img_data, full_path){
|
getBestPreview: function(gid, size, img_data, full_path){
|
||||||
if(img_data === true){
|
if(img_data === true){
|
||||||
full_path = true
|
full_path = true
|
||||||
@ -476,7 +485,7 @@ module.ImagesPrototype = {
|
|||||||
|
|
||||||
var s
|
var s
|
||||||
// XXX not sure about encodeURI(..) here...
|
// XXX not sure about encodeURI(..) here...
|
||||||
var url = encodeURI(img_data.path)
|
var url = encodeURI(util.path2url(img_data.path))
|
||||||
var preview_size = 'Original'
|
var preview_size = 'Original'
|
||||||
var p = Infinity
|
var p = Infinity
|
||||||
var previews = img_data.preview || {}
|
var previews = img_data.preview || {}
|
||||||
@ -492,7 +501,7 @@ module.ImagesPrototype = {
|
|||||||
return {
|
return {
|
||||||
//url: normalizePath(url),
|
//url: normalizePath(url),
|
||||||
url: (full_path && img_data.base_path ?
|
url: (full_path && img_data.base_path ?
|
||||||
img_data.base_path + '/'
|
util.path2url(img_data.base_path) + '/'
|
||||||
: '')
|
: '')
|
||||||
+ url,
|
+ url,
|
||||||
size: preview_size
|
size: preview_size
|
||||||
|
|||||||
@ -179,11 +179,12 @@ function(path){
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
// skip encoding windows drives...
|
// skip encoding windows drives...
|
||||||
var drive = path.split(/^([a-z]:[\\\/])/i)
|
path = path
|
||||||
path = drive.pop()
|
|
||||||
drive = drive.pop() || ''
|
|
||||||
return drive + (path
|
|
||||||
.split(/[\\\/]/g)
|
.split(/[\\\/]/g)
|
||||||
|
drive = path[0].endsWith(':') ?
|
||||||
|
path.shift() + '/'
|
||||||
|
: ''
|
||||||
|
return drive + (path
|
||||||
// XXX these are too aggressive...
|
// XXX these are too aggressive...
|
||||||
//.map(encodeURI)
|
//.map(encodeURI)
|
||||||
//.map(encodeURIComponent)
|
//.map(encodeURIComponent)
|
||||||
|
|||||||
@ -105,6 +105,7 @@ function handleDrop(evt){
|
|||||||
|
|
||||||
var files = event.dataTransfer.files
|
var files = event.dataTransfer.files
|
||||||
var lst = {}
|
var lst = {}
|
||||||
|
var paths = []
|
||||||
|
|
||||||
// files is a FileList of File objects. List some properties.
|
// files is a FileList of File objects. List some properties.
|
||||||
var output = []
|
var output = []
|
||||||
@ -114,9 +115,12 @@ function handleDrop(evt){
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
lst[f.name] = {
|
if(f.path){
|
||||||
|
paths.push(f.path)
|
||||||
|
|
||||||
|
} else {
|
||||||
// XXX get the metadata...
|
// XXX get the metadata...
|
||||||
}
|
lst[f.name] = {}
|
||||||
|
|
||||||
var reader = new FileReader()
|
var reader = new FileReader()
|
||||||
|
|
||||||
@ -130,7 +134,12 @@ function handleDrop(evt){
|
|||||||
|
|
||||||
reader.readAsDataURL(f)
|
reader.readAsDataURL(f)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(paths.length > 0){
|
||||||
|
ig.loadURLs(paths)
|
||||||
|
|
||||||
|
} else {
|
||||||
ig.loadURLs(Object.keys(lst))
|
ig.loadURLs(Object.keys(lst))
|
||||||
|
|
||||||
// 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
|
||||||
@ -140,6 +149,7 @@ function handleDrop(evt){
|
|||||||
img.name = img.path
|
img.name = img.path
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
function handleDragOver(evt) {
|
function handleDragOver(evt) {
|
||||||
evt.stopPropagation()
|
evt.stopPropagation()
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user