Sha256: 66b0a6503d23e536c3da7d1951ab0b8a848ab66fddc4d7bb831ebfbe05959836

Contents?: true

Size: 929 Bytes

Versions: 7

Compression:

Stored size: 929 Bytes

Contents

#= require jquery-ui/sortable

###
variants:
  data-sortable
  data-sortable = 'url'
  data-sortable = {}
  data-sortable = {url: 'url', ...}
###

$ ->
  $("[data-sortable]").each ->
    $this = $(this)

    opts = $this.data('sortable')

    if $.isPlainObject( opts ) && opts.url
      url = opts.url
      delete opts.url
    else if (typeof opts == 'string') && opts != ""
      url = opts
      opts = {}

    unless url? || url == ""
      url = location.pathname + "/sort"

    defs =
      dropOnEmpty: false
      cursor: "crosshair"
      opacity: 0.75
      handle: ".handle"
      axis: "y"
      items: "tr"
      scroll: true
      update: ->
        $.ajax
          type: "post"
          data: $this.sortable("serialize") # + '&authenticity_token=#{u(form_authenticity_token)}',
          dataType: "script"
          url: url

    opts = $.extend( {}, defs, opts )
    $this.sortable opts

    return

  return

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
redde-0.3.6 app/assets/javascripts/redde/sortable.coffee
redde-0.3.5 app/assets/javascripts/redde/sortable.coffee
redde-0.3.4 app/assets/javascripts/redde/sortable.coffee
redde-0.3.3 app/assets/javascripts/redde/sortable.coffee
redde-0.3.2 app/assets/javascripts/redde/sortable.coffee
redde-0.3.1 app/assets/javascripts/redde/sortable.coffee
redde-0.3.0 app/assets/javascripts/redde/sortable.coffee