Sha256: 211be9cdc33102f9902c0a1f8b39b2f596492d7714a5b47aa29ec206bf32e150

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 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()
  

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shoppe-0.0.10 app/assets/javascripts/shoppe/application.coffee
shoppe-0.0.9 app/assets/javascripts/shoppe/application.coffee
shoppe-0.0.8 app/assets/javascripts/shoppe/application.coffee