Aeron Calendar 表單日期套件美觀又方便!!
Calendar 自訂圖片執行畫面 |
首先載入MooTools框架和Calendar主程式碼
//MooTools框架程式碼
<script type="text/javascript" src="mootools.js"></script>
//本套件的主程式碼
<script type="text/javascript" src="calendar.js"></script>
本範例的CSS
<style>
input.i-heart-ny,
select.i-heart-ny {
width: 149px;
}
button.i-heart-ny {
background: url(i-heart-ny-icon.gif);
border: 0;
cursor: pointer;
float: left;
height: 20px;
margin-right: 6px;
width: 20px;
}
button.i-heart-ny:hover,
button.i-heart-ny.active {
background-position: 0 20px;
}
div.i-heart-ny {
background: url(i-heart-ny.png);
height: 278px;
padding: 4px;
width: 164px;
}
div.i-heart-ny * {
margin: 0;
padding: 0;
}
div.i-heart-ny div {
background-repeat: no-repeat;
background-position: 8px 8px;
cursor: move;
height: 278px;
overflow: hidden;
position: relative;
width: 164px;
}/* 一到十二月的圖片設定*/
div.i-heart-ny.january div { background-image: url(i-heart-ny-jan.jpg); }
div.i-heart-ny.february div { background-image: url(i-heart-ny-feb.jpg); }
div.i-heart-ny.march div { background-image: url(i-heart-ny-mar.jpg); }
div.i-heart-ny.april div { background-image: url(i-heart-ny-apr.jpg); }
div.i-heart-ny.may div { background-image: url(i-heart-ny-may.jpg); }
div.i-heart-ny.june div { background-image: url(i-heart-ny-jun.jpg); }
div.i-heart-ny.july div { background-image: url(i-heart-ny-jul.jpg); }
div.i-heart-ny.august div { background-image: url(i-heart-ny-aug.jpg); }
div.i-heart-ny.september div { background-image: url(i-heart-ny-sep.jpg); }
div.i-heart-ny.october div { background-image: url(i-heart-ny-oct.jpg); }
div.i-heart-ny.november div { background-image: url(i-heart-ny-nov.jpg); }
div.i-heart-ny.december div { background-image: url(i-heart-ny-dec.jpg); }
div.i-heart-ny caption {
color: #808080;
height: 0%;
line-height: 0;
}
div.i-heart-ny caption a {
cursor: pointer;
display: block;
height: 25px;
overflow: hidden;
position: absolute;
text-indent: -100px;
top: 0;
width: 23px;
z-index: 200;
}
div.i-heart-ny caption a.prev {
background-image: url(i-heart-ny-prev.png);
left: 0;
}/* 上下頁的小圖 */
div.i-heart-ny caption a.next {
background-image: url(i-heart-ny-next.png);
right: 0;
}
div.i-heart-ny caption a:hover {
background-position: 0 25px;
}
div.i-heart-ny caption span.month {
bottom: 8px;
font: normal 11px Arial, Helvetica, sans-serif;
position: absolute;
right: 10px;
z-index: 100;
}
div.i-heart-ny caption span.year {
display: none;
}
div.i-heart-ny table {
border: 0;
border-collapse: collapse;
border-spacing: 0;
margin: 143px 10px 0 7px;
}
div.i-heart-ny tbody {
cursor: default;
}
div.i-heart-ny td {
border: 0;
color: #FFF;
font: normal 9px Arial, Helvetica, sans-serif;
height: 21px;
text-align: right;
vertical-align: bottom;
width: 21px;
}
div.i-heart-ny td.active,
div.i-heart-ny td.hover {
background: url(i-heart-ny-active.gif);
color: #25A8C2;
cursor: pointer;
}
div.i-heart-ny td.invalid {
background: url(i-heart-ny-invalid.gif);
color: #DA2727;
}
div.i-heart-ny td.valid {
color: #808080;
cursor: pointer;
}
div.i-heart-ny td.inactive {
background: url(i-heart-ny-inactive.gif);
color: #808080;
}
div.i-heart-ny thead {
display: none;
}
</style>
HTML的部份只需要有id的表單元素
<input id="date" name="date" type="text" />
最後JavaScripts的執行部分
<script type="text/javascript">
window.addEvent('domready', function() {
myCal3 = new Calendar({ date: 'd/m/Y' }, { classes: ['i-heart-ny'], direction: 1, tweak: {x: 3, y: 0} });
});//date 日期輸出格式 classes 讀取的CLASS direction 日期的方向 tweak XY軸的微調
</script>
作者網站:http://www.electricprism.com/aeron/calendar/
檔案大小:158 KB
檔案下載:https://github.com/aglemann/calendar
檔案備份:下載
0 意見