announcement-test/app/views/announcements/show.html.erb

185 lines
5.4 KiB
Plaintext
Raw Normal View History

<%
params = OrbitHelper.params
2022-02-27 04:58:52 +00:00
page = @page || Page.where(url:params['url']).first
@show_back_and_next_flag = 0
2022-01-20 07:09:12 +00:00
content = ''
prev_content = ''
next_content = ''
if page.methods.include? 'select_option_items'.to_sym
ModuleApp.all.select{|tmp| tmp.key.to_s=='announcement'}.each do |modile_app|
@show_option_items = modile_app.show_option_items rescue nil
end
page.select_option_items.each do |select_option_item|
if !(@show_option_items.nil?) && select_option_item.field_name == @show_option_items.keys.first.to_s
value = YAML.load(select_option_item.value)
2020-04-25 04:35:30 +00:00
tmp = value[:en]
I18n.with_locale(:en) do
if tmp == t('announcement.not_show')
@show_back_and_next_flag = 0
elsif tmp == t('announcement.show_top')
@show_back_and_next_flag = 1
elsif tmp == t('announcement.show_bottom')
@show_back_and_next_flag = 2
end
end
end
end
end
if @show_back_and_next_flag != 0
uid = params['uid']
2020-04-25 04:35:30 +00:00
sorted,total_pages = get_sorted_annc(0)
now_index = sorted.to_enum.with_index.select{|v| v[0].uid==uid}[0][1] rescue nil
if !now_index.nil?
if now_index != 0
prev_result = sorted[now_index-1]
prev_url = params['url'] + '/' + prev_result.to_param
prev_content = "<a href='#{prev_url}' title='#{t('announcement.prev')}' class='prev'><b>#{t('announcement.prev')}</b><p>#{prev_result['title'][I18n.locale]}</p></a>"
end
if now_index != sorted.length-1
next_result = sorted[now_index+1]
next_url = params['url'] + '/' + next_result.to_param
next_content = "<a href='#{next_url}' title='#{t('announcement.next')}' class='next'><b>#{t('announcement.next')}</b><p>#{next_result['title'][I18n.locale]}</p></a>"
end
2022-01-20 07:09:12 +00:00
if prev_content != '' || next_content != ''
content = "<div class='see_more_boxTitle'>#{prev_content}#{next_content}</div>".html_safe
end
2020-04-25 04:35:30 +00:00
else
content = ''
end
end
%>
<% if @show_back_and_next_flag!=0 %>
<style type="text/css">
.see_more_boxTitle{
display: flex;
margin: 1em 0em;
padding: 1em;
2022-01-20 07:15:17 +00:00
border: 0.2em double;
}
a.prev, a.next{
width: 50%;
border: 0.2em solid;
padding: 1em;
flex: 1;
}
a.next{
margin-left: 1em;
}
a.prev{
margin-right: 1em;
}
</style>
<% end %>
<% if @show_back_and_next_flag==1 %>
<%= content %>
<% end %>
<%= render_view %>
<% if @show_back_and_next_flag==2 %>
<%= content %>
2020-07-30 14:12:21 +00:00
<% end %>
<% site = Site.first
hover_color = site.orbit_bar_background_hover_color rescue nil
hover_color = '#0095CF' if hover_color.blank?
bg_color = site.orbit_bar_background_color rescue nil
2021-04-11 14:37:50 +00:00
bg_color = bg_color.blank? ? '#3a3b3c' : AnnouncementsHelper.lighten_color(bg_color,-40)
color1 = AnnouncementsHelper.lighten_color(bg_color,-40)
color2 = AnnouncementsHelper.lighten_color(AnnouncementsHelper.complementaryColor(bg_color),40)
2020-07-30 14:12:21 +00:00
%>
<style type="text/css">
div[contentEditable=true]:empty:before{
content: attr(data-ph);
color: <%= color1 %>;
padding-left: 3%;
font-weight: bold;
font-family: serif;
}
.announcement-comment {
2020-07-31 03:35:00 +00:00
margin-top: 1em;
2020-11-16 15:07:37 +00:00
border: solid 0.2em <%= bg_color %>;
background: <%= color2 %>;
color: <%= bg_color %>;
2020-07-31 03:35:00 +00:00
font-size: 1.15em;
2020-07-31 03:42:53 +00:00
padding: 0.3em 0 0.3em 3%;
2020-07-30 14:12:21 +00:00
border-radius: 0.7em;
display: inline-block;
width: 80%;
outline: 0;
}
2020-11-16 15:07:37 +00:00
.annc-comment-div,.annc-comments{
2020-07-30 14:12:21 +00:00
display: flex;
2020-07-31 03:35:00 +00:00
align-items: center;
flex-wrap: wrap;
2020-07-30 14:12:21 +00:00
}
.btn-comment{
2020-07-31 03:35:00 +00:00
margin-top: 1em;
2020-07-30 14:12:21 +00:00
margin-left: 3%;
color: <%= color2 %>;
2020-07-31 03:35:00 +00:00
font-size: 1em;
2020-07-30 14:12:21 +00:00
background: <%= bg_color %>;
margin-left: 3%;
}
.btn.btn-comment:focus{
color: <%= color2 %>;
}
.btn-comment:hover{
color: <%= color2 %>;
background-color: <%= hover_color %>;
}
2020-11-16 15:07:37 +00:00
.annc-comments-nickname {
margin-top: 1em;
margin-left: 3%;
color: <%= bg_color %>;
}
2020-07-30 14:12:21 +00:00
.comment-time{
padding-left: 1em;
2020-11-16 15:07:37 +00:00
width: 100%;
2020-07-30 14:12:21 +00:00
color: <%= bg_color %>;
}
.annc-comments{
margin: 1.5em 0;
}
2020-07-31 03:35:00 +00:00
@media (max-width: 767px) {
2020-11-16 15:07:37 +00:00
.annc-comment-div,.annc-comments{
2020-07-31 03:35:00 +00:00
justify-content: center;
}
.announcement-comment {
width: 100%;
}
}
2020-07-30 14:12:21 +00:00
</style>
<script type="text/javascript">
$(function(){
$('.annc-comment-div .btn-comment').click(function(){
$.ajax({
url: "<%= "/xhr/announcements/#{params[:slug]}-#{params[:uid]}/comment" %>",
data : {"comment" : $(this).parents('.annc-comment-div').find('.announcement-comment').html()},
dataType : "json",
type : "get",
success : function(data){
window.location.href = window.location.href
}
})
})
})
</script>
<% action_data['comments'].reverse.each do |comment| %>
<div class="annc-comments">
<div class="comment-time">
<%= comment.time %>
</div>
<div class="announcement-comment">
<%= comment.comment.html_safe %>
</div>
2020-11-16 15:07:37 +00:00
<div class="annc-comments-nickname">by <%= comment.account %></div>
2020-07-30 14:12:21 +00:00
<br>
</div>
2021-09-01 09:51:22 +00:00
<% end rescue nil %>
2020-07-30 14:12:21 +00:00
<% if action_data['show_comment_flag'] %>
<div class="annc-comment-div">
<div data-ph="<%= t('announcement.comment') %>" contenteditable="true" class="announcement-comment"></div>
<button class="btn btn-comment">
<%= t('announcement.send_comment') %>
</button>
</div>
2021-09-01 09:51:22 +00:00
<% end rescue nil %>