Skip to content

Commit

Permalink
validating on delete of each and all files
Browse files Browse the repository at this point in the history
  • Loading branch information
yortz committed Oct 27, 2011
1 parent 1dedc74 commit 85abe7a
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions app/assets/javascripts/pictures/customupload.js
Expand Up @@ -11,6 +11,70 @@
maxNumberOfFiles: 'Max number of files exceeded' maxNumberOfFiles: 'Max number of files exceeded'
} }
}, },

_initFileUploadButtonBar: function () {
var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
filesList = this.element.find('.files'),
ns = this.options.namespace;
fileUploadButtonBar
.addClass('ui-widget-header ui-corner-top');
this.element.find('.fileinput-button').each(function () {
var fileInput = $(this).find('input:file').detach();
$(this).button({icons: {primary: 'ui-icon-plusthick'}})
.append(fileInput);
});
fileUploadButtonBar.find('.start')
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
.bind('click.' + ns, function (e) {
e.preventDefault();
filesList.find('.start button').click();
});
fileUploadButtonBar.find('.cancel')
.button({icons: {primary: 'ui-icon-cancel'}})
.bind('click.' + ns, function (e) {
e.preventDefault();
filesList.find('.cancel button').click();
});
fileUploadButtonBar.find('.delete')
.button({icons: {primary: 'ui-icon-trash'}})
.bind('click.' + ns, function (e) {
e.preventDefault();
if (confirm("Are you sure you want to delete all files?")) {
filesList.find('.delete').addClass("all");
filesList.find('.all button').click();
}
else {
return false;
}
});
},

_deleteHandler: function (e) {
e.preventDefault();
var button = $(this);
if ($(this).parent().hasClass("all")) {
e.data.fileupload._trigger('destroy', e, {
context: button.closest('.template-download'),
url: button.attr('data-url'),
type: button.attr('data-type'),
dataType: e.data.fileupload.options.dataType
});
}
else {
if ( confirm("Are you sure you want to delete this file ?") == true) {
e.data.fileupload._trigger('destroy', e, {
context: button.closest('.template-download'),
url: button.attr('data-url'),
type: button.attr('data-type'),
dataType: e.data.fileupload.options.dataType
});
console.info($(this).parent());
}
else {
return false;
}
}
},


_renderUploadTemplate: function (files) { _renderUploadTemplate: function (files) {
var that = this, var that = this,
Expand Down

0 comments on commit 85abe7a

Please sign in to comment.