Sha256: 07499674904c9a47451727fc463f90f873db7ef058e8e8596d65372aca677e0b

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

<%= heading_with_title t('views.pages.index.heading') %>

<% if @pages.any? %>
  <ul id="activa-pages">
    <%= render :partial => :page, :collection => @pages %>
  </ul>
<% else %>
  <p><%= t('views.pages.index.empty') %></p>
<% end %>

<%= render 'activa/pages/partials/menu/index' %>

<% content_for :javascript do %>
<script>
  $(function() {
    // see: https://github.com/mjsarfatti/nestedSortable
    $('#activa-pages').nestedSortable({
      handle           : 'div',
      items            : 'li',
      toleranceElement : '> div',
      listType         : 'ul',
      protectRoot      : true,
      forcePlaceholderSize: true,
      placeholder      : 'placeholder',
      helper           : 'clone',
      stop: function(event, ui) {
        var item      = $(ui.item[0])
        var moveAfter = item.prev('li')
        var nesting   = 0

        // Has nesting
        if (!moveAfter.length) {
          nesting   = 1
          moveAfter = item.parent('ul').parent('li')
        }

        var params = {
          'first_node_id'  : item.data('id'),
          'second_node_id' : moveAfter.data('id'),
          'nesting'        : nesting,
          '_method'        : 'put'
        }

        $.post('<%= position_pages_path(:format => :json) %>', params, function(data) {
          console.log(data)
        })
      }
    });
  });
  </script>
<% end %>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activa-0.0.14 app/views/activa/pages/index.html.erb
activa-0.0.13 app/views/activa/pages/index.html.erb