Sitemap with main

This commit is contained in:
Christophe Vilayphiou 2012-07-27 12:05:17 +08:00
parent 38804bd118
commit 934b515914
5 changed files with 54 additions and 21 deletions

View File

@ -862,6 +862,12 @@
padding: 5px 15px; padding: 5px 15px;
border-top: 1px solid #FFF; border-top: 1px solid #FFF;
border-bottom: 1px solid #dedede; border-bottom: 1px solid #dedede;
display: table;
width: 100%;
}
.site-map .map-block li span {
width: 170px;
display: block;
} }
.site-map .map-block li:last-child { .site-map .map-block li:last-child {
border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;
@ -879,8 +885,9 @@
color: #CACACA; color: #CACACA;
} }
.site-map .map-block h4 { .site-map .map-block h4 {
line-height: 30px; line-height: 18px;
padding: 0 15px; min-height: 20px;
padding: 5px 15px;
border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;
box-shadow: 0px 1px 2px #A8A8A8; box-shadow: 0px 1px 2px #A8A8A8;
position: relative; position: relative;
@ -893,6 +900,20 @@
background-repeat: repeat-x; background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FCFCFC', endColorstr='#DFDFDF', GradientType=0); filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FCFCFC', endColorstr='#DFDFDF', GradientType=0);
} }
.site-map .map-block h4 span {
width: 170px;
display: block;
}
.site-map .map-block h4 .onoff {
}
.site-map .disabled h4 {
color: #CACACA;
}
.site-map .disabled h4 .onoff {
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(0,0,0,.2) inset;
background-color: #9C9C9C;
color: #CACACA;
}
.onoff { .onoff {
display: block; display: block;
background-color: #5EB92B; background-color: #5EB92B;

View File

@ -35,6 +35,12 @@ class Admin::SitesController < ApplicationController
@item = Item.find(params[:id]) @item = Item.find(params[:id])
@item.sitemap_enabled = !@item.sitemap_enabled @item.sitemap_enabled = !@item.sitemap_enabled
@item.save @item.save
if params[:parent]
@item.children.each do |child|
child.sitemap_enabled = @item.sitemap_enabled
child.save
end
end
render :nothing => true render :nothing => true
end end

View File

@ -25,6 +25,7 @@ class Page < Item
protected protected
def create_parts def create_parts
if self.new_record? || self.design.changed?
page_design = self.design page_design = self.design
parent = self.parent parent = self.parent
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
@ -42,5 +43,6 @@ class Page < Item
end end
end end
end end
end
end end

View File

@ -1,12 +1,13 @@
<div class="map-block"> <div class="map-block <%= 'disabled' if !sitemap_block.sitemap_enabled %>">
<h4><%= sitemap_block.i18n_variable[I18n.locale] %><button class="onoff pull-right"><%= sitemap_block.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button></h4> <h4>
<button id="<%= sitemap_block.id %>" class="onoff pull-right"><%= sitemap_block.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button>
<span><%= sitemap_block.i18n_variable[I18n.locale] %></span>
</h4>
<ul> <ul>
<% sitemap_block.children.each do |child| %> <% sitemap_block.children.each do |child| %>
<li class="clear <%= 'disabled' if !child.sitemap_enabled %>"> <li class="clear <%= 'disabled' if !child.sitemap_enabled %>">
<%= child.i18n_variable[I18n.locale] %> <button id="<%= child.id %>" class="onoff pull-right" disabled="<%= 'disabled' if !sitemap_block.sitemap_enabled %>" ><%= child.sitemap_enabled ? t('on_upcase') : t('off_upcase') %></button>
<button id="<%= child.id %>" class="onoff pull-right"> <span><%= child.i18n_variable[I18n.locale] %></span>
<%= child.sitemap_enabled ? t('on_upcase') : t('off_upcase') %>
</button>
</li> </li>
<% end if sitemap_block.children %> <% end if sitemap_block.children %>
</ul> </ul>

View File

@ -32,11 +32,14 @@
$(this).text("<%= t('off_upcase') %>") $(this).text("<%= t('off_upcase') %>")
$(this).parents(".map-block").find('li').addClass('disabled') $(this).parents(".map-block").find('li').addClass('disabled')
$(this).parents(".map-block").find('button').text("<%= t('off_upcase') %>") $(this).parents(".map-block").find('button').text("<%= t('off_upcase') %>")
$(this).parents(".map-block").find('li button').attr('disabled', 'disabled')
} else { } else {
$(this).text("<%= t('on_upcase') %>") $(this).text("<%= t('on_upcase') %>")
$(this).parents(".map-block").find('li').removeClass('disabled') $(this).parents(".map-block").find('li').removeClass('disabled')
$(this).parents(".map-block").find('button').text("<%= t('on_upcase') %>") $(this).parents(".map-block").find('button').text("<%= t('on_upcase') %>")
$(this).parents(".map-block").find('li button').removeAttr("disabled")
} }
$.getScript('<%= admin_sites_path %>' + '/' + $(this).attr('id') + '/sitemap_toggle?parent=true');
}); });
</script> </script>
<% end %> <% end %>