update uploadFileDialog

This commit is contained in:
rolux 2013-03-24 15:15:09 +05:30
parent 2b599e3ef4
commit 665930885e

View file

@ -5,12 +5,26 @@ pandora.ui.uploadFileDialog = function(file, callback) {
var extension = file.name.split('.').pop().toLowerCase(), var extension = file.name.split('.').pop().toLowerCase(),
extensions = ['jpg', 'jpeg', 'pdf', 'png'], extensions = ['gif', 'jpg', 'jpeg', 'pdf', 'png'],
jpg = false,
upload, 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(), $content = Ox.Element(),
$text = $('<div>') $text = $('<div>')
@ -24,51 +38,6 @@ pandora.ui.uploadFileDialog = function(file, callback) {
}) })
.appendTo($content), .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?<br><br>'
+ '(JPGs are significantly smaller, but do not support transparency.)',
title: 'Upload File'
}),
$uploadDialog = Ox.Dialog({ $uploadDialog = Ox.Dialog({
buttons: [ buttons: [
Ox.Button({ Ox.Button({
@ -93,7 +62,7 @@ pandora.ui.uploadFileDialog = function(file, callback) {
open: function() { open: function() {
upload = pandora.chunkupload({ upload = pandora.chunkupload({
data: { data: {
filename: jpg || extension == 'jpeg' filename: extension == 'jpeg'
? file.name.split('.').slice(0, -1).join('.') + '.jpg' ? file.name.split('.').slice(0, -1).join('.') + '.jpg'
: file.name : file.name
}, },
@ -117,9 +86,7 @@ pandora.ui.uploadFileDialog = function(file, callback) {
} }
}); });
return !Ox.contains(extensions, extension) ? $extensionDialog return !Ox.contains(extensions, extension) ? $errorDialog : $uploadDialog;
: extension == 'png' ? $imageDialog
: $uploadDialog;
}; };