Permalink
Browse files

validating on delete of each and all files

  • Loading branch information...
1 parent 1dedc74 commit 85abe7a45c51f5dab2a2d476e8d997e778d3ff3c @yortz committed Oct 27, 2011
Showing with 64 additions and 0 deletions.
  1. +64 −0 app/assets/javascripts/pictures/customupload.js
@@ -11,6 +11,70 @@
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) {
var that = this,

0 comments on commit 85abe7a

Please sign in to comment.