【问题标题】:How to mark "current time" in calendar view and custom titles如何在日历视图和自定义标题中标记“当前时间”
【发布时间】:2011-04-13 13:51:13
【问题描述】:

到目前为止,我一直对FullCalendar 的灵活性感到惊讶,但以下两个元素让我卡住了;

  1. 有没有什么方法可以让当前时间在列出小时的日视图中以粗体显示,而不需要过多的修改?

  2. 有没有办法改变日历元素的标题,到目前为止,它只需要用月份名称或类似名称替换的占位符“变量”,但我希望能够指定我自己的标题对他们来说(这很容易通过将它添加到元素上方来完成,但是如果可以在其中添加它,那为什么不呢,对吧?)

【问题讨论】:

  • 对于#1,仅在查看今天时应该将时间加粗,还是不考虑日期加粗?您是指“基本日”视图、“议程日”视图还是两者兼而有之?

标签: javascript jquery fullcalendar


【解决方案1】:

对于 #1 Agenda DAY 视图,我看到此代码

<tr class="fc-slot22 ">
  <th class="fc-agenda-axis fc-widget-header">11am</th>
  <td class="fc-widget-content"><div style="position:relative">&nbsp;</div></td>
</tr>
<tr class="fc-slot23 fc-minor">
  <th class="fc-agenda-axis fc-widget-header">&nbsp;</th>
  <td class="fc-widget-content"><div style="position:relative">&nbsp;</div></td>
</tr>
<tr class="fc-slot24 ">
   <th class="fc-agenda-axis fc-widget-header">12pm</th>
   <td class="fc-widget-content"><div style="position:relative">&nbsp;</div></td>
</tr>

所以我们需要看看 TH:

var nowHours = new Date().getHours(); 
var hourAMPM = (nowHours>12)?(nowHours-12)+"pm":nowHours+"am";
if (nowHours===12) hourAMPM ="12pm";
$("th").removeClass("nowtime");
$("th").contains(hourAMPM).addClass("nowtime");

对于 #1 到粗体日历当前 DAY 更改

.fc-state-highlight {
    background: none repeat scroll 0 0 #FFFFCC;
}

.fc-state-highlight {
    background: none repeat scroll 0 0 #FFFFCC;
    font-weight: bold;
}

#2 你可以改变

<span class="fc-header-title">
<h2>April‌·2011</h2>
</span>

创建日历后随心所欲

【讨论】:

  • 确实,我认为这就是解决问题的方法,我只是希望有一些我目前不知道的功能可以更改它们,谢谢您的反馈!跨度>
  • @Strifariz 也许作者会很高兴看到这个?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-07-13
  • 1970-01-01
相关资源
最近更新 更多