Sha256: 9311aab378f82b861522aee00b6da3bae81c5fb81e41bd85d58a5552bac9bc64

Contents?: true

Size: 984 Bytes

Versions: 31

Compression:

Stored size: 984 Bytes

Contents

- if policy(document.class).preview?
  button(
    id       = "preview-button"
    class    = "btn btn-default"
    type     = "button"
    data-url = url_for(action: :preview, format: :pdf)
  )
    = icon(:eye)
    = " "
    = ta(:preview)

  coffee:
    $button = $("#preview-button").detach()
    $button.click ->
      data  = $(this).parents("form").serializeArray()
      $form = $("<form>")

      # jQuery's form clone() does not work with select2
      data.map (e) ->
        return if e.name == "_method" # always post
        return if e.name.indexOf("[lines_attributes]") >= 0 && e.name.indexOf("[id]") >= 0
        $input = $("<input/>").attr(type: "hidden", name: e.name, value: e.value)
        $form.append($input)

      $form.attr(action: $button.data("url"), method: "post", target: "_blank")
      $form.hide()
      $(document.body).append($form)
      $form.submit()
      $form.remove()

    $submit = $("form [type=submit]")
    $button.insertBefore($submit)

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
dorsale-4.0.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.20.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.19.1 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.19.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.18.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.17.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.16.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.15.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.11 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.10 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.9 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.8 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.7 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.6 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.5 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.4 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.3 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.2 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.1 app/views/dorsale/billing_machine/commons/_preview_button.html.slim
dorsale-3.14.0 app/views/dorsale/billing_machine/commons/_preview_button.html.slim