Sha256: b80640106977cfc57bcc1949f80faf4212a867cb07b5eb19a4a34a4439134afb

Contents?: true

Size: 1.2 KB

Versions: 5

Compression:

Stored size: 1.2 KB

Contents

class @ProjectPage
  download_icon: ->
    jQuery('#icon_file_download')

  upload_icon: ->
    jQuery('#icon_file_upload')

  input_file_field: ->
    jQuery('#attachment_attributes_io_stream_fields input[id$=_io_stream][type=file]')

  upload_form: ->
    jQuery('#contents form:first')

  file_name_label: ->
    jQuery('#file_name')

  hide_upload_field: ->
    jQuery('#attachment_attributes_io_stream_fields li[id$=_io_stream_input]').addClass('visually_hidden')

  bind_upload_icon_to_file_field: ->
    @upload_icon().click ->
      page = new ProjectPage
      file_field = page.input_file_field()
      file_field.click()
      file_field.change ->
        page.file_name_label().text(jQuery(@).val().replace("C:\\fakepath\\", ""))
        page.upload_form().find('input[type=submit]').click()

  drop_new_form_faux_link: ->
    @download_icon().removeClass 'faux_link' if @upload_form().attr('id') is 'new_attachment'

  hide_new_form_download_icon: ->
    @download_icon().hide() if @upload_form().attr('id') is 'new_attachment'

jQuery(document).ready ->
  page = new ProjectPage
  page.hide_upload_field()
  page.bind_upload_icon_to_file_field()
  page.drop_new_form_faux_link()
  page.hide_new_form_download_icon()

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
importable_attachments-0.0.18 app/assets/javascripts/importable_attachments/attachments.coffee
importable_attachments-0.0.17 app/assets/javascripts/importable_attachments/attachments.coffee
importable_attachments-0.0.15 app/assets/javascripts/importable_attachments/attachments.coffee
importable_attachments-0.0.14 app/assets/javascripts/importable_attachments/attachments.coffee
importable_attachments-0.0.13 app/assets/javascripts/importable_attachments/attachments.coffee