summaryrefslogtreecommitdiff
path: root/www/js/importer.js
diff options
context:
space:
mode:
Diffstat (limited to 'www/js/importer.js')
-rw-r--r--www/js/importer.js68
1 files changed, 39 insertions, 29 deletions
diff --git a/www/js/importer.js b/www/js/importer.js
index 5261f6d..8aa6c09 100644
--- a/www/js/importer.js
+++ b/www/js/importer.js
@@ -28,12 +28,18 @@ Rivendell.Importer = function() {
this.$el = $('#uploadModal');
};
-Rivendell.Importer.prototype.showUploadModal = function(group) {
+Rivendell.Importer.prototype.resetModal = function(group) {
$('div.modal-header h3', this.$el).text("Datei auswählen...");
- var form = $('<form>');
- $('.modal-body', uploadModal).empty().append(form).css("background-image", "url('/img/dz-backdrop.png')");
+ $('.modal-body', this.$el).css("background-image", "url('/img/dz-backdrop.png')");
+ $('#uploadModal-confirm', this.$el).attr('disabled','disabled').off('click');
+};
+
+Rivendell.Importer.prototype.openModal = function(group) {
+ this.resetModal();
+
+ var $form = $('<form>');
var self = this;
- var dropzone = form.dropzone({
+ $form.dropzone({
url: '/rd-bin/rdxport.cgi',
parallelUploads: 1,
maxFilesize: 2048,
@@ -44,37 +50,40 @@ Rivendell.Importer.prototype.showUploadModal = function(group) {
acceptedFiles: '.flac,.wav,.ogg,.mp3',
autoProcessQueue: false,
init: function() {
- this.on("addedfile", function(file) {
+ this.on('addedfile', function(file) {
self.importFileAdded(this, file, group);
});
- this.on("error", function(file, msg) {
+ this.on('error', function(file, msg) {
self.importFileSelectError(this, file, msg);
});
}
});
+ $('.modal-body', this.$el).empty().append($form);
this.$el.modal({keyboard: true});
};
Rivendell.Importer.prototype.importFileAdded = function(dropzone, file, group) {
- $(dropzone.getAcceptedFiles()).each(function(idx, elem) { dropzone.removeFile(elem); });
+ // wtf? remove accepted files?
+ /*$(dropzone.getAcceptedFiles()).each(function(index, elem) {
+ dropzone.removeFile(elem);
+ });*/
$('div.modal-body', this.$el).css("background-image", "url('/img/audio_file.png')");
$('div.modal-header h3', this.$el).text(file.name);
+
var self = this;
- $('#uploadModal-confirm', this.$el).unbind('click').click(function() {
+ $('#uploadModal-confirm', this.$el).off('click').on('click', function() {
self.importCartConfirm(dropzone, group);
}).removeAttr('disabled');
};
Rivendell.Importer.prototype.importFileSelectError = function(dropzone, file, msg) {
- $('div.modal-header h3', this.$el).text("Datei auswählen...");
- $('div.modal-body', this.$el).css("background-image", "url('/img/dz-backdrop.png')");
- $('#uploadModal-confirm', this.$el).attr('disabled','disabled').unbind('click');
+ this.resetModal();
dropzone.removeFile(file);
};
-Rivendell.Importer.prototype.importCartConfirm = function(dz, group) {
+Rivendell.Importer.prototype.importCartConfirm = function(dropzone, group) {
this.$el.modal('hide');
//var progressBar = group.addUpload();
@@ -84,25 +93,26 @@ Rivendell.Importer.prototype.importCartConfirm = function(dz, group) {
//var cart_row = $('#show-cart-' + cart);
//cart_row.find('.btn').attr('disabled','disabled');
//var importing_row = jingles_newImportingEntry(cart);
- //importing_row.find('button').unbind('click').click(function() { jingles_importCartCancel(cart, dz); });
+ //importing_row.find('button').unbind('click').click(function() { jingles_importCartCancel(cart, dropzone); });
//cart_row.replaceWith(importing_row);
- dz.off("error");
- var files = dz.getAcceptedFiles();
+ var files = dropzone.getAcceptedFiles();
//importing_row.find('.file-name').text(files[0].name);
//jingles_importUpdateProgress(files[0], importing_row);
var self = this;
- dz.on('uploadprogress', function(file) { self.uploadProgress(file); });
- dz.on('success', function(file) {
- self.importFileUploadSuccess(dz, file, group);
+ dropzone.on('uploadprogress', function(file) {
+ self.uploadProgress(file);
+ });
+ dropzone.on('success', function(file) {
+ self.importFileUploadSuccess(dropzone, file, group);
});
- dz.on('error', function(file, msg, xhr) {
+ dropzone.off('error').on('error', function(file, msg, xhr) {
self.importFileUploadError(this, file, msg, xhr);
});
/*$(files).each(function(index, file) {
- self.importAddCut(dz, group, file);
+ self.importAddCut(dropzone, group, file);
});*/
- self.importAddCut(dz, group, files[0]);
+ self.importAddCut(dropzone, group, files[0]);
};
Rivendell.Importer.prototype.uploadProgress = function(file) {
@@ -128,31 +138,31 @@ Rivendell.Importer.prototype.uploadProgress = function(file) {
}
};
-Rivendell.Importer.prototype.importFileUploadSuccess = function(dz, file, group) {
+Rivendell.Importer.prototype.importFileUploadSuccess = function(dropzone, file, group) {
//var command = { LOGIN_NAME: auth_username, PASSWORD: auth_token, DESCRIPTION: file. };
//jingles_updateGroupCartInfo(cart);
- dz.disable();
+ dropzone.disable();
//progressBar.remove();
group.fetchCarts();
//$(this.currentGroup.mainCart).trigger('add');
};
-Rivendell.Importer.prototype.importFileUploadError = function(dz, file, msg, xhr) {
+Rivendell.Importer.prototype.importFileUploadError = function(dropzone, file, msg, xhr) {
//var error_row = jingles_newImportErrorEntry(cart, msg);
//error_row.find('button').unbind('click').click(function() {
//jingles_deleteCart(cart);
//});
//$('#show-cart-' + cart).replaceWith(error_row);
//error_row.find('.file-name').text(file.name);
- dz.disable();
+ dropzone.disable();
};
-Rivendell.Importer.prototype.importAddCut = function(dz, group, file) {
+Rivendell.Importer.prototype.importAddCut = function(dropzone, group, file) {
var cart = group.mainCart;
rivendell.addAndEditCut(cart.number, {DESCRIPTION: file.name}, function(cutXml) {
group.fetchCarts();
- dz.on('sending', function(file, xhr, formData) {
+ dropzone.on('sending', function(file, xhr, formData) {
var cutNumber = $(cutXml).find('cutNumber').text();
var cutNumberLeading = cutNumber;
switch (cutNumber.toString().length) {
@@ -174,8 +184,8 @@ Rivendell.Importer.prototype.importAddCut = function(dz, group, file) {
formData.append('AUTOTRIM_LEVEL', cart.trimlevel);
formData.append('USE_METADATA', 0); // don't set USE_METADATA 1 for jingles
});
- dz.processQueue();
+ dropzone.processQueue();
}).fail(function(xhr, status, err) {
- self.importFileUploadError(cart, dz, file, err, xhr);
+ self.importFileUploadError(cart, dropzone, file, err, xhr);
});
};