added item grouping and sorting by traversability...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-13 09:01:43 +03:00
parent eb15fa613a
commit b477cdc992
2 changed files with 53 additions and 24 deletions

View File

@ -229,6 +229,8 @@ WalkPrototype.options = {
traversable: true,
flat: false,
sortTraversable: 'first',
//actionButton: '&ctdot;',
actionButton: '&odot;',
pushButton: false,

View File

@ -244,6 +244,14 @@ var BrowserPrototype = {
// affected...
toggleDisabledDrawing: true,
// Group traversable elements...
//
// Possible values:
// null | false | 'none' - show items as-is
// 'first' - group traversable items at top
// 'last' - group traversable items at bottom
sortTraversable: null,
// Controls the display of the action button on each list item...
//
// Possible values:
@ -735,6 +743,8 @@ var BrowserPrototype = {
p.scrollLeft(0)
}
var sort_traversable = this.options.sortTraversable
var section_tail
// fill the children list...
// NOTE: this will be set to true if make(..) is called at least once...
var interactive = false
@ -767,10 +777,9 @@ var BrowserPrototype = {
.append($('<div>')
.addClass('text')
.text(p))
.appendTo(l)
if(!traversable){
res.addClass('not-traversable')
}
if(disabled){
res.addClass('disabled')
@ -832,6 +841,24 @@ var BrowserPrototype = {
}))
})
// place in list...
// as-is...
if(!sort_traversable || sort_traversable == 'none'){
res.appendTo(l)
// traversable first/last...
} else {
if(sort_traversable == 'first' ? traversable : !traversable){
section_tail == null ?
l.prepend(res)
: section_tail.after(res)
section_tail = res
} else {
res.appendTo(l)
}
}
return res
}