transfer panel: fix cancel button

This commit is contained in:
rlx 2016-01-17 16:04:38 +05:30
parent 36be2bb3b2
commit 881956b4f4

View file

@ -5,55 +5,68 @@ oml.ui.transfersPanel = function() {
var ui = oml.user.ui,
$list = Ox.TableList({
columns: [
'id', 'title', 'extension', 'size',
'transferadded', 'transferprogress'
].map(function(id) {
var key = Ox.getObjectById(oml.config.itemKeys, id);
return {
align: Ox.contains([
'size', 'transferprogress'
], id) ? 'right' : 'left',
format: function(value) {
return Ox.encodeHTMLEntities(
(key.format || Ox.identity)(value)
);
},
id: id,
operator: oml.getSortOperator(id),
title: Ox._(key.title),
visible: id != 'id',
width: id == 'title' ? 240
: id == 'transferadded' ? 160
: id == 'transferprogress' ? 80 - Ox.UI.SCROLLBAR_SIZE
: key.columnWidth
};
columns: [
'id', 'title', 'extension', 'size',
'transferadded', 'transferprogress'
].map(function(id) {
var key = Ox.getObjectById(oml.config.itemKeys, id);
return {
align: Ox.contains([
'size', 'transferprogress'
], id) ? 'right' : 'left',
format: function(value) {
return Ox.encodeHTMLEntities(
(key.format || Ox.identity)(value)
);
},
id: id,
operator: oml.getSortOperator(id),
title: Ox._(key.title),
visible: id != 'id',
width: id == 'title' ? 240
: id == 'transferadded' ? 160
: id == 'transferprogress' ? 80 - Ox.UI.SCROLLBAR_SIZE
: key.columnWidth
};
}),
columnsVisible: true,
items: function(data, callback) {
Ox.Request.clearCache('find'); // FIXME: not ideal - and doesn't work
oml.api.find(Ox.extend(data, {
query: {
conditions: [{
key: 'mediastate',
operator: '==',
value: 'transferring'
}],
operator: '&'
}
}), callback);
},
keys: ['author'],
scrollbarVisible: true,
sort: [{key: 'transferadded', operator: '-'}],
unique: 'id'
})
.bindEvent({
select: function(data) {
$cancelButton.options({
disabled: data.ids.length == 0,
title: Ox._(
data.ids.length < 2
? 'Cancel Transfer...'
: 'Cancel Transfers...'
)
});
}
}),
columnsVisible: true,
items: function(data, callback) {
Ox.Request.clearCache('find'); // FIXME: not ideal - and doesn't work
oml.api.find(Ox.extend(data, {
query: {
conditions: [{
key: 'mediastate',
operator: '==',
value: 'transferring'
}],
operator: '&'
}
}), callback);
},
keys: ['author'],
scrollbarVisible: true,
sort: [{key: 'transferadded', operator: '-'}],
unique: 'id'
}),
$item = Ox.Element(),
$cancelButton = Ox.Button({
disabled: true,
style: 'squared',
title: 'Cancel Transfer...',
title: Ox._('Cancel Transfer...'),
width: 128
})
.css({
@ -61,9 +74,8 @@ oml.ui.transfersPanel = function() {
})
.bindEvent({
click: function() {
var ids = $list.options('selected');
ids && ids.length && oml.api.cancelDownloads({
ids: ids
oml.api.cancelDownloads({
ids: $list.options('selected')
}, function() {
$list.reloadList(true);
});