Sha256: 386b8dd10be5de1ac0b6ac0e0b102e2b4e9444f523bdc6d0d0d963b2ac7e0a56

Contents?: true

Size: 777 Bytes

Versions: 11

Compression:

Stored size: 777 Bytes

Contents

(($) ->
  window.crm ||= {}

  crm.init_sortables = ->
    $('[data-sortable]').each ->
      $el = $(this)

      checkEmpty = ->
        $el.children('.empty').toggle($el.sortable('toArray').length is 1)

      $el.sortable(
        forcePlaceholderSize: true
        connectWith: $el.data('sortable-connect-with')
        handle: $el.data('sortable-handle')
        create: checkEmpty
        update: ->
          ids = []
          for dom_id in $el.sortable('toArray')
            ids.push dom_id.replace(/[^\d]/g, '')
          data = {}
          data[$el.attr('id')] = ids
          $.post($el.attr('data-sortable'), data)
          checkEmpty()
      )

  $(document).ready ->
    crm.init_sortables()

  $(document).ajaxComplete ->
    crm.init_sortables()

) jQuery

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
fat_free_crm-0.14.2 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.14.1 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.15.0.beta.2 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.15.0.beta app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.14.0 app/assets/javascripts/crm_sortable.js.coffee
reduced_fat_crm-0.15.0.beta app/assets/javascripts/crm_sortable.js.coffee
reduced_fat_crm-0.14.0 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.13.6 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.13.5 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.13.4 app/assets/javascripts/crm_sortable.js.coffee
fat_free_crm-0.13.3 app/assets/javascripts/crm_sortable.js.coffee