小版本的fullcalendar
问题描述:
我希望有人可以告诉我如何获得一个非常小的FullCalendar版本(或类似的东西),将做一个没有标题的小部件大小日历,只是日期的事件,可点击彩色块。我在一个非常棒的WordPress站点中使用fullcalendar,但所有的谷歌日历小工具真的很烂!小版本的fullcalendar
答
您可以通过添加一点CSS来制作一个功能完整的小版本。我不得不添加一个“eventMouseover”回调函数将事件名称添加到title属性中,这样您可以在工具提示中看到它的名称。
下面是迷你尺寸日历(200 x 225)和demo的屏幕截图。
的CSS
#calendar {
width: 200px;
margin: 0 auto;
font-size: 10px;
}
.fc-header-title h2 {
font-size: .9em;
white-space: normal !important;
}
.fc-view-month .fc-event, .fc-view-agendaWeek .fc-event {
font-size: 0;
overflow: hidden;
height: 2px;
}
.fc-view-agendaWeek .fc-event-vert {
font-size: 0;
overflow: hidden;
width: 2px !important;
}
.fc-agenda-axis {
width: 20px !important;
font-size: .7em;
}
.fc-button-content {
padding: 0;
}
的Javascript
$(document).ready(function() {
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
editable: true,
// add event name to title attribute on mouseover
eventMouseover: function(event, jsEvent, view) {
if (view.name !== 'agendaDay') {
$(jsEvent.target).attr('title', event.title);
}
}
});
});
更新地:周水平视事件更小,并且所有的事件2px的宽或高,使它更容易悬停在他们身上。
更新V2.4 +不是更新上面的答案,我就发布修改后的代码我用来做FullCalendar V2.4微小(demo)
CSS
#calendar {
width: 200px;
margin: 0 auto;
font-size: 10px;
}
.fc-toolbar {
font-size: .9em;
}
.fc-toolbar h2 {
font-size: 12px;
white-space: normal !important;
}
/* click +2 more for popup */
.fc-more-cell a {
display: block;
width: 85%;
margin: 1px auto 0 auto;
border-radius: 3px;
background: grey;
color: transparent;
overflow: hidden;
height: 4px;
}
.fc-more-popover {
width: 100px;
}
.fc-view-month .fc-event, .fc-view-agendaWeek .fc-event, .fc-content {
font-size: 0;
overflow: hidden;
height: 2px;
}
.fc-view-agendaWeek .fc-event-vert {
font-size: 0;
overflow: hidden;
width: 2px !important;
}
.fc-agenda-axis {
width: 20px !important;
font-size: .7em;
}
.fc-button-content {
padding: 0;
}
的Javascript
$(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
eventAfterRender: function() {
// add titles to "+# more links"
$('.fc-more-cell a').each(function() {
this.title = this.textContent;
});
},
// add event name to title attribute on mouseover
eventMouseover: function (event, jsEvent, view) {
if (view.name !== 'agendaDay') {
$(jsEvent.target).attr('title', event.title);
}
},
editable: true,
eventLimit: true // allow "more" link when too many events
});
});
你好,这是伟大的。非常感谢你。但它似乎并不完全适用于FullCalenar 2.0。 单元呈现为较大(垂直)。你有没有想法如何解决这个问题? – Dave 2015-11-11 10:10:34
Hi @Dave!我更新了我的答案 - [新演示](http://jsfiddle.net/Mottie/G6K6Y/1482/) - 更改为“+2更多”链接添加标题和灰色背景,并减少流行音乐大小。 – Mottie 2015-11-12 17:46:23
这很光滑,谢谢分享 – KTU 2017-03-29 19:26:29