1234567 |
- /* http://keith-wood.name/datepick.html
- Datepicker extensions for jQuery v4.0.6.
- Written by Keith Wood (kbwood{at}iinet.com.au) August 2009.
- Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
- MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
- Please attribute the author if you use it. */
- (function($){var p={picker:'<div{popup:start} id="ui-datepicker-div"{popup:end} class="ui-datepicker ui-widget '+'ui-widget-content ui-helper-clearfix ui-corner-all{inline:start} ui-datepicker-inline{inline:end}">'+'<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">'+'{link:prev}{link:today}{link:next}</div>{months}'+'{popup:start}<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix '+'ui-corner-all">{button:clear}{button:close}</div>{popup:end}'+'<div class="ui-helper-clearfix"></div></div>',monthRow:'<div class="ui-datepicker-row-break">{months}</div>',month:'<div class="ui-datepicker-group">'+'<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix ui-corner-all">{monthHeader:MM yyyy}</div>'+'<table class="ui-datepicker-calendar"><thead>{weekHeader}</thead><tbody>{weeks}</tbody></table></div>',weekHeader:'<tr>{days}</tr>',dayHeader:'<th>{day}</th>',week:'<tr>{days}</tr>',day:'<td>{day}</td>',monthSelector:'.ui-datepicker-group',daySelector:'td',rtlClass:'ui-datepicker-rtl',multiClass:'ui-datepicker-multi',defaultClass:'ui-state-default',selectedClass:'ui-state-active',highlightedClass:'ui-state-hover',todayClass:'ui-state-highlight',otherMonthClass:'ui-datepicker-other-month',weekendClass:'ui-datepicker-week-end',commandClass:'ui-datepicker-cmd',commandButtonClass:'ui-state-default ui-corner-all',commandLinkClass:'',disabledClass:'ui-datepicker-disabled'};$.extend($.datepick,{weekOfYearRenderer:$.extend({},$.datepick.defaultRenderer,{weekHeader:'<tr><th class="datepick-week">'+'<span title="{l10n:weekStatus}">{l10n:weekText}</span></th>{days}</tr>',week:'<tr><td class="datepick-week">{weekOfYear}</td>{days}</tr>'}),themeRollerRenderer:p,themeRollerWeekOfYearRenderer:$.extend({},p,{weekHeader:'<tr><th class="ui-state-hover"><span>{l10n:weekText}</span></th>{days}</tr>',week:'<tr><td class="ui-state-hover">{weekOfYear}</td>{days}</tr>'}),noWeekends:function(a){return{selectable:(a.getDay()||7)<6}},changeFirstDay:function(c,d){var e=$(this);c.find('th span').each(function(){var b=$(this).parent();if(b.is('.datepick-week')||b.is('.ui-state-hover')){return}$('<a href="javascript:void(0)" class="'+this.className+'" title="Change first day of the week">'+$(this).text()+'</a>').click(function(){var a=parseInt(this.className.replace(/^.*datepick-dow-(\d+).*$/,'$1'),10);e.datepick('option',{firstDay:a})}).replaceAll(this)})},hoverCallback:function(e){return function(a,b){var c=this;var d=b.get('renderer');a.find(d.daySelector+' a, '+d.daySelector+' span').hover(function(){e.apply(c,[$.datepick.retrieveDate(c,this),this.nodeName.toLowerCase()=='a'])},function(){e.apply(c,[])})}},highlightWeek:function(a,b){var c=this;var d=b.get('renderer');a.find(d.daySelector+' a, '+d.daySelector+' span').hover(function(){$(this).parents('tr').find(d.daySelector+' *').addClass(d.highlightedClass)},function(){$(this).parents('tr').find(d.daySelector+' *').removeClass(d.highlightedClass)})},showStatus:function(b,c){var d=c.get('renderer');var e=(d.selectedClass==p.selectedClass);var f=c.get('defaultStatus')||' ';var g=$('<div class="'+(!e?'datepick-status':'ui-datepicker-status ui-widget-header ui-helper-clearfix ui-corner-all')+'">'+f+'</div>').insertAfter(b.find('.datepick-month-row:last,.ui-datepicker-row-break:last'));b.find('*[title]').each(function(){var a=$(this).attr('title');$(this).removeAttr('title').hover(function(){g.text(a||f)},function(){g.text(f)})})},monthNavigation:function(b,c){var d=$(this);var e=c.get('renderer');var f=(e.selectedClass==p.selectedClass);var g=c.curMinDate();var h=c.get('maxDate');var j=c.get('monthNames');var k=c.get('monthNamesShort');var l=c.drawDate.getMonth();var m=c.drawDate.getFullYear();var n='<div class="'+(!f?'datepick-month-nav':'ui-datepicker-month-nav')+'"'+' style="display: none;">';for(var i=0;i<j.length;i++){var o=((!g||new Date(m,i+1,0).getTime()>=g.getTime())&&(!h||new Date(m,i,1).getTime()<=h.getTime()));n+='<div>'+(o?'<a href="#" class="dp'+new Date(m,i,1).getTime()+'"':'<span')+' title="'+j[i]+'">'+k[i]+(o?'</a>':'</span>')+'</div>'}for(var i=-6;i<=6;i++){if(i==0){continue}var o=((!g||new Date(m+i,12-1,31).getTime()>=g.getTime())&&(!h||new Date(m+i,1-1,1).getTime()<=h.getTime()));n+='<div>'+(o?'<a href="#" class="dp'+new Date(m+i,l,1).getTime()+'"':'<span')+' title="'+(m+i)+'">'+(m+i)+(o?'</a>':'</span>')+'</div>'}n+='</div>';n=$(n).insertAfter(b.find('div.datepick-nav,div.ui-datepicker-header:first'));n.find('a').click(function(){var a=$.datepick.retrieveDate(d[0],this);d.datepick('showMonth',a.getFullYear(),a.getMonth()+1);return false});b.find('div.datepick-month-header,div.ui-datepicker-month-header').click(function(){n.slideToggle()}).css('cursor','pointer')},selectWeek:function(c,d){var e=$(this);c.find('td.datepick-week span,td.ui-state-hover span').each(function(){$('<a href="javascript:void(0)" class="'+this.className+'" title="Select the entire week">'+$(this).text()+'</a>').click(function(){var a=e.datepick('retrieveDate',this);var b=[a];for(var i=1;i<7;i++){b.push(a=$.datepick.add($.datepick.newDate(a),1,'d'))}if(d.get('rangeSelect')){b.splice(1,b.length-2)}e.datepick('setDate',b).datepick('hide')}).replaceAll(this)})},selectMonth:function(d,e){var f=$(this);d.find('th.datepick-week span,th.ui-state-hover span').each(function(){$('<a href="javascript:void(0)" title="Select the entire month">'+$(this).text()+'</a>').click(function(){var a=f.datepick('retrieveDate',$(this).parents('table').find('td:not(.datepick-week):not(.ui-state-hover) '+'*:not(.datepick-other-month):not(.ui-datepicker-other-month)')[0]);var b=[a];var c=$.datepick.daysInMonth(a);for(var i=1;i<c;i++){b.push(a=$.datepick.add($.datepick.newDate(a),1,'d'))}if(e.get('rangeSelect')){b.splice(1,b.length-2)}f.datepick('setDate',b).datepick('hide')}).replaceAll(this)})},monthOnly:function(b,c){var d=$(this);var e=$('<div style="text-align: center;"><button type="button">Select</button></div>').insertAfter(b.find('.datepick-month-row:last,.ui-datepicker-row-break:last')).children().click(function(){var a=b.find('.datepick-month-year:first').val().split('/');d.datepick('setDate',$.datepick.newDate(parseInt(a[1],10),parseInt(a[0],10),1)).datepick('hide')});b.find('.datepick-month-row table,.ui-datepicker-row-break table').remove()}})})(jQuery);
|