Ox.TreeList: add 'expanded' option
This commit is contained in:
parent
c287892606
commit
63d5f04af7
1 changed files with 12 additions and 10 deletions
|
@ -1,17 +1,18 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
Ox.TreeList <f> TreeList Object
|
Ox.TreeList <f> Tree List
|
||||||
([options[, self]]) -> <o:Ox.List> TreeList Object
|
([options[, self]]) -> <o:Ox.List> Tree List Object
|
||||||
options <o> Options object
|
options <o> Options object
|
||||||
data <f|null> data to be parsed to items, needs documentation
|
data <f|null> Data to be parsed as items (needs documentation)
|
||||||
|
expanded <b|false> If true, and data is not null, all items are expanded
|
||||||
icon <o|f|null> Image URL, or function that returns an image object
|
icon <o|f|null> Image URL, or function that returns an image object
|
||||||
items <a|[]> array of items
|
items <a|[]> Array of items
|
||||||
max <n|-1> maximum number of items that can be selected, -1 unlimited
|
max <n|-1> Maximum number of items that can be selected, -1 unlimited
|
||||||
min <n|0> minimum number of items that have to be selected
|
min <n|0> Minimum number of items that have to be selected
|
||||||
selected <a|[]> selected ids
|
selected <a|[]> Selected ids
|
||||||
width <n|256> list width
|
width <n|256> List width
|
||||||
self <o> shared private variable
|
self <o> Shared private variable
|
||||||
@*/
|
@*/
|
||||||
|
|
||||||
Ox.TreeList = function(options, self) {
|
Ox.TreeList = function(options, self) {
|
||||||
|
@ -22,6 +23,7 @@ Ox.TreeList = function(options, self) {
|
||||||
var that = Ox.Element({}, self)
|
var that = Ox.Element({}, self)
|
||||||
.defaults({
|
.defaults({
|
||||||
data: null,
|
data: null,
|
||||||
|
expanded: false,
|
||||||
icon: null,
|
icon: null,
|
||||||
items: [],
|
items: [],
|
||||||
max: 1,
|
max: 1,
|
||||||
|
@ -172,12 +174,12 @@ Ox.TreeList = function(options, self) {
|
||||||
|
|
||||||
function parseData(key, value) {
|
function parseData(key, value) {
|
||||||
var ret = {
|
var ret = {
|
||||||
expanded: false,
|
|
||||||
id: Ox.uid().toString(),
|
id: Ox.uid().toString(),
|
||||||
title: key.toString() + ': '
|
title: key.toString() + ': '
|
||||||
},
|
},
|
||||||
type = Ox.typeOf(value);
|
type = Ox.typeOf(value);
|
||||||
if (type == 'array' || type == 'object') {
|
if (type == 'array' || type == 'object') {
|
||||||
|
ret.expanded = self.options.expanded;
|
||||||
ret.title += Ox.toTitleCase(type)
|
ret.title += Ox.toTitleCase(type)
|
||||||
+ ' <span class="OxLight">[' + Ox.len(value) + ']</span>';
|
+ ' <span class="OxLight">[' + Ox.len(value) + ']</span>';
|
||||||
ret.items = type == 'array' ? value.map(function(v, i) {
|
ret.items = type == 'array' ? value.map(function(v, i) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue