首页 > 其他分享 >js插件fullcalendar配置项及样例

js插件fullcalendar配置项及样例

时间:2022-12-02 17:00:19浏览次数:59  
标签:building 插件 项及 title fullcalendar 564 Pacific id Auditorium

 部分配置项

<link href="./plugins/fullcalendar-5.11.2/lib/main.css" rel="stylesheet" />

<script type="text/javascript" language="javascript" src="./plugins/jquery/jquery-1.9.1.min.js"></script>
<script type="text/javascript" language="javascript" src="./plugins/fullcalendar-5.11.2/lib/main.min.js"></script>
<script type="text/javascript" language="javascript" src="./plugins/fullcalendar-5.11.2/lib/locales-all.min.js"></script>

<div class="calendar" id="calendar"></div>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    var calendarEl = document.getElementById("calendar");
    var calendar = new FullCalendar.Calendar(calendarEl, {
      locale: "zh-cn",
      themeSystem: "standard", //样式主题
      height: "auto", //高度自动
      aspectRatio: 1.35, //宽高比
      initialView: "dayGridMonth",

      //自定义按钮
      customButtons: {
        myCustomButton: {
          text: "custom!",
          click: function () {
            alert("clicked the custom button!");
          },
        },
      },
      headerToolbar: {
        left: "prevYear,prev,next,nextYear today myCustomButton",
        center: "title",
        right: "dayGridMonth,timeGridWeek,timeGridDay,listMonth",
      },
      //自定义按钮文本内容
      views: {
        listMonth: { buttonText: "list month" },
      },
      footerToolbar: false,
      dayHeaders: true, //是否显示日历中首行的周一至周日行

      buttonIcons: false, //按钮图标用文本替代
      weekends: true, //是否显示周六日
      hiddenDays: [], //排除掉一周中的第几天,Sunday=0
      weekNumbers: true, //是否显示当前是第几周
      editable: true, //是否日历上的事件可以被修改
      selectable: true, //是否允许用户选择连续的多日
      select: function (arg) {
        var title = prompt("Event Title:");
        if (title) {
          calendar.addEvent({
            title: title,
            start: arg.start,
            end: arg.end,
            allDay: arg.allDay,
          });
        }
        calendar.unselect();
      },
      eventClick: function (arg) {
        if (confirm("Are you sure you want to delete this event?")) {
          arg.event.remove();
        }
      },
      droppable: true, //是否允许接收外部事件
      unselectAuto: true, //用户点击其它区域时,目前选择区域是否清空,selectable=true时生效
      navLinks: true, //定义单元格是否可点击
      slotMinTime: "08:00", //定义每天的时间范围
      slotMaxTime: "20:00",
      dayMaxEvents: true, // 事件太多时添加more按钮
      businessHours: [
        {
          daysOfWeek: [1, 2, 3], // Monday, Tuesday, Wednesday
          startTime: "08:00", // 8am
          endTime: "18:00", // 6pm
        },
        {
          daysOfWeek: [4, 5], // Thursday, Friday
          startTime: "10:00", // 10am
          endTime: "16:00", // 4pm
        },
      ],
      navLinkDayClick: function (date, jsEvent) {
        console.log("day", date.toISOString());
        console.log("coords", jsEvent.pageX, jsEvent.pageY);
      },

      dateClick: function (info) {
        alert(info.dateStr + " has been clicked!");
      },
      events: [
        {
          title: "Business Lunch",
          start: "2022-12-01T13:00:00",
          constraint: "businessHours",
        },
        {
          title: "Meeting",
          start: "2022-12-01T11:00:00",
          constraint: "availableForMeeting", // defined below
          color: "#257e4a",
        },
        {
          groupId: 999,
          title: "Group Event",
          start: "2022-12-06T16:00:00",
        },
        {
          groupId: 999,
          title: "Group Event",
          start: "2022-12-07T16:00:00",
        },
        {
          title: "Click for baidu",
          url: "https://www.baidu.com/",
          start: "2022-12-05T16:00:00",
        },

        // areas where "Meeting" must be dropped
        {
          groupId: "availableForMeeting",
          start: "2022-12-07T10:00:00",
          end: "2022-12-07T12:00:00",
          display: "background",
        },
        // red areas where no events can be dropped
        {
          start: "2022-12-02",
          end: "2022-12-03",
          overlap: false,
          display: "background",
          color: "#ff9f89",
        },
      ],
    });
    calendar.render();

    calendar.on("dateClick", function (info) {
      console.log("clicked on " + info.dateStr);
    });
  });
