淡定的502

导航

对jquery中的Simple jQuery Date-picker Plugin时间选择插件做了简单汉化处理

因为最近要用一个时间插件,查了很多发现一款jquery ui里的时间插件很美观也很实用,但是太过庞大了,所以就想找一款简单的时间控件,然后就选中了这款插件。

这是最后修改之后的样子

汉化之后要记得

<script charset="GB2312" src="/js/jquery/cal.js"></script>

这样引用进来,记得加上charset="GB2312"。

月份的汉化是直接更改cal.js的15行

var months = '一月,二月,三月,四月,五月,六月,七月,八月,九月,十月,十一月,十二月'.split(',');

星期和“今天”“关闭”是在97行

jQuery("thead",table).append('<tr class="controls"><th colspan="7"><span class="prevMonth">&laquo;</span>&nbsp;'+monthselect+yearselect+'&nbsp;<span class="nextMonth">&raquo;</span></th></tr>');
jQuery("thead",table).append('<tr class="days"><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr>');
jQuery("tfoot",table).append('<tr><td colspan="2"><span class="today">今天</span></td><td colspan="3">&nbsp;</td><td colspan="2"><span class="close">关闭</span></td></tr>');

最后为了生成一个2012-01-06格式的日期,我更改了228行得内容

jQuery.fn.simpleDatepicker.formatOutput = function (dateObj) {
if((dateObj.getMonth() + 1)<10){
cmonth='0'+(dateObj.getMonth() + 1);
}
else{
cmonth=dateObj.getMonth() + 1;
}
if(dateObj.getDate()<10){
cday='0'+dateObj.getDate();
}
else{
cday=dateObj.getDate();
}
return dateObj.getFullYear() + "-" + cmonth + "-" +cday;
};

好了,打完收工,其他的一些用法,可以通过其他文章搜索到了,这里就不详述了。



posted on 2011-12-14 10:27  淡定的502  阅读(1193)  评论(0编辑  收藏  举报