Sha256: 31b0bcd3c3de443f51edc315c9acfe9663e6abcd70e4f508560daa86c3bd442f

Contents?: true

Size: 962 Bytes

Versions: 33

Compression:

Stored size: 962 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: "[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

33 entries across 33 versions & 1 rubygems

Version Path
redde-0.3.39 app/assets/javascripts/redde/sortable.coffee
redde-0.3.38 app/assets/javascripts/redde/sortable.coffee
redde-0.3.37 app/assets/javascripts/redde/sortable.coffee
redde-0.3.36 app/assets/javascripts/redde/sortable.coffee
redde-0.3.35 app/assets/javascripts/redde/sortable.coffee
redde-0.3.34 app/assets/javascripts/redde/sortable.coffee
redde-0.3.33 app/assets/javascripts/redde/sortable.coffee
redde-0.3.32 app/assets/javascripts/redde/sortable.coffee
redde-0.3.31 app/assets/javascripts/redde/sortable.coffee
redde-0.3.30 app/assets/javascripts/redde/sortable.coffee
redde-0.3.29 app/assets/javascripts/redde/sortable.coffee
redde-0.3.28 app/assets/javascripts/redde/sortable.coffee
redde-0.3.27 app/assets/javascripts/redde/sortable.coffee
redde-0.3.26 app/assets/javascripts/redde/sortable.coffee
redde-0.3.25 app/assets/javascripts/redde/sortable.coffee
redde-0.3.24 app/assets/javascripts/redde/sortable.coffee
redde-0.3.23 app/assets/javascripts/redde/sortable.coffee
redde-0.3.22 app/assets/javascripts/redde/sortable.coffee
redde-0.3.21 app/assets/javascripts/redde/sortable.coffee
redde-0.3.20 app/assets/javascripts/redde/sortable.coffee