mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
some refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
0deba5d277
commit
9fceef362d
@ -400,6 +400,21 @@ var KeyboardActions = actions.Actions({
|
|||||||
'max-key-repeat-rate': 0,
|
'max-key-repeat-rate': 0,
|
||||||
|
|
||||||
'keyboard-repeat-pause-check': 100,
|
'keyboard-repeat-pause-check': 100,
|
||||||
|
|
||||||
|
// Sets the target element to which the keyboard event handler
|
||||||
|
// is bound...
|
||||||
|
//
|
||||||
|
// Supported values:
|
||||||
|
// 'window' - window element
|
||||||
|
// 'document' - document element
|
||||||
|
// 'viewer' - the viewer (default)
|
||||||
|
// null - default element
|
||||||
|
// <css selector> - any css selector
|
||||||
|
//
|
||||||
|
// NOTE: this value is not live, to update the target restart
|
||||||
|
// the handler by cycling the toggler off and on...
|
||||||
|
// NOTE: the target element must be focusable...
|
||||||
|
'keyboard-event-source': 'window',
|
||||||
},
|
},
|
||||||
|
|
||||||
get keyboard(){
|
get keyboard(){
|
||||||
@ -408,8 +423,7 @@ var KeyboardActions = actions.Actions({
|
|||||||
|
|
||||||
pauseKeyboardRepeat: ['- Interface/',
|
pauseKeyboardRepeat: ['- Interface/',
|
||||||
function(){
|
function(){
|
||||||
this.__keyboard_repeat_paused = true
|
this.__keyboard_repeat_paused = true }],
|
||||||
}],
|
|
||||||
|
|
||||||
toggleKeyboardHandling: ['- Interface/Toggle keyboard handling',
|
toggleKeyboardHandling: ['- Interface/Toggle keyboard handling',
|
||||||
toggler.Toggler(null, function(_, state){
|
toggler.Toggler(null, function(_, state){
|
||||||
@ -435,14 +449,19 @@ var KeyboardActions = actions.Actions({
|
|||||||
return true
|
return true
|
||||||
}).bind(this)
|
}).bind(this)
|
||||||
|
|
||||||
// XXX this does not work yet...
|
|
||||||
//var target = this.ribbons.viewer
|
|
||||||
var target = $(document)
|
|
||||||
|
|
||||||
// start/reset keyboard handling...
|
// start/reset keyboard handling...
|
||||||
if(state == 'on'){
|
if(state == 'on'){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
|
// NOTE: the target element must be focusable...
|
||||||
|
var target =
|
||||||
|
this.__keyboard_event_source =
|
||||||
|
this.config['keyboard-event-source'] == null
|
||||||
|
|| this.config['keyboard-event-source'] == 'viewer' ? this.ribbons.viewer
|
||||||
|
: this.config['keyboard-event-source'] == 'window' ? $(window)
|
||||||
|
: this.config['keyboard-event-source'] == 'document' ? $(document)
|
||||||
|
: $(this.config['keyboard-event-source'])
|
||||||
|
|
||||||
// need to reset...
|
// need to reset...
|
||||||
if(this.__keyboard_handler != null){
|
if(this.__keyboard_handler != null){
|
||||||
target.off('keydown', this.__keyboard_handler)
|
target.off('keydown', this.__keyboard_handler)
|
||||||
@ -483,8 +502,12 @@ var KeyboardActions = actions.Actions({
|
|||||||
|
|
||||||
// stop keyboard handling...
|
// stop keyboard handling...
|
||||||
} else {
|
} else {
|
||||||
target.off('keydown', this.__keyboard_handler)
|
this.__keyboard_event_source
|
||||||
|
&& this.__keyboard_event_source
|
||||||
|
.off('keydown', this.__keyboard_handler)
|
||||||
|
|
||||||
delete this.__keyboard_handler
|
delete this.__keyboard_handler
|
||||||
|
delete this.__keyboard_event_source
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
['on', 'off'])],
|
['on', 'off'])],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user