Add cover image setting.

This commit is contained in:
BoHung Chiu 2021-05-21 15:48:40 +08:00
parent 2f5e52c331
commit a5a25c5684
6 changed files with 34 additions and 2 deletions

View File

@ -590,7 +590,7 @@ class AnnouncementsController < ApplicationController
"image" => announcement.image.url, "image" => announcement.image.url,
"img_src" => img_src, "img_src" => img_src,
"img_description" => img_description, "img_description" => img_description,
"hide_class" => announcement.display_img? ? '' : ' hide', "hide_class" => announcement.display_img? ? announcement.image_display_class : ' hide',
"alt_title" => desc, "alt_title" => desc,
"resume_btn_title" => resume_btn_title, "resume_btn_title" => resume_btn_title,
"pause_btn_title" => pause_btn_title, "pause_btn_title" => pause_btn_title,

View File

@ -26,6 +26,7 @@ class Bulletin
before_destroy do before_destroy do
AnnsCache.all.destroy AnnsCache.all.destroy
end end
field :image_display_class, type: String, default: "full-size-img" #3 choices: full-size-img , pull-left , pull-right
field :add_to_calendar,type: Boolean,default: false field :add_to_calendar,type: Boolean,default: false
field :calendar_start_date, :type => DateTime field :calendar_start_date, :type => DateTime
field :calendar_end_date, :type => DateTime field :calendar_end_date, :type => DateTime

View File

@ -114,6 +114,20 @@
<%= f.check_box :display_img %> <%= f.check_box :display_img %>
</div> </div>
</div> </div>
<!-- Image display setting -->
<% image_display_class_relation = {"full_width"=>"full-size-img","up_left_corner"=>"pull-left","up_right_corner"=>"pull-right"} %>
<div class="control-group <%='hide' if !f.object.display_img %>" id="image_display_setting">
<%= f.label :image_display_class, t("announcement.cover_image_display_setting"), :class => "control-label muted" %>
<div class="controls">
<% image_display_class_relation.each.with_index do |(key,value),i| %>
<label>
<%= radio_button_tag "#{f.object_name}[image_display_class]", value , (f.object.image_display_class == value) %>
<%= t("announcement.#{key}") %>
</label>
<% end %>
</div>
</div>
</div> </div>
<!-- Calendar Module --> <!-- Calendar Module -->
@ -518,6 +532,7 @@
} }
</style> </style>
<script> <script>
$("#bulletin_display_img").click(function(){$("#image_display_setting").toggleClass("hide")})
function Appendzero(obj) function Appendzero(obj)
{ {
if(obj<10) return "0" +""+ obj; if(obj<10) return "0" +""+ obj;

View File

@ -3,6 +3,10 @@ en:
feed: Feed feed: Feed
import: Import import: Import
announcement: announcement:
cover_image_display_setting: Cover Image display setting
full_width: Full width
up_left_corner: Up-left corner
up_right_corner: Up-right corner
all_tabs_setting: '"All" tab setting' all_tabs_setting: '"All" tab setting'
the_same_as_data_count: The same as data count the_same_as_data_count: The same as data count
display_all_in_other_tabs: Display all contents in other tabs display_all_in_other_tabs: Display all contents in other tabs

View File

@ -3,6 +3,10 @@ zh_tw:
feed: 供給 feed: 供給
import: 匯入 import: 匯入
announcement: announcement:
cover_image_display_setting: 封面圖片顯示設定
full_width: 滿版呈現
up_left_corner: 左上角
up_right_corner: 右上角
all_tabs_setting: '"全部"頁籤設定' all_tabs_setting: '"全部"頁籤設定'
the_same_as_data_count: 與Data count相同 the_same_as_data_count: 與Data count相同
display_all_in_other_tabs: 顯示在其他頁籤的全部內容 display_all_in_other_tabs: 顯示在其他頁籤的全部內容

View File

@ -1,3 +1,11 @@
<style type="text/css">
.full-size-img img {
width: 100%;
}
.full-size-img {
width: 100%;
}
</style>
<article class="s-annc show-announcement"> <article class="s-annc show-announcement">
<h1 class="s-annc__show-title">{{title}}</h1> <h1 class="s-annc__show-title">{{title}}</h1>
@ -19,7 +27,7 @@
</ul> </ul>
<section class="s-annc__post-wrap"> <section class="s-annc__post-wrap">
<div class="s-annc__sub-img pull-right {{hide_class}}"> <div class="s-annc__sub-img {{hide_class}}">
<img src="{{img_src}}" alt="{{img_description}}"></img> <img src="{{img_src}}" alt="{{img_description}}"></img>
<span class="s-annc__img_description">{{img_description}}</span> <span class="s-annc__img_description">{{img_description}}</span>
</div> </div>