Sha256: 6105a951aaff263a864a9052957261db73122f9369737611db3d697645aa6910

Contents?: true

Size: 785 Bytes

Versions: 6

Compression:

Stored size: 785 Bytes

Contents

$(document).ready(function(){
  
  var updateURL = $('#content_pages').attr('data-update-url');
  
  var sortableSettings = {
    axis: "y",
    handle: ".sort_handle",
    update: postRefresh
  }
  
  $('#content_pages, .page_group').sortable(sortableSettings);
  
  function postRefresh(event, ui) {
    var content = ui.item.html();
    
    // post results to server and save effect
    $.post(updateURL, {id: ui.item.attr('id').replace('pages_', ''), index: ui.item.index()})
      .done(function() {
        $(ui.item).html('<div class="link_wrap"><a href="#" class="offset-0 saving">Saved!</a></div>');
        setTimeout(function(){
          $(ui.item).html(content);
          $('#content_pages, .page_group').sortable(sortableSettings);
        }, 800);
      });
  }
  
});

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cardboard_cms-0.3.1 app/assets/javascripts/cardboard/content_sidebar.js
cardboard_cms-0.2.2 app/assets/javascripts/cardboard/content_sidebar.js
cardboard_cms-0.2.1 app/assets/javascripts/cardboard/content_sidebar.js
cardboard_cms-0.1.8 app/assets/javascripts/cardboard/content_sidebar.js
cardboard_cms-0.1.6 app/assets/javascripts/cardboard/content_sidebar.js
cardboard_cms-0.1.4 app/assets/javascripts/cardboard/content_sidebar.js