|
イベントの背景カラーを設定出来るように変更
modelにclassnameを追加
1.app/controllers/events_cintroller.rb
@events = Event.find(:all, :select => 'id, title, start, end, allday, classname',
:conditions => ["start >= ? AND end <= ?",searchstart, searchend]).map{|e|
{
:id => e.id,
:title => e.title,
:start => e.start,
:end => e.end,
:allDay => e.allday,
:url => event_path(e.id),
#追加
:className => e.classname
}
}
2.app/views/events/new.html.erbとapp/views/events/edit.html.erb
以下を追加
<div class="group">
<%= f.label :classname, Event.human_attribute_name('classname'), :class => :label %>
<%= f.select(:classname, [["red","classname_red"],["blue","classname_blue"],["yellow","classname_yellow"],["green","classname_green"]]) %>
<span class="description">Ex: a simple text</span>
</div>
3.public/fullcalendar/fullcalendar.css
以下を追加
/* Use the 'className' CalEvent property and the following
* example CSS to change event color on a per-event basis:
*
* .my-event-class,
* .my-event-class a {
* border-color: black;
* background-color: black;
* color: red;
* }
*/
.classname_red,
.classname_red a {
border-color: #FF0000;
background-color: #FF0000;
color: #fff;
}
.classname_blue,
.classname_blue a {
border-color: #36c;
background-color: #36c;
color: #fff;
}
.classname_yellow,
.classname_yellow a {
border-color: #FFFF99;
background-color: #FFFF99;
color: black;
}
.classname_green,
.classname_green a {
border-color: #99FF99;
background-color: #99FF99;
color: black;
}
|