use itemKeys and turn .format into function

This commit is contained in:
j 2016-01-17 16:22:45 +05:30
parent 7da4bd0ec3
commit 6d659b8049
1 changed files with 7 additions and 2 deletions

View File

@ -9,13 +9,18 @@ oml.ui.transfersPanel = function() {
'id', 'title', 'extension', 'size', 'id', 'title', 'extension', 'size',
'transferadded', 'transferprogress' 'transferadded', 'transferprogress'
].map(function(id) { ].map(function(id) {
var key = Ox.getObjectById(oml.config.sortKeys, id); var key = Ox.getObjectById(oml.config.itemKeys, id);
return { return {
align: Ox.contains([ align: Ox.contains([
'size', 'transferprogress' 'size', 'transferprogress'
], id) ? 'right' : 'left', ], id) ? 'right' : 'left',
format: function(value) { format: function(value) {
return Ox.encodeHTMLEntities(key.format(value)); return Ox.encodeHTMLEntities(key.format
? Ox['format' + Ox.toTitleCase(key.format.type)].apply(
this, [value].concat(key.format.args || [])
)
: Ox.isArray(key.type) ? (value || []).join(', ')
: (value || ''));
}, },
id: id, id: id,
operator: oml.getSortOperator(id), operator: oml.getSortOperator(id),