This commit is contained in:
rolux 2015-04-20 10:13:56 +02:00
parent 02552f3f83
commit c6c2a425cc
16 changed files with 224 additions and 73 deletions

View file

@ -18,7 +18,10 @@ pandora.ui.appearanceDialog = function() {
Ox.Select({ Ox.Select({
id: 'theme', id: 'theme',
items: pandora.site.themes.map(function(theme) { items: pandora.site.themes.map(function(theme) {
return {id: theme, title: Ox.Theme.getThemeData(theme).themeName} return {
id: theme,
title: Ox.Theme.getThemeData(theme).themeName
};
}), }),
label: Ox._('Theme'), label: Ox._('Theme'),
labelWidth: 120, labelWidth: 120,
@ -34,7 +37,10 @@ pandora.ui.appearanceDialog = function() {
Ox.Select({ Ox.Select({
id: 'locale', id: 'locale',
items: pandora.site.languages.map(function(locale) { items: pandora.site.languages.map(function(locale) {
return {id: locale, title: Ox.LOCALE_NAMES[locale]} return {
id: locale,
title: Ox.LOCALE_NAMES[locale]
};
}), }),
label: Ox._('Language'), label: Ox._('Language'),
labelWidth: 120, labelWidth: 120,

View file

@ -5,6 +5,7 @@
pandora.ui.deleteDocumentDialog = function(files, callback) { pandora.ui.deleteDocumentDialog = function(files, callback) {
var string = Ox._(files.length == 1 ? 'Document' : 'Documents'), var string = Ox._(files.length == 1 ? 'Document' : 'Documents'),
that = pandora.ui.iconDialog({ that = pandora.ui.iconDialog({
buttons: [ buttons: [
Ox.Button({ Ox.Button({

View file

@ -5,6 +5,7 @@
pandora.ui.deleteEntityDialog = function(entities, callback) { pandora.ui.deleteEntityDialog = function(entities, callback) {
var string = Ox._(entities.length == 1 ? 'Entity' : 'Entities'), var string = Ox._(entities.length == 1 ? 'Entity' : 'Entities'),
that = pandora.ui.iconDialog({ that = pandora.ui.iconDialog({
buttons: [ buttons: [
Ox.Button({ Ox.Button({

View file

@ -36,12 +36,16 @@ pandora.ui.deleteListDialog = function(list) {
.bindEventOnce({ .bindEventOnce({
load: function() { load: function() {
if (ui.section == 'items') { if (ui.section == 'items') {
pandora.UI.set('lists.' + listData.id, null); pandora.UI.set(
'lists.' + listData.id, null
);
pandora.UI.set({ pandora.UI.set({
find: pandora.site.user.ui.find find: pandora.site.user.ui.find
}); });
} else { } else {
pandora.UI.set(folderItem.toLowerCase(), ''); pandora.UI.set(
folderItem.toLowerCase(), ''
);
} }
} }
}) })
@ -50,8 +54,10 @@ pandora.ui.deleteListDialog = function(list) {
} }
}) })
], ],
content: Ox._('Are you sure you want to delete the {0} "{1}"?', content: Ox._(
[Ox._(folderItem.toLowerCase()), listData.name]), 'Are you sure you want to delete the {0} "{1}"?',
[Ox._(folderItem.toLowerCase()), listData.name]
),
keys: {enter: 'delete', escape: 'keep'}, keys: {enter: 'delete', escape: 'keep'},
title: Ox._('Delete {0}', [Ox._(folderItem)]) title: Ox._('Delete {0}', [Ox._(folderItem)])
}); });

View file

@ -9,7 +9,8 @@ pandora.ui.documentsDialog = function() {
// FIXME: user may not have the manage entites capability // FIXME: user may not have the manage entites capability
$switchButton = Ox.Button({ $switchButton = Ox.Button({
disabled: !pandora.site.entities.length || !pandora.site.capabilities.canManageEntities[pandora.user.level], disabled: !pandora.site.entities.length
|| !pandora.site.capabilities.canManageEntities[pandora.user.level],
title: Ox._('Manage Entities...') title: Ox._('Manage Entities...')
}) })
.bindEvent({ .bindEvent({

View file

@ -151,7 +151,9 @@ pandora.ui.importAnnotationsDialog = function(options) {
[annotations.length] [annotations.length]
)); ));
annotations = annotations.map(function(annotation) { annotations = annotations.map(function(annotation) {
var value = Ox.sanitizeHTML(annotation.text ? annotation.text : annotation.value); var value = Ox.sanitizeHTML(
annotation.text ? annotation.text : annotation.value
);
if (format == 'srt') { if (format == 'srt') {
value = value.replace(/<br[ /]*?>\n/g, '\n') value = value.replace(/<br[ /]*?>\n/g, '\n')
.replace(/\n\n/g, '<br>\n') .replace(/\n\n/g, '<br>\n')

View file

@ -56,9 +56,11 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
range: [0, 1], range: [0, 1],
sort: [{key: 'id', operator: '+'}], sort: [{key: 'id', operator: '+'}],
}, },
sites = [pandora.site.site].concat(pandora.site.sites).map(function(site) { sites = [pandora.site.site].concat(pandora.site.sites).map(
function(site) {
return {id: site.url, title: site.url, https: site.https}; return {id: site.url, title: site.url, https: site.https};
}); }
);
api.find(options, function(result) { api.find(options, function(result) {
@ -76,8 +78,16 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
return getForm(id); return getForm(id);
}, },
tabs: [ tabs: [
{id: 'basic', title: Ox._('Basic'), selected: !advanced}, {
{id: 'advanced', title: Ox._('Advanced'), selected: advanced} id: 'basic',
title: Ox._('Basic'),
selected: !advanced
},
{
id: 'advanced',
title: Ox._('Advanced'),
selected: advanced
}
] ]
}); });
} else { } else {
@ -124,8 +134,15 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
$input.protocol = Ox.Select({ $input.protocol = Ox.Select({
items: [ items: [
{id: 'http', title: 'http'}, {
{id: 'https', title: 'https', disabled: !pandora.site.site.https} id: 'http',
title: 'http'
},
{
id: 'https',
title: 'https',
disabled: !pandora.site.site.https
}
], ],
label: Ox._('Protocol'), label: Ox._('Protocol'),
labelWidth: 128, labelWidth: 128,
@ -141,7 +158,9 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
$input.site = Ox.SelectInput({ $input.site = Ox.SelectInput({
inputWidth: 128, inputWidth: 128,
items: sites.concat([{id: 'other', title: Ox._('Other...')}]), items: sites.concat(
[{id: 'other', title: Ox._('Other...')}]
),
label: Ox._('Site'), label: Ox._('Site'),
labelWidth: 128, labelWidth: 128,
placeholder: 'example.com', placeholder: 'example.com',
@ -155,9 +174,11 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
if (data.value) { if (data.value) {
var site = Ox.getObjectById(sites, data.value); var site = Ox.getObjectById(sites, data.value);
$input.protocol[ $input.protocol[
!site || site.https ? 'enableItem' : 'disableItem' !site || site.https
? 'enableItem' : 'disableItem'
]('https').options({ ]('https').options({
value: !site || !site.https ? 'http' : 'https' value: !site || !site.https
? 'http' : 'https'
}); });
updateAPI(data.value, formatURL); updateAPI(data.value, formatURL);
} }
@ -225,8 +246,10 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
$input.position.options({ $input.position.options({
value: limitPoint( value: limitPoint(
data.value, data.value,
hasInAndOut ? $input['in'].options('value') : 0, hasInAndOut
hasInAndOut ? $input.out.options('value') : duration ? $input['in'].options('value') : 0,
hasInAndOut
? $input.out.options('value') : duration
) )
}); });
} }
@ -250,7 +273,9 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
value: limitPoint(data.value, 0, duration) value: limitPoint(data.value, 0, duration)
}); });
if ($input.out.options('value') === '') { if ($input.out.options('value') === '') {
$input.out.options({value: Ox.formatDuration(duration)}); $input.out.options({
value: Ox.formatDuration(duration)
});
} else if ( } else if (
Ox.parseDuration($input.out.options('value')) Ox.parseDuration($input.out.options('value'))
< Ox.parseDuration(data.value) < Ox.parseDuration(data.value)
@ -278,7 +303,9 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
value: limitPoint(data.value, 0, duration) value: limitPoint(data.value, 0, duration)
}); });
if ($input['in'].options('value') === '') { if ($input['in'].options('value') === '') {
$input['in'].options({value: Ox.formatDuration(0)}); $input['in'].options({
value: Ox.formatDuration(0)
});
} else if ( } else if (
Ox.parseDuration($input['in'].options('value')) Ox.parseDuration($input['in'].options('value'))
> Ox.parseDuration(data.value) > Ox.parseDuration(data.value)
@ -418,9 +445,11 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
options = Ox.serialize({ options = Ox.serialize({
title: data.title || void 0, title: data.title || void 0,
showTimeline: data.showTimeline || void 0, showTimeline: data.showTimeline || void 0,
timeline: data.timeline && data.timeline != 'default' ? data.timeline : void 0, timeline: data.timeline && data.timeline != 'default'
? data.timeline : void 0,
showAnnotations: data.showAnnotations || void 0, showAnnotations: data.showAnnotations || void 0,
showLayers: data.showAnnotations && data.showLayers ? data.showLayers : void 0, showLayers: data.showAnnotations && data.showLayers
? data.showLayers : void 0,
//matchRatio: true //matchRatio: true
}, true) }, true)
.replace(/_/g, '%09').replace(/\s/g, '_') .replace(/_/g, '%09').replace(/\s/g, '_')
@ -472,7 +501,10 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
query[condition.key] = condition.value; query[condition.key] = condition.value;
}); });
} }
(isSameItem ? Ox.noop : api.get)({id: id, keys: ['duration']}, function(result) { (isSameItem ? Ox.noop : api.get)({
id: id,
keys: ['duration']
}, function(result) {
if (result && result.data) { if (result && result.data) {
duration = result.data.duration; duration = result.data.duration;
item = id; item = id;
@ -494,7 +526,8 @@ pandora.ui.insertEmbedDialog = function(/*[url, ]callback*/) {
showTimeline: query.showTimeline || false, showTimeline: query.showTimeline || false,
timeline: query.timeline || 'default', timeline: query.timeline || 'default',
showAnnotations: query.showAnnotations || false, showAnnotations: query.showAnnotations || false,
showLayers: query.showLayers || pandora.site.layers.map(function(layer) { showLayers: query.showLayers
|| pandora.site.layers.map(function(layer) {
return layer.id; return layer.id;
}) })
}, function(value, key) { }, function(value, key) {

View file

@ -27,11 +27,17 @@ pandora.ui.makeListPrivateDialog = function(name, subscribers, callback) {
} }
}) })
], ],
content: Ox._('Are you sure you want to make the {0} "{1}" private and lose its {2}?', [ content: Ox._(
'Are you sure you want to make the {0} "{1}" private'
+ ' and lose its {2}?',
[
folderItem.toLowerCase(), folderItem.toLowerCase(),
name, name,
subscribers == 1 ? Ox._('subscriber') : Ox._('{0} subscribers', [subscribers]) subscribers == 1
]), ? Ox._('subscriber')
: Ox._('{0} subscribers', [subscribers])
]
),
keys: {enter: 'make', escape: 'keep'}, keys: {enter: 'make', escape: 'keep'},
title: Ox._('Make {0} Private', [folderItem]) title: Ox._('Make {0} Private', [folderItem])
}); });

View file

@ -166,7 +166,10 @@ pandora.ui.metadataDialog = function(data) {
} }
function getMetadata() { function getMetadata() {
pandora.api.getMetadata({id: data.imdbId, keys: keys.concat(['originalTitle'])}, function(result) { pandora.api.getMetadata({
id: data.imdbId,
keys: keys.concat(['originalTitle'])
}, function(result) {
var $bar = Ox.Bar({size: 24}), var $bar = Ox.Bar({size: 24}),
$data = Ox.Element() $data = Ox.Element()
.css({padding: '13px', overflowY: 'auto'}), .css({padding: '13px', overflowY: 'auto'}),
@ -219,7 +222,10 @@ pandora.ui.metadataDialog = function(data) {
title: getTitle(key), title: getTitle(key),
width: formWidth width: formWidth
}) })
.css({display: 'inline-block', margin: '3px 3px 5px 3px'}) .css({
display: 'inline-block',
margin: '3px 3px 5px 3px'
})
.appendTo($data); .appendTo($data);
$input[key] = [data[key], imdb[key]].map(function(v, i) { $input[key] = [data[key], imdb[key]].map(function(v, i) {
return Ox.InputGroup({ return Ox.InputGroup({
@ -251,7 +257,10 @@ pandora.ui.metadataDialog = function(data) {
}) })
], ],
separators: [ separators: [
{title: [Ox._('Current'), Ox._('Update')][i], width: 64} {
title: [Ox._('Current'), Ox._('Update')][i],
width: 64
}
] ]
}) })
.css({display: 'inline-block', margin: '3px'}) .css({display: 'inline-block', margin: '3px'})

View file

@ -18,8 +18,16 @@ pandora.ui.namesDialog = function() {
change: function(data) { change: function(data) {
var query = { var query = {
conditions: [ conditions: [
{key: 'name', value: data.value, operator: '='}, {
{key: 'sortname', value: data.value, operator: '='} key: 'name',
operator: '=',
value: data.value
},
{
key: 'sortname',
operator: '=',
value: data.value
}
], ],
operator: '|' operator: '|'
}; };
@ -103,7 +111,9 @@ pandora.ui.namesDialog = function() {
pandora.UI.set({find: { pandora.UI.set({find: {
conditions: [{ conditions: [{
key: 'name', key: 'name',
value: $list.value($list.options('selected'), 'name'), value: $list.value(
$list.options('selected'), 'name'
),
operator: '=' operator: '='
}], }],
operator: '&' operator: '&'
@ -188,4 +198,3 @@ pandora.ui.namesDialog = function() {
return that; return that;
}; };

View file

@ -8,7 +8,9 @@ pandora.ui.preferencesDialog = function() {
{id: 'appearance', title: Ox._('Appearance')}, {id: 'appearance', title: Ox._('Appearance')},
{id: 'advanced', title: Ox._('Advanced')} {id: 'advanced', title: Ox._('Advanced')}
]; ];
Ox.getObjectById(tabs, pandora.user.ui.part.preferences || 'account').selected = true; Ox.getObjectById(
tabs, pandora.user.ui.part.preferences || 'account'
).selected = true;
var $tabPanel = Ox.TabPanel({ var $tabPanel = Ox.TabPanel({
content: function(id) { content: function(id) {
var $content = Ox.Element() var $content = Ox.Element()
@ -91,7 +93,9 @@ pandora.ui.preferencesDialog = function() {
id: 'newsletter', id: 'newsletter',
label: Ox._('Newsletter'), label: Ox._('Newsletter'),
labelWidth: 120, labelWidth: 120,
title: pandora.user.newsletter ? Ox._('Subscribed') : Ox._('Unsubscribed'), title: pandora.user.newsletter
? Ox._('Subscribed')
: Ox._('Unsubscribed'),
value: pandora.user.newsletter, value: pandora.user.newsletter,
width: 320 width: 320
}) })
@ -99,7 +103,9 @@ pandora.ui.preferencesDialog = function() {
change: function(data) { change: function(data) {
pandora.user.newsletter = data.value; pandora.user.newsletter = data.value;
this.options({ this.options({
title: pandora.user.newsletter ? Ox._('Subscribed') : Ox._('Unsubscribed') title: pandora.user.newsletter
? Ox._('Subscribed')
: Ox._('Unsubscribed')
}); });
pandora.api.editPreferences({ pandora.api.editPreferences({
newsletter: pandora.user.newsletter newsletter: pandora.user.newsletter
@ -118,7 +124,10 @@ pandora.ui.preferencesDialog = function() {
Ox.Select({ Ox.Select({
id: 'theme', id: 'theme',
items: pandora.site.themes.map(function(theme) { items: pandora.site.themes.map(function(theme) {
return {id: theme, title: Ox.Theme.getThemeData(theme).themeName} return {
id: theme,
title: Ox.Theme.getThemeData(theme).themeName
};
}), }),
label: Ox._('Theme'), label: Ox._('Theme'),
labelWidth: 120, labelWidth: 120,
@ -134,7 +143,10 @@ pandora.ui.preferencesDialog = function() {
Ox.Select({ Ox.Select({
id: 'locale', id: 'locale',
items: pandora.site.languages.map(function(locale) { items: pandora.site.languages.map(function(locale) {
return {id: locale, title: Ox.LOCALE_NAMES[locale]} return {
id: locale,
title: Ox.LOCALE_NAMES[locale]
};
}), }),
label: Ox._('Language'), label: Ox._('Language'),
labelWidth: 120, labelWidth: 120,
@ -238,7 +250,9 @@ pandora.ui.preferencesDialog = function() {
}, },
'pandora_part.preferences': function(data) { 'pandora_part.preferences': function(data) {
if (pandora.user.ui.page == 'preferences') { if (pandora.user.ui.page == 'preferences') {
$tabPanel.select(data.value == '' ? 'account' : data.value); $tabPanel.select(
data.value == '' ? 'account' : data.value
);
} }
} }
}); });

View file

@ -9,6 +9,7 @@ pandora.ui.previewDialog = function() {
? pandora.site.posters.ratio ? pandora.site.posters.ratio
: ($list.value(item, 'posterRatio') || pandora.site.posters.ratio), : ($list.value(item, 'posterRatio') || pandora.site.posters.ratio),
size = getSize(posterRatio), size = getSize(posterRatio),
that = Ox.Dialog({ that = Ox.Dialog({
closeButton: true, closeButton: true,
content: Ox.Element(), content: Ox.Element(),
@ -58,7 +59,9 @@ pandora.ui.previewDialog = function() {
that.update = function() { that.update = function() {
pandora.requests.preview && pandora.api.cancel(pandora.requests.preview); pandora.requests.preview && pandora.api.cancel(pandora.requests.preview);
pandora.requests.preview = pandora.api.find({ pandora.requests.preview = pandora.api.find({
keys: ['id', 'modified', 'posterRatio'].concat(pandora.site.itemTitleKeys), keys: [
'id', 'modified', 'posterRatio'
].concat(pandora.site.itemTitleKeys),
query: { query: {
conditions: [{ conditions: [{
key: 'id', key: 'id',

View file

@ -16,8 +16,16 @@ pandora.ui.titlesDialog = function() {
change: function(data) { change: function(data) {
var query = { var query = {
conditions: [ conditions: [
{key: 'title', value: data.value, operator: '='}, {
{key: 'sorttitle', value: data.value, operator: '='} key: 'title',
operator: '=',
value: data.value
},
{
key: 'sorttitle',
operator: '=',
value: data.value
}
], ],
operator: '|' operator: '|'
}; };
@ -92,7 +100,9 @@ pandora.ui.titlesDialog = function() {
pandora.UI.set({find: { pandora.UI.set({find: {
conditions: [{ conditions: [{
key: 'title', key: 'title',
value: $list.value($list.options('selected'), 'title'), value: $list.value(
$list.options('selected'), 'title'
),
operator: '=' operator: '='
}], }],
operator: '&' operator: '&'

View file

@ -70,7 +70,9 @@ pandora.ui.uploadDocumentDialog = function(files, callback) {
if (!Ox.every(extensions, function(extension) { if (!Ox.every(extensions, function(extension) {
return Ox.contains(supportedExtensions, extension) return Ox.contains(supportedExtensions, extension)
})) { })) {
return errorDialog(Ox._('Supported file types are GIF, JPG, PNG and PDF.')); return errorDialog(
Ox._('Supported file types are GIF, JPG, PNG and PDF.')
);
} else { } else {
var valid = true; var valid = true;
Ox.parallelForEach(files, function(file, index, array, callback) { Ox.parallelForEach(files, function(file, index, array, callback) {
@ -81,18 +83,29 @@ pandora.ui.uploadDocumentDialog = function(files, callback) {
pandora.api.findDocuments({ pandora.api.findDocuments({
keys: ['id', 'user', 'name', 'extension'], keys: ['id', 'user', 'name', 'extension'],
query: { query: {
conditions: [{key: 'oshash', value: oshash, operator: '=='}], conditions: [{
key: 'oshash',
operator: '==',
value: oshash
}],
operator: '&' operator: '&'
}, },
range: [0, 1], range: [0, 1],
sort: [{key: 'name', operator: '+'}] sort: [{key: 'name', operator: '+'}]
}, function(result) { }, function(result) {
if (result.data.items.length) { if (result.data.items.length) {
var id = result.data.items[0].name + '.' + result.data.items[0].extension; var id = result.data.items[0].name + '.'
+ result.data.items[0].extension;
valid && errorDialog( valid && errorDialog(
filename == id filename == id
? Ox._('The file "{0}" already exists.', [filename]) ? Ox._(
: Ox._('The file "{0}" already exists as "{1}".', [filename, id]) 'The file "{0}" already exists.',
[filename]
)
: Ox._(
'The file "{0}" already exists as "{1}".',
[filename, id]
)
).open(); ).open();
valid = false; valid = false;
} }
@ -151,7 +164,9 @@ pandora.ui.uploadDocumentDialog = function(files, callback) {
} }
} else { } else {
$message.html(Ox._('Upload failed.')) $message.html(Ox._('Upload failed.'))
$uploadDialog.options('buttons')[0].options({title: Ox._('Close')}); $uploadDialog.options('buttons')[0].options({
title: Ox._('Close')
});
} }
}, },
progress: function(data) { progress: function(data) {

View file

@ -76,7 +76,9 @@ pandora.ui.uploadPDFDialog = function(options) {
done: function(data) { done: function(data) {
if (data.progress == 1) { if (data.progress == 1) {
Ox.Request.clearCache(); Ox.Request.clearCache();
pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.textPanel = pandora.ui.textPanel()); pandora.$ui.mainPanel.replaceElement(
1, pandora.$ui.textPanel = pandora.ui.textPanel()
);
that.close(); that.close();
} else { } else {
$content.html("failed: " + data.responseText); $content.html("failed: " + data.responseText);

View file

@ -8,8 +8,9 @@ pandora.ui.uploadVideoDialog = function(data) {
hasFirefogg = !(Ox.isUndefined(Firefogg)) && ( hasFirefogg = !(Ox.isUndefined(Firefogg)) && (
$.browser.version < '35' || Firefogg().version >= 334 $.browser.version < '35' || Firefogg().version >= 334
), ),
itemView = pandora.site.capabilities.canSeeExtraItemViews[pandora.user.level] itemView = pandora.site.capabilities.canSeeExtraItemViews[
? 'media' : 'info', pandora.user.level
] ? 'media' : 'info',
selectFile, selectFile,
$actionButton, $actionButton,
$closeButton, $closeButton,
@ -84,14 +85,20 @@ pandora.ui.uploadVideoDialog = function(data) {
disabled: false disabled: false
}).bindEvent({ }).bindEvent({
click: function() { click: function() {
info.direct ? directUpload(data.files[0], info) : upload(data.files[0]); info.direct
? directUpload(data.files[0], info)
: upload(data.files[0]);
} }
}); });
$info.html(formatVideoInfo(info)); $info.html(formatVideoInfo(info));
$status.html( $status.html(
info.direct info.direct
? Ox._('Your video will be uploaded directly.') ? Ox._(
: Ox._('Your video will be transcoded before uploading.') 'Your video will be uploaded directly.'
)
: Ox._(
'Your video will be transcoded before uploading.'
)
); );
}); });
//$closeButton.options('title', Ox._('Cancel')); //$closeButton.options('title', Ox._('Cancel'));
@ -164,7 +171,9 @@ pandora.ui.uploadVideoDialog = function(data) {
pandora.api.addMedia({ pandora.api.addMedia({
filename: info.name, filename: info.name,
id: info.oshash, id: info.oshash,
item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item item: pandora.site.itemRequiresVideo
? undefined
: pandora.user.ui.item
}, function(result) { }, function(result) {
uploadStream(result.data.item, info, file); uploadStream(result.data.item, info, file);
}); });
@ -181,7 +190,9 @@ pandora.ui.uploadVideoDialog = function(data) {
filename: filename, filename: filename,
id: oshash, id: oshash,
info: info, info: info,
item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item item: pandora.site.itemRequiresVideo
? undefined
: pandora.user.ui.item
}, function(result) { }, function(result) {
item = result.data.item; item = result.data.item;
pandora.firefogg.encode( pandora.firefogg.encode(
@ -189,12 +200,19 @@ pandora.ui.uploadVideoDialog = function(data) {
function(result, file) { function(result, file) {
result = JSON.parse(result); result = JSON.parse(result);
if (result.progress != 1) { if (result.progress != 1) {
$status.html(cancelled ? Ox._('Encoding cancelled.') : Ox._('Encoding failed.')); $status.html(
cancelled
? Ox._('Encoding cancelled.')
: Ox._('Encoding failed.')
);
delete pandora.firefogg; delete pandora.firefogg;
return; return;
} }
setTimeout(function() { setTimeout(function() {
$info.html('<b>' + filename + '</b><br>' + Ox._('uploading...')); $info.html(
'<b>' + filename + '</b><br>'
+ Ox._('uploading...')
);
uploadStream(item, info, file); uploadStream(item, info, file);
}); });
}, },
@ -260,13 +278,17 @@ pandora.ui.uploadVideoDialog = function(data) {
resolution = getResolution(info); resolution = getResolution(info);
pandora.$ui.upload = pandora.chunkupload({ pandora.$ui.upload = pandora.chunkupload({
file: file, file: file,
url: '/api/upload/?profile=' + resolution + 'p.' + format + '&id=' + oshash, url: '/api/upload/?profile=' + resolution + 'p.'
+ format + '&id=' + oshash,
data: {} data: {}
}).bindEvent({ }).bindEvent({
done: function(data) { done: function(data) {
if (data.progress == 1) { if (data.progress == 1) {
Ox.Request.clearCache(); Ox.Request.clearCache();
if (pandora.user.ui.item == item && pandora.user.ui.itemView == itemView) { if (
pandora.user.ui.item == item
&& pandora.user.ui.itemView == itemView
) {
pandora.$ui.item.reload(); pandora.$ui.item.reload();
} else { } else {
pandora.UI.set({ pandora.UI.set({
@ -308,7 +330,9 @@ pandora.ui.uploadVideoDialog = function(data) {
pandora.api.addMedia({ pandora.api.addMedia({
filename: file.name, filename: file.name,
id: oshash, id: oshash,
item: pandora.site.itemRequiresVideo ? undefined : pandora.user.ui.item item: pandora.site.itemRequiresVideo
? undefined
: pandora.user.ui.item
}, function(result) { }, function(result) {
var item = result.data.item; var item = result.data.item;
pandora.$ui.upload = pandora.chunkupload({ pandora.$ui.upload = pandora.chunkupload({
@ -321,7 +345,10 @@ pandora.ui.uploadVideoDialog = function(data) {
done: function(data) { done: function(data) {
if (data.progress == 1) { if (data.progress == 1) {
Ox.Request.clearCache(); Ox.Request.clearCache();
if (pandora.user.ui.item == item && pandora.user.ui.itemView == itemView) { if (
pandora.user.ui.item == item
&& pandora.user.ui.itemView == itemView
) {
pandora.$ui.item.reload(); pandora.$ui.item.reload();
} else { } else {
pandora.UI.set({ pandora.UI.set({
@ -331,7 +358,11 @@ pandora.ui.uploadVideoDialog = function(data) {
} }
that.close(); that.close();
} else { } else {
$status.html(cancelled ? Ox._('Upload cancelled.') : Ox._('Upload failed.')); $status.html(
cancelled
? Ox._('Upload cancelled.')
: Ox._('Upload failed.')
);
!cancelled && pandora.api.logError({ !cancelled && pandora.api.logError({
text: data.responseText, text: data.responseText,
url: '/' + item, url: '/' + item,
@ -340,7 +371,9 @@ pandora.ui.uploadVideoDialog = function(data) {
} }
}, },
progress: function(data) { progress: function(data) {
$progress.options({progress: data.progress || 0}); $progress.options({
progress: data.progress || 0
});
} }
}); });
}); });