Sha256: b48f89a9a951b1e21aff37af778a44b378c0de720a78abb126d2e8711c915a98

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

// Upload Gallery
function fileSelectAndUploadGallery(evt) {
  var files = evt.target.files;

  for (i = 0; i < files.length; ++i) {
    var formData = new FormData();
    formData.append('content_builder_image', files[i]);

    $.ajax({
      url: 'create_images',
      data: formData,
      cache: false,
      contentType: false,
      processData: false,
      type: 'PUT',
      beforeSend: function () {
        $('#' + evt.target.id).find('figure').append('<div class="cb-loading"></div>');
        $('.cb-tools--center').addClass('cb-tools--disabled');
      },
      complete: function () {
        $('.cb-loading').remove();
        $('.cb-tools--center').removeClass('cb-tools--disabled');
      }
    }).done(function (e) {
      var p = evt.target.getAttribute('data-position');
      id = generateID();

      element = '<div class="cb-gallery__item" id="' + id + '">';
      element += '<div class="cb-tools cb-tools--center">';
      element += '<a class="cb-tools__btn cb-gallery__btn--move fa fa-arrows" href="#"></a>';
      element += '<a class="cb-tools__btn cb-tools__btn--delete fa fa-trash" href="#' + id + '"></a>';
      element += '</div>';
      element += '<figure class="cb-gallery__figure">';
      element += '<img class="cb-gallery__image" src="' + getImageOfPosition(p, e) + '">';
      element += '</figure>';
      element += '</div>';

      $('#' + evt.target.id + ' .cb-gallery').append(element);
    }).fail(function (e) {
      alert('error: ' + e);
    });
  }
}

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_admin_content_builder_rails_6-1.2.0 app/assets/javascripts/rails_admin/helpers/file_select_and_upload_gallery.js
rails_admin_content_builder_rails_6-1.1.0 app/assets/javascripts/rails_admin/helpers/file_select_and_upload_gallery.js
rails_admin_content_builder_rails_6-1.0.1 app/assets/javascripts/rails_admin/helpers/file_select_and_upload_gallery.js
rails_admin_content_builder_rails_6-1.0.0 app/assets/javascripts/rails_admin/helpers/file_select_and_upload_gallery.js