added direction awareness to shifting images up/down + several tweeks...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-05-03 00:57:26 +04:00
parent 346b09b4c0
commit 1975f01dce
2 changed files with 29 additions and 15 deletions

View File

@ -433,16 +433,19 @@ function nextRibbon(moving, mode){
// XXX get move direction...
function _shiftImageTo(image, direction, moving, force_create_ribbon){
function _shiftImageTo(image, direction, moving, force_create_ribbon, mode){
if(image == null){
image = $('.current.image')
}
if(mode == null){
mode = NAV_DEFAULT
}
// account move for direction...
// XXX get the value from some place more logical than the argument...
var a = moving == 'prev' ? 'prev' : 'next'
var b = moving == 'prev' ? 'next' : 'prev'
var target = image[a]('.image')
var a = moving == 'prev' ? 'prevAll' : 'nextAll'
var b = moving == 'prev' ? 'nextAll' : 'prevAll'
var target = image[a]('.image' + mode).first()
target = target.length == 0 ? image[b]() : target
@ -453,17 +456,17 @@ function _shiftImageTo(image, direction, moving, force_create_ribbon){
// XXX does this need to be animated???
return centerImage(focusImage(target), 'css')
}
function shiftImageUp(image){
return _shiftImageTo(image, 'prev')
function shiftImageUp(image, moving){
return _shiftImageTo(image, 'prev', moving)
}
function shiftImageDown(image){
function shiftImageDown(image, moving){
return _shiftImageTo(image, 'next')
}
function shiftImageUpNewRibbon(image){
return _shiftImageTo(image, 'prev', true)
function shiftImageUpNewRibbon(image, moving){
return _shiftImageTo(image, 'prev', moving, true)
}
function shiftImageDownNewRibbon(image){
return _shiftImageTo(image, 'prev', false)
function shiftImageDownNewRibbon(image, moving){
return _shiftImageTo(image, 'prev', moving, false)
}

View File

@ -215,11 +215,11 @@ var KEYBOARD_CONFIG = {
'.viewer': {
Up: {
default: function(){ prevRibbon(DIRECTION) },
shift: function(){ shiftImageUp() },
shift: function(){ shiftImageUp(null, DIRECTION) },
},
Down: {
default: function(){ nextRibbon(DIRECTION) },
shift: function(){ shiftImageDown() },
shift: function(){ shiftImageDown(null, DIRECTION) },
},
// XXX need to cancel the animation of the prev action...
@ -285,6 +285,14 @@ var KEYBOARD_CONFIG = {
default: 'Right',
shift: 'Left',
},
/* XXX for some reason this does not work,,,
// XXX for some odd reason, returning false does not cancel
// default behaviour here...
Backspace: {
default: 'Left',
shift: 'Right',
},
*/
Home: function(){
firstImage()
@ -301,16 +309,20 @@ var KEYBOARD_CONFIG = {
'5': function(){ fitNImages(5) },
'6': function(){ fitNImages(6) },
'7': function(){ fitNImages(7) },
// XXX for some reason this also hooks the Backspace key (80)...
'8': function(){ fitNImages(8) },
'9': function(){ fitNImages(9) },
// XXX this is temporary, combine this with single image mode...
F: function(){ toggleImageProportions() },
// marking...
// XXX not final, think of a better way to do this...
I: {
shift: function(){ invertImageMarks() },
},
},
A: {
shift: function(){ toggleImageMarkBlock() },
ctrl: function(){ markAll('ribbon') },
@ -319,7 +331,6 @@ var KEYBOARD_CONFIG = {
default: function(){ toggleImageMark() },
shift: function(){ toggleMarkedOnlyView() },
},
}
}