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 <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-09-13 17:21:14 +04:00
parent d020318fe7
commit a23acab9ec
2 changed files with 58 additions and 30 deletions

View File

@ -78,19 +78,28 @@ var KEYBOARD_CONFIG = {
ignore: '*', ignore: '*',
Enter: doc('Accept dialog', 'insert-return': doc('Insert return'),
function(){
var f = $(':focus')
// trigger the default button action...
if(/button/i.test(f[0].tagName) || f.attr('type') == 'button'){
return true
// accept the dialog... Enter: {
} else { default: doc('Accept dialog',
getOverlay($('.viewer')).trigger('accept') function(){
hideOverlay($('.viewer')) 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', Esc: doc('Close dialog',
function(){ function(){
//getOverlay($('.viewer')).trigger('close') //getOverlay($('.viewer')).trigger('close')
@ -616,8 +625,6 @@ var KEYBOARD_CONFIG = {
// marking... // marking...
ctrl: 'invert-marks', ctrl: 'invert-marks',
}, },
// XXX this is not permanent...
C: doc('Edit image comment', imageCommentDialog),
P: { P: {
default: doc('Show options', default: doc('Show options',
function(){ toggleOptionsUI() }), function(){ toggleOptionsUI() }),

View File

@ -726,6 +726,8 @@ function formDialog(root, message, config, btn, cls){
if(btn !== false){ if(btn !== false){
var button = $('<button class="accept">'+btn+'</button>') var button = $('<button class="accept">'+btn+'</button>')
form.append(button) form.append(button)
} else {
var button = null
} }
var overlay = showInOverlay(root, form) var overlay = showInOverlay(root, form)
@ -745,9 +747,11 @@ function formDialog(root, message, config, btn, cls){
}) })
button.click(function(){ if(button != null){
overlay.trigger('accept') button.click(function(){
}) overlay.trigger('accept')
})
}
setTimeout(function(){ setTimeout(function(){
form.find('.field input').first() form.find('.field input').first()
@ -976,22 +980,39 @@ function showImageInfo(){
var name = data.path.split('/').pop() var name = data.path.split('/').pop()
var comment = data.comment var comment = data.comment
comment = comment == null ? '' : comment comment = comment == null ? '' : comment
comment = comment.replace(/\n/g, '<br>')
// make this something other than alert...
alert('<div>'+ alert('<div>'+
'<h2>"'+ name +'"</h2>'+ '<h2>"'+ name +'"</h2>'+
'<table>'+ '<table>'+
'<tr><td>GID: </td><td>'+ gid +'</td></tr>'+ '<tr><td>GID: </td><td>'+ gid +'</td></tr>'+
'<tr><td>Path: </td><td>"'+ data.path +'"</td></tr>'+ '<tr><td>Path: </td><td>"'+ data.path +'"</td></tr>'+
'<tr><td>Orientation: </td><td>'+ orientation +'&deg;'+flipped+'</td></tr>'+ '<tr><td>Orientation: </td><td>'+ orientation +'&deg;'+flipped+'</td></tr>'+
'<tr><td>Order: </td><td>'+ order +'</td></tr>'+ '<tr><td>Order: </td><td>'+ order +'</td></tr>'+
'<tr><td>Position (ribbon): </td><td>'+ (DATA.ribbons[r].indexOf(gid)+1) + '<tr><td>Position (ribbon): </td><td>'+ (DATA.ribbons[r].indexOf(gid)+1) +
'/'+ DATA.ribbons[r].length +'</td></tr>'+ '/'+ DATA.ribbons[r].length +'</td></tr>'+
'<tr><td>Position (global): </td><td>'+ (order+1) +'/'+ DATA.order.length +'</td></tr>'+ '<tr><td>Position (global): </td><td>'+ (order+1) +'/'+ DATA.order.length +'</td></tr>'+
'<tr><td colspan="2"><hr></td></tr>'+
'<tr><td>Comment: </td><td class="comment">'+ comment +'</td></tr>'+ // editable fields...
'</table>'+ '<tr><td colspan="2"><hr></td></tr>'+
'</div>') // XXX this expanding to a too big size will not scroll...
// add per editable and global dialog max-height and overflow
'<tr><td>Comment: </td><td class="comment" contenteditable>'+ comment +'</td></tr>'+
'</table>'+
'</div>')
// XXX hanck???
.done(function(){
var comment = $('.dialog .comment').html().replace(/<br>/ig, '\n')
if(comment.trim() == ''){
delete data.comment
} else {
data.comment = comment
}
IMAGES_UPDATED.push(gid)
})
} }