added expanded/collapsed group support to data.getImage(..) and data.getRibbon(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-24 18:09:45 +03:00
parent ea88c16472
commit 3c5521dece

View File

@ -607,6 +607,10 @@ var DataPrototype = {
mode = mode == null ? 'before' : mode mode = mode == null ? 'before' : mode
} }
// get the loaded group gid...
var x = this.getLoadedInGroup(target)
target = x != null ? x : target
var i = this.order.indexOf(target) var i = this.order.indexOf(target)
// invalid gid... // invalid gid...
@ -920,6 +924,10 @@ var DataPrototype = {
// image gid... // image gid...
} else { } else {
// get the loaded group gid...
var x = this.getLoadedInGroup(target)
target = x != null ? x : target
var i = this.order.indexOf(target) var i = this.order.indexOf(target)
if(i == -1){ if(i == -1){
return null return null
@ -1505,6 +1513,44 @@ var DataPrototype = {
return null return null
}, },
// Get loaded gid representing a group...
//
// This will either be a group gid if collapsed or first loaded gid
// from within if group expanded...
//
// NOTE: this will get the first loaded image of a group regardless
// of group/image gid given...
// Thus, this will return the argument ONLY if it is loaded.
// NOTE: this does not account for current position in selecting an
// image from the group...
getLoadedInGroup: function(gid){
var group = this.getGroup(gid)
// not a group...
if(group == null){
return null
}
// get the actual image gid...
var gids = gid == group ? this.groups[group] : [gid]
// find either
for(var k in this.ribbons){
if(this.ribbons[k].indexOf(group) >= 0){
return group
}
// get the first loaded gid in group...
for(var i=0; i<gids.length; i++){
if(this.ribbons[k].indexOf(gids[i]) >= 0){
return gids[i]
}
}
}
// nothing loaded...
return null
},
// Group image(s)... // Group image(s)...
// //
// Group image(s) into a new group // Group image(s) into a new group