|
|
/*! UIkit 2.5.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(t){"function"==typeof define&&define.amd&&define("uikit-datepicker",["uikit"],function(){return jQuery.UIkit.datepicker||t(window,window.jQuery,window.jQuery.UIkit)}),window&&window.jQuery&&window.jQuery.UIkit&&t(window,window.jQuery,window.jQuery.UIkit)})(function(t,e,n){var i,s=!1,o=e('<div class="uk-dropdown uk-datepicker"></div>');o.on("click",".uk-datepicker-next, .uk-datepicker-previous, [data-date]",function(t){t.stopPropagation(),t.preventDefault();var n=e(this);n.is("[data-date]")?(s.element.val(i(n.data("date")).format(s.options.format)).trigger("change"),o.hide(),s=!1):s.add("months",1*(n.hasClass("uk-datepicker-next")?1:-1))});var a=function(t,n){var o=this,r=e(t);r.data("datepicker")||(this.element=r,this.options=e.extend({},a.defaults,n),this.current=this.element.val()?i(this.element.val(),this.options.format):i(),this.element.on("click",function(){s!==o&&o.pick(this.value)}).on("change",function(){o.element.val()&&!i(o.element.val(),o.options.format).isValid()&&o.element.val(i().format(o.options.format))}),this.element.data("datepicker",this))};return a.defaults={weekstart:1,i18n:{months:["January","February","March","April","May","June","July","August","September","October","November","December"],weekdays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]},format:"DD.MM.YYYY",offsettop:5,template:function(t,e){var n="";n+='<div class="uk-datepicker-nav">',n+='<a href="" class="uk-datepicker-previous"></a>',n+='<a href="" class="uk-datepicker-next"></a>',n+='<div class="uk-datepicker-heading">'+e.i18n.months[t.month]+" "+t.year+"</div>",n+="</div>",n+='<table class="uk-datepicker-table">',n+="<thead>";for(var i=0;t.weekdays.length>i;i++)t.weekdays[i]&&(n+="<th>"+t.weekdays[i]+"</th>");n+="</thead>",n+="<tbody>";for(var i=0;t.days.length>i;i++)if(t.days[i]&&t.days[i].length){n+="<tr>";for(var s=0;t.days[i].length>s;s++)if(t.days[i][s]){var o=t.days[i][s],a=[];o.inmonth||a.push("uk-datepicker-table-muted"),o.selected&&a.push("uk-active"),n+='<td><a href="" class="'+a.join(" ")+'" data-date="'+o.day.format()+'">'+o.day.format("D")+"</a></td>"}n+="</tr>"}return n+="</tbody>",n+="</table>"}},e.extend(a.prototype,{pick:function(t){var n=this.element.offset(),a={top:n.top+this.element.outerHeight()+this.options.offsettop,left:n.left,right:""};this.current=t?i(t,this.options.format):i(),this.initdate=this.current.format("YYYY-MM-DD"),this.update(),"right"==e.UIkit.langdirection&&(a.right=window.innerWidth-(a.left+this.element.outerWidth()),a.left=""),o.css(a).show(),s=this},add:function(t,e){this.current.add(t,e),this.update()},setMonth:function(t){this.current.month(t),this.update()},setYear:function(t){this.current.year(t),this.update()},update:function(){var t=this.getRows(this.current.year(),this.current.month()),e=this.options.template(t,this.options);o.html(e)},getRows:function(t,e){var n=this.options,s=i().format("YYYY-MM-DD"),o=[31,0===t%4&&0!==t%100||0===t%400?29:28,31,30,31,30,31,31,30,31,30,31][e],a=new Date(t,e,1).getDay(),r={month:e,year:t,weekdays:[],days:[]},u=[];r.weekdays=function(){for(var t=0,e=[];7>t;t++){for(var i=t+(n.weekstart||0);i>=7;)i-=7;e.push(n.i18n.weekdays[i])}return e}(),n.weekstart&&n.weekstart>0&&(a-=n.weekstart,0>a&&(a+=7));for(var l=o+a,d=l;d>7;)d-=7;l+=7-d;for(var c,h,f,p,m,g=0,v=0;l>g;g++)c=new Date(t,e,1+(g-a)),h=n.mindate&&n.mindate>c||n.maxdate&&c>n.maxdate,m=!(a>g||g>=o+a),c=i(c),f=this.initdate==c.format("YYYY-MM-DD"),p=s==c.format("YYYY-MM-DD"),u.push({selected:f,today:p,disabled:h,day:c,inmonth:m}),7===++v&&(r.days.push(u),u=[],v=0);return r}}),n.datepicker=a,e(document).on("focus.datepicker.uikit","[data-uk-datepicker]",function(t){var i=e(this);i.data("datepicker")||(t.preventDefault(),new a(i,n.Utils.options(i.attr("data-uk-datepicker"))),i.trigger("focus"))}),e(document).on("click.datepicker.uikit",function(t){var n=e(t.target);!s||n[0]==o[0]||n.data("datepicker")||n.parents(".uk-datepicker:first").length||(o.hide(),s=!1)}),e(function(){o.appendTo("body")}),i=function(t){function e(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,null
|