From 665930885e02e9c87bc7b03c966a7a3877ae788f Mon Sep 17 00:00:00 2001 From: rolux Date: Sun, 24 Mar 2013 15:15:09 +0530 Subject: [PATCH] update uploadFileDialog --- static/js/pandora/uploadFileDialog.js | 71 +++++++-------------------- 1 file changed, 19 insertions(+), 52 deletions(-) diff --git a/static/js/pandora/uploadFileDialog.js b/static/js/pandora/uploadFileDialog.js index f4a0bb66..86fe2eba 100644 --- a/static/js/pandora/uploadFileDialog.js +++ b/static/js/pandora/uploadFileDialog.js @@ -5,12 +5,26 @@ pandora.ui.uploadFileDialog = function(file, callback) { var extension = file.name.split('.').pop().toLowerCase(), - extensions = ['jpg', 'jpeg', 'pdf', 'png'], - - jpg = false, + extensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png'], upload, + $errorDialog = pandora.iconDialog({ + buttons: [ + Ox.Button({ + id: 'close', + title: 'Close' + }) + .bindEvent({ + click: function() { + $extensionDialog.close(); + } + }) + ], + title: 'Upload File', + text: 'Supported file types are GIF, JPG, PNG and PDF.' + }), + $content = Ox.Element(), $text = $('
') @@ -24,51 +38,6 @@ pandora.ui.uploadFileDialog = function(file, callback) { }) .appendTo($content), - $extensionDialog = pandora.iconDialog({ - buttons: [ - Ox.Button({ - id: 'close', - title: 'Close' - }) - .bindEvent({ - click: function() { - $extensionDialog.close(); - } - }) - ], - title: 'Upload File', - text: 'Supported file types are JPG, PNG and PDF.' - }), - - $imageDialog = pandora.iconDialog({ - buttons: [ - Ox.Button({ - id: 'png', - title: 'Keep as PNG', - }) - .bindEvent({ - click: function() { - $imageDialog.close(); - $uploadDialog.open(); - } - }), - Ox.Button({ - id: 'jpg' - title: 'Encode as JPG' - }) - .bindEvent({ - click: function() { - jpg = true; - $imageDialog.close(); - $uploadDialog.open(); - } - }) - ], - text: 'Do you want to encode the image as JPG?

' - + '(JPGs are significantly smaller, but do not support transparency.)', - title: 'Upload File' - }), - $uploadDialog = Ox.Dialog({ buttons: [ Ox.Button({ @@ -93,7 +62,7 @@ pandora.ui.uploadFileDialog = function(file, callback) { open: function() { upload = pandora.chunkupload({ data: { - filename: jpg || extension == 'jpeg' + filename: extension == 'jpeg' ? file.name.split('.').slice(0, -1).join('.') + '.jpg' : file.name }, @@ -117,9 +86,7 @@ pandora.ui.uploadFileDialog = function(file, callback) { } }); - return !Ox.contains(extensions, extension) ? $extensionDialog - : extension == 'png' ? $imageDialog - : $uploadDialog; + return !Ox.contains(extensions, extension) ? $errorDialog : $uploadDialog; };