From 4ae0323eb2bb7a6de0d340ac48b7bfb30d6e0a95 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 2 Jun 2019 17:59:30 +0300 Subject: [PATCH] more tweaking... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/widget/browse2.js | 47 ++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/ui (gen4)/lib/widget/browse2.js b/ui (gen4)/lib/widget/browse2.js index 5d142b04..7e764fa2 100755 --- a/ui (gen4)/lib/widget/browse2.js +++ b/ui (gen4)/lib/widget/browse2.js @@ -2072,6 +2072,23 @@ var BaseBrowserPrototype = { // root: , // options: , // + // + // // These are the same as in options... + // // + // // NOTE: these will get set to the item indexes... + // from: | , + // to: | , + // // optional... + // // NOTE: in general we set these in options... + // //around: | , + // //count: , + // + // ... + // } + // + // + // options: + // { // // Partial render parameters... // // // // supported combinations: @@ -2088,12 +2105,6 @@ var BaseBrowserPrototype = { // around: | , // count: , // - // ... - // } - // - // - // options: - // { // nonFinalized: , // // // for more supported options see: .walk(..) @@ -2124,16 +2135,28 @@ var BaseBrowserPrototype = { context.options = context.options || options // build range bounds... + // use .get(..) on full (non-partial) range... + var get_options = Object.assign( + Object.create(options), + {from: null, to: null, around: null}) + // index getter... var normIndex = function(i){ return (i === undefined || typeof(i) == typeof(123)) ? i - : this.get(i, function(e, i){ return i }) }.bind(this) - var from = context.from = normIndex(context.from) - var to = context.to = normIndex(context.to) - var around = normIndex(context.around) - var count = context.count < 0 ? + : this.get(i, function(e, i){ return i }, get_options) }.bind(this) + // NOTE: we prefer context.from / context.to as they are more + // likely to be normalized. + // as to the rest of the values of set we look first in the + // options as we'll need them only if from/to are not + // normalized... + var from = context.from = normIndex(context.from || options.from) + var to = context.to = normIndex(context.to || options.to) + var around = normIndex(options.around || context.around) + var count = options.count || context.count + // NOTE: count < 0 is the same as no count / all... + count = count < 0 ? null - : context.count + : count // complete to/from based on count and/or around... // NOTE: we do not care about overflow here... ;(from == null && count != null)