Sha256: 171f76ee94c99c572671515adef741936b8f90ddd995fee083e87a032fe46dc6

Contents?: true

Size: 986 Bytes

Versions: 21

Compression:

Stored size: 986 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', decodeURIComponent $.parseJSON xhr.getResponseHeader('X-Message'))

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.6 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.6.rc2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.6.rc1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.5 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.4 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.3 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.0 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.0.rc3 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.0.rc2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.5.0.rc1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.4.1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.4.0 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.3.1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.3.0 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.2.3 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.2.2 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee
locomotive_cms-2.2.1 app/assets/javascripts/locomotive/views/pages/list_view.js.coffee