From a5a25c56849123d4f6c0ea984c5e27b8e0d9f569 Mon Sep 17 00:00:00 2001 From: Bohung Date: Fri, 21 May 2021 15:48:40 +0800 Subject: [PATCH] Add cover image setting. --- app/controllers/announcements_controller.rb | 2 +- app/models/bulletin.rb | 1 + app/views/admin/announcements/_form.html.erb | 15 +++++++++++++++ config/locales/en.yml | 4 ++++ config/locales/zh_tw.yml | 4 ++++ modules/announcement/show.html.erb | 10 +++++++++- 6 files changed, 34 insertions(+), 2 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index c23e2b3..c8dfb34 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -590,7 +590,7 @@ class AnnouncementsController < ApplicationController "image" => announcement.image.url, "img_src" => img_src, "img_description" => img_description, - "hide_class" => announcement.display_img? ? '' : ' hide', + "hide_class" => announcement.display_img? ? announcement.image_display_class : ' hide', "alt_title" => desc, "resume_btn_title" => resume_btn_title, "pause_btn_title" => pause_btn_title, diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 3551b60..a669e03 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -26,6 +26,7 @@ class Bulletin before_destroy do AnnsCache.all.destroy 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 :calendar_start_date, :type => DateTime field :calendar_end_date, :type => DateTime diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index 3dbb71f..6d8954c 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -114,6 +114,20 @@ <%= f.check_box :display_img %> + + + <% image_display_class_relation = {"full_width"=>"full-size-img","up_left_corner"=>"pull-left","up_right_corner"=>"pull-right"} %> +
+ <%= f.label :image_display_class, t("announcement.cover_image_display_setting"), :class => "control-label muted" %> +
+ <% image_display_class_relation.each.with_index do |(key,value),i| %> + + <% end %> +
+
@@ -518,6 +532,7 @@ }