</script>

 

 页面如下:

 

 Premium 部分样例 

<link href="./plugins/fullcalendar-5.11.2/fullcalendar-scheduler/main.min.css" rel="stylesheet" />

<script type="text/javascript" language="javascript" src="./plugins/fullcalendar-5.11.2/fullcalendar-scheduler/main.min.js"></script>
<script type="text/javascript" language="javascript" src="./plugins/fullcalendar-5.11.2/lib/locales-all.min.js"></script>

<div class="calendar" id="calendar" style="margin: 2rem auto"></div>
<div class="calendar" id="calendar1" style="margin: 2rem auto"></div>
<div class="calendar" id="calendar2" style="margin: 2rem auto"></div>
<div class="calendar" id="calendar3" style="margin: 2rem auto"></div>
<div class="calendar" id="calendar4" style="margin: 2rem auto"></div>
<script>
  document.addEventListener("DOMContentLoaded", function () {
    var calendarEl = document.getElementById("calendar");

    var calendar = new FullCalendar.Calendar(calendarEl, {
      schedulerLicenseKey: "CC-Attribution-NonCommercial-NoDerivatives",
      timeZone: "Asia/Shanghai",
      headerToolbar: {
        left: "today prev,next",
        center: "title",
        right: "resourceTimelineDay,resourceTimelineTenDay,resourceTimelineMonth,resourceTimelineYear",
      },
      initialView: "resourceTimelineDay",
      scrollTime: "08:00",
      aspectRatio: 1.5,
      views: {
        resourceTimelineDay: {
          buttonText: ":15 slots",
          slotDuration: "00:15",
        },
        resourceTimelineTenDay: {
          type: "resourceTimeline",
          duration: { days: 10 },
          buttonText: "10 days",
        },
      },
      editable: true,
      resourceAreaHeaderContent: "Rooms",
      resources: "http://localhost:3000/html-demos/files/resources.json?with-nesting&with-colors",
      // events: "http://localhost:3000/html-demos/files/events-for-resources.json?single-day&for-resource-timeline",
      events: {
        url: "../test.php",
        method: "POST",
        extraParams: {
          custom_param1: "something",
          custom_param2: "somethingelse",
        },
        failure: function () {
          alert("there was an error while fetching events!");
        },
      },

      eventSources: [
        {
          url: "../test1.php",
          method: "POST",
          extraParams: {
            custom_param1: "something",
            custom_param2: "somethingelse",
          },
          failure: function () {
            alert("there was an error while fetching events!");
          },
          color: "yellow",
          textColor: "black",
        },
      ],
    });

    calendar.render();
  });
</script>

 

 

<script>
  document.addEventListener("DOMContentLoaded", function () {
    var calendarEl = document.getElementById("calendar1");

    var calendar = new FullCalendar.Calendar(calendarEl, {
      schedulerLicenseKey: "CC-Attribution-NonCommercial-NoDerivatives",
      headerToolbar: {
        left: "today prev,next",
        center: "title",
        right: "resourceTimelineDay,resourceTimelineWeek",
      },
      aspectRatio: 1.5,
      initialView: "resourceTimelineDay",
      resourceAreaWidth: "40%",
      resourceAreaColumns: [
        {
          group: true,
          field: "building",
          headerContent: "Building",
        },
        {
          field: "title",
          headerContent: "Room",
        },
        {
          field: "occupancy",
          headerContent: "Occupancy",
        },
      ],
      resources: [
        { id: "a", building: "460 Bryant", title: "Auditorium A", occupancy: 40 },
        { id: "b", building: "460 Bryant", title: "Auditorium B", occupancy: 40 },
        { id: "c", building: "460 Bryant", title: "Auditorium C", occupancy: 40 },
        { id: "d", building: "460 Bryant", title: "Auditorium D", occupancy: 40 },
        { id: "e", building: "460 Bryant", title: "Auditorium E", occupancy: 40 },
        { id: "f", building: "460 Bryant", title: "Auditorium F", occupancy: 40 },
        { id: "g", building: "564 Pacific", title: "Auditorium G", occupancy: 40 },
        { id: "h", building: "564 Pacific", title: "Auditorium H", occupancy: 40 },
        { id: "i", building: "564 Pacific", title: "Auditorium I", occupancy: 40 },
        { id: "j", building: "564 Pacific", title: "Auditorium J", occupancy: 40 },
        { id: "k", building: "564 Pacific", title: "Auditorium K", occupancy: 40 },
        { id: "l", building: "564 Pacific", title: "Auditorium L", occupancy: 40 },
        { id: "m", building: "564 Pacific", title: "Auditorium M", occupancy: 40 },
        { id: "n", building: "564 Pacific", title: "Auditorium N", occupancy: 40 },
        { id: "o", building: "564 Pacific", title: "Auditorium O", occupancy: 40 },
        { id: "p", building: "564 Pacific", title: "Auditorium P", occupancy: 40 },
        { id: "q", building: "564 Pacific", title: "Auditorium Q", occupancy: 40 },
        { id: "r", building: "564 Pacific", title: "Auditorium R", occupancy: 40 },
        { id: "s", building: "564 Pacific", title: "Auditorium S", occupancy: 40 },
        { id: "t", building: "564 Pacific", title: "Auditorium T", occupancy: 40 },
        { id: "u", building: "564 Pacific", title: "Auditorium U", occupancy: 40 },
        { id: "v", building: "564 Pacific", title: "Auditorium V", occupancy: 40 },
        { id: "w", building: "564 Pacific", title: "Auditorium W", occupancy: 40 },
        { id: "x", building: "564 Pacific", title: "Auditorium X", occupancy: 40 },
        { id: "y", building: "564 Pacific", title: "Auditorium Y", occupancy: 40 },
        { id: "z", building: "564 Pacific", title: "Auditorium Z", occupancy: 40 },
      ],
    });

    calendar.render();
  });
