From 2479cde5623b755bd96eccbfcc670dede0465400 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 6 Mar 2019 16:06:48 +0300 Subject: [PATCH] ... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/widget/browse2.html | 1 + ui (gen4)/lib/widget/browse2.js | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ui (gen4)/lib/widget/browse2.html b/ui (gen4)/lib/widget/browse2.html index a7f15025..09e0e91b 100755 --- a/ui (gen4)/lib/widget/browse2.html +++ b/ui (gen4)/lib/widget/browse2.html @@ -134,6 +134,7 @@ requirejs([ make('aaa') make.nest('D', browser.Browser(function(make){ make('a') + make('---') make('b') })) make('bbb') diff --git a/ui (gen4)/lib/widget/browse2.js b/ui (gen4)/lib/widget/browse2.js index 7f5dfc47..5b2a38ce 100755 --- a/ui (gen4)/lib/widget/browse2.js +++ b/ui (gen4)/lib/widget/browse2.js @@ -201,7 +201,10 @@ var makeEventMethod = function(event, handler){ // XXX can we generate this in one spot??? // ...currently it is generated here and in .trigger(..) var evt = { - name: event, + name: event, + // XXX + //stopPropagation: function(){ + //}, } // XXX handle more of the API??? @@ -253,6 +256,7 @@ var BaseBrowserPrototype = { noDuplicateValues: false, }, + // XXX needed to bubble the events up... parent: null, // @@ -510,6 +514,10 @@ var BaseBrowserPrototype = { parent: this, }) + // XXX do we need both this and the above ref??? + item.sublist instanceof Browser + && (item.sublist.parent = this) + // store the item... items.push(item) new_index[key] = item @@ -779,20 +787,29 @@ var BaseBrowserPrototype = { }, trigger: function(evt, ...args){ var that = this + var stopPropagation = false var evt = typeof(evt) == typeof('str') ? // XXX construct this in one place... // ...currently it is constructed here and in makeEventMethod(..) { name: evt, + stopPropagation: function(){ + stopPropagation = true }, } : evt + + // call the main set of handlers... ;((this.__event_handlers || {})[evt.name] || []) // prevent .off(..) from affecting the call loop... .slice() .forEach(function(handler){ handler.call(that, evt, ...args) }) - // XXX should we trigger the parent event???? - //this.parent.trigger(evt, ...args) + + // trigger the parent's event... + !stopPropagation + && this.parent + && this.parent.trigger(evt, ...args) + return this },