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

@ -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\/>');