rewritten data.join(..), now it works correctly...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-03-26 19:54:02 +03:00
parent 3c18655767
commit f5ffc93fcd
3 changed files with 50 additions and 32 deletions

View File

@ -723,9 +723,7 @@ var FileSystemLoaderActions = actions.Actions({
// NOTE: we are prepending new images to the start... // NOTE: we are prepending new images to the start...
// NOTE: all ribbon gids will change here... // NOTE: all ribbon gids will change here...
var cur = that.data.current var cur = that.data.current
// XXX this does not seem to work... that.data = new_data.join(that.data)
//that.data = new_data.join(that.data)
that.data = new_data.join('top', that.data)
that.data.current = cur that.data.current = cur
that.images.join(imgs) that.images.join(imgs)

View File

@ -2386,8 +2386,7 @@ var DataPrototype = {
// //
// XXX test more complex cases... // XXX test more complex cases...
// XXX add a 'gid' align mode... // XXX add a 'gid' align mode...
join: function(){ join: function(...args){
var args = Array.apply(null, arguments)
var align = typeof(args[0]) == typeof('str') || args[0] == null ? var align = typeof(args[0]) == typeof('str') || args[0] == null ?
args.shift() args.shift()
: 'base' : 'base'
@ -2398,6 +2397,8 @@ var DataPrototype = {
args.forEach(function(data){ args.forEach(function(data){
// calculate align offset... // calculate align offset...
// NOTE: negative d means we push data up while positive
// pushes data down by number of ribbons...
if(align == 'base'){ if(align == 'base'){
var d = base.getRibbonOrder('base') - data.getRibbonOrder('base') var d = base.getRibbonOrder('base') - data.getRibbonOrder('base')
@ -2411,45 +2412,62 @@ var DataPrototype = {
var t = 0 var t = 0
// merge order... // merge order...
// XXX need to take care of gid conflicts...
base.order = base.order.concat(data.order) base.order = base.order.concat(data.order)
// merge ribbons... // merge .ribbons and .ribbon_order...
//
// NOTE: this is a special case, so we do not handle it in // NOTE: this is a special case, so we do not handle it in
// the .eachImageList(..) below. the reason being that // the .eachImageList(..) below. the reason being that
// ribbons can be merged is different ways. // ribbons can be merged in different ways.
for(var i=0; i < data.ribbon_order.length; i++){ // NOTE: we will reuse gids of some ribbons... (XXX???)
var g = data.ribbon_order[i] var n_base = d > 0 ?
var r = data.ribbons[g] base.getRibbonOrder('base')
: data.getRibbonOrder('base')
var cur = base.current
// push the new ribbon just before the base... var i = 0
if(d < 0){ var n_ribbons = {}
// see if g is unique... var n_ribbon_order = []
if(g in base.ribbons || base.order.indexOf(g) >= 0){ var b_ribbon_order = base.ribbon_order.slice()
g = base.newGID() var d_ribbon_order = data.ribbon_order.slice()
} while(b_ribbon_order.length > 0
base.ribbon_order.splice(t, 0, g) || d_ribbon_order.length > 0){
base.ribbons[g] = r // pull data up by d...
t += 1 if(d + i < 0){
d -= 1 var bg = null
var dg = d_ribbon_order.shift()
var gid = dg
// append ribbons... // push data down by d...
} else if(d < base.ribbon_order.length){ } else if(d - i > 0){
var tg = base.ribbon_order[d] var bg = b_ribbon_order.shift()
base.ribbons[tg] = base.ribbons[tg].concat(r) var dg = null
var gid = bg
// push the new ribbon to the end... // merge...
} else { } else {
// see if g is unique... var bg = b_ribbon_order.shift()
if(g in base.ribbons || base.order.indexOf(g) >= 0){ var dg = d_ribbon_order.shift()
g = base.newGID() var gid = base.newGID()
}
base.ribbon_order.push(g)
base.ribbons[g] = r
} }
d += 1 // do the actual merge...
// NOTE: the tails will take care of themselves via the
// defaults...
n_ribbons[gid] =
(base.ribbons[bg] || [])
.concat(data.ribbons[dg] || [])
n_ribbon_order.push(gid)
i++
} }
// set the new data...
base.ribbon_order = n_ribbon_order
base.ribbons = n_ribbons
base.base = base.getRibbon(n_base)
base.current = cur
// merge other stuff... // merge other stuff...
data.eachImageList(function(list, key, set){ data.eachImageList(function(list, key, set){
if(set == 'ribbons'){ if(set == 'ribbons'){

View File

@ -574,6 +574,8 @@ if(typeof(jQuery) != typeof(undefined)){
// continue handling... // continue handling...
} else if(options.propagate_unhandled_keys !== false){ } else if(options.propagate_unhandled_keys !== false){
// NOTE: jQuery can't reuse browser events, this
// we need to pass a jq event/proxy here...
$(this).parent().trigger(in_evt) $(this).parent().trigger(in_evt)
} }
}) })