|
|
/*! UIkit 2.3.1 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
(function(global, $, UI){
// Datepicker
var active = false, dropdown = $('<div class="uk-dropdown uk-datepicker"></div>');
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 += '<div class="uk-datepicker-nav">'; content += '<a href="" class="uk-datepicker-previous"></a>'; content += '<a href="" class="uk-datepicker-next"></a>'; content += '<div class="uk-datepicker-heading">'+ opts.i18n.months[data.month] +' '+ data.year+'</div>'; content += '</div>';
content += '<table class="uk-datepicker-table">'; content += '<thead>'; for(var i = 0; i < data.weekdays.length; i++) { if (data.weekdays[i]) { content += '<th>'+data.weekdays[i]+'</th>'; } } content += '</thead>';
content += '<tbody>'; for(var i = 0; i < data.days.length; i++) { if (data.days[i] && data.days[i].length){ content += '<tr>'; 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 += '<td><a href="" class="'+cls.join(" ")+'" data-date="'+day.day.format()+'">'+day.day.format("D")+'</a></td>'; } } content += '</tr>'; } } content += '</tbody>';
content += '</table>';
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"); });
})(this, jQuery, jQuery.UIkit);
if(!window.moment) {
//! moment.js
//! version : 2.5.1
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! momentjs.com
(function(a){function b(){return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1}}function c(a,b){return function(c){return k(a.call(this,c),b)}}function d(a,b){return function(c){return this.lang().ordinal(a.call(this,c),b)}}function e(){}function f(a){w(a),h(this,a)}function g(a){var b=q(a),c=b.year||0,d=b.month||0,e=b.week||0,f=b.day||0,g=b.hour||0,h=b.minute||0,i=b.second||0,j=b.millisecond||0;this._milliseconds=+j+1e3*i+6e4*h+36e5*g,this._days=+f+7*e,this._months=+d+12*c,this._data={},this._bubble()}function h(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a}function i(a){var b,c={};for(b in a)a.hasOwnProperty(b)&&qb.hasOwnProperty(b)&&(c[b]=a[b]);return c}function j(a){return 0>a?Math.ceil(a):Math.floor(a)}function k(a,b,c){for(var d=""+Math.abs(a),e=a>=0;d.length<b;)d="0"+d;return(e?c?"+":"":"-")+d}function l(a,b,c,d){var e,f,g=b._milliseconds,h=b._days,i=b._months;g&&a._d.setTime(+a._d+g*c),(h||i)&&(e=a.minute(),f=a.hour()),h&&a.date(a.date()+h*c),i&&a.month(a.month()+i*c),g&&!d&&db.updateOffset(a),(h||i)&&(a.minute(e),a.hour(f))}function m(a){return"[object Array]"===Object.prototype.toString.call(a)}function n(a){return"[object Date]"===Object.prototype.toString.call(a)||a instanceof Date}function o(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;e>d;d++)(c&&a[d]!==b[d]||!c&&s(a[d])!==s(b[d]))&&g++;return g+f}function p(a){if(a){var b=a.toLowerCase().replace(/(.)s$/,"$1");a=Tb[a]||Ub[b]||b}return a}function q(a){var b,c,d={};for(c in a)a.hasOwnProperty(c)&&(b=p(c),b&&(d[b]=a[c]));return d}function r(b){var c,d;if(0===b.indexOf("week"))c=7,d="day";else{if(0!==b.indexOf("month"))return;c=12,d="month"}db[b]=function(e,f){var g,h,i=db.fn._lang[b],j=[];if("number"==typeof e&&(f=e,e=a),h=function(a){var b=db().utc().set(d,a);return i.call(db.fn._lang,b,e||"")},null!=f)return h(f);for(g=0;c>g;g++)j.push(h(g));return j}}function s(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=b>=0?Math.floor(b):Math.ceil(b)),c}function t(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function u(a){return v(a)?366:365}function v(a){return a%4===0&&a%100!==0||a%400===0}function w(a){var b;a._a&&-2===a._pf.overflow&&(b=a._a[jb]<0||a._a[jb]>11?jb:a._a[kb]<1||a._a[kb]>t(a._a[ib],a._a[jb])?kb:a._a[lb]<0||a._a[lb]>23?lb:a._a[mb]<0||a._a[mb]>59?mb:a._a[nb]<0||a._a[nb]>59?nb:a._a[ob]<0||a._a[ob]>999?ob:-1,a._pf._overflowDayOfYear&&(ib>b||b>kb)&&(b=kb),a._pf.overflow=b)}function x(a){return null==a._isValid&&(a._isValid=!isNaN(a._d.getTime())&&a._pf.overflow<0&&!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)),a._isValid}function y(a){return a?a.toLowerCase().replace("_","-"):a}function z(a,b){return b._isUTC?db(a).zone(b._offset||0):db(a).local()}function A(a,b){return b.abbr=a,pb[a]||(pb[a]=new e),pb[a].set(b),pb[a]}function B(a){delete pb[a]}function C(a){var b,c,d,e,f=0,g=function(a){if(!pb[a]&&rb)try{require("./lang/"+a)}catch(b){}return pb[a]};if(!a)return db.fn._lang;if(!m(a)){if(c=g(a))return c;a=[a]}for(;f<a.length;){for(e=y(a[f]).split("-"),b=e.length,d=y(a[f+1]),d=d?d.split("-"):null;b>0;){if(c=g(e.slice(0,b).join("-")))return c;if(d&&d.length>=b&&o(e,d,!0)>=b-1)break;b--}f++}return db.fn._lang}function D(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function E(a){var b,c,d=a.match(vb);for(b=0,c=d.length;c>b;b++)d[b]=Yb[d[b]]?Yb[d[b]]:D(d[b]);return function(e){var f="";for(b=0;c>b;b++)f+=d[b]instanceof Function?d[b].call(e,a):d[b];return f}}function F(a,b){return a.isValid()?(b=G(b,a.lang()),Vb[b]||(Vb[b]=E(b)),Vb[b](a)):a.lang().invalidDate()}function G(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(wb.lastIndex=0;d>=0&&wb.test(a);)a=a.replace(wb,c),wb.lastIndex=0,d-=1;return a}function H(a,b){var c,d=
}
|