Sha256: 5865c0386e03d0f71d458c710a3d83ab83db3bf792909853c7d5d738b147f6ee

Contents?: true

Size: 924 Bytes

Versions: 9

Compression:

Stored size: 924 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 .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.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

9 entries across 9 versions & 1 rubygems

Version Path
locomotive_cms-2.1.4 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.1.3 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.1.2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.1.1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.1.0 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.3 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.0.0 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee