jquery.datepick.ext.min.js 6.6KB

1234567
  1. /* http://keith-wood.name/datepick.html
  2. Datepicker extensions for jQuery v4.1.0.
  3. Written by Keith Wood (kbwood{at}iinet.com.au) August 2009.
  4. Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
  5. MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
  6. Please attribute the author if you use it. */
  7. (function($){var m={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:m,themeRollerWeekOfYearRenderer:$.extend({},m,{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(d){return function(a,b){if($.isFunction(d)){var c=this;a.find(b.options.renderer.daySelector+' a, '+b.options.renderer.daySelector+' span').hover(function(){d.apply(c,[$(c).datepick('retrieveDate',this),this.nodeName.toLowerCase()=='a'])},function(){d.apply(c,[])})}}},highlightWeek:function(a,b){var c=this;var d=b.options.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.options.renderer.selectedClass==m.selectedClass);var e=c.options.defaultStatus||'&nbsp;';var f=$('<div class="'+(!d?'datepick-status':'ui-datepicker-status ui-widget-header ui-helper-clearfix ui-corner-all')+'">'+e+'</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(){f.text(a||e)},function(){f.text(e)})})},monthNavigation:function(b,c){var d=$(this);var e=(c.options.renderer.selectedClass==m.selectedClass);var f=c.curMinDate();var g=c.get('maxDate');var h=c.drawDate.getMonth();var j=c.drawDate.getFullYear();var k='<div class="'+(!e?'datepick-month-nav':'ui-datepicker-month-nav')+'"'+' style="display: none;">';for(var i=0;i<c.options.monthNames.length;i++){var l=((!f||new Date(j,i+1,0).getTime()>=f.getTime())&&(!g||new Date(j,i,1).getTime()<=g.getTime()));k+='<div>'+(l?'<a href="#" class="dp'+new Date(j,i,1).getTime()+'"':'<span')+' title="'+c.options.monthNames[i]+'">'+c.options.monthNamesShort[i]+(l?'</a>':'</span>')+'</div>'}for(var i=-6;i<=6;i++){if(i==0){continue}var l=((!f||new Date(j+i,12-1,31).getTime()>=f.getTime())&&(!g||new Date(j+i,1-1,1).getTime()<=g.getTime()));k+='<div>'+(l?'<a href="#" class="dp'+new Date(j+i,h,1).getTime()+'"':'<span')+' title="'+(j+i)+'">'+(j+i)+(l?'</a>':'</span>')+'</div>'}k+='</div>';k=$(k).insertAfter(b.find('div.datepick-nav,div.ui-datepicker-header:first'));k.find('a').click(function(){var a=d.datepick('retrieveDate',this);d.datepick('showMonth',a.getFullYear(),a.getMonth()+1);return false});b.find('div.datepick-month-header,div.ui-datepicker-month-header').click(function(){k.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.options.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.options.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);