now keyboard handler calls actions directly and the config is serialiable...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-10-20 06:52:13 +04:00
parent fc84b5a1cf
commit 98350a576b
2 changed files with 43 additions and 44 deletions

View File

@ -242,6 +242,8 @@ function Action(name, doc, ldoc, func){
return meth return meth
} }
// this will make action instances behave like real functions...
Action.prototype.__proto__ = Function
// A base action-set object... // A base action-set object...

View File

@ -110,66 +110,66 @@ module.GLOBAL_KEYBOARD = {
}, },
// XXX testing... // XXX testing...
Home: function(){ a.firstImage() }, Home: 'firstImage',
End: function(){ a.lastImage() }, End: 'lastImage',
Left: { Left: {
default: function(){ a.prevImage() }, default: 'prevImage',
alt: function(){ alt: 'shiftImageLeft!',
event.preventDefault() ctrl: 'prevScreen',
a.shiftImageLeft()
},
ctrl: function(){ a.prevScreen() },
}, },
Right: { Right: {
default: function(){ a.nextImage() }, default: 'nextImage',
alt: function(){ alt: 'shiftImageRight!',
event.preventDefault() ctrl: 'nextScreen',
a.shiftImageRight()
},
ctrl: function(){ a.nextScreen() },
}, },
'(': function(){ a.prevImageInOrder() }, '(': 'prevImageInOrder',
')': function(){ a.nextImageInOrder() }, ')': 'nextImageInOrder',
Up: { Up: {
default: function(){ a.prevRibbon() }, default: 'prevRibbon',
shift: function(){ a.shiftImageUp() }, shift: 'shiftImageUp',
'ctrl+shift': function(){ a.shiftImageUpNewRibbon() }, 'ctrl+shift': 'shiftImageUpNewRibbon',
}, },
Down: { Down: {
default: function(){ a.nextRibbon() }, default: 'nextRibbon',
shift: function(){ a.shiftImageDown() }, shift: 'shiftImageDown',
'ctrl+shift': function(){ a.shiftImageDownNewRibbon() }, 'ctrl+shift': 'shiftImageDownNewRibbon',
}, },
'#0': function(){ a.fitMax() }, '#0': 'fitMax',
'#1': { '#1': {
default: function(){ a.fitImage() }, default: 'fitImage',
ctrl: function(){ ctrl: 'fitOrig!',
event.preventDefault()
a.fitOrig()
},
}, },
'#2': function(){ a.fitTwo() }, '#2': 'fitTwo',
'#3': function(){ a.fitThree() }, '#3': 'fitThree',
'#4': function(){ a.fitFour() }, '#4': 'fitFour',
'#5': function(){ a.fitFive() }, '#5': 'fitFive',
'#6': function(){ a.fitSix() }, '#6': 'fitSix',
'#7': function(){ a.fitSeven() }, '#7': 'fitSeven',
'#8': function(){ a.fitEight() }, '#8': 'fitEight',
'#9': function(){ a.fitNine() }, '#9': 'fitNine',
'+': function(){ a.zoomIn() }, '+': 'zoomIn',
'=': '+', '=': '+',
'-': function(){ a.zoomOut() }, '-': 'zoomOut',
}, },
} }
/*********************************************************************/ /*********************************************************************/
$(function(){ $(function(){
window.a = testing.setupActions()
viewer.Animation.setup(a)
// this publishes all the actions...
//module.GLOBAL_KEYBOARD.__proto__ = a
// setup base keyboard for devel, in case something breaks... // setup base keyboard for devel, in case something breaks...
$(document) $(document)
.keydown( .keydown(
@ -177,11 +177,8 @@ $(function(){
module.GLOBAL_KEYBOARD, module.GLOBAL_KEYBOARD,
function(k){ function(k){
window.DEBUG && console.log(k) window.DEBUG && console.log(k)
})) },
a))
window.a = testing.setupActions()
viewer.Animation.setup(a)
}) })