From 4e97e645d11a759019dc3762a2f66140a112c46e Mon Sep 17 00:00:00 2001
From: j <0x006A@0x2620.org>
Date: Thu, 21 Feb 2013 14:03:48 +0000
Subject: [PATCH] checking missing file
---
static/js/pandora/uploadPDFDialog.js | 109 +++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
create mode 100644 static/js/pandora/uploadPDFDialog.js
diff --git a/static/js/pandora/uploadPDFDialog.js b/static/js/pandora/uploadPDFDialog.js
new file mode 100644
index 000000000..efd51e309
--- /dev/null
+++ b/static/js/pandora/uploadPDFDialog.js
@@ -0,0 +1,109 @@
+// vim: et:ts=4:sw=4:sts=4:ft=javascript
+'use strict';
+
+pandora.ui.uploadPDFDialog = function(options) {
+
+ var cancelled = false,
+ file,
+ selectFile,
+ $cancelButton,
+ $closeButton,
+ $content = Ox.Element().css({margin: '16px'}),
+ $progress,
+ $status = $('
').css({padding: '4px', paddingTop: '8px'}),
+ that = Ox.Dialog({
+ buttons: [
+ $closeButton = Ox.Button({
+ id: 'close',
+ title: 'Close'
+ }).bindEvent({
+ click: function() {
+ that.triggerEvent('close');
+ }
+ }),
+ $cancelButton = Ox.Button({
+ id: 'cancel',
+ title: 'Cancel',
+ disabled: true
+ }).bindEvent({
+ click: function(data) {
+ cancelled = true;
+ pandora.$ui.upload && pandora.$ui.upload.abort();
+ $fileButton.show();
+ $cancelButton.hide()
+ $closeButton.show();
+ }
+ }),
+ ],
+ content: $content,
+ height: 128,
+ removeOnClose: true,
+ width: 368,
+ title: 'Upload PDF',
+ })
+ .bindEvent({
+ close: function(data) {
+ if (pandora.firefogg) {
+ pandora.firefogg.cancel();
+ delete pandora.firefogg;
+ }
+ that.close();
+ }
+ });
+
+ $content.append($status);
+ upload(options.file);
+
+ function resetProgress() {
+ $progress = Ox.Progressbar({
+ progress: 0,
+ showPercent: true,
+ showTime: true,
+ width: 304
+ });
+ $status.html('').append($progress);
+ }
+
+ function upload(file) {
+ resetProgress();
+ pandora.$ui.upload = pandora.chunkupload({
+ file: file,
+ url: '/api/upload/text/',
+ data: {
+ name: file.name,
+ id: options.id
+ },
+ progress: function(data) {
+ var progress = data.progress || 0;
+ $progress.options({progress: progress});
+ },
+ callback: function(result) {
+ if(result.progress == 1) {
+ Ox.Request.clearCache();
+ //fixme reload text view here
+ that.close();
+ } else {
+ $content.html("failed: " + result.responseText);
+ }
+ }
+ }).bindEvent({
+ progress: function(data) {
+ var progress = data.progress || 0;
+ $progress.options({progress: progress});
+ },
+ done: function(data) {
+ if(data.progress == 1) {
+ Ox.Request.clearCache();
+ pandora.$ui.mainPanel.replaceElement(1, pandora.$ui.rightPanel = pandora.ui.rightPanel());
+ that.close();
+ } else {
+ $content.html("failed: " + data.responseText);
+ }
+ }
+ });
+ }
+
+ return that;
+
+};
+