cleaned up metadata paths... (not final yet)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-01-24 01:58:48 +03:00
parent 029a2f2280
commit 765569c742

View File

@ -244,6 +244,7 @@ module.MetadataReader = core.ImageGridFeatures.Feature({
// - EXIF // - EXIF
// - IPTC // - IPTC
// - ... // - ...
// XXX should this be a panel or a list (as is now...)????
var MetadataUIActions = actions.Actions({ var MetadataUIActions = actions.Actions({
config: { config: {
'metadata-auto-select-modes': [ 'metadata-auto-select-modes': [
@ -259,6 +260,10 @@ var MetadataUIActions = actions.Actions({
'Comment', 'Comment',
], ],
'metadata-field-order': [ 'metadata-field-order': [
// base
'GID',
'File Name', 'Parent Directory', 'Full Path',
// metadata... // metadata...
'Make', 'Camera Model Name', 'Lens ID', 'Lens', 'Lens Profile Name', 'Focal Length', 'Make', 'Camera Model Name', 'Lens ID', 'Lens', 'Lens Profile Name', 'Focal Length',
@ -292,6 +297,23 @@ var MetadataUIActions = actions.Actions({
// get image metadata... // get image metadata...
var metadata = img && img.metadata || {} var metadata = img && img.metadata || {}
// helpers...
var _cmp = function(a, b){
a = field_order.indexOf(a[0].replace(/: $/, ''))
a = a == -1 ? x : a
b = field_order.indexOf(b[0].replace(/: $/, ''))
b = b == -1 ? x : b
return a - b
}
var _selectElemText = function(elem){
var range = document.createRange()
range.selectNodeContents(elem)
var sel = window.getSelection()
sel.removeAllRanges()
sel.addRange(range)
}
// XXX move these to an info feature... // XXX move these to an info feature...
// base fields... // base fields...
var base = [ var base = [
@ -318,10 +340,24 @@ var MetadataUIActions = actions.Actions({
} }
// fields that expect that image data is available... // fields that expect that image data is available...
if(img){ if(img){
// XXX should these be here???
var _normalize = typeof(path) != 'undefined' ?
path.normalize
: function(e){ return e.replace(/\/\.\//, '') }
var _basename = typeof(path) != 'undefined' ?
path.basename
: function(e){ return e.split(/[\\\/]/g).pop() }
var _dirname = typeof(path) != 'undefined' ?
function(e){ return path.normalize(path.dirname(e)) }
: function(e){ return _normalize(e.split(/[\\\/]/g).slice(0, -1).join('/')) }
base = base.concat([ base = base.concat([
['File Name: ', img.path], ['File Name: ',
// XXX normalize this... _basename(img.path)],
['Full Path: ', (img.base_path || '.') +'/'+ img.path], ['Parent Directory: ',
_dirname((img.base_path || '.') +'/'+ img.path)],
['Full Path: ',
_normalize((img.base_path || '.') +'/'+ img.path)],
]) ])
} }
@ -349,25 +385,12 @@ var MetadataUIActions = actions.Actions({
}) })
// sort fields... // sort fields...
fields.sort(function(a, b){ base.sort(_cmp)
a = field_order.indexOf(a[0].replace(/: $/, '')) fields.sort(_cmp)
a = a == -1 ? x : a
b = field_order.indexOf(b[0].replace(/: $/, ''))
b = b == -1 ? x : b
return a - b
})
// add separator to base... // add separator to base...
fields.length > 0 && base.push('---') fields.length > 0 && base.push('---')
var selectElemText = function(elem){
var range = document.createRange()
range.selectNodeContents(elem)
var sel = window.getSelection()
sel.removeAllRanges()
sel.addRange(range)
}
var o = overlay.Overlay(this.ribbons.viewer, var o = overlay.Overlay(this.ribbons.viewer,
browse.makeList( browse.makeList(
null, null,
@ -378,7 +401,7 @@ var MetadataUIActions = actions.Actions({
// select value of current item... // select value of current item...
.on('select', function(evt, elem){ .on('select', function(evt, elem){
if(that.config['metadata-auto-select-mode'] == 'on select'){ if(that.config['metadata-auto-select-mode'] == 'on select'){
selectElemText($(elem).find('.text').last()[0]) _selectElemText($(elem).find('.text').last()[0])
} }
}) })
// path selected... // path selected...
@ -389,8 +412,9 @@ var MetadataUIActions = actions.Actions({
var elem = o.client.filter(path).find('.text').last() var elem = o.client.filter(path).find('.text').last()
// handle select...
if(that.config['metadata-auto-select-mode'] == 'on open'){ if(that.config['metadata-auto-select-mode'] == 'on open'){
selectElemText(elem[0]) _selectElemText(elem[0])
} }
// skip non-editable fields... // skip non-editable fields...