From 3c5521decec9d7c0579920d0f41efb3a99eb2d3b Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 24 Nov 2014 18:09:45 +0300 Subject: [PATCH] added expanded/collapsed group support to data.getImage(..) and data.getRibbon(..)... Signed-off-by: Alex A. Naanou --- ui (gen4)/data.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/ui (gen4)/data.js b/ui (gen4)/data.js index 27cd8843..36542274 100755 --- a/ui (gen4)/data.js +++ b/ui (gen4)/data.js @@ -607,6 +607,10 @@ var DataPrototype = { 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) // invalid gid... @@ -920,6 +924,10 @@ var DataPrototype = { // image gid... } else { + // get the loaded group gid... + var x = this.getLoadedInGroup(target) + target = x != null ? x : target + var i = this.order.indexOf(target) if(i == -1){ return null @@ -1505,6 +1513,44 @@ var DataPrototype = { 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= 0){ + return gids[i] + } + } + } + + // nothing loaded... + return null + }, + // Group image(s)... // // Group image(s) into a new group