Sha256: 3040a6b672e7a36cbe74301df2e78d573c10c1ace790c8bad40b500f2b13ef71

Contents?: true

Size: 932 Bytes

Versions: 11

Compression:

Stored size: 932 Bytes

Contents

Locomotive.Views.Pages ||= {}

class Locomotive.Views.Pages.ListView extends Backbone.View

  el: '#pages-list'

  render: ->
    @make_foldable()

    @make_sortable()

    return @

  make_foldable: ->
    @$('ul.folder img.toggler').toggleMe()

  make_sortable: ->
    self = @

    @$('ul.folder').sortable
      handle: 'em'
      axis:   'y'
      update: (event, ui) -> self.call_sort $(@)

  call_sort: (folder) ->
    $.rails.ajax
      url:        folder.attr('data-url')
      type:       'post'
      dataType:   'json'
      data:
        children: (_.map folder.sortable('toArray'), (el) -> el.replace('item-', ''))
        _method:  'put'
      success:    @.on_successful_sort
      error:      @.on_failed_sort

  on_successful_sort: (data, status, xhr) ->
    $.growl('success', xhr.getResponseHeader('X-Message'))

  on_failed_sort: (data, status, xhr) ->
    $.growl('error', xhr.getResponseHeader('X-Message'))

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
locomotive_cms-2.0.0.rc12 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc11 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc10 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc9 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc8 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc7 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc6 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc5 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc4 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0.rc1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee