From 4deb4daad3741b96d1d4c0fdf2732253eb323c7f Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 19 May 2015 23:10:30 +0200 Subject: [PATCH] typo in length check, fix cancel button before stating upload --- static/js/uploadVideoDialog.js | 68 ++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/static/js/uploadVideoDialog.js b/static/js/uploadVideoDialog.js index 2f09e748..f92c0832 100644 --- a/static/js/uploadVideoDialog.js +++ b/static/js/uploadVideoDialog.js @@ -8,6 +8,7 @@ pandora.ui.uploadVideoDialog = function(data) { hasFirefogg = !(Ox.isUndefined(window.Firefogg)) && ( $.browser.version < '35' || Firefogg().version >= 334 ), + infoContent = Ox._('Please select the video file that you want to upload.'), itemView = pandora.site.capabilities.canSeeExtraItemViews[ pandora.user.level ] ? 'media' : 'info', @@ -17,7 +18,7 @@ pandora.ui.uploadVideoDialog = function(data) { $content = Ox.Element().css({margin: '16px'}), $info = $('
') .css({padding: '4px'}) - .html(Ox._('Please select the video file that you want to upload.')), + .html(infoContent), $progress, $status = $('
').css({padding: '4px', paddingTop: '8px'}), that = Ox.Dialog({ @@ -31,38 +32,25 @@ pandora.ui.uploadVideoDialog = function(data) { click: function() { if ($closeButton.options('title') == Ox._('Cancel')) { cancelled = true; + $info.html(infoContent); + $status.html(''); pandora.firefogg && pandora.firefogg.cancel(); pandora.$ui.upload && pandora.$ui.upload.abort(); $closeButton.options('title', Ox._('Close')); + if ($actionButton.options('title') == Ox._('Upload')) { + $closeButton.options('title', Ox._('Close')); + $actionButton.replaceWith($actionButton = hasFirefogg + ? getFirefoggButton() + : getSelectVideoButton() + ); + } $actionButton.show(); } else { that.triggerEvent('close'); } } }), - $actionButton = hasFirefogg ? - 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() + $actionButton = hasFirefogg ? getFirefoggButton() : getSelectVideoButton() ], content: $content, height: 128, @@ -211,7 +199,7 @@ pandora.ui.uploadVideoDialog = function(data) { var format = pandora.site.video.formats[0], resolution = getResolution(info); info.direct = Ox.endsWith(info.name, format) - && info.video.lengh > 0 + && info.video.length > 0 && info.video[0].height <= resolution; callback(info); }); @@ -230,6 +218,32 @@ pandora.ui.uploadVideoDialog = function(data) { 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() { return Ox.FileButton({ id: 'action', @@ -264,10 +278,10 @@ pandora.ui.uploadVideoDialog = function(data) { $status.html( info.direct ? Ox._( - 'Your video will be uploaded directly.' + 'Your video will be used directly.' ) : Ox._( - 'Your video will be transcoded before uploading.' + 'Your video will be transcoded on the server.' ) ); });