diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 78c1fb9..ccbd0df 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -596,7 +596,7 @@ class AnnouncementsController < ApplicationController "pause_btn_title" => pause_btn_title, "prev_btn_title" => prev_btn_title, "next_btn_title" => next_btn_title, - "carousel_display_style" => (bulletin_carousel_images.count == 0 ? 'display: none' : 'width: 50%;margin: auto;'), + "carousel_display_style" => (bulletin_carousel_images.count == 0 ? 'display: none' : "width: #{announcement.carousel_image_width};margin: auto;"), "carousel_count" => bulletin_carousel_images.count }, "comments" => announcement.comments, @@ -680,7 +680,7 @@ class AnnouncementsController < ApplicationController "pause_btn_title" => pause_btn_title, "prev_btn_title" => prev_btn_title, "next_btn_title" => next_btn_title, - "carousel_display_style" => (bulletin_carousel_images.count == 0 ? 'display: none' : 'width: 50%;margin: auto;'), + "carousel_display_style" => (bulletin_carousel_images.count == 0 ? 'display: none' : "width: #{AnnouncementSetting.last.carousel_image_width};margin: auto;"), "carousel_count" => bulletin_carousel_images.count }, "comments" => [], diff --git a/app/models/announcement_setting.rb b/app/models/announcement_setting.rb index e4a7810..3f19b45 100644 --- a/app/models/announcement_setting.rb +++ b/app/models/announcement_setting.rb @@ -1,7 +1,7 @@ class AnnouncementSetting include Mongoid::Document include Mongoid::Timestamps - + field :carousel_image_width, type: String, :default => "75%" field :top_limit, type: Integer, :default => 0 field :pro_enabled, type: Boolean, :default => false field :approvers, type: Array, :default => [] diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index a669e03..1076a5f 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 :custom_carousel_image_width, type: String, default: "" 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 @@ -222,4 +223,7 @@ class Bulletin def hidden_text I18n.t("announcement.status.hidden") end + def carousel_image_width + (self.custom_carousel_image_width.blank? ? AnnouncementSetting.last.carousel_image_width : self.custom_carousel_image_width) + end end diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index 6d8954c..68a8732 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -303,6 +303,12 @@