mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 10:50:08 +00:00
refactored getRibbonGIDs(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6d429f257e
commit
c38cda3746
55
ui/data.js
55
ui/data.js
@ -721,32 +721,47 @@ function getGIDRibbonIndex(gid, data){
|
|||||||
|
|
||||||
// Get a list of gids in ribbon...
|
// Get a list of gids in ribbon...
|
||||||
//
|
//
|
||||||
// The ribbon can be given as:
|
// Possible signatures:
|
||||||
// - null - get current ribbon
|
|
||||||
// - number - ribbon index
|
|
||||||
// - gid
|
|
||||||
// - image
|
|
||||||
// - list - return only images in ribbon
|
|
||||||
//
|
//
|
||||||
// XXX we should be able to pass both a ribbon number and a list of
|
// getRibbonGIDs([<image>[, <no-clone>]])
|
||||||
// gids to filter...
|
// find a ribbon with <image> and return its gids
|
||||||
function getRibbonGIDs(a, no_clone, data){
|
// <image> can be anything than getGIDRibbonIndex(..) accepts.
|
||||||
|
// if <image> is omitted then current ribbon is assumed.
|
||||||
|
// <no-clone> if true will prevent the result from being cloned, use
|
||||||
|
// with caution.
|
||||||
|
//
|
||||||
|
// getRibbonGIDs(<gids>[, <ribbon-index>])
|
||||||
|
// <gids> is list of gids.
|
||||||
|
// return a filtered list of gids, containing only gids from target
|
||||||
|
// ribbon.
|
||||||
|
// <ribbon-index> is getGIDRibbonIndex(..) compatible value or number,
|
||||||
|
// if it is not given, then current ribbon is used.
|
||||||
|
//
|
||||||
|
function getRibbonGIDs(a, b, data){
|
||||||
data = data == null ? DATA : data
|
data = data == null ? DATA : data
|
||||||
|
|
||||||
|
// a is ribbon number...
|
||||||
if(typeof(a) == typeof(123)){
|
if(typeof(a) == typeof(123)){
|
||||||
var res = data.ribbons[a]
|
var res = data.ribbons[a]
|
||||||
} else {
|
|
||||||
var res = data.ribbons[getGIDRibbonIndex(
|
// a is list of gids, b if given is ribbon number...
|
||||||
(a != null && a.constructor.name != 'Array')
|
} else if(a != null && a.constructor.name == 'Array'){
|
||||||
? a
|
// b is a number...
|
||||||
: null,
|
if(typeof(b) == typeof(123)){
|
||||||
data)]
|
var res = data.ribbons[b]
|
||||||
}
|
// b is an getGIDRibbonIndex(..) compatible...
|
||||||
if(a != null && a.constructor.name == 'Array'){
|
} else {
|
||||||
res = res.filter(function(e){
|
var res = data.ribbons[getGIDRibbonIndex(b, data)]
|
||||||
return a.indexOf(e) >= 0
|
}
|
||||||
|
res = a.filter(function(e){
|
||||||
|
return res.indexOf(e) >= 0
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// a is an getGIDRibbonIndex(..) compatible...
|
||||||
|
} else {
|
||||||
|
var res = data.ribbons[getGIDRibbonIndex(a, data)]
|
||||||
}
|
}
|
||||||
if(no_clone){
|
if(b){
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
return res.slice()
|
return res.slice()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user