Sha256: 6c25ece5261dc1a30899499ba0aa6e9ce4f26fa534ea41c2d687883d13d91f11

Contents?: true

Size: 863 Bytes

Versions: 10

Compression:

Stored size: 863 Bytes

Contents

sendSorted = (dataList) ->
  $.ajax
    type : 'PATCH'
    url : "#{window.location.pathname}/sort"
    data :
      sorted : dataList

initDnDSorting = ->
  $table = $('[data-sortable]')
  $tableRows = $table.children('tr')

  if isDnDSorting($table, $tableRows)
    minimum = $tableRows.first().data('position')
    $table.tableDnD
      onDrop : ->
        resortedList = []
        $table.children('tr').each (index, item) ->
          $item = $(item)
          resortedList.push
            id : $item.data('id')
            position : index + minimum
        sendSorted resortedList
        return
    return

isDnDSorting = ($table, $tableRows) ->
  first = window.location.search.indexOf('sort') is -1
  second = $tableRows.length > 0
  third = $table.data('sortable')
  first and second and third

$ ->
  $(document).on 'ready page:load', initDnDSorting

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rademade_admin-0.2.2 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.2.1 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.2.0 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.6 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.5 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.4 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.3 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.2 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.1 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee
rademade_admin-0.1.0 app/assets/javascripts/rademade_admin/app/common/dnd-sort.coffee