forked from 0x2620/pandora
typo in length check, fix cancel button before stating upload
This commit is contained in:
parent
f11772b8db
commit
4deb4daad3
1 changed files with 41 additions and 27 deletions
|
@ -8,6 +8,7 @@ pandora.ui.uploadVideoDialog = function(data) {
|
||||||
hasFirefogg = !(Ox.isUndefined(window.Firefogg)) && (
|
hasFirefogg = !(Ox.isUndefined(window.Firefogg)) && (
|
||||||
$.browser.version < '35' || Firefogg().version >= 334
|
$.browser.version < '35' || Firefogg().version >= 334
|
||||||
),
|
),
|
||||||
|
infoContent = Ox._('Please select the video file that you want to upload.'),
|
||||||
itemView = pandora.site.capabilities.canSeeExtraItemViews[
|
itemView = pandora.site.capabilities.canSeeExtraItemViews[
|
||||||
pandora.user.level
|
pandora.user.level
|
||||||
] ? 'media' : 'info',
|
] ? 'media' : 'info',
|
||||||
|
@ -17,7 +18,7 @@ pandora.ui.uploadVideoDialog = function(data) {
|
||||||
$content = Ox.Element().css({margin: '16px'}),
|
$content = Ox.Element().css({margin: '16px'}),
|
||||||
$info = $('<div>')
|
$info = $('<div>')
|
||||||
.css({padding: '4px'})
|
.css({padding: '4px'})
|
||||||
.html(Ox._('Please select the video file that you want to upload.')),
|
.html(infoContent),
|
||||||
$progress,
|
$progress,
|
||||||
$status = $('<div>').css({padding: '4px', paddingTop: '8px'}),
|
$status = $('<div>').css({padding: '4px', paddingTop: '8px'}),
|
||||||
that = Ox.Dialog({
|
that = Ox.Dialog({
|
||||||
|
@ -31,38 +32,25 @@ pandora.ui.uploadVideoDialog = function(data) {
|
||||||
click: function() {
|
click: function() {
|
||||||
if ($closeButton.options('title') == Ox._('Cancel')) {
|
if ($closeButton.options('title') == Ox._('Cancel')) {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
|
$info.html(infoContent);
|
||||||
|
$status.html('');
|
||||||
pandora.firefogg && pandora.firefogg.cancel();
|
pandora.firefogg && pandora.firefogg.cancel();
|
||||||
pandora.$ui.upload && pandora.$ui.upload.abort();
|
pandora.$ui.upload && pandora.$ui.upload.abort();
|
||||||
$closeButton.options('title', Ox._('Close'));
|
$closeButton.options('title', Ox._('Close'));
|
||||||
|
if ($actionButton.options('title') == Ox._('Upload')) {
|
||||||
|
$closeButton.options('title', Ox._('Close'));
|
||||||
|
$actionButton.replaceWith($actionButton = hasFirefogg
|
||||||
|
? getFirefoggButton()
|
||||||
|
: getSelectVideoButton()
|
||||||
|
);
|
||||||
|
}
|
||||||
$actionButton.show();
|
$actionButton.show();
|
||||||
} else {
|
} else {
|
||||||
that.triggerEvent('close');
|
that.triggerEvent('close');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
$actionButton = hasFirefogg ?
|
$actionButton = hasFirefogg ? getFirefoggButton() : getSelectVideoButton()
|
||||||
Ox.Button({
|
|
||||||
id: 'action',
|
|
||||||
title: Ox._('Select Video')
|
|
||||||
}).bindEvent({
|
|
||||||
click: function() {
|
|
||||||
if ($actionButton.options('title') == Ox._('Select Video')) {
|
|
||||||
if (selectVideo()) {
|
|
||||||
$actionButton.options('title', Ox._('Upload'));
|
|
||||||
}
|
|
||||||
} else if ($actionButton.options('title') == Ox._('Cancel')) {
|
|
||||||
cancelled = true;
|
|
||||||
pandora.firefogg && pandora.firefogg.cancel();
|
|
||||||
pandora.$ui.upload && pandora.$ui.upload.abort();
|
|
||||||
$actionButton.options('title', Ox._('Select Video'));
|
|
||||||
$closeButton.show();
|
|
||||||
} else {
|
|
||||||
$closeButton.options('title', Ox._('Cancel'));
|
|
||||||
$actionButton.hide().options('title', Ox._('Select Video'));
|
|
||||||
encode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) : getSelectVideoButton()
|
|
||||||
],
|
],
|
||||||
content: $content,
|
content: $content,
|
||||||
height: 128,
|
height: 128,
|
||||||
|
@ -211,7 +199,7 @@ pandora.ui.uploadVideoDialog = function(data) {
|
||||||
var format = pandora.site.video.formats[0],
|
var format = pandora.site.video.formats[0],
|
||||||
resolution = getResolution(info);
|
resolution = getResolution(info);
|
||||||
info.direct = Ox.endsWith(info.name, format)
|
info.direct = Ox.endsWith(info.name, format)
|
||||||
&& info.video.lengh > 0
|
&& info.video.length > 0
|
||||||
&& info.video[0].height <= resolution;
|
&& info.video[0].height <= resolution;
|
||||||
callback(info);
|
callback(info);
|
||||||
});
|
});
|
||||||
|
@ -230,6 +218,32 @@ pandora.ui.uploadVideoDialog = function(data) {
|
||||||
return resolution;
|
return resolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getFirefoggButton() {
|
||||||
|
return Ox.Button({
|
||||||
|
id: 'action',
|
||||||
|
title: Ox._('Select Video')
|
||||||
|
}).bindEvent({
|
||||||
|
click: function() {
|
||||||
|
if ($actionButton.options('title') == Ox._('Select Video')) {
|
||||||
|
if (selectVideo()) {
|
||||||
|
$closeButton.options('title', Ox._('Cancel'));
|
||||||
|
$actionButton.options('title', Ox._('Upload'));
|
||||||
|
}
|
||||||
|
} else if ($actionButton.options('title') == Ox._('Cancel')) {
|
||||||
|
cancelled = true;
|
||||||
|
pandora.firefogg && pandora.firefogg.cancel();
|
||||||
|
pandora.$ui.upload && pandora.$ui.upload.abort();
|
||||||
|
$actionButton.options('title', Ox._('Select Video'));
|
||||||
|
$closeButton.show();
|
||||||
|
} else {
|
||||||
|
$closeButton.options('title', Ox._('Cancel'));
|
||||||
|
$actionButton.hide().options('title', Ox._('Select Video'));
|
||||||
|
encode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function getSelectVideoButton() {
|
function getSelectVideoButton() {
|
||||||
return Ox.FileButton({
|
return Ox.FileButton({
|
||||||
id: 'action',
|
id: 'action',
|
||||||
|
@ -264,10 +278,10 @@ pandora.ui.uploadVideoDialog = function(data) {
|
||||||
$status.html(
|
$status.html(
|
||||||
info.direct
|
info.direct
|
||||||
? Ox._(
|
? Ox._(
|
||||||
'Your video will be uploaded directly.'
|
'Your video will be used directly.'
|
||||||
)
|
)
|
||||||
: Ox._(
|
: Ox._(
|
||||||
'Your video will be transcoded before uploading.'
|
'Your video will be transcoded on the server.'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue