Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="calendar">


                #calendar {
  width: 80%;

/* ------- Agenda View ------- */
#agendaView > table{
    width: 100%;
    min-height: 500px;
    background: #FFF;

#agendaView .fc-agendaView-event-start,
#agendaView .fc-agendaView-event-end{
    width: 20%;

#agendaView .fc-agendaView-event-title{
    width: 60%;
#agendaView th{
    height: 30px;
    font-size: 14px;
    vertical-align: text-bottom;
    font-weight: bold;
    padding: 10px 0 0 10px;

#agendaView td{
    height: 30px;
    padding: 10px 0 0 10px;
    font-size: 14px;
    vertical-align: text-bottom;    



                var $calendar = $("#calendar");
            header: {
                left: ' today,prev,next,  title',
                right: 'month,agendaWeek,agendaDay '
            weekends: true,
            allDaySlot: true,
            droppable: true, /* 允許拖入 */
                var header =  $calendar.find(".fc-header");
                // trigger current view
                header.find('.fc-header-right').find('.fc-button').off('mouseup').on('mouseup', function(){
                        $"view", '');

                if( $"view") != 'agendaView' ){
                    header.find(".fc-button-agendaView").removeClass('fc-state-active active');


            eventRender: function(event, e){

                currentView = $('#calendar').fullCalendar('getView').name; /* 用來偵測哪個view進行什麼樣的處理用 */
            },dayClick: function(date, jsEvent, view) { 
              /* 點選日期觸發 */

            eventClick: function(calEvent, jsEvent, view) {
                console.log("===== eventClick =====");


    var headerRight = $calendar.find(".fc-header").find(".fc-header-right");

    var agendaBtn = headerRight.find(".fc-corner-right").removeClass('fc-corner-right')
                    .clone().addClass('fc-corner-right fc-button-agendaView').removeClass('fc-button-agendaDay').text("agenda");

    agendaBtn.on('click', function(){

// test event data
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();

var newEvent = {
  title: 'NEW EVENT',
  start: new Date(y, m, d, 10),
  end: new Date(y, m, d, 15),
  editable: true

// add event to calendar
var event = $('#calendar').fullCalendar( 'renderEvent', newEvent , 'stick');

function renderAgendaView(){

  if($calendar.fullCalendar('getView') != 'agendaView'){
    // 複製原本的month為agendaView ,這樣可解決切換為agenda View時 month 無法點之問題
    $calendar.fullCalendar( 'changeView', 'month' );
    var newView = $calendar.fullCalendar('getView'); = 'agendaView';

    $calendar.fullCalendar( 'changeView', 'agendaView' );

  // get current events in memory
  var events = $calendar.fullCalendar( 'clientEvents' );

  // get current date
  var currentDate = $calendar.fullCalendar( 'getDate' );

  $"view", 'agendaView');
  var agendaViewHtml = document.createElement('div');
  agendaViewHtml.setAttribute("id", "agendaView");
  var contents = "<table>" + 
      "<thead><tr>" +
      "<th class='fc-widget-header fc-agendaView-event-start'>DateStart</th>" + 
      "<th class='fc-widget-header fc-agendaView-event-end'>DateEnd</th>" + 
      "<th class='fc-widget-header fc-agendaView-event-title'>Event</th>" +
      "</tr></thead>" + 

  for (key in events) {
    //  detect month range
    var monthRange = moment().range(moment(currentDate).startOf('month'), moment(currentDate).endOf('month'));
    var eventStart = moment(events[key].start).format("YYYY/MM/DD-H:mm:ss");
    var eventEnd = moment(events[key].end).format("YYYY/MM/DD-H:mm:ss");
    if(monthRange.contains(events[key].start) && monthRange.contains(events[key].end)){
      var eventTitle = events[key].title;
      contents += '<tr>' + 
        '<td class="fc-widget-content">' + eventStart + '</td>' + 
        '<td class="fc-widget-content">' + eventEnd + '</td>' + 
        '<td class="fc-widget-content">' + eventTitle + '</td>' + 

  contents += "</tbody></table>";
  agendaViewHtml.innerHTML = contents;

  // console.log(events);