第11款插件:jCal顯示日曆插件

描述:日曆插件jCal用於需要輸入日期的表單文本框。

兼容瀏覽器:IE瀏覽器/Firefox/Google Chrome

官方鏈接: http://www.overset.com/2008/05/1 ... cker-jquery-plugin/

JS下載: http://ijquery.360sites.cn/js/jquery.jCal.min.js

預覽:  http://ijquery.360sites.cn/demo/jCal

打包下載: http://ijquery.360sites.cn/demo/jCal/jCal.zip

參數說明:

  1.     $('#calOne').jCal({
  2.     day: new Date(), // 初始日期設置,一般是當前的,所以填寫爲new Date
  3.     days:1,    // 當你鼠標移動到日期控件上默認所選擇的日期數
  4.     showMonths: 1, // 日期控件的個數,如果你填寫2,那麼將會顯示相鄰二個月的日期
  5.     monthSelect:false, // 是否允許月份選擇
  6.     dCheck:function (day) { return true; }, // 你可以設置一些日期不可選(參考實例)
  7.     callback: function (day, days) { return true; }, // 點擊日期時候的回調函數(參考實例)
  8.     selectedBG: 'rgb(0, 143, 214)',   // 日期被選擇後的背景顏色(貌似無效)
  9.     defaultBG:'rgb(255, 255, 255)', // 日期沒有被選擇時的背景顏色(貌似無效)
  10.     dayOffset:0,   // 意味着日期排序從星期日開始,1意味着從星期一
  11.     forceWeek:false, // true=force selection at start of week, false=select days out from selected day
  12.     dow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'], // 設置日期表格行頭,是轉化成中文的關鍵
  13.     ml: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],//月份的名稱,可以轉化爲中文
  14.     ms:    ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']//月份的簡寫
  15.     })
複製代碼
圖片展示:


JS引用代碼:
  1. <script type="text/javascript" charset="utf-8" src="http://ijquery.360sites.cn/js/jquery-1.4.2.min.js"></script>
  2. <script type="text/javascript" charset="utf-8" src="http://ijquery.360sites.cn/js/jquery.animate.clip.js"></script>
  3. <script type="text/javascript" charset="utf-8" src="http://ijquery.360sites.cn/js/jquery.jCal.min.js"></script>
  4. <script>
  5.         $(function () {
  6.                 $('#calendar').jCal({
  7.                         day: new Date(),
  8.                         days: 1,
  9.                         showMonths: 2,
  10.                         monthSelect: true,
  11.                         dow: ['日', '一', '二', '三', '四', '五', '六'],
  12.                         ml: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  13.                         callback: function (day, days) {
  14.                                 $('#result').html(day.getFullYear() + '/' + (day.getMonth() + 1) +'/'+ day.getDate());
  15.                         }
  16.                 });
  17.         });
  18. </script>
複製代碼
HTML代碼:
  1. <!--顯示日曆-->
  2.                                 <div id="calendar"></div>
  3.                                 <!--顯示選擇日曆的結果-->
  4.                                 <div id="result"></div>
複製代碼
CSS代碼:
  1. <link rel="stylesheet" type="text/css" href="http://ijquery.360sites.cn/js/jquery.jCal.css" media="all" />
複製代碼
這裏用到的圖片:
http://ijquery.360sites.cn/js/jquery.jCal.zip 點擊進行打包下載

