fixed a bug + doc revision...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-11-04 15:08:30 +03:00
parent 2199acc88d
commit 1c507a8915
2 changed files with 23 additions and 13 deletions

View File

@ -473,7 +473,8 @@ actions.Actions({
has a slightly different signature to the above, this is done has a slightly different signature to the above, this is done
for simplicity... for simplicity...
`, `,
function(img, list){ this.data.focusImage.apply(this.data, arguments) }], //function(img, list){ this.data.focusImage.apply(this.data, arguments) }],
function(img, list){ this.data.focusImage(...arguments) }],
// Focuses a ribbon by selecting an image in it... // Focuses a ribbon by selecting an image in it...
// //
// modes supported: // modes supported:

View File

@ -760,16 +760,11 @@ var DataPrototype = {
// NOTE: the second argument must be .getRibbon(..) compatible. // NOTE: the second argument must be .getRibbon(..) compatible.
// NOTE: to get global first/last image use the index, e.g.: // NOTE: to get global first/last image use the index, e.g.:
// .getImage(0) / .getImage(-1) // .getImage(0) / .getImage(-1)
// // NOTE: to reference relative ribbon 'before'/'after' keywords
// Get image closest to current in list/ribbon: // are ignored, use 'above'/'prev' or 'below'/'next' instead.
// .getImage(list|ribbon[, 'before'|'after']) // This is done foe uniformity with:
// -> gid // .getImage(gid|order, 'before'|'after', ...)
// -> null // ...see below for more info.
// NOTE: null is returned if there is no image before/after the
// current image in the given list/ribbon, e.g. the
// current image is first/last resp.
// NOTE: 'before' is default.
// NOTE: the first argument must not be a number.
// //
// Get image closest to current or a specific image: // Get image closest to current or a specific image:
// .getImage('before'[, list|ribbon]) // .getImage('before'[, list|ribbon])
@ -786,6 +781,17 @@ var DataPrototype = {
// NOTE: in both the above cases if gid|order is found explicitly // NOTE: in both the above cases if gid|order is found explicitly
// it will be returned. // it will be returned.
// //
// Get image closest to current in list/ribbon (special case):
// .getImage(list|ribbon[, 'before'|'after'])
// -> gid
// -> null
// NOTE: null is returned if there is no image before/after the
// current image in the given list/ribbon, e.g. the
// current image is first/last resp.
// NOTE: 'before' is default.
// NOTE: the first argument must not be a number.
//
//
// Get next/prev image (offset of 1): // Get next/prev image (offset of 1):
// .getImage('next') // .getImage('next')
// .getImage('prev') // .getImage('prev')
@ -818,6 +824,7 @@ var DataPrototype = {
// //
// XXX most of the complexity here comes from argument DSL parsing, // XXX most of the complexity here comes from argument DSL parsing,
// might be good to revise argument syntax and handling... // might be good to revise argument syntax and handling...
// XXX doc needs revision....
getImage: function(target, mode, list){ getImage: function(target, mode, list){
// empty data... // empty data...
if(this.order == null || (this.order && this.order.length == 0)){ if(this.order == null || (this.order && this.order.length == 0)){
@ -842,6 +849,7 @@ var DataPrototype = {
// first/last special case... // first/last special case...
// XXX need to get first loaded... // XXX need to get first loaded...
if(target == 'first'){ if(target == 'first'){
mode = mode == 'before' || mode == 'after' ? null : mode
list = this.ribbons[this.getRibbon(mode)] list = this.ribbons[this.getRibbon(mode)]
for(var res in list){ for(var res in list){
return list[res] return list[res]
@ -849,6 +857,7 @@ var DataPrototype = {
return null return null
} }
if(target == 'last'){ if(target == 'last'){
mode = mode == 'before' || mode == 'after' ? null : mode
list = this.ribbons[this.getRibbon(mode)] list = this.ribbons[this.getRibbon(mode)]
for(var i=list.length; i >= 0; i--){ for(var i=list.length; i >= 0; i--){
if(list[i] != null){ if(list[i] != null){
@ -1341,8 +1350,8 @@ var DataPrototype = {
return this.ribbon_order.slice(-1)[0] return this.ribbon_order.slice(-1)[0]
} }
target = target == 'next' ? 'after' : target target = target == 'next' || target == 'below' ? 'after' : target
target = target == 'prev' ? 'before' : target target = target == 'prev' || target == 'above' ? 'before' : target
if(target == 'before' || target == 'after'){ if(target == 'before' || target == 'after'){
offset = target offset = target