Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

validating on delete of each and all files

  • Loading branch information...
commit 85abe7a45c51f5dab2a2d476e8d997e778d3ff3c 1 parent 1dedc74
Y0rTz authored

Showing 1 changed file with 64 additions and 0 deletions. Show diff stats Hide diff stats

  1. +64 0 app/assets/javascripts/pictures/customupload.js
64 app/assets/javascripts/pictures/customupload.js
@@ -11,6 +11,70 @@
11 11 maxNumberOfFiles: 'Max number of files exceeded'
12 12 }
13 13 },
  14 +
  15 + _initFileUploadButtonBar: function () {
  16 + var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
  17 + filesList = this.element.find('.files'),
  18 + ns = this.options.namespace;
  19 + fileUploadButtonBar
  20 + .addClass('ui-widget-header ui-corner-top');
  21 + this.element.find('.fileinput-button').each(function () {
  22 + var fileInput = $(this).find('input:file').detach();
  23 + $(this).button({icons: {primary: 'ui-icon-plusthick'}})
  24 + .append(fileInput);
  25 + });
  26 + fileUploadButtonBar.find('.start')
  27 + .button({icons: {primary: 'ui-icon-circle-arrow-e'}})
  28 + .bind('click.' + ns, function (e) {
  29 + e.preventDefault();
  30 + filesList.find('.start button').click();
  31 + });
  32 + fileUploadButtonBar.find('.cancel')
  33 + .button({icons: {primary: 'ui-icon-cancel'}})
  34 + .bind('click.' + ns, function (e) {
  35 + e.preventDefault();
  36 + filesList.find('.cancel button').click();
  37 + });
  38 + fileUploadButtonBar.find('.delete')
  39 + .button({icons: {primary: 'ui-icon-trash'}})
  40 + .bind('click.' + ns, function (e) {
  41 + e.preventDefault();
  42 + if (confirm("Are you sure you want to delete all files?")) {
  43 + filesList.find('.delete').addClass("all");
  44 + filesList.find('.all button').click();
  45 + }
  46 + else {
  47 + return false;
  48 + }
  49 + });
  50 + },
  51 +
  52 + _deleteHandler: function (e) {
  53 + e.preventDefault();
  54 + var button = $(this);
  55 + if ($(this).parent().hasClass("all")) {
  56 + e.data.fileupload._trigger('destroy', e, {
  57 + context: button.closest('.template-download'),
  58 + url: button.attr('data-url'),
  59 + type: button.attr('data-type'),
  60 + dataType: e.data.fileupload.options.dataType
  61 + });
  62 + }
  63 + else {
  64 + if ( confirm("Are you sure you want to delete this file ?") == true) {
  65 + e.data.fileupload._trigger('destroy', e, {
  66 + context: button.closest('.template-download'),
  67 + url: button.attr('data-url'),
  68 + type: button.attr('data-type'),
  69 + dataType: e.data.fileupload.options.dataType
  70 + });
  71 + console.info($(this).parent());
  72 + }
  73 + else {
  74 + return false;
  75 + }
  76 + }
  77 + },
14 78
15 79 _renderUploadTemplate: function (files) {
16 80 var that = this,

0 comments on commit 85abe7a

Please sign in to comment.
Something went wrong with that request. Please try again.