From 06e009b72c7a35d11606f63a3d5a50db914e82cb Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 26 Mar 2016 04:01:13 +0300 Subject: [PATCH] clenup and tweaking... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/metadata.js | 34 +++++++++++++++++++++++++++------- ui (gen4)/lib/widget/browse.js | 5 ++++- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/ui (gen4)/features/metadata.js b/ui (gen4)/features/metadata.js index e2f8e77f..5546e4ba 100755 --- a/ui (gen4)/features/metadata.js +++ b/ui (gen4)/features/metadata.js @@ -21,6 +21,7 @@ define(function(require){ var module = {} var util = require('lib/util') var toggler = require('lib/toggler') var tasks = require('lib/tasks') +var keyboard = require('lib/keyboard') var actions = require('lib/actions') var core = require('features/core') @@ -337,6 +338,7 @@ var MetadataUIActions = actions.Actions({ ]) } // fields that expect that image data is available... + var info = ['---'] if(img){ // XXX should these be here??? var _normalize = typeof(path) != 'undefined' ? @@ -357,8 +359,14 @@ var MetadataUIActions = actions.Actions({ ['Full Path: ', _normalize((img.base_path || '.') +'/'+ img.path)], ]) + + // comment and tags... + info.push(['Comment', + function(){ return img.comment || '' }]) } + info.push(['Tags', + function(){ return that.data.getTags().join(', ') || '' }]) // build fields... var fields = [] @@ -387,13 +395,15 @@ var MetadataUIActions = actions.Actions({ fields.sort(_cmp) // add separator to base... - fields.length > 0 && base.push('---') + fields.length > 0 && info.push('---') // XXX might be a good idea to directly bind ctrl-c to copy value... var o = overlay.Overlay(this.ribbons.viewer, browse.makeList( null, - base.concat(fields), + base + .concat(info) + .concat(fields), { showDisabled: false, }) @@ -421,12 +431,22 @@ var MetadataUIActions = actions.Actions({ elem .prop('contenteditable', true) .focus() - /* - .one('blur', function(){ - $(this) - .prop('contenteditable', false) + .keydown(function(){ + event.stopPropagation() + + var n = keyboard.toKeyName(event.keyCode) + + // reset to original value... + if(n == 'Esc'){ + // XXX + + // save value... + } else if(n == 'Enter' && event.ctrlKey){ + event.preventDefault() + + // XXX + } }) - */ } })) .close(function(){ diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 16c96105..b1ce8019 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -721,6 +721,8 @@ var BrowserPrototype = { // If an item is a function it is called // and the returned value is treated as // the text. + // NOTE: empty strings will get replaced + // with   // - DOM/jQuery - an element to be used as an item // // Both traversable and disabled are optional and can take bool @@ -894,7 +896,8 @@ var BrowserPrototype = { p = $(p.map(function(t){ return $('') .addClass('text') - .text(t)[0] + // here we also replace empty strings with  ... + [t ? 'text' : 'html'](t || ' ')[0] })) // jQuery or dom...