kosen-venture/RocketAnswer

View on GitHub
app/views/answers/_upload_form.html.erb

Summary

Maintainability
Test Coverage
<div class="uploader">
  <div class="page-header">
  <h3>画像/PDFを追加</h3>
  <p>PDF, JPG, PNG形式の画像をアップロードできます。</p>
  </div>

  <%= form_for [@answer, @new_answer_file],
    html: { multipart: true } do |f| %>
    <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
    <div class="row fileupload-buttonbar">
      <div class="col-md-7">
        <!-- The fileinput-button span is used to style the file input field as button -->
        <span class="btn btn-success btn-sm fileinput-button">
          <i class="fa fa-plus"></i>
          <span>追加...</span>
          <%= f.file_field :image %>
        </span>
        <button type="submit" class="btn btn-primary btn-sm start">
          <i class="fa fa-upload"></i>
          <span>全てアップロード</span>
        </button>
        <button type="reset" class="btn btn-warning btn-sm cancel">
          <i class="fa fa-times-circle"></i>
          <span>キャンセル</span>
        </button>
      </div>
      <div class="col-md-5">
        <!-- The global progress bar -->
        <div class="progress progress-striped">
          <div id="progressall" class="progress-bar" style="width:0%;"></div>
        </div>
      </div>
    </div>
    <!-- The loading indicator is shown during image processing -->
    <div class="fileupload-loading"></div>
    <br>
    <!-- The table listing the files available for upload/download -->
    <table class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody>
    </table>
  <% end %>

  <hr>

  <h3>テキスト形式で記述</h3>
  <p>TeX数式とMarkdown記法で記述できます。</p>
  <small>
  ※インライン数式は\$ \$で、ディスプレイ数式の場合は\$\$ \$\$で囲んでください。改行は\\\ですることが出来ます。<br>
  ※画像をアップロードした場合は空欄で省略できます。
  </small>
  <%=form_for @answer do |f| %>
    <div class="field">
      <%= f.text_area :answer_text , size: "100x20"%>
    </div>

    <div class="actions">
      <%= f.submit "変更する",class: 'btn btn-primary btn-sm'%>
    </div>
  <% end %>
</div>

<%= render partial: 'shared/using_notice' %>

<script id="template-upload" type="text/x-tmpl">
{% for (var i=0, file; file=o.files[i]; i++) { %}
  <tr class="template-upload fade">
    <td class="preview"><span class="fade"></span></td>
    <td class="name"><span>{%=file.name%}</span></td>
    <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>

    {% console.log(o); if (file.error) { %}
      <td class="error" colspan="2">
      <span class="label label-important">{%=locale.fileupload.error%}</span>
      {%=locale.fileupload.errors[file.error] || file.error%}
      </td>
    {% } else if (!i) { %}
      <td>
        <div class="progress progress-striped">
          <div class="progress-bar" style="width:0%;"></div>
        </div>
      </td>

      <td class="start">
        {% if (!o.options.autoUpload) { %}
          <button class="btn btn-primary btn-sm">
            <i class="fa fa-upload"></i>
            <span>開始</span>
          </button>
        {% } %}
      </td>
    {% } else { %}
      <td colspan="2"></td>
    {% } %}

    <td class="cancel">
      {% if (!i) { %}
        <button class="btn btn-warning btn-sm">
          <i class="fa fa-times-circle"></i>
          <span>キャンセル</span>
        </button>
      {% } %}
    </td>
  </tr>
{% } %}
</script>
<script id="template-download" type="text/x-tmpl">
dummy
</script>