87,901
社区成员
发帖
与我相关
我的任务
分享
build: function () {
var monthNav = $('<p class="month_nav">' +
'<span class="button prev" title="[Page-Up]">«</span>' +
' <span class="month_name"></span> ' +
'<span class="button next" title="[Page-Down]">»</span>' +
'</p>');
this.monthNameSpan = $(".month_name", monthNav);
$(".prev", monthNav).click(this.bindToObj(function () { this.moveMonthBy(-1); }));
$(".next", monthNav).click(this.bindToObj(function () { this.moveMonthBy(1); }));
var yearNav = $('<p class="year_nav">' +
'<span class="button prev" title="[Ctrl+Page-Up]">«</span>' +
' <span class="year_name"></span> ' +
'<span class="button next" title="[Ctrl+Page-Down]">»</span>' +
'</p>');
this.yearNameSpan = $(".year_name", yearNav);
$(".prev", yearNav).click(this.bindToObj(function () { this.moveMonthBy(-12); }));
$(".next", yearNav).click(this.bindToObj(function () { this.moveMonthBy(12); }));
var nav = $('<div class="nav"></div>').append(monthNav, yearNav);
var tableShell = "<table><thead><tr>";
$(this.adjustDays(this.short_day_names)).each(function () {
tableShell += "<th>" + this + "</th>";
});
tableShell += "</tr></thead><tbody></tbody></table>";
this.dateSelector = this.rootLayers = $('<div class="date_selector"></div>').append(nav, tableShell).insertAfter(this.input);
if ($.browser.msie && $.browser.version < 7) {
this.ieframe = $('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').insertBefore(this.dateSelector);
this.rootLayers = this.rootLayers.add(this.ieframe);
// IE 6 only does :hover on A elements
$(".button", nav).mouseover(function () { $(this).addClass("hover") });
$(".button", nav).mouseout(function () { $(this).removeClass("hover") });
};
this.tbody = $("tbody", this.dateSelector);
this.input.change(this.bindToObj(function () { this.selectDate(); }));
this.selectDate();
},
insideSelector: function (event) {
var offset = this.dateSelector.position();
offset.right = offset.left + this.dateSelector.outerWidth();
offset.bottom = offset.top + this.dateSelector.outerHeight();
return event.pageY < offset.bottom &&
event.pageY > offset.top &&
event.pageX < offset.right &&
event.pageX > offset.left;
},
/* Some resets for compatibility with existing CSS */
.date_selector, .date_selector * {
width: auto;
height: auto;
border: none;
background: none;
margin: 0;
padding: 0;
text-align: left;
text-decoration: none;
}
.date_selector {
background: #F2F2F2;
border: 1px solid #bbb;
padding: 5px;
margin: -1px 0 0 0;
position: absolute;
z-index: 100000;
display: none;
}
.date_selector_ieframe {
position: absolute;
z-index: 99999;
display: none;
}
.date_selector .nav {
width: 17.5em; /* 7 * 2.5em */
}
.date_selector .month_nav, .date_selector .year_nav {
margin: 0 0 3px 0;
padding: 0;
display: block;
position: relative;
text-align: center;
}
.date_selector .month_nav {
float: left;
width: 55%;
}
.date_selector .year_nav {
float: right;
width: 35%;
margin-right: -8px; /* Compensates for cell borders */
}
.date_selector .month_name, .date_selector .year_name {
font-weight: bold;
line-height: 20px;
}
.date_selector .button {
display: block;
position: absolute;
top: 0;
width: 18px;
height: 18px;
line-height: 17px;
font-weight: bold;
color: #003C78;
text-align: center;
font-size: 120%;
overflow: hidden;
border: 1px solid #F2F2F2;
}
.date_selector .button:hover, .date_selector .button.hover {
background: none;
color: #003C78;
cursor: pointer;
border-color: #ccc;
}
.date_selector .prev {
left: 0;
}
.date_selector .next {
right: 0;
}
.date_selector table {
border-spacing: 0;
border-collapse: collapse;
clear: both;
}
.date_selector th, .date_selector td {
width: 2.5em;
height: 2em;
padding: 0;
text-align: center;
color: black;
}
.date_selector td {
border: 1px solid #ccc;
line-height: 2em;
text-align: center;
white-space: nowrap;
color: #003C78;
background: white;
}
.date_selector td.today {
background: #FFFEB3;
}
.date_selector td.unselected_month {
color: #ccc;
}
.date_selector td.selectable_day {
cursor: pointer;
}
.date_selector td.selected {
background: #D8DFE5;
font-weight: bold;
}
.date_selector td.selectable_day:hover, .date_selector td.selectable_day.hover {
background: #003C78;
color: white;
}
this.ieframe = $('<iframe class="date_selector_ieframe" frameborder="0" src="#"></iframe>').insertBefore(this.dateSelector);
this.rootLayers = this.rootLayers.add(this.ieframe);