Sha256: 8ff6e18d65b92e8cb0238e5dad0aceb9b4cafebea5af97d5765b0c42013b66ab

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

#= require jquery
#= require jquery_ujs
#= require shoppe/jquery_ui
#= require shoppe/chosen.jquery
#= require_tree .

$ ->
  # Automatically focus all fields with the 'focus' class
  $('input.focus').focus()
  
  # When clicking the order search button, toggle the form
  $('a[rel=searchOrders]').on 'click', ->
    $('div.orderSearch').toggle()
  
  # Add a new attribute to a table
  $('a[data-behavior=addAttributeToAttributesTable]').on 'click', ->
    table = $('table.productAttributes')
    if $('tbody tr', table).length == 1 || $('tbody tr:last td:first input', table).val().length > 0
      template = $('tr.template', table).html()
      table.append("<tr>#{template}</tr>")
    false
  
  # Remove an attribute from a table
  $('table.productAttributes tbody').on 'click', 'tr td.remove a', -> 
    $(this).parents('tr').remove()
    false
  
  # Sorting on the product attribtues table
  $('table.productAttributes tbody').sortable
    axis: 'y'
    handle: '.handle'
    cursor: 'move',
    helper: (e,tr)->
      originals = tr.children()
      helper = tr.clone()
      helper.children().each (index)->
        $(this).width(originals.eq(index).width())
      helper
  
  # Chosen
  $('select.chosen').chosen()
  $('select.chosen-with-deselect').chosen({allow_single_deselect: true})

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shoppe-0.0.14 app/assets/javascripts/shoppe/application.coffee
shoppe-0.0.13 app/assets/javascripts/shoppe/application.coffee
shoppe-0.0.12 app/assets/javascripts/shoppe/application.coffee
shoppe-0.0.11 app/assets/javascripts/shoppe/application.coffee