From a23acab9ec70d7c29c5ada5016c4fb5ce5d5028f Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Fri, 13 Sep 2013 17:21:14 +0400 Subject: [PATCH] now comments are edited from the info dialog + idetified and fixed a couple of bugs with button-less dialogs... Signed-off-by: Alex A. Naanou --- ui/keybindings.js | 35 ++++++++++++++++++------------- ui/ui.js | 53 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/ui/keybindings.js b/ui/keybindings.js index fdb6f4fc..88ffc3c6 100755 --- a/ui/keybindings.js +++ b/ui/keybindings.js @@ -78,19 +78,28 @@ var KEYBOARD_CONFIG = { ignore: '*', - Enter: doc('Accept dialog', - function(){ - var f = $(':focus') - // trigger the default button action... - if(/button/i.test(f[0].tagName) || f.attr('type') == 'button'){ - return true + 'insert-return': doc('Insert return'), - // accept the dialog... - } else { - getOverlay($('.viewer')).trigger('accept') - hideOverlay($('.viewer')) - } - }), + Enter: { + default: doc('Accept dialog', + function(){ + var f = $(':focus') + + // trigger the default button action... + if(f.length > 0 + && (/button/i.test(f[0].tagName) + || f.attr('type') == 'button')){ + return true + + // accept the dialog... + } else { + getOverlay($('.viewer')).trigger('accept') + hideOverlay($('.viewer')) + } + }), + shift: 'insert-return', + //ctrl: 'insert-return', + }, Esc: doc('Close dialog', function(){ //getOverlay($('.viewer')).trigger('close') @@ -616,8 +625,6 @@ var KEYBOARD_CONFIG = { // marking... ctrl: 'invert-marks', }, - // XXX this is not permanent... - C: doc('Edit image comment', imageCommentDialog), P: { default: doc('Show options', function(){ toggleOptionsUI() }), diff --git a/ui/ui.js b/ui/ui.js index b2984037..c2ddbb54 100755 --- a/ui/ui.js +++ b/ui/ui.js @@ -726,6 +726,8 @@ function formDialog(root, message, config, btn, cls){ if(btn !== false){ var button = $('') form.append(button) + } else { + var button = null } var overlay = showInOverlay(root, form) @@ -745,9 +747,11 @@ function formDialog(root, message, config, btn, cls){ }) - button.click(function(){ - overlay.trigger('accept') - }) + if(button != null){ + button.click(function(){ + overlay.trigger('accept') + }) + } setTimeout(function(){ form.find('.field input').first() @@ -976,22 +980,39 @@ function showImageInfo(){ var name = data.path.split('/').pop() var comment = data.comment comment = comment == null ? '' : comment + comment = comment.replace(/\n/g, '
') + // make this something other than alert... alert('
'+ - '

"'+ name +'"

'+ + '

"'+ name +'"

'+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - ''+ - '
GID: '+ gid +'
Path: "'+ data.path +'"
Orientation: '+ orientation +'°'+flipped+'
Order: '+ order +'
Position (ribbon): '+ (DATA.ribbons[r].indexOf(gid)+1) + - '/'+ DATA.ribbons[r].length +'
Position (global): '+ (order+1) +'/'+ DATA.order.length +'

Comment: '+ comment +'
'+ - '
') + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + + // editable fields... + ''+ + // XXX this expanding to a too big size will not scroll... + // add per editable and global dialog max-height and overflow + ''+ + '
GID: '+ gid +'
Path: "'+ data.path +'"
Orientation: '+ orientation +'°'+flipped+'
Order: '+ order +'
Position (ribbon): '+ (DATA.ribbons[r].indexOf(gid)+1) + + '/'+ DATA.ribbons[r].length +'
Position (global): '+ (order+1) +'/'+ DATA.order.length +'

Comment: '+ comment +'
'+ + '') + // XXX hanck??? + .done(function(){ + var comment = $('.dialog .comment').html().replace(/
/ig, '\n') + + if(comment.trim() == ''){ + delete data.comment + } else { + data.comment = comment + } + IMAGES_UPDATED.push(gid) + }) }