1
0
Fork 0
forked from 0x2620/oxjs

less obscure Ox.map

This commit is contained in:
rolux 2012-05-22 16:29:37 +02:00
commit 12cf77cef5
21 changed files with 125 additions and 101 deletions

View file

@ -154,8 +154,8 @@ Ox.Chart = function(options, self) {
});
while (Ox.sum(widths) != totalWidth) {
max = Ox.max(widths);
maxKeys = Ox.map(Object.keys(widths), function(key) {
return widths[key] == max ? key : null;
maxKeys = Object.keys(widths).filter(function(key) {
return widths[key] == max;
});
widths[maxKeys[0]] += Ox.sum(widths) < totalWidth ? 1 : -1;
}

View file

@ -160,16 +160,13 @@ Ox.IconItem = function(options, self) {
text = Ox.isArray(text) ? text.join(', ') : text;
var lines = Ox.wordwrap(text, maxLength, '\n', true, false).split('\n');
return Ox.highlightHTML(
Ox.map(lines, function(line, i) {
if (i < maxLines - 1) {
return line;
} else if (i == maxLines - 1) {
return lines.length == maxLines ? line : Ox.truncate(lines.map(function(line, i) {
return i < maxLines - 1 ? null : line;
}).join(' '), maxLength, '...', 'center');
} else {
return null;
}
lines.slice(0, maxLines).map(function(line, i) {
return i < maxLines - 1 || lines.length == maxLines
? line
: Ox.truncate(
lines.slice(maxLines).join(' '),
maxLength, '...', 'center'
);
}).join(' <br/>'),
self.options.find, 'OxHighlight', ['br']
).replace(/ (<.*?>)?<br\/>/g, ' $1<br\/>');

View file

@ -183,8 +183,10 @@ Ox.TextList = function(options, self) {
max: -1,
min: 1,
type: 'image',
value: Ox.map(self.options.columns, function(column) {
return column.visible ? column.id : null;
value: Ox.filter(self.options.columns, function(column) {
return column.visible;
}).map(function(column) {
return column.id;
})
})
.bindEvent('change', changeColumns)

View file

@ -160,7 +160,7 @@ Ox.TreeList = function(options, self) {
if (type == 'array' || type == 'object') {
ret.title += Ox.toTitleCase(type)
+ ' <span class="OxLight">[' + Ox.len(value) + ']</span>';
ret.items = Ox.map(Ox.sort(Ox.keys(value)), function(k) {
ret.items = Ox.sort(Ox.keys(value).map(function(k) {
return parseData(k, value[k]);
});
} else {