CSS源代碼如下:
  1. /* default dimensions and justification for each month including title */
  2. .jCal {
  3.         /* each day width + border-left + border-right */
  4.         width:224px;
  5.         height:21px;
  6.         text-align:center;
  7.         vertical-align:top;
  8. }
  9. /* default dimensions and justification for each month not including title */
  10. .jCalMo {
  11.         width:224px;                /* each day width + border-left + border-right */
  12.         float:left;
  13.         overflow:visible;
  14.         height:100%;
  15.         padding-right:2px;
  16.         padding-left:2px;
  17.         white-space:nowrap;
  18. }
  19. /* top month display block - i.e. January */
  20. .jCal .month, .jCal .monthSelect, .jCal .monthName, .jCal .monthYear {
  21.         line-height:16px;
  22.         height:16px;
  23.         text-align:center;
  24.         vertical-align:bottom;
  25.         font-family:Tahoma;
  26.         font-size:8pt;
  27.         color:#000000;
  28.         cursor:pointer;
  29.         float:left;
  30. }
  31. /* month name per calendar style - includes left/right padding and alignment */
  32. .jCal .monthName {
  33.         padding-left:2px;
  34.         padding-right:2px; 
  35.         text-align:right;
  36. }
  37. /* year per calendar style - includes left/right padding and alignment */
  38. .jCal .monthYear {
  39.         float:right;
  40.         padding-left:2px;
  41.         padding-right:2px;
  42.         text-align:left;
  43. }
  44. /* hilight style for new month combobox pulldown for hover */
  45. .jCal .monthSelect {
  46.         background:#EEE url(eeGrad2.gif) bottom repeat-x;
  47. }
  48. /* do not edit - this enables the new month combobox selector */
  49. .jCal .monthSelector {
  50.         position:absolute;
  51. }
  52. /* do not edit - this enables the new month combobox selector "shadow" for capturing auto-hide */
  53. .jCal .monthSelectorShadow {
  54.         position:absolute;
  55.         background:#808080;
  56.         padding:0px;
  57. }
  58. /* this is the hover for the month name */
  59. .jCal .monthNameHover {
  60.         background:#EDEDED url(double-arrow-vert.gif) center left no-repeat;
  61.         color:#808080;
  62. }
  63. /* this is the hover for the year */
  64. .jCal .monthYearHover {
  65.         background:#EDEDED url(double-arrow-vert.gif) center right no-repeat;
  66.         color:#808080;
  67. }
  68. /* this is the hover for the new month or year hover in the new combobox selection */
  69. .jCal .monthSelectHover {
  70.         background:#069;
  71.         color:#FFF;
  72. }
  73. /* day block dimensions and style - for all day blocks */
  74. .jCalMo .dow, .jCalMo .day, .jCalMo .pday, .jCalMo .aday, .jCalMo .overDay, .jCalMo .invday, .jCalMo .selectedDay {
  75.         width:30px;
  76.         font-family:Tahoma;
  77.         font-size:8pt;
  78.         color:#000000;
  79.         border-right:1px solid #CCC;
  80.         border-bottom:1px solid #CCC;
  81.         border-left:1px solid #EEE;
  82.         text-align:center;
  83.         cursor:default;
  84.         float:left;
  85. }
  86. /* day of week header specific style */
  87. .jCalMo .dow {
  88.         background:#EEE url(eeGrad.gif) bottom repeat-x;
  89.         border-bottom:0px;
  90. }
  91. /* actual calendar day default style */
  92. .jCalMo .day, .jCalMo .invday {
  93.         height:30px;
  94.         text-align:center;
  95. }
  96. /* selectable calendar day specific style */
  97. .jCalMo .day {
  98.         cursor:pointer;
  99.         background:#FFF;
  100. }
  101. /* blacked-out calendar day specific style */
  102. .jCalMo .invday {
  103.         color:#808080;
  104.         background:#eeeeee;
  105.         text-decoration:line-through;
  106. }
  107. /* previous and subsequent months calendar day specific style */
  108. .jCalMo .pday, .jCalMo .aday {
  109.         height:30px;
  110.         background:#e3e3e3;
  111.         color:#CCC;
  112. }
  113. /* selected day */
  114. .jCalMo .selectedDay {
  115.         color:#FFF;
  116.         /* must use rgb() syntax for jquery.color.js compliance */
  117.         background:rgb(0, 143, 214);
  118. }
  119. /* mouseover hilighted selectable day */
  120. .jCalMo .overDay {
  121.         color:#FFF;
  122.         /* must use rgb() syntax for jquery.color.js compliance */
  123.         background:rgb(0, 102, 153);
  124. }
  125. /* left month navigation button - no need to change */
  126. .jCal .left {
  127.         background:url(_left.gif) center center no-repeat;
  128.         width:16px;
  129.         height:16px;
  130.         vertical-align:middle;
  131.         cursor:pointer;
  132.         float:left;
  133. }
  134. /* right month navigation button - no need to change */
  135. .jCal .right {
  136.         background:url(_right.gif) center center no-repeat;
  137.         width:16px;
  138.         height:16px;
  139.         vertical-align:middle;
  140.         cursor:pointer;
  141.         float:right;
  142. }
  143. /* no need to change - this is for carousel opacity */
  144. .jCalMask, .jCalMove {
  145.         position:absolute;
  146.         overflow:hidden;
  147. }
複製代碼

[轉] http://ijquery.360sites.cn/forum.php?mod=viewthread&tid=11

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章