diff --git a/changelog.md b/changelog.md index ef1cc94..cdba59d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +3.2.0 (07 December, 2018) +* `title_format` can now be a function, allowing more customization + 3.1.3 (06 March, 2018) * Fix `top` and `left` positions that were working incorrectly because of hidden root element diff --git a/dist/pickmeup.min.js b/dist/pickmeup.min.js index 06b9d04..0196241 100644 --- a/dist/pickmeup.min.js +++ b/dist/pickmeup.min.js @@ -1,36 +1,36 @@ /* 0BSD */ -(function(F,y){"function"===typeof define&&define.amd?define(y):"object"===typeof exports?module.exports=y():F.pickmeup=y()})(this,function(){function F(a,b,c){c=c||[];if(a instanceof Element)b.apply(b,[a].concat(c));else{var d,e;d=a.length;for(e=0;em)){--h;q(G,-1);r=void 0;continue}r=new Date(k);if(!t&&(t=new Date(k), -t.setDate(1),q(t,1),A(t,-1),f&&f>t)){--h;q(G,1);t=void 0;continue}n.querySelector(".pmu-month").textContent=l;var u=function(a){return"range"==c.mode&&a>=(new Date(e[0])).getFullYear()&&a<=(new Date(e[1])).getFullYear()||"multiple"==c.mode&&-1!==e.reduce(function(a,c){a.push((new Date(c)).getFullYear());return a},[]).indexOf(a)||(new Date(e)).getFullYear()==a},v=function(a,b){var d=(new Date(e[0])).getFullYear(),k=(new Date(e[1])).getFullYear(),g=(new Date(e[0])).getMonth(),f=(new Date(e[1])).getMonth(); -return"range"==c.mode&&(a>d&&ad&&a==k&&b<=f||a==d&&a=g||a==d&&a==k&&b>=g&&b<=f)||"multiple"==c.mode&&-1!==e.reduce(function(a,c){c=new Date(c);a.push(c.getFullYear()+"-"+c.getMonth());return a},[]).indexOf(a+"-"+b)||(new Date(e)).getFullYear()==a&&(new Date(e)).getMonth()==b};(function(){var a=[],b=k.getFullYear()-6,d=(new Date(c.min)).getFullYear(),e=(new Date(c.max)).getFullYear(),f,h,l;for(l=0;12>l;++l)f=b+l,h=document.createElement("div"),h.textContent=f,h.__pickmeup_year=f,c.min&& -fe?g(h,"pmu-disabled"):u(f)&&g(h,"pmu-selected"),a.push(h);n.appendChild(c.instance_content_template(a,"pmu-years"))})();(function(){var a=[],b=k.getFullYear(),d=(new Date(c.min)).getFullYear(),e=(new Date(c.min)).getMonth(),f=(new Date(c.max)).getFullYear(),h=(new Date(c.max)).getMonth(),l,m;for(l=0;12>l;++l)m=document.createElement("div"),m.textContent=c.locales[c.locale].monthsShort[l],m.__pickmeup_month=l,m.__pickmeup_year=b,c.min&&(bf||l>h&&b>=f)?g(m,"pmu-disabled"): -v(b,l)&&g(m,"pmu-selected"),a.push(m);n.appendChild(c.instance_content_template(a,"pmu-months"))})();(function(){var a=[],b=k.getMonth(),d=x(new Date).valueOf(),e,f,h,l,m,t;(function(){k.setDate(1);var a=(k.getDay()-c.first_day)%7;A(k,-(a+(0>a?7:0)))})();for(e=0;42>e;++e)f=document.createElement("div"),f.textContent=k.getDate(),f.__pickmeup_day=k.getDate(),f.__pickmeup_month=k.getMonth(),f.__pickmeup_year=k.getFullYear(),b!=k.getMonth()&&g(f,"pmu-not-in-month"),0==k.getDay()?g(f,"pmu-sunday"):6== -k.getDay()&&g(f,"pmu-saturday"),h=c.render(new Date(k))||{},l=x(new Date(k)).valueOf(),m=c.min&&c.min>k||c.max&&c.max=c.date[0]&&l<=c.date[1],h.disabled||!("disabled"in h)&&m?g(f,"pmu-disabled"):(h.selected||!("selected"in h)&&t)&&g(f,"pmu-selected"),l==d&&g(f,"pmu-today"),h.class_name&&h.class_name.split(" ").forEach(g.bind(f,f)),a.push(f),A(k,1);n.appendChild(c.instance_content_template(a, -"pmu-days"))})()}t.setDate(1);r.setDate(1);q(r,1);A(r,-1);d=b.querySelector(".pmu-prev");b=b.querySelector(".pmu-next");d&&(d.style.visibility=c.min&&c.min>=t?"hidden":"visible");b&&(b.style.visibility=c.max&&c.max<=r?"hidden":"visible");C(a,"fill")}function v(a,b){var c=b.format,d=b.separator,e=b.locales[b.locale];if(a instanceof Date||a instanceof Number)return x(new Date(a));if(!a)return x(new Date);if(a instanceof Array){a=a.slice();for(c=0;cm?2E3:1900;break;case "H":case "I":case "k":case "l":k=parseInt(a[c],10);break;case "P":case "p":/pm/i.test(a[c])&&12>k?k+=12:/am/i.test(a[c])&&12<=k&&(k-=12);break;case "M":l=parseInt(a[c],10)}e=new Date(void 0===m?n.getFullYear():m,void 0===f?n.getMonth():f,void 0===g?n.getDate():g,void 0===k?n.getHours():k,void 0===l?n.getMinutes():l,0);isNaN(1*e)&&(e=new Date);return x(e)}function x(a){a.setHours(0,0,0,0);return a}function D(a,b,c){var d=a.getMonth(),e=a.getDate(),g=a.getFullYear(), -f=a.getDay(),m=a.getHours(),k=12<=m,l=k?m-12:m,n;n=new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0);var p=new Date(a.getFullYear(),0,0,0,0,0);n=Math.floor((n-p)/864E5);0==l&&(l=12);var p=a.getMinutes(),r=a.getSeconds();b=b.split("");for(var h,q=0;qe?"0"+e:e;break;case "e":h=e;break;case "H":h= -10>m?"0"+m:m;break;case "I":h=10>l?"0"+l:l;break;case "j":h=100>n?10>n?"00"+n:"0"+n:n;break;case "k":h=m;break;case "l":h=l;break;case "m":h=9>d?"0"+(1+d):1+d;break;case "M":h=10>p?"0"+p:p;break;case "p":case "P":h=k?"PM":"AM";break;case "s":h=Math.floor(a.getTime()/1E3);break;case "S":h=10>r?"0"+r:r;break;case "u":h=f+1;break;case "w":h=f;break;case "y":h=(""+g).substr(2,2);break;case "Y":h=g}b[q]=h}return b.join("")}function O(a,b){var c=a.__pickmeup.options,d;x(b);a:{var e;switch(c.mode){case "multiple":e= -b.valueOf();for(d=0;df+k&&(l=e.top-c.offsetHeight);lg+m&&(n=e.left-c.offsetWidth);na?new Date(b):c&&c :not(nav)")));for(var w=0;wv){--w;p(h,-1);r=void 0;continue}}r=new Date(f);if(!g){var g=new Date(f);g.setDate(1);p(g,1);A(g,-1);if(m&&m>g){--w;p(h,1);g=void 0;continue}}n.querySelector(".pmu-month").innerHTML=G;var q=function(a){return"range"===b.mode&&a>=(new Date(e[0])).getFullYear()&&a<=(new Date(e[1])).getFullYear()||"multiple"===b.mode&&-1!==e.reduce(function(a,b){a.push((new Date(b)).getFullYear());return a},[]).indexOf(a)||(new Date(e)).getFullYear()===a},t=function(a,c){var d=(new Date(e[0])).getFullYear(),f=(new Date(e[1])).getFullYear(), +h=(new Date(e[0])).getMonth(),g=(new Date(e[1])).getMonth();return"range"===b.mode&&(a>d&&ad&&a===f&&c<=g||a===d&&a=h||a===d&&a===f&&c>=h&&c<=g)||"multiple"===b.mode&&-1!==e.reduce(function(a,b){b=new Date(b);a.push(b.getFullYear()+"-"+b.getMonth());return a},[]).indexOf(a+"-"+c)||(new Date(e)).getFullYear()===a&&(new Date(e)).getMonth()===c};(function(){var a=[],c=f.getFullYear()-6,d=(new Date(b.min)).getFullYear(),e=(new Date(b.max)).getFullYear(),h;for(h=0;12>h;++h){var g=c+h;var m= +document.createElement("div");m.textContent=g;m.__pickmeup_year=g;b.min&&ge?l(m,"pmu-disabled"):q(g)&&l(m,"pmu-selected");a.push(m)}n.appendChild(b.instance_content_template(a,"pmu-years"))})();(function(){var a=[],c=f.getFullYear(),d=(new Date(b.min)).getFullYear(),e=(new Date(b.min)).getMonth(),g=(new Date(b.max)).getFullYear(),h=(new Date(b.max)).getMonth(),m;for(m=0;12>m;++m){var k=document.createElement("div");k.textContent=b.locales[b.locale].monthsShort[m];k.__pickmeup_month=m; +k.__pickmeup_year=c;b.min&&(cg||m>h&&c>=g)?l(k,"pmu-disabled"):t(c,m)&&l(k,"pmu-selected");a.push(k)}n.appendChild(b.instance_content_template(a,"pmu-months"))})();(function(){var a=[],c=f.getMonth(),d=x(new Date).valueOf(),e;(function(){f.setDate(1);var a=(f.getDay()-b.first_day)%7;A(f,-(a+(0>a?7:0)))})();for(e=0;42>e;++e){var g=document.createElement("div");g.textContent=f.getDate();g.__pickmeup_day=f.getDate();g.__pickmeup_month=f.getMonth();g.__pickmeup_year=f.getFullYear(); +c!==f.getMonth()&&l(g,"pmu-not-in-month");0===f.getDay()?l(g,"pmu-sunday"):6===f.getDay()&&l(g,"pmu-saturday");var h=b.render(new Date(f))||{};var m=x(new Date(f)).valueOf();var k=b.min&&b.min>f||b.max&&b.max=b.date[0]&&m<=b.date[1];h.disabled||!("disabled"in h)&&k?l(g,"pmu-disabled"):(h.selected||!("selected"in h)&&v)&&l(g,"pmu-selected");m===d&&l(g,"pmu-today"); +h.class_name&&h.class_name.split(" ").forEach(l.bind(g,g));a.push(g);A(f,1)}n.appendChild(b.instance_content_template(a,"pmu-days"))})()}g.setDate(1);r.setDate(1);p(r,1);A(r,-1);d=c.querySelector(".pmu-prev");c=c.querySelector(".pmu-next");d&&(d.style.visibility=b.min&&b.min>=g?"hidden":"visible");c&&(c.style.visibility=b.max&&b.max<=r?"hidden":"visible");C(a,"fill")}function t(a,c){var b=c.format,d=c.separator,e=c.locales[c.locale];if(a instanceof Date||a instanceof Number)return x(new Date(a)); +if(!a)return x(new Date);if(a instanceof Array){a=a.slice();for(b=0;bk?2E3:1900;break;case "H":case "I":case "k":case "l":var f=parseInt(a[b],10);break;case "P":case "p":/pm/i.test(a[b])&&12>f?f+=12:/am/i.test(a[b])&&12<=f&&(f-=12);break;case "M":var n=parseInt(a[b],10)}e=new Date(void 0===k?h.getFullYear():k,void 0===m?h.getMonth():m,void 0===l?h.getDate():l,void 0===f?h.getHours():f,void 0===n?h.getMinutes():n,0);isNaN(1*e)&& +(e=new Date);return x(e)}function x(a){a.setHours(0,0,0,0);return a}function D(a,c,b){var d=a.getMonth(),e=a.getDate(),h=a.getFullYear(),m=a.getDay(),k=a.getHours(),l=12<=k,f=l?k-12:k;var n=new Date(a.getFullYear(),a.getMonth(),a.getDate(),0,0,0);var p=new Date(a.getFullYear(),0,0,0,0,0);n=Math.floor((n-p)/864E5);0===f&&(f=12);p=a.getMinutes();var r=a.getSeconds();c=c.split("");for(var g,q=0;qe?"0"+e:e;break;case "e":g=e;break;case "H":g=10>k?"0"+k:k;break;case "I":g=10>f?"0"+f:f;break;case "j":g=100>n?10>n?"00"+n:"0"+n:n;break;case "k":g=k;break;case "l":g=f;break;case "m":g=9>d?"0"+(1+d):1+d;break;case "M":g=10>p?"0"+p:p;break;case "p":case "P":g=l?"PM":"AM";break;case "s":g=Math.floor(a.getTime()/1E3);break;case "S":g=10>r?"0"+r:r;break;case "u":g=m+1;break;case "w":g=m;break;case "y":g=(""+h).substr(2, +2);break;case "Y":g=h}c[q]=g}return c.join("")}function O(a,c){var b=a.__pickmeup.options,d;x(c);a:switch(b.mode){case "multiple":var e=c.valueOf();for(d=0;dm+p&&(f=e.top-b.offsetHeight);fh+l&&(n=e.left-b.offsetWidth);na?new Date(c):b&&b"},instance_content_template:function(a,c){var b=document.createElement("div");l(b,c);for(c=0;c", "repository" : {