mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-12-17 08:41:40 +00:00
made the editor a real mode and tweaked controling it from keyboard...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
27cb832249
commit
2087d0768a
62
ui/editor.js
62
ui/editor.js
@ -9,39 +9,41 @@
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// ImageGrid-specific editor setup...
|
var toggleEditor = createCSSClassToggler('.viewer', '.editor-visible',
|
||||||
function setupEditor(){
|
function(action){
|
||||||
// build the editor...
|
var ed = $('.panel')
|
||||||
if($('.panel').length == 0){
|
|
||||||
$('.viewer')
|
|
||||||
.append(makeEditorControls('.current.image')
|
|
||||||
.addClass('noScroll'))
|
|
||||||
|
|
||||||
// setup the event to update the editor...
|
if(action == 'on'){
|
||||||
.on('focusingImage', function(){
|
// create the editor if this is first init...
|
||||||
if($('.panel').css('display') != 'none'){
|
if(ed.length == 0){
|
||||||
reloadControls('.current.image')
|
$('.viewer')
|
||||||
|
.append(makeEditorControls('.current.image')
|
||||||
|
.addClass('noScroll')
|
||||||
|
// make clicks on unfocusable elements remove focus...
|
||||||
|
.click(function(){
|
||||||
|
if(event.target != $('.panel :focus')[0]){
|
||||||
|
$('.panel :focus').blur()
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
|
||||||
|
// setup the event to update the editor...
|
||||||
|
.on('focusingImage', function(){
|
||||||
|
if(toggleEditor('?') == 'on'){
|
||||||
|
reloadControls('.current.image')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// show the editor...
|
||||||
|
} else {
|
||||||
|
ed.show()
|
||||||
}
|
}
|
||||||
})
|
// update the state...
|
||||||
|
reloadControls('.current.image')
|
||||||
|
|
||||||
reloadControls('.current.image')
|
// hide...
|
||||||
|
} else {
|
||||||
// toggle the editor...
|
ed.hide()
|
||||||
// XXX do we need a real mode for this?
|
}
|
||||||
} else {
|
})
|
||||||
var ed = $('.panel')
|
|
||||||
|
|
||||||
// show...
|
|
||||||
if(ed.css('display') == 'none'){
|
|
||||||
reloadControls('.current.image')
|
|
||||||
ed.show()
|
|
||||||
|
|
||||||
// hide...
|
|
||||||
} else {
|
|
||||||
ed.hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -118,7 +118,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
|
|
||||||
// dialogs...
|
// dialogs...
|
||||||
//
|
//
|
||||||
'.viewer.overlay .overlay-block.dialog': {
|
'.viewer.overlay .overlay-block.dialog, .panel :focus': {
|
||||||
title: 'Dialog',
|
title: 'Dialog',
|
||||||
doc: 'NOTE: to <i>close</i> a dialog, in addition to the keyaboard '+
|
doc: 'NOTE: to <i>close</i> a dialog, in addition to the keyaboard '+
|
||||||
'shortcuts, one can also click anywhere outside the dialog.',
|
'shortcuts, one can also click anywhere outside the dialog.',
|
||||||
@ -128,18 +128,26 @@ var KEYBOARD_CONFIG = {
|
|||||||
'insert-return': doc('Insert return'),
|
'insert-return': doc('Insert return'),
|
||||||
|
|
||||||
Enter: {
|
Enter: {
|
||||||
default: doc('Accept dialog',
|
default: doc('Accept dialog / input',
|
||||||
function(){
|
function(){
|
||||||
var f = $(':focus')
|
var f = $(':focus')
|
||||||
|
|
||||||
// trigger the default button action...
|
// trigger the default button action...
|
||||||
if(f.length > 0
|
if(f.length > 0
|
||||||
&& (/button/i.test(f[0].tagName)
|
&& (/button|summary/i.test(f[0].tagName)
|
||||||
|| f.attr('type') == 'button')){
|
|| /button|checkbox/i.test(f.attr('type')))){
|
||||||
return true
|
f.click()
|
||||||
|
// prevent the key from propagating to the viewer...
|
||||||
|
return false
|
||||||
|
|
||||||
|
// accept the input...
|
||||||
|
} else if(toggleEditor('?') == 'on'){
|
||||||
|
f.blur()
|
||||||
|
// prevent the key from propagating to the viewer...
|
||||||
|
return false
|
||||||
|
|
||||||
// accept the dialog...
|
// accept the dialog...
|
||||||
} else {
|
} else if(isOverlayVisible('.viewer')) {
|
||||||
getOverlay($('.viewer')).trigger('accept')
|
getOverlay($('.viewer')).trigger('accept')
|
||||||
hideOverlay($('.viewer'))
|
hideOverlay($('.viewer'))
|
||||||
}
|
}
|
||||||
@ -149,9 +157,19 @@ var KEYBOARD_CONFIG = {
|
|||||||
},
|
},
|
||||||
Esc: doc('Close dialog',
|
Esc: doc('Close dialog',
|
||||||
function(){
|
function(){
|
||||||
//getOverlay($('.viewer')).trigger('close')
|
if(isOverlayVisible('.viewer')){
|
||||||
hideOverlay($('.viewer'))
|
//getOverlay($('.viewer')).trigger('close')
|
||||||
return false
|
hideOverlay($('.viewer'))
|
||||||
|
return false
|
||||||
|
|
||||||
|
} else if(toggleEditor('?') == 'on'){
|
||||||
|
var f = $(':focus')
|
||||||
|
if(f.length > 0){
|
||||||
|
f.blur()
|
||||||
|
} else {
|
||||||
|
toggleEditor('off')
|
||||||
|
}
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -703,7 +721,8 @@ var KEYBOARD_CONFIG = {
|
|||||||
E: {
|
E: {
|
||||||
default: doc('Open image in external software', openImage),
|
default: doc('Open image in external software', openImage),
|
||||||
// XXX Experimental
|
// XXX Experimental
|
||||||
ctrl: doc('Open preview editor panel (Experimental)', setupEditor),
|
ctrl: doc('Open preview editor panel (Experimental)',
|
||||||
|
function(){ toggleEditor() }),
|
||||||
},
|
},
|
||||||
// XXX make F4 a default editor and E a default viewer...
|
// XXX make F4 a default editor and E a default viewer...
|
||||||
F4: 'E',
|
F4: 'E',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user