UXC.LunarCalendar Class
农历日历组件
全局访问请使用 UXC.LunarCalendar 或 LunarCalendar
DOM 加载完毕后
, LunarCalendar会自动初始化页面所有具备识别符的日历, 目前可识别: div.jsLunarCalendar, td.jsLunarCalendar, li.js_LunarCalendar
Ajax 加载内容后, 如果有日历组件需求的话, 需要手动初始化 var ins = new UXC.LunarCalendar( _selector );
初始化时, 如果日历是添加到某个selector里, 那么selector可以指定一些设置属性
hidecontrol: 如果设置该属性, 那么日历将隐藏操作控件
minvalue: 设置日历的有效最小选择范围, 格式YYYY-mm-dd
maxvalue: 设置日历的有效最大选择范围, 格式YYYY-mm-dd
nopreviousfestivals: 不显示上个月的节日
nonextfestivals: 不显示下个月的节日
require: jQuery
require: window.cloneDate
require: window.parseISODate
require: window.maxDayOfMonth
require: window.isSameDay
require: window.isSameMonth
Constructor
UXC.LunarCalendar
-
_container
-
_date
Parameters:
-
_container
Selector指定要显示日历的选择器, 如果不显示指定该值, 默认为 document.body
-
_date
Date日历的当前日期, 如果不显示指定该值, 默认为当天
Item Index
Methods
- _init
- comment static
- commentTitle static
- getAllDate
- getComment static
- getContainer
- getDate
- getFestivals static
- getItemByTimestamp static
- getLayout
- getSelectedDate
- getSelectedDateGlobal static
- getSelectedItemGlobal static
- gregorianToLunar static
- holiday static
- isComment static
- isHideControl
- isHoliday static
- isWorkday static
- nextMonth
- nextYear
- preMonth
- preYear
- update
- updateStatus static
- UXC.LunarCalendar.getFestival.intPad static
- workday static
Properties
- _model
- _view
- autoinit static
- commentSeparator static
- defaultYearSpan static
- tpl static
Methods
_init
()
private
LunarCalendar 内部初始化
comment
-
_td
-
_customSet
添加或者清除注释
Parameters:
-
_td
Selector要设置注释的 td
-
_customSet
String | Bool如果 _customSet 为 undefined, 将清除注释. 如果 _customSet 为 string, 将添加注释
commentTitle
-
_td
-
_title
把注释添加到 a title 里
Parameters:
-
_td
Selector要设置注释的 a 父容器 td
-
_title
String | Undefined如果 _title 为真, 将把注释添加到a title里. 如果 _title 为假, 将从 a title 里删除注释
getAllDate
()
Object
获取所有的默认时间对象
Returns:
getContainer
()
获取初始化日历的选择器对象
Returns:
getFestivals
-
_lunarDate
-
_greDate
返回农历和国历的所在日期的所有节日
假日条目数据样例: { 'name': '春节', 'fullname': '春节', 'priority': 8 }
返回数据格式: { 'dayName': 农历日期/节日名, 'festivals': 节日数组, 'isHoliday': 是否为假日 }
Returns:
getItemByTimestamp
-
_tm
从时间截获取选择器对象
Parameters:
-
_tm
Int时间截, 如果时间截少于13位, 将自动补0到13位, ps: php时间截为10位
Returns:
getLayout
()
获取日历的主选择器对象
Returns:
getSelectedDateGlobal
()
Date | Undefined
static
从所有的LunarCalendar取得当前选中日期的日期对象
如果用户没有显式选中某个日期, 将尝试获取当前日期, 如果两者都没有返回undefined
Returns:
getSelectedItemGlobal
()
Object | Undefined
static
从所有的LunarCalendar取得当前选中的日期
如果用户没有显式选中某个日期, 将尝试获取当前日期, 如果两者都没有返回undefined
Returns:
gregorianToLunar
-
_date
从公历日期获得农历日期
返回的数据格式
{ shengxiao: '' //生肖 , ganzhi: '' //干支 , yue: '' //月份 , ri: '' //日 , shi: '' //时 , year: '' //农历数字年 , month: '' //农历数字月 , day: '' //农历数字天 , hour: '' //农历数字时 };
Parameters:
-
_date
Date要获取农历日期的时间对象
Returns:
holiday
-
_td
-
_customSet
添加或者清除假日样式
Parameters:
-
_td
Selector要设置为假日状态的 td
-
_customSet
Any如果 _customSet 为 undefined, 将设为假日. 如果 _customSet 非 undefined, 那么根据真假值判断清除假日/添加假日
isComment
-
_td
判断 td 是否为注释状态
Parameters:
-
_td
Selector
Returns:
isHideControl
()
判断日历是否隐藏操作控件
Returns:
isHoliday
-
_td
判断 td 是否为假日状态
Parameters:
-
_td
Selector
Returns:
isWorkday
-
_td
判断 td 是否为工作日状态
Parameters:
-
_td
Selector
Returns:
nextMonth
()
显示下一个月的日期
nextYear
()
显示下一年的日期
preMonth
()
显示上一个月的日期
preYear
()
显示上一年的日期
updateStatus
-
_data
从JSON数据更新日历状态( 工作日, 休息日, 注释 )
注意, 该方法更新页面上所有的 LunarCalendar
Parameters:
-
_data
Object{ phpTimestamp:{ dayaction: 0|1|2, comment: string}, ... }
dayaction: 0: delete workday/holiday 1: workday 2: holiday
Example:
LunarCalendar.updateStatus( {
"1369843200": {
"dayaction": 2,
"comment": "dfdfgdsfgsdfgsdg<b></b>'\"'asdf\"\"'sdf"
},
"1370966400": {
"dayaction": 0,
"comment": "asdfasdfsa"
},
"1371139200": {
"dayaction": 1
},
"1371225600": {
"dayaction": 0,
"comment": "dddd"
}
});
UXC.LunarCalendar.getFestival.intPad
-
_n
-
_len
为数字添加前置0
Parameters:
-
_n
Int需要添加前置0的数字
-
_len
Int需要添加_len个0, 默认为2
Returns:
workday
-
_td
-
_customSet
添加或者清除工作日样式
Parameters:
-
_td
Selector要设置为工作日状态的 td
-
_customSet
Any如果 _customSet 为 undefined, 将设为工作日. 如果 _customSet 非 undefined, 那么根据真假值判断清除工作日/添加工作日
Properties
_model
private
LunarCalendar 的数据模型对象
_view
private
LunarCalendar 的视图对像
autoinit
Bool
static
设置是否在 dom 加载完毕后, 自动初始化所有日期控件
Default: true
defaultYearSpan
Int
static
设置默认显示的年份数, 该数为前后各多少年 默认为前后各10年
Default: 20