Skip to content

Commit

Permalink
Only init sortable pages on children from root page. Fixes AlchemyCMS…
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas von Deyen committed Feb 7, 2012
1 parent 751de2c commit 3152398
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions app/assets/javascripts/alchemy/alchemy.page_sorter.js
Expand Up @@ -10,7 +10,8 @@ if (typeof(Alchemy) === 'undefined') {
Alchemy.PageSorter = {

init : function () {
$('ul#sitemap').nestedSortable({
var $sortables = $('ul#sitemap').find('ul.level_1_children');
$sortables.nestedSortable({
disableNesting: 'no-nest',
forcePlaceholderSize: true,
handle: 'span.handle',
Expand All @@ -26,7 +27,7 @@ if (typeof(Alchemy) === 'undefined') {
Alchemy.pleaseWaitOverlay();
e.preventDefault();
var params = {
set: JSON.stringify($('ul#sitemap').nestedSortable('toHierarchy'))
set: JSON.stringify($sortables.nestedSortable('toHierarchy'))
};
$.post(Alchemy.routes.order_admin_pages_path, params);
return false;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/alchemy/admin/pages_controller.rb
Expand Up @@ -203,7 +203,7 @@ def order
prev_item = nil
neworder.each do |item|
dbitem = Page.find(item['id'])
prev_item.nil? ? dbitem.move_to_child_of(Page.root) : dbitem.move_to_right_of(prev_item)
prev_item.nil? ? dbitem.move_to_child_of(@page_root) : dbitem.move_to_right_of(prev_item)
sort_children(item, dbitem) unless item['children'].nil?
prev_item = dbitem.reload
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/alchemy/admin/pages/_page.html.erb
Expand Up @@ -2,7 +2,7 @@
<div class="sitemap_page<%= page.locked ? ' locked' : '' %>">
<div class="sitemap_left_images">
<%= sitemapFolderLink(page) unless page.children.blank? || @sorting %>
<span class="site_status <%= @sorting ? 'handle' : nil %> tooltip"></span>
<span class="site_status <%= @sorting && page.level > 1 ? 'handle' : nil %> tooltip"></span>
<div class="tooltip_content" style="display: none;">
<h1><%= t("page_type") %>: <%= page.layout_display_name %></h1>
<p>
Expand Down Expand Up @@ -107,7 +107,7 @@
</div>
</div>
<%- if @sorting || (!page.folded?(current_user) && !page.children.empty?) -%>
<ul id="page_<%= page.id %>_children">
<ul id="page_<%= page.id %>_children" class="level_<%= page.level %>_children">
<%= render :partial => 'page', :collection => page.children %>
</ul>
<%- end -%>
Expand Down

0 comments on commit 3152398

Please sign in to comment.