Sha256: 6b29c0b64a978d38353ce75984760e551483682e6fff6fb52c75d962f3fd6206

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

$(document).ready ->
  $(".file-input-choose-file-button").live "click", ->
    self = $(@)
    
    if self.hasClass("disabled")
      return 0
    
    file_input = self.find("~ input[type='file']")
    file_name_span = self.closest(".input").find(".file-input-attachment-filename")
     
    file_input.change ->
      file_input_val = file_input.val()
      file_name      = file_input_val.substring(file_input_val.lastIndexOf('/') + 1).substring(file_input_val.lastIndexOf('\\') + 1)
      file_name_span.text(file_name)

    file_input.click()
    
  $(".file-input-delete-attachment-button").live "click", ->
    
    btn = $(@)
    input_container = btn.closest(".input")
    
    if btn.hasClass("active")
      input_container.find(".btn:not(.file-input-delete-attachment-button)").addClass("disabled")
      btn.siblings(".file-input-attachment-filename").css({"text-decoration": "line-through", opacity: 0.5})
      btn.find("~ .file-input-delete-attachment-checkbox").attr('checked', true);
    else
      input_container.find(".btn:not(.file-input-delete-attachment-button)").removeClass("disabled")
      btn.siblings(".file-input-attachment-filename").css({"text-decoration": "none", opacity: 1})
      btn.find("~ .file-input-delete-attachment-checkbox").attr('checked', false);
      

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
fullstack-admin-0.1.43 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.42 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.41 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.40 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.39 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.38 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.37 app/assets/javascripts/support/file_input.js.coffee
fullstack-admin-0.1.36 app/assets/javascripts/support/file_input.js.coffee