mirror of
https://github.com/flynx/ImageGrid.git
synced 2026-01-08 11:21:09 +00:00
make keyboard.js more general...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
2fe8479720
commit
3f65740c71
@ -147,13 +147,13 @@ var KEYBOARD_CONFIG = {
|
|||||||
doc: 'These key bindings work in most other modes.',
|
doc: 'These key bindings work in most other modes.',
|
||||||
|
|
||||||
// Actions...
|
// Actions...
|
||||||
'.next-screen': doc('Next screen',
|
'next-screen': doc('Next screen',
|
||||||
function(){
|
function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
nextScreenImages()
|
nextScreenImages()
|
||||||
centerRibbons()
|
centerRibbons()
|
||||||
}),
|
}),
|
||||||
'.prev-screen': doc('Previous screen',
|
'prev-screen': doc('Previous screen',
|
||||||
function(){
|
function(){
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
prevScreenImages()
|
prevScreenImages()
|
||||||
@ -179,7 +179,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
prevImage()
|
prevImage()
|
||||||
centerRibbons()
|
centerRibbons()
|
||||||
}),
|
}),
|
||||||
ctrl: '.prev-screen',
|
ctrl: 'prev-screen',
|
||||||
},
|
},
|
||||||
Right: {
|
Right: {
|
||||||
default: doc('Next image',
|
default: doc('Next image',
|
||||||
@ -198,7 +198,7 @@ var KEYBOARD_CONFIG = {
|
|||||||
nextImage()
|
nextImage()
|
||||||
centerRibbons()
|
centerRibbons()
|
||||||
}),
|
}),
|
||||||
ctrl: '.next-screen',
|
ctrl: 'next-screen',
|
||||||
},
|
},
|
||||||
|
|
||||||
Space: {
|
Space: {
|
||||||
@ -206,14 +206,14 @@ var KEYBOARD_CONFIG = {
|
|||||||
shift: 'Left',
|
shift: 'Left',
|
||||||
// screen-oriented movement...
|
// screen-oriented movement...
|
||||||
ctrl: 'Right',
|
ctrl: 'Right',
|
||||||
'ctrl+shift': '.prev-screen',
|
'ctrl+shift': 'prev-screen',
|
||||||
},
|
},
|
||||||
Backspace: {
|
Backspace: {
|
||||||
default: 'Left',
|
default: 'Left',
|
||||||
shift: 'Right',
|
shift: 'Right',
|
||||||
// screen-oriented movement...
|
// screen-oriented movement...
|
||||||
ctrl: 'Left',
|
ctrl: 'Left',
|
||||||
'ctrl+shift': '.next-screen',
|
'ctrl+shift': 'next-screen',
|
||||||
},
|
},
|
||||||
Home: doc('First image',
|
Home: doc('First image',
|
||||||
function(){
|
function(){
|
||||||
|
|||||||
@ -68,7 +68,7 @@ var _SHIFT_KEYS = {
|
|||||||
1: '!', 2: '@', 3: '#', 4: '$', 5: '%',
|
1: '!', 2: '@', 3: '#', 4: '$', 5: '%',
|
||||||
6:'^', 7:'&', 8: '*', 9: '(', 0: ')',
|
6:'^', 7:'&', 8: '*', 9: '(', 0: ')',
|
||||||
|
|
||||||
'[': '{', ']': '}i', '\\': '|',
|
'[': '{', ']': '}', '\\': '|',
|
||||||
';': ':', '\'': '"',
|
';': ':', '\'': '"',
|
||||||
',': '<', '.': '>', '/': '?'
|
',': '<', '.': '>', '/': '?'
|
||||||
}
|
}
|
||||||
@ -351,14 +351,11 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys){
|
|||||||
* - explicit key code, e.g. 65
|
* - explicit key code, e.g. 65
|
||||||
* - key name, if present in _SPECIAL_KEYS, e.g. Enter
|
* - key name, if present in _SPECIAL_KEYS, e.g. Enter
|
||||||
* - key char (uppercase), as is returned by String.fromCharCode(...) e.g. A
|
* - key char (uppercase), as is returned by String.fromCharCode(...) e.g. A
|
||||||
* - action -- any arbitrary string (recommended to start with a '.').
|
* - action -- any arbitrary string that is not in the above categories.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* NOTE: actions,the last case, are for alias referencing, it will never
|
* NOTE: actions,the last case, are used for alias referencing, they will
|
||||||
* match a real key, but will get resolved in alias searches.
|
* never match a real key, but will get resolved in alias searches.
|
||||||
* NOTE: it is recommended to start actions with a '.' to prevent them
|
|
||||||
* from being included as keys in the generated docs.
|
|
||||||
* see: buildKeybindingsHelp(...)
|
|
||||||
* NOTE: to rest what to use as <key-def> use toKeyCode(..) / toKeyName(..).
|
* NOTE: to rest what to use as <key-def> use toKeyCode(..) / toKeyName(..).
|
||||||
* NOTE: all fields are optional.
|
* NOTE: all fields are optional.
|
||||||
* NOTE: if a handler explicitly returns false then that will break the
|
* NOTE: if a handler explicitly returns false then that will break the
|
||||||
@ -375,6 +372,7 @@ function getKeyHandlers(key, modifiers, keybindings, modes, shifted_keys){
|
|||||||
* it will only assign .doc attr and return the original function.
|
* it will only assign .doc attr and return the original function.
|
||||||
*
|
*
|
||||||
* XXX need an explicit way to prioritize modes...
|
* XXX need an explicit way to prioritize modes...
|
||||||
|
* XXX will aliases get resolved if they are in a different mode??
|
||||||
*/
|
*/
|
||||||
function makeKeyboardHandler(keybindings, unhandled){
|
function makeKeyboardHandler(keybindings, unhandled){
|
||||||
if(unhandled == null){
|
if(unhandled == null){
|
||||||
@ -436,8 +434,7 @@ function makeKeyboardHandler(keybindings, unhandled){
|
|||||||
* <keys-spec> - list of key names.
|
* <keys-spec> - list of key names.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* NOTE: this will not add keys (key names) that start with a '.', these
|
* NOTE: this will not add keys (key names) that are not explicit key names.
|
||||||
* are actions, intended for aliasing.
|
|
||||||
*/
|
*/
|
||||||
function buildKeybindingsHelp(keybindings, shifted_keys){
|
function buildKeybindingsHelp(keybindings, shifted_keys){
|
||||||
shifted_keys = shifted_keys == null ? _SHIFT_KEYS : shifted_keys
|
shifted_keys = shifted_keys == null ? _SHIFT_KEYS : shifted_keys
|
||||||
@ -502,10 +499,14 @@ function buildKeybindingsHelp(keybindings, shifted_keys){
|
|||||||
key = shifted_keys[key]
|
key = shifted_keys[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip keys that start with a dot...
|
// skip anything that is not a key...
|
||||||
if(!/\..+/.test(key)){
|
//if(key.length > 1 && (!(key in _KEY_CODES) || /\..+/.test(key))){
|
||||||
keys.push((mod == '' || mod == 'default') ? key : (mod +'+'+ key))
|
if(key.length > 1 && !(key in _KEY_CODES)){
|
||||||
|
console.log('### skipping:', key)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys.push((mod == '' || mod == 'default') ? key : (mod +'+'+ key))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user