jQuery Frontier Calendar简介

jQuery Frontier Calendar是一个可灵活定制的月日历jQuery插件,同时利用了jquery.qtip和colorpicker.js。它看起来类似于Google Calendar。当在一个日期单元格中有比较多的待办事项 时,将出现一个更多的链接,点击这个链接会弹一个jQuery模式对话框来显示所有的事务。这个日历还支持通过CSS文件改变整个日历的背景。

 

其使用较为方便,首先引入其所需要的各类资源,而后像jQplot一样调用一个接口(jFrontierCal)设置显示数据和回调函数等处理方法。其调用格式如下所示:

var jfcalplugin = $('selector').jFrontierCal(date,dayClickCallback,agendaClickCallback,agendaDropCallback,dragAndDropEnabled)

参数说明见下表:

ParameterTypeDescription
datejavascript Date objectA Date object with the year and month you want the calendar initialized to. Remember that with javascript Dates the months start at 0 (Januaray=0)
dayClickCallbackfunctionA function that is triggered when a day cell is clicked. This is where you can create your customized add event form.
agendaClickCallbackfunctionA function that is triggered when an agenda item is clicked. This is where you can create your customized delete/edit agenda item form.
agendaDropCallbackfunctionA function that is called when an agenda item is dropped into a day cell. Here is where you could for example perform an AJAX call to update your database.
dragAndDropEnabledbooleanTrue to enable drag-and-drop, false to disable.

 

详细信息参见官网:http://code.google.com/p/jquery-frontier-calendar/

 

 简单实例(展现当月的所有日期,点击某日进行相应提示)如下所示

<%@page contentType="text/html; charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Frontier JQuery Calendar</title>

<link rel="stylesheet" type="text/css" href="css/frontierCalendar/jquery-frontier-cal-1.3.2.css" />
<!-- Include CSS for color picker plugin (Not required for calendar plugin. Used for example.) -->
<link rel="stylesheet" type="text/css" href="css/colorpicker/colorpicker.css" />
<link rel="stylesheet" type="text/css" href="css/jquery-ui/smoothness/jquery-ui-1.8.1.custom.css" />
<script type="text/javascript" src="js/jquery-core/jquery-1.4.2-ie-fix.min.js"></script>
<script type="text/javascript" src="js/jquery-ui/smoothness/jquery-ui-1.8.1.custom.min.js"></script>
<!-- Include color picker plugin (Not required for calendar plugin. Used for example.) -->
<script type="text/javascript" src="js/colorpicker/colorpicker.js"></script>
<!-- Include jquery tooltip plugin (Not required for calendar plugin. Used for example.) -->
<script type="text/javascript" src="js/jquery-qtip-1.0.0-rc3140944/jquery.qtip-1.0.js"></script>
<!--
    ** jshashtable-2.1.js MUST BE INCLUDED BEFORE THE FRONTIER CALENDAR PLUGIN. **
-->
<script type="text/javascript" src="js/lib/jshashtable-2.1.js"></script>
<script type="text/javascript" src="js/frontierCalendar/jquery-frontier-cal-1.3.2.min.js"></script>

<script type="text/javascript">
$(document).ready(function(){	
	/**
	 * Initialize with current year and date. Returns reference to plugin object.
	 */
	var jfcalplugin = $("#mycal").jFrontierCal({
		date: new Date(),
		dayClickCallback: myDayClickHandler,
		agendaClickCallback: myAgendaClickHandler,
		agendaDropCallback: myAgendaDropHandler,
		dragAndDropEnabled: true
	}).data("plugin");
	/**
	 * Get the date (Date object) of the day that was clicked from the event object
	 */
	function myDayClickHandler(eventObj){
		var date = eventObj.data.calDayDate;
		alert("You clicked day " + date.toDateString());
	};
	/**
	 * Get the agenda item that was clicked.
	 */
	function myAgendaClickHandler (eventObj){
		var agendaId = eventObj.data.agendaId;
		var agendaItem = jfcalplugin.getAgendaItemById("#mycal",agendaId);
	};
	/**
	 * get the agenda item that was dropped. It's start and end dates will be updated.
	 */
	function myAgendaDropHandler(eventObj){
		var agendaId = eventObj.data.agendaId;
		var date = eventObj.data.calDayDate;		
		var agendaItem = jfcalplugin.getAgendaItemById("#mycal",agendaId);		
		alert("You dropped agenda item " + agendaItem.title + 
			" onto " + date.toString() + ". Here is where you can make an AJAX call to update your database.");
	};

});

</script>

<body>
<form>
	<div >
		<h1 style="font-size: 30px; font-weight: bold;">jQuery Frontier Calendar</h1>
		
		<div id="mycal" title="View Agenda Item">
		</div>		
	
	</div>
</form>
</body>
</html>


 

之前在网上想找一个简单易用的周日历选择插件,发现这种前端周日历插件很少,而且很多文章写的周的算法都不是统一的,所以自己实现了一个基于jquery的周日历插件(还支持跳转到指定年份和周哦)。 插件中周的算法:每周以周日为起始,第一周以每年第一个星期四所在的周为第一周(网上找的好像这个算法比较正规) 实现的效果是在手机端,也可以在PC端用,毕竟功能才是主要的。如果觉得样式不入眼可以自行随意修改。 //调用周日历方法 var weekfn = new jcalendar_week({ element: "#jcalendar_week",//填充日历的dom元素 dayaddclass:function(date){ //添加某天时给添加类名(参数:1.日期)(返回类名字符串,多个以空格分开) return ""; }, dayclick:function(date,obj){ //day点击事件(参数:1.日期,2.所点击DOM元素) $(obj).addClass("calendar_day_act").siblings().removeClass("calendar_day_act"); } }); 点击上方显示当前年份和周的DOM部分可选择并跳转到指定年份和周。 插件提供的方法: //获取周第一天方法weekfirstdate(),传入年份和周数 console.log(weekfn.weekfirstdate(2018,36)); //获取传入日期为当年第几周getweeknum(),传入年,月,日(注:这里的月份从0开始) console.log(weekfn.getweeknum(2018,0,16)); //跳转到指定周confirmweek(),传入年份和周数 weekfn.confirmweek(getyear,getweek); //跳转到本周nowweek() weekfn.nowweek();
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值