</script>

 

  

<script>
  document.addEventListener("DOMContentLoaded", function () {
    var calendarEl = document.getElementById("calendar2");

    var calendar = new FullCalendar.Calendar(calendarEl, {
      schedulerLicenseKey: "CC-Attribution-NonCommercial-NoDerivatives",
      headerToolbar: {
        left: "today prev,next",
        center: "title",
        right: "resourceTimelineDay,resourceTimelineWeek",
      },
      aspectRatio: 1.6,
      initialView: "resourceTimelineDay",
      resourceGroupField: "building",
      resources: [
        { id: "a", building: "460 Bryant", title: "Auditorium A" },
        { id: "b", building: "460 Bryant", title: "Auditorium B" },
        { id: "c", building: "460 Bryant", title: "Auditorium C" },
        { id: "d", building: "460 Bryant", title: "Auditorium D" },
        { id: "e", building: "460 Bryant", title: "Auditorium E" },
        { id: "f", building: "460 Bryant", title: "Auditorium F" },
        { id: "g", building: "564 Pacific", title: "Auditorium G" },
        { id: "h", building: "564 Pacific", title: "Auditorium H" },
        { id: "i", building: "564 Pacific", title: "Auditorium I" },
        { id: "j", building: "564 Pacific", title: "Auditorium J" },
        { id: "k", building: "564 Pacific", title: "Auditorium K" },
        { id: "l", building: "564 Pacific", title: "Auditorium L" },
        { id: "m", building: "564 Pacific", title: "Auditorium M" },
        { id: "n", building: "564 Pacific", title: "Auditorium N" },
        { id: "o", building: "101 Main St", title: "Auditorium O" },
        { id: "p", building: "101 Main St", title: "Auditorium P" },
        { id: "q", building: "101 Main St", title: "Auditorium Q" },
        { id: "r", building: "101 Main St", title: "Auditorium R" },
        { id: "s", building: "101 Main St", title: "Auditorium S" },
        { id: "t", building: "101 Main St", title: "Auditorium T" },
        { id: "u", building: "101 Main St", title: "Auditorium U" },
        { id: "v", building: "101 Main St", title: "Auditorium V" },
        { id: "w", building: "101 Main St", title: "Auditorium W" },
        { id: "x", building: "101 Main St", title: "Auditorium X" },
        { id: "y", building: "101 Main St", title: "Auditorium Y" },
        { id: "z", building: "101 Main St", title: "Auditorium Z" },
      ],
    });

    calendar.render();
  });
</script>

 

 

