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,11 +78,17 @@ var KEYBOARD_CONFIG = {
ignore: '*', ignore: '*',
Enter: doc('Accept dialog', 'insert-return': doc('Insert return'),
Enter: {
default: doc('Accept dialog',
function(){ function(){
var f = $(':focus') var f = $(':focus')
// trigger the default button action... // trigger the default button action...
if(/button/i.test(f[0].tagName) || f.attr('type') == 'button'){ if(f.length > 0
&& (/button/i.test(f[0].tagName)
|| f.attr('type') == 'button')){
return true return true
// accept the dialog... // accept the dialog...
@ -91,6 +97,9 @@ var KEYBOARD_CONFIG = {
hideOverlay($('.viewer')) 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){
}) })
if(button != null){
button.click(function(){ button.click(function(){
overlay.trigger('accept') overlay.trigger('accept')
}) })
}
setTimeout(function(){ setTimeout(function(){
form.find('.field input').first() form.find('.field input').first()
@ -976,7 +980,9 @@ 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>'+
@ -988,10 +994,25 @@ function showImageInfo(){
'<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>'+
// editable fields...
'<tr><td colspan="2"><hr></td></tr>'+ '<tr><td colspan="2"><hr></td></tr>'+
'<tr><td>Comment: </td><td class="comment">'+ comment +'</td></tr>'+ // 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>'+ '</table>'+
'</div>') '</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)
})
} }