pandora/static/js/mediaExistsDialog.js

88 lines
2.8 KiB
JavaScript
Raw Permalink Normal View History

2016-09-15 15:20:24 +00:00
'use strict';
pandora.ui.mediaExistsDialog = function(options) {
var title = options.media.length == 1 ? 'File Exists' : 'Files Exist';
var $content = Ox.Element().addClass('OxText').css({
margin: '16px',
overflow: 'auto'
}).html(
'<p>' + (
options.media.length == 1 && options.items.length == 1
? Ox._('The video file already exists:')
: options.media.length == options.items.length
? Ox._(
'All {0} video files already exist:',
[options.media.length]
)
: Ox._(
'{0} of the {1} video files already exist:',
[options.media.length, options.items.length])
) + '</p>' + options.media.map(function(media) {
return media[options.action == 'upload' ? 'name' : 'title']
+ ': <a href="/' + media.itemID + '" target="_blank">'
+ media.itemTitle + '</a>';
}).join('<br/>')
)
var $buttons = options.media.length == options.items.length ? [
Ox.Button({
id: 'close',
title: Ox._('Close')
}).bindEvent({
click: function() {
that.close();
}
})
] : [
Ox.Button({
id: 'cancel',
title: Ox._('Don\'t {0}', [Ox.toTitleCase(options.action)])
}).bindEvent({
click: function() {
that.close();
}
}),
Ox.Button({
id: 'continue',
title: Ox._(Ox.toTitleCase(options.action)) + ' '
+ (options.items.length - options.media.length) + ' '
+ Ox._(options.items.length - options.media.length == 1 ? 'File' : 'Files')
}).bindEvent({
click: function() {
var existing = options.media.map(function(item) {
return item.id;
}),
items = options.items.filter(function(item) {
return existing.indexOf(item.oshash) == -1;
});
2016-09-19 18:36:14 +00:00
that.close();
2020-09-11 12:07:08 +00:00
(pandora.user.ui.item ? pandora.api.get : Ox.noop)({
id: pandora.user.ui.item,
keys: ['editable']
}, function(result) {
pandora.ui.addFilesDialog({
action: options.action,
items: items,
editable: pandora.user.ui.item && result.data.editable
}).open();
})
2016-09-15 15:20:24 +00:00
}
})
];
var that = Ox.Dialog({
buttons: $buttons,
closeButton: true,
content: $content,
height: 256,
removeOnClose: true,
title: title,
width: 512,
});
return that;
};