Sha256: 46461e5537d0ee33178b01cf7cfc19854aef9dd831e65101cb122f5cfa1d8b4e

Contents?: true

Size: 970 Bytes

Versions: 5

Compression:

Stored size: 970 Bytes

Contents

#= require jquery-ui/widgets/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: "[data-sortable-handle]"
      axis: "y"
      items: "[data-sortable-item]"
      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

5 entries across 5 versions & 1 rubygems

Version Path
redde-0.4.4 app/assets/javascripts/redde/sortable.coffee
redde-0.4.3 app/assets/javascripts/redde/sortable.coffee
redde-0.4.2 app/assets/javascripts/redde/sortable.coffee
redde-0.4.1 app/assets/javascripts/redde/sortable.coffee
redde-0.4.0 app/assets/javascripts/redde/sortable.coffee