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,19 +25,21 @@ class Page < Item
protected protected
def create_parts def create_parts
page_design = self.design if self.new_record? || self.design.changed?
parent = self.parent page_design = self.design
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 parent = self.parent
page_design.layout.layout_parts.each do |layout_part| 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
current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)} page_design.layout.layout_parts.each do |layout_part|
current_part = self.page_parts.build(:name => layout_part.name) unless current_part current_part = self.page_parts.detect{|page_part| page_part.name.eql?(layout_part.name)}
if menu_part && current_part.name.eql?(menu_part.name) current_part = self.page_parts.build(:name => layout_part.name) unless current_part
if current_part.new_record? if menu_part && current_part.name.eql?(menu_part.name)
current_part.kind = menu_part.kind if current_part.new_record?
current_part.public_r_tag = menu_part.public_r_tag current_part.kind = menu_part.kind
current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id current_part.public_r_tag = menu_part.public_r_tag
else current_part.public_r_tag_object_id = menu_part.public_r_tag_object_id
current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id) else
current_part.update_attributes(:kind => menu_part.kind, :public_r_tag => menu_part.public_r_tag, :public_r_tag_object_id => menu_part.public_r_tag_object_id)
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 %>