<script>
  document.addEventListener("DOMContentLoaded", function () {
    var calendarEl = document.getElementById("calendar3");

    var calendar = new FullCalendar.Calendar(calendarEl, {
      schedulerLicenseKey: "CC-Attribution-NonCommercial-NoDerivatives",
      timeZone: "UTC",
      initialView: "resourceTimeGridFourDay",
      datesAboveResources: true,
      headerToolbar: {
        left: "prev,next",
        center: "title",
        right: "resourceTimeGridDay,resourceTimeGridFourDay",
      },
      views: {
        resourceTimeGridFourDay: {
          type: "resourceTimeGrid",
          duration: { days: 4 },
          buttonText: "4 days",
        },
      },
      resources: [
        { id: "a", title: "Room A" },
        { id: "b", title: "Room B" },
      ],
    });

    calendar.render();
  });
</script>

 

<script>
  document.addEventListener("DOMContentLoaded", function () {
    var calendarEl = document.getElementById("calendar4");

    var calendar = new FullCalendar.Calendar(calendarEl, {
      schedulerLicenseKey: "CC-Attribution-NonCommercial-NoDerivatives",
      timeZone: "UTC",
      initialView: "resourceTimeGridFourDay",
      headerToolbar: {
        left: "prev,next",
        center: "title",
        right: "resourceTimeGridDay,resourceTimeGridFourDay",
      },
      views: {
        resourceTimeGridFourDay: {
          type: "resourceTimeGrid",
          duration: { days: 4 },
          buttonText: "4 days",
        },
      },
      resources: [
        { id: "a", title: "Room A" },
        { id: "b", title: "Room B" },
      ],
    });

    calendar.render();
  });
</script>

 

标签:building,插件,项及,title,fullcalendar,564,Pacific,id,Auditorium
From: https://www.cnblogs.com/caroline2016/p/16944968.html

相关文章

  • 使用fullcalendar构建简单会议室预约页面
    <linkhref="./plugins/fullcalendar-5.11.2/fullcalendar-scheduler/main.min.css"rel="stylesheet"/><scripttype="text/javascript"language="javascript"src=".......
  • vue中swiper轮播插件的一个错误
    在引入插件的时候无论如何也不生效,后来发现2.添加HTML内容。Swiper7的默认容器是'.swiper',Swiper6之前是'.swiper-container'。<divclass="swiper"><divclass="s......
  • RLM:AMPED破解插件软件安装方法V3(Win/Mac/Linux)
    AMPED软件安装方法V3(Win/Mac/Linux)    一、AMPED软件的应用范围      二、win 1、拷贝RLM_Windows文件夹到C盘根目录"C:\";2、在C:......
  • KBL406-ASEMI插件整流桥KBL406
    编辑:llKBL406-ASEMI插件整流桥KBL406型号:KBL406品牌:ASEMI封装:KBL-4特性:整流桥正向电流:4A反向耐压:600V恢复时间:>2000ns引脚数量:4芯片个数:4芯片尺寸:84MIL浪涌电流:120A 漏电流:>......
  • KBL406-ASEMI插件整流桥KBL406
    编辑:llKBL406-ASEMI插件整流桥KBL406型号:KBL406品牌:ASEMI封装:KBL-4特性:整流桥正向电流:4A反向耐压:600V恢复时间:>2000ns引脚数量:4芯片个数:4芯片尺寸:84MIL浪涌电......
  • 一个不错的生成条形码的jquery插件兼介绍条形码
    首先介绍下条形码的原理先:条形码技术最早产生在风声鹤唳的二十年代,诞生于Westinghouse的实验室里。一位名叫JohnKermode性格古怪的发明家“异想天开......
  • 强烈推荐:240多个jQuery插件
    概述jQuery是继prototype之后又一个优秀的Javascript框架。其宗旨是—写更少的代码,做更多的事情。它是轻量级的js库(压缩后只有21k),这是其它的js库所不​​​​......
  • vscode编辑器设置背景图片(background-cover插件)以及代码颜色,编辑器其他颜色设置
    vscode编辑器设置背景图片(background-cover插件)以及代码颜色,编辑器其他颜色设置对着编辑器敲久了,看着编辑器总是一种颜色,有点厌烦,这时我们可以自己定义背景颜色或者背景......
  • 火狐firebug和firepath插件安装方法
    火狐浏览器下掉了firebug和firepath插件,用户即使下载了火狐55以下的版本,也无法查找到这两个插件。可以用以下方法来获取这两个插件。第1步:下载火狐55以内版本安装包,安装时......
  • Photoshop CS3 ICO 图标保存插件
    最近编程发现,没有啥好看的图标文件于是,本人使用功能强大的ps,制作了图标文件做后发现,无法保存为ico图标文件在网上搜索了半天,终于从茫茫网海找到ico保存插件下载存放的地方是......