Sha256: e65526db6fb5a7590a0aefb6bc8e2b2ad1db537070230a94d0461629d0010eec

Contents?: true

Size: 1.75 KB

Versions: 66

Compression:

Stored size: 1.75 KB

Contents

:javascript
  var $here = $("#csv-drop-here");
  var form_data = new FormData;

  var appendFiles = function(files) {
    $.each(files, function(i, file) {
      form_data.append("files[]", file);
      $("#csv-file-list").append($("<div>" + file.name + "</div>"));
    });
  };

  $("#csv-drop-cover").hide();
  $here.on("dragenter", function(e) {
    $("#csv-drop-cover").show();
  });

  $("#csv-drop-cover")
    .on("dragenter", function(e) {
      $here.addClass("dragover");
    })
    .on("dragover", function(e) {
      e.preventDefault();
      e.dataTransfer.dropEffect = "copy";
      return false;
    })
    .on("dragleave", function(e) {
      $here.removeClass("dragover");
      $(this).hide();
    })
    .on("drop", function(e) {
      e.preventDefault();
      $here.removeClass("dragover");
      $(this).hide();
      appendFiles(e.dataTransfer.files);
    });

  $("#csv-select-file-button").on("click", function(e) {
    $("#csv-select-file-input").click();
  });

  $("#csv-select-file-input").on("change", function(e) {
    appendFiles(this.files);
  });

  $("#csv-import-files").on("click", function(e) {
    $.ajax({
      url: "/api/csv/import",
      type: "post",
      data: form_data,
      processData: false,
      contentType: false
    });
  });

#csv-drop-here
  .inner
    %div
      %div ここにCSVファイルをドラッグ&ドロップ
      %div.else もしくは…
      %div
        %input#csv-select-file-input.hidden(type="file" multiple="multiple")
        %button#csv-select-file-button.btn.btn-warning.btn-xs
          ファイルを選択
  #csv-drop-cover.drop-cover(effectAllowed="all")
#csv-file-list

-# インポートダイアログの「インポート」ボタンから処理を移譲されてくる
#csv-import-files.hidden

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
narou-2.8.2 lib/web/views/partial/csv_import.haml
narou-2.8.1 lib/web/views/partial/csv_import.haml
narou-2.8.0 lib/web/views/partial/csv_import.haml
narou-2.7.2 lib/web/views/partial/csv_import.haml
narou-2.7.1 lib/web/views/partial/csv_import.haml
narou-2.7.0 lib/web/views/parts/csv_import.haml