/*! UIkit 2.5.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(addon) {
if (typeof define == "function" && define.amd) { // AMD
define("uikit-datepicker", ["uikit"], function(){
return jQuery.UIkit.datepicker || addon(window, window.jQuery, window.jQuery.UIkit);
});
}
if(window && window.jQuery && window.jQuery.UIkit) {
addon(window, window.jQuery, window.jQuery.UIkit);
}
})(function(global, $, UI){
// Datepicker
var active = false,
dropdown = $('
'),
moment;
dropdown.on("click", ".uk-datepicker-next, .uk-datepicker-previous, [data-date]", function(e){
e.stopPropagation();
e.preventDefault();
var ele = $(this);
if(ele.is('[data-date]')) {
active.element.val(moment(ele.data("date")).format(active.options.format)).trigger("change");
dropdown.hide();
active = false;
} else {
active.add("months", 1 * (ele.hasClass("uk-datepicker-next") ? 1:-1));
}
});
var DatePicker = function(element, options) {
var $this = this, $element = $(element);
if($element.data("datepicker")) return;
this.element = $element;
this.options = $.extend({}, DatePicker.defaults, options);
this.current = this.element.val() ? moment(this.element.val(), this.options.format) : moment();
this.element.on("click", function(){
if(active!==$this) $this.pick(this.value);
}).on("change", function(){
if($this.element.val() && !moment($this.element.val(), $this.options.format).isValid()) {
$this.element.val(moment().format($this.options.format));
}
});
this.element.data("datepicker", this);
};
DatePicker.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(data, opts) {
var content = '';
content += '';
content += '
';
content += '
';
content += '
'+ opts.i18n.months[data.month] +' '+ data.year+'
';
content += '
';
content += '';
content += '';
for(var i = 0; i < data.weekdays.length; i++) {
if (data.weekdays[i]) {
content += ''+data.weekdays[i]+' | ';
}
}
content += '';
content += '';
for(var i = 0; i < data.days.length; i++) {
if (data.days[i] && data.days[i].length){
content += '';
for(var d = 0; d < data.days[i].length; d++) {
if (data.days[i][d]) {
var day = data.days[i][d],
cls = [];
if(!day.inmonth) cls.push("uk-datepicker-table-muted");
if(day.selected) cls.push("uk-active");
content += ''+day.day.format("D")+' | ';
}
}
content += '
';
}
}
content += '';
content += '
';
return content;
}
};
$.extend(DatePicker.prototype, {
pick: function(initdate) {
var offset = this.element.offset(),
css = {"top": offset.top + this.element.outerHeight() + this.options.offsettop, "left": offset.left, "right":""};
this.current = initdate ? moment(initdate, this.options.format):moment();
this.initdate = this.current.format("YYYY-MM-DD");
this.update();
if ($.UIkit.langdirection == 'right') {
css.right = window.innerWidth - (css.left + this.element.outerWidth());
css.left = "";
}
dropdown.css(css).show();
active = this;
},
add: function(unit, value) {
this.current.add(unit, value);
this.update();
},
setMonth: function(month) {
this.current.month(month);
this.update();
},
setYear: function(year) {
this.current.year(year);
this.update();
},
update: function() {
var data = this.getRows(this.current.year(), this.current.month()),
tpl = this.options.template(data, this.options);
dropdown.html(tpl);
},
getRows: function(year, month) {
var opts = this.options,
now = moment().format('YYYY-MM-DD'),
days = [31, (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month],
before = new Date(year, month, 1).getDay(),
data = {"month":month, "year":year,"weekdays":[],"days":[]},
row = [];
data.weekdays = (function(){
for (var i=0, arr=[]; i < 7; i++) {
var day = i + (opts.weekstart || 0);
while (day >= 7) {
day -= 7;
}
arr.push(opts.i18n.weekdays[day]);
}
return arr;
})();
if (opts.weekstart && opts.weekstart > 0) {
before -= opts.weekstart;
if (before < 0) {
before += 7;
}
}
var cells = days + before, after = cells;
while(after > 7) { after -= 7; }
cells += 7 - after;
var day, isDisabled, isSelected, isToday, isInMonth;
for (var i = 0, r = 0; i < cells; i++) {
day = new Date(year, month, 1 + (i - before));
isDisabled = (opts.mindate && day < opts.mindate) || (opts.maxdate && day > opts.maxdate);
isInMonth = !(i < before || i >= (days + before));
day = moment(day);
isSelected = this.initdate == day.format("YYYY-MM-DD");
isToday = now == day.format("YYYY-MM-DD");
row.push({"selected": isSelected, "today": isToday, "disabled": isDisabled, "day":day, "inmonth":isInMonth});
if (++r === 7) {
data.days.push(row);
row = [];
r = 0;
}
}
return data;
}
});
UI["datepicker"] = DatePicker;
// init code
$(document).on("focus.datepicker.uikit", "[data-uk-datepicker]", function(e) {
var ele = $(this);
if (!ele.data("datepicker")) {
e.preventDefault();
var obj = new DatePicker(ele, UI.Utils.options(ele.attr("data-uk-datepicker")));
ele.trigger("focus");
}
});
$(document).on("click.datepicker.uikit", function(e) {
var target = $(e.target);
if (active && target[0] != dropdown[0] && !target.data("datepicker") && !target.parents(".uk-datepicker:first").length) {
dropdown.hide();
active = false;
}
});
$(function(){
dropdown.appendTo("body");
});
//! moment.js
//! version : 2.5.1
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
moment = (function(B){function G(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function Z(a,b){return function(c){return l(a.call(this,c),b)}}function ta(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function $(){}function H(a){aa(a);v(this,a)}function I(a){a=ba(a);var b=a.year||0,c=a.month||0,d=a.week||0,f=a.day||0;this._milliseconds=+(a.millisecond||0)+1E3*(a.second||0)+6E4*(a.minute||
0)+36E5*(a.hour||0);this._days=+f+7*d;this._months=+c+12*b;this._data={};this._bubble()}function v(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);b.hasOwnProperty("toString")&&(a.toString=b.toString);b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf);return a}function w(a){return 0>a?Math.ceil(a):Math.floor(a)}function l(a,b,c){for(var d=""+Math.abs(a);d.lengtha._a[x]||11a._a[q]||a._a[q]>L(a._a[r],a._a[x])?q:0>a._a[p]||23a._a[y]||59a._a[D]||59a._a[E]||999q)&&(b=q),a._pf.overflow=b)}function ea(a){null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&0>a._pf.overflow&&!a._pf.empty&&!a._pf.invalidMonth&&
!a._pf.nullInput&&!a._pf.invalidFormat&&!a._pf.userInvalidated,a._strict&&(a._isValid=a._isValid&&0===a._pf.charsLeftOver&&0===a._pf.unusedTokens.length));return a._isValid}function N(a){return a?a.toLowerCase().replace("_","-"):a}function O(a,b){return b._isUTC?e(a).zone(b._offset||0):e(a).local()}function s(a){var b=0,c,d,f,g,m=function(a){if(!z[a]&&xa)try{require("./lang/"+a)}catch(b){}return z[a]};if(!a)return e.fn._lang;if(!K(a)){if(d=m(a))return d;a=[a]}for(;b=c&&ca(g,f,!0)>=c-1)break;c--}b++}return e.fn._lang}function ya(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function za(a){var b=a.match(fa),c,d;c=0;for(d=b.length;cb.length?68(M(b)?366:365)&&(a._pf._overflowDayOfYear=!0),b=T(b,0,a._dayOfYear),a._a[x]=b.getUTCMonth(),a._a[q]=b.getUTCDate());for(b=0;3>b&&null==a._a[b];++b)a._a[b]=c[b]=d[b];for(;7>b;b++)a._a[b]=c[b]=null==a._a[b]?2===b?1:0:a._a[b];c[p]+=h((a._tzm||0)/60);c[y]+=h((a._tzm||0)%60);a._d=(a._useUTC?T:Qa).apply(null,c)}}
function Pa(a){var b=new Date;return a._useUTC?[b.getUTCFullYear(),b.getUTCMonth(),b.getUTCDate()]:[b.getFullYear(),b.getMonth(),b.getDate()]}function U(a){a._a=[];a._pf.empty=!0;var b=s(a._l),c=""+a._i,d,f,g,e,k=c.length,l=0;f=ga(a._f,b).match(fa)||[];for(b=0;ba._a[p]&&(a._a[p]+=12);!1===a._isPm&&12===a._a[p]&&(a._a[p]=0);S(a);aa(a)}function Na(a){return a.replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,c,d,f,e){return c||d||f||e})}function Qa(a,b,c,d,f,e,h){b=new Date(a,b,c,d,f,e,h);1970>a&&b.setFullYear(a);return b}function T(a){var b=new Date(Date.UTC.apply(null,arguments));1970>a&&b.setUTCFullYear(a);return b}function ma(a,b){if("string"===typeof a)if(isNaN(a)){if(a=b.weekdaysParse(a),"number"!==
typeof a)return null}else a=parseInt(a,10);return a}function Ra(a,b,c,d,f){return f.relativeTime(b||1,!!c,a,d)}function C(a,b,c){b=c-b;c-=a.day();c>b&&(c-=7);cd?7:0)-(ea&&(a=-a,b="-");return b+l(h(a/60),2)+":"+l(h(a)%60,2)},ZZ:function(){var a=-this.zone(),b="+";0>a&&(a=-a,b="-");
return b+l(h(a/60),2)+l(h(a)%60,2)},z:function(){return this.zoneAbbr()},zz:function(){return this.zoneName()},X:function(){return this.unix()},Q:function(){return this.quarter()}},sa=["months","monthsShort","weekdays","weekdaysShort","weekdaysMin"];qa.length;)k=qa.pop(),u[k+"o"]=ta(u[k],k);for(;ra.length;)k=ra.pop(),u[k+k]=Z(u[k],2);u.DDDD=Z(u.DDD,3);v($.prototype,{set:function(a){var b,c;for(c in a)b=a[c],"function"===typeof b?this[c]=b:this["_"+c]=b},_months:"January February March April May June July August September October November December".split(" "),
months:function(a){return this._months[a.month()]},_monthsShort:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),monthsShort:function(a){return this._monthsShort[a.month()]},monthsParse:function(a){var b,c;this._monthsParse||(this._monthsParse=[]);for(b=0;12>b;b++)if(this._monthsParse[b]||(c=e.utc([2E3,b]),c="^"+this.months(c,"")+"|^"+this.monthsShort(c,""),this._monthsParse[b]=RegExp(c.replace(".",""),"i")),this._monthsParse[b].test(a))return b},_weekdays:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),
weekdays:function(a){return this._weekdays[a.day()]},_weekdaysShort:"Sun Mon Tue Wed Thu Fri Sat".split(" "),weekdaysShort:function(a){return this._weekdaysShort[a.day()]},_weekdaysMin:"Su Mo Tu We Th Fr Sa".split(" "),weekdaysMin:function(a){return this._weekdaysMin[a.day()]},weekdaysParse:function(a){var b,c;this._weekdaysParse||(this._weekdaysParse=[]);for(b=0;7>b;b++)if(this._weekdaysParse[b]||(c=e([2E3,1]).day(b),c="^"+this.weekdays(c,"")+"|^"+this.weekdaysShort(c,"")+"|^"+this.weekdaysMin(c,
""),this._weekdaysParse[b]=RegExp(c.replace(".",""),"i")),this._weekdaysParse[b].test(a))return b},_longDateFormat:{LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D YYYY",LLL:"MMMM D YYYY LT",LLLL:"dddd, MMMM D YYYY LT"},longDateFormat:function(a){var b=this._longDateFormat[a];!b&&this._longDateFormat[a.toUpperCase()]&&(b=this._longDateFormat[a.toUpperCase()].replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a]=b);return b},isPM:function(a){return"p"===(a+"").toLowerCase().charAt(0)},
_meridiemParse:/[ap]\.?m?\.?/i,meridiem:function(a,b,c){return 11=a.year()?P(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):P(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")},toArray:function(){return[this.year(),this.month(),this.date(),this.hours(),this.minutes(),this.seconds(),this.milliseconds()]},isValid:function(){return ea(this)},isDSTShifted:function(){return this._a?this.isValid()&&0a?"sameElse":-1>a?"lastWeek":0>a?"lastDay":1>a?"sameDay":2>a?"nextDay":7>a?"nextWeek":"sameElse";return this.format(this.lang().calendar(a,this))},isLeapYear:function(){return M(this.year())},isDST:function(){return this.zone()+e(a).startOf(b)},isBefore:function(a,b){b="undefined"!==typeof b?b:"millisecond";return+this.clone().startOf(b)<+e(a).startOf(b)},isSame:function(a,b){b=b||"ms";return+this.clone().startOf(b)===+O(a,this).startOf(b)},min:function(a){a=e.apply(null,
arguments);return athis?this:a},zone:function(a,b){b=null==b?!0:!1;var c=this._offset||0;if(null!=a)"string"===typeof a&&(a=ka(a)),16>Math.abs(a)&&(a*=60),this._offset=a,this._isUTC=!0,c!==a&&b&&J(this,e.duration(c-a,"m"),1,!0);else return this._isUTC?c:this._d.getTimezoneOffset();return this},zoneAbbr:function(){return this._isUTC?"UTC":""},zoneName:function(){return this._isUTC?"Coordinated Universal Time":""},parseZone:function(){this._tzm?
this.zone(this._tzm):"string"===typeof this._i&&this.zone(this._i);return this},hasAlignedHourOffset:function(a){a=a?e(a).zone():0;return 0===(this.zone()-a)%60},daysInMonth:function(){return L(this.year(),this.month())},dayOfYear:function(a){var b=A((e(this).startOf("day")-e(this).startOf("year"))/864E5)+1;return null==a?b:this.add("d",a-b)},quarter:function(){return Math.ceil((this.month()+1)/3)},weekYear:function(a){var b=C(this,this.lang()._week.dow,this.lang()._week.doy).year;return null==a?
b:this.add("y",a-b)},isoWeekYear:function(a){var b=C(this,1,4).year;return null==a?b:this.add("y",a-b)},week:function(a){var b=this.lang().week(this);return null==a?b:this.add("d",7*(a-b))},isoWeek:function(a){var b=C(this,1,4).week;return null==a?b:this.add("d",7*(a-b))},weekday:function(a){var b=(this.day()+7-this.lang()._week.dow)%7;return null==a?b:this.add("d",a-b)},isoWeekday:function(a){return null==a?this.day()||7:this.day(this.day()%7?a:a-7)},isoWeeksInYear:function(){return da(this.year(),
1,4)},weeksInYear:function(){var a=this._lang._week;return da(this.year(),a.dow,a.doy)},get:function(a){a=n(a);return this[a]()},set:function(a,b){a=n(a);if("function"===typeof this[a])this[a](b);return this},lang:function(a){if(a===B)return this._lang;this._lang=s(a);return this}});for(k=0;kf&&["s",f]||1===e&&["m"]||45>e&&["mm",e]||1===h&&["h"]||22>h&&["hh",h]||1===k&&["d"]||25>=k&&["dd",k]||45>=k&&["M"]||345>k&&["MM",A(k/30)]||1===l&&["y"]||["yy",l];f[2]=c;f[3]=0
this.asSeconds()?"-":"")+"P"+(a?a+"Y":"")+(b?b+"M":"")+(c?c+"D":"")+(d||e||g?"T":"")+(d?d+"H":"")+(e?e+"M":"")+(g?g+"S":""):"P0D"}});for(k in Y)Y.hasOwnProperty(k)&&(pa(k,Y[k]),Va(k.toLowerCase()));pa("Weeks",6048E5);e.duration.fn.asMonths=function(){return(+this-31536E6*this.years())/2592E6+12*this.years()};e.lang("en",{ordinal:function(a){var b=a%10,b=1===h(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+b}});return e}).call(this);
DatePicker.moment = moment;
return DatePicker;
});