pandora/static/js/deleteDocumentDialog.js

47 lines
1.6 KiB
JavaScript

'use strict';
pandora.ui.deleteDocumentDialog = function(files, callback) {
var string = Ox._(files.length == 1 ? 'Document' : 'Documents'),
$content = Ox.Element().html(
files.length == 1
? Ox._('Are you sure you want to delete the document "{0}"?', [files[0].title + '.' + files[0].extension])
: Ox._('Are you sure you want to delete {0} documents?', [files.length])
).css({
overflow: 'hidden',
}),
that = pandora.ui.iconDialog({
buttons: [
Ox.Button({
id: 'keep',
title: Ox._('Keep {0}', [string])
}).bindEvent({
click: function() {
that.close();
}
}),
Ox.Button({
id: 'delete',
title: Ox._('Delete {0}', [string])
}).bindEvent({
click: function() {
that.close();
pandora.api.removeDocument({
ids: files.map(function(file) {
return file.id;
})
}, callback);
}
})
],
content: $content,
keys: {enter: 'delete', escape: 'keep'},
title: files.length == 1
? Ox._('Delete {0}', [string])
: Ox._('Delete {0} Documents', [files.length])
});
return that;
};