updated .focused / .selected props, still need to do events...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-05-13 14:39:58 +03:00
parent bc483edb26
commit adc25ca1a9

View File

@ -324,27 +324,49 @@ var BaseBrowserPrototype = {
this.__item_index = value }, this.__item_index = value },
// XXX what should these return??? (item, id, ...) // XXX should this be more pedantic???
__focused: undefined, __focused: undefined,
get focused(){ get focused(){
return this.__focused && this.__focused.focused ? return (this.__focused && this.__focused.focused) ?
this.__focused this.__focused
: (this.__focused = this : (this.__focused = this.get('focused')) },
// XXX should we simple bailout when we find an item??? // XXX should this trigger focus/blur events???
.filter(function(e){ // ...or should this call .focus(..)
return e.focused }).shift()) },
set focused(value){ set focused(value){
// XXX delete this.get('focused').focused
}, this.__focused = value == null ?
null
: this.get(value,
function(e){
e.focused = true
return e}) },
__selected: null, __selected: null,
get selected(){ get selected(){
return this.__selected return this.__selected
|| (this.__selected = this || (this.__selected = this.search('selected')) },
.filter(function(e){ // XXX should this trigger select/deselect events???
return e.selected })) }, // ...or should this call .select(..)
set selected(value){ set selected(value){
// XXX var that = this
// deselect...
this.__selected = null
this.search('selected',
function(e){
delete e.selected })
// select...
this.__selected = value == null ?
null
: (value instanceof Array ?
value
: [value])
.map(function(p){
return that.search(p,
function(e){
e.selected = true
return e }) })
.flat()
.unique()
}, },