refactoring and some tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-20 04:29:44 +03:00
parent 080b7ea853
commit ebf92c5acf
3 changed files with 45 additions and 12 deletions

View File

@ -80,6 +80,7 @@ function(attr, states, callback){
/*********************************************************************/
// XXX split this into read and write actions...
// XXX check if align by position is relevant here...
var BaseActions =
module.BaseActions =
actions.Actions({
@ -98,12 +99,11 @@ actions.Actions({
//
// XXX should this be here???
'ribbon-focus-modes': [
'visual', // select image closest visually
'order', // select image closest to current in order
'first', // select first image
'last', // select last image
],
'ribbon-focus-mode': 'visual',
'ribbon-focus-mode': 'order',
},
@ -293,17 +293,9 @@ actions.Actions({
} else if(mode == 'first' || mode == 'last'){
var t = data.getImage(mode, r)
// visually closest image...
//} else if(mode == 'visual'){
// unknown mode...
} else {
var ribbons = this.ribbons
var t = ribbons.getImageByPosition('current', r)
if(t.length > 1){
t = t.eq(direction == 'before' ? 0 : 1)
}
t = ribbons.getElemGID(t)
return
}
this.focusImage(t, r)

View File

@ -144,6 +144,16 @@ actions.Actions({
'dark',
'light',
],
// XXX BUG: for some reason this get's shadowed by base.config...
'ribbon-focus-modes': [
'visual', // select image closest visually
'order', // select image closest to current in order
'first', // select first image
'last', // select last image
],
'ribbon-focus-mode': 'visual',
},
// Images...
@ -718,6 +728,33 @@ module.Viewer = core.ImageGridFeatures.Feature({
delete that.__viewer_resize
}
}],
// add support for visual mode...
// XXX 'visual' mode fails in single-image-mode....
['focusRibbon',
function(res, target, mode){
mode = mode || this.config['ribbon-focus-mode']
var c = this.data.getRibbonOrder()
var i = this.data.getRibbonOrder(r)
// NOTE: we are not changing the direction here based on
// this.direction as swap will confuse the user...
var direction = c < i ? 'before' : 'after'
if(mode == 'visual'){
var ribbons = this.ribbons
var r = this.data.getRibbon(target)
var t = ribbons.getImageByPosition('current', r)
if(t.length > 1){
t = t.eq(direction == 'before' ? 0 : 1)
}
t = ribbons.getElemGID(t)
this.focusImage(t, r)
}
}],
],
})

View File

@ -110,10 +110,14 @@ module.FeatureProto = {
actions.config = {}
}
Object.keys(config).forEach(function(n){
/*
// keep existing keys...
if(actions.config[n] === undefined){
actions.config[n] = config[n]
}
*/
// NOTE: this will overwrite existing values...
actions.config[n] = config[n]
})
}