onReturn: false,//当选择日期后回调的函数
version: “1.0”,//版本
applyrule: false, //日期选择规则,可设置可选择的日期范围function(){};return rule={startdate,endate};
showtarget: null, //显示载体,日历展开式所依赖的对象,默认是对象本身
picker: “” //附加点击事件的对象
};
$.extend(def, o);//用传递过来的参数来填充默认
第二部自然是初始化月视图和年月选择视图的HTML了
//给日期选择控件一个特殊的ID,获取这个ID的对象,判断如果对象存在,则直接使用
// 日期的HTML采用单例,即一个页面上只生成一份HTML
var cp = $(“#BBIT_DP_CONTAINER”);
if (cp.length == 0) {
var cpHA = []; //老规矩还是用数组拼接html,最后用innerHTML的方式附加到容器,提升性能
cpHA.push(“<div id=’BBIT_DP_CONTAINER’ class=’bbit-dp’ style=’width:175px;z-index:999;’>”);
if ($.browser.msie6) { //如果是IE6弹出层遮盖select
cpHA.push(‘<iframe style=”position:absolute;z-index:-1;width:100%;height:100%;top:0;left:0;scrolling:no;” frameborder=”0″ src=”about:blank”></iframe>’);
}
cpHA.push(“<table class=’dp-maintable’ cellspacing=’0′ cellpadding=’0′ style=’width:175px;’><tbody><tr><td>”);
//头哟
cpHA.push(“<table class=’bbit-dp-top’ cellspacing=’0′><tr><td class=’bbit-dp-top-left’> <a id=’BBIT_DP_LEFTBTN’ href=’javascript:void(0);’ title=’向前一个月’> </a></td><td class=’bbit-dp-top-center’ align=’center’><em><button id=’BBIT_DP_YMBTN’>九月 2009</button></em></td><td class=’bbit-dp-top-right’><a id=’BBIT_DP_RIGHTBTN’ href=’javascript:void(0);’ title=’向后一个月’> </a></td></tr></table>”);
cpHA.push(“</td></tr>”);
cpHA.push(“<tr><td>”);
//周
cpHA.push(“<table id=’BBIT_DP_INNER’ class=’bbit-dp-inner’ cellspacing=’0′><thead><tr>”);
//生成周
for (var i = def.weekStart, j = 0; j < 7; j++) {
cpHA.push(“<th><span>”, def.weekName[i], “</span></th>”);
if (i == 6) { i = 0; } else { i++; }
}
…..//省略若干代码
cpHA.push(“</tbody></table>”);
cpHA.push(“</div>”);
cpHA.push(“</div>”);
var s = cpHA.join(“”);
$(document.body).append(s); //添加到body中
cp = $(“#BBIT_DP_CONTAINER”); //再获取一遍










