squashed several bugs...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-11-02 15:01:51 +03:00
parent ca8724f2a7
commit 014dcc80a0
2 changed files with 33 additions and 7 deletions

View File

@ -591,6 +591,13 @@ var DataPrototype = {
target = this.current target = this.current
} }
var offset = list == 'before' ? -1
: list == 'after' ? 1
: 0
if(list == 'before' || list == 'after'){
list = null
}
// normalize mode... // normalize mode...
if(mode != null if(mode != null
&& mode.constructor === Array && mode.constructor === Array
@ -600,7 +607,7 @@ var DataPrototype = {
} }
// relative mode and offset... // relative mode and offset...
if(typeof(mode) == typeof(123)){ if(typeof(mode) == typeof(123)){
var offset = mode offset += mode
mode = offset < 0 ? 'before' mode = offset < 0 ? 'before'
: offset > 0 ? 'after' : offset > 0 ? 'after'
: mode : mode
@ -622,6 +629,7 @@ var DataPrototype = {
return -1 return -1
} }
// normalize the list to a sparse list of gids... // normalize the list to a sparse list of gids...
list = list == null ? list = list == null ?
this.ribbons[this.getRibbon(target)] this.ribbons[this.getRibbon(target)]
@ -636,14 +644,12 @@ var DataPrototype = {
} }
// prepare for the search... // prepare for the search...
if(mode == 'before' || mode == 'prev'){ var step = (mode == 'before' || mode == 'prev') ? -1
var step = -1 : (mode == 'after' || mode == 'next') ? 1
: null
} else if(mode == 'after' || mode == 'next'){
var step = 1
// strict -- no hit means there is no point in searching... // strict -- no hit means there is no point in searching...
} else { if(step == null){
return null return null
} }
@ -652,6 +658,8 @@ var DataPrototype = {
// get the first non-null, also accounting for offset... // get the first non-null, also accounting for offset...
// NOTE: we are using this.order.length here as ribbons might // NOTE: we are using this.order.length here as ribbons might
// be truncated... // be truncated...
// XXX currently this works correctly ONLY when step and offset
// are in the same direction...
for(; i >= 0 && i < this.order.length; i+=step){ for(; i >= 0 && i < this.order.length; i+=step){
var cur = list[i] var cur = list[i]
// skip undefined or unloaded images... // skip undefined or unloaded images...

View File

@ -274,10 +274,28 @@ actions.Actions({
// basic navigation... // basic navigation...
// //
focusImage: ['Navigate/Focus image', focusImage: ['Navigate/Focus image',
/* XXX same structure as action but instead of a function uses
a list of args...
// aliases...
{
'firstImage': ['Navigate/First image in current ribbon', [ 'first' ]],
'lastImage': ['Navigate/Last image in current ribbon', [ 'last' ]],
'firstGlobalImage': ['Navigate/First globally image', [ 0 ]],
'lastGlobalImage': ['Navigate/Last globally image', [ -1 ]],
},
*/
function(img, list){ function(img, list){
this.data.focusImage(img, list) this.data.focusImage(img, list)
}], }],
focusRibbon: ['Navigate/Focus Ribbon', focusRibbon: ['Navigate/Focus Ribbon',
/*
{
firstRibbon: ['Navigate/First ribbon', [ 'first' ]],
lastRibbon: ['Navigate/Last ribbon', [ 'last' ]],
prevRibbon: ['Navigate/Previous ribbon', [ 'before' ]],
nextRibbon: ['Navigate/Next ribbon', [ 'after' ]],
},
*/
function(target){ function(target){
var data = this.data var data = this.data
var r = data.getRibbon(target) var r = data.getRibbon(target)