diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b208ee..40beef6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.6 (Jan 19, 2019) + +- Fix wrong parameter for the `$.contains` function. + ## 1.0.5 (Jan 19, 2019) - Emulate click in touch devices to support hiding the picker automatically (#197). diff --git a/dist/datepicker.common.js b/dist/datepicker.common.js index 456b712..05c4de2 100644 --- a/dist/datepicker.common.js +++ b/dist/datepicker.common.js @@ -1,11 +1,11 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:06:03.574Z + * Date: 2019-01-19T09:15:49.236Z */ 'use strict'; @@ -269,6 +269,11 @@ var methods = { $(window).on(EVENT_RESIZE, this.onResize = proxy(this.place, this)); $(document).on(EVENT_CLICK, this.onGlobalClick = proxy(this.globalClick, this)); $(document).on(EVENT_KEYUP, this.onGlobalKeyup = proxy(this.globalKeyup, this)); + + if (IS_TOUCH_DEVICE) { + $(document).on(EVENT_TOUCH_START, this.onTouchStart = proxy(this.touchstart, this)); + } + this.place(); } }, @@ -290,6 +295,10 @@ var methods = { $(window).off(EVENT_RESIZE, this.onResize); $(document).off(EVENT_CLICK, this.onGlobalClick); $(document).off(EVENT_KEYUP, this.onGlobalKeyup); + + if (IS_TOUCH_DEVICE) { + $(document).off(EVENT_TOUCH_START, this.onTouchStart); + } } }, toggle: function toggle() { @@ -768,7 +777,7 @@ var handlers = { var target = _ref3.target; // Emulate click in touch devices to support hiding the picker automatically (#197). - if (this.isInput && target !== this.element && !$.contains(this.$picker, target)) { + if (this.isInput && target !== this.element && !$.contains(this.$picker[0], target)) { this.hide(); this.element.blur(); } @@ -1241,10 +1250,6 @@ function () { } else { $this.on(EVENT_CLICK, $.proxy(this.show, this)); } - - if (IS_TOUCH_DEVICE) { - $(document).on(EVENT_TOUCH_START, $.proxy(this.touchstart, this)); - } } } }, { @@ -1277,10 +1282,6 @@ function () { } else { $this.off(EVENT_CLICK, this.show); } - - if (IS_TOUCH_DEVICE) { - $(document).off(EVENT_TOUCH_START, this.touchstart); - } } } }, { diff --git a/dist/datepicker.css b/dist/datepicker.css index 53116ae..a38ba94 100644 --- a/dist/datepicker.css +++ b/dist/datepicker.css @@ -1,11 +1,11 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:05:59.993Z + * Date: 2019-01-19T09:15:45.725Z */ .datepicker-container { diff --git a/dist/datepicker.esm.js b/dist/datepicker.esm.js index 6922edf..a3f3951 100644 --- a/dist/datepicker.esm.js +++ b/dist/datepicker.esm.js @@ -1,11 +1,11 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:06:03.574Z + * Date: 2019-01-19T09:15:49.236Z */ import $ from 'jquery'; @@ -265,6 +265,11 @@ var methods = { $(window).on(EVENT_RESIZE, this.onResize = proxy(this.place, this)); $(document).on(EVENT_CLICK, this.onGlobalClick = proxy(this.globalClick, this)); $(document).on(EVENT_KEYUP, this.onGlobalKeyup = proxy(this.globalKeyup, this)); + + if (IS_TOUCH_DEVICE) { + $(document).on(EVENT_TOUCH_START, this.onTouchStart = proxy(this.touchstart, this)); + } + this.place(); } }, @@ -286,6 +291,10 @@ var methods = { $(window).off(EVENT_RESIZE, this.onResize); $(document).off(EVENT_CLICK, this.onGlobalClick); $(document).off(EVENT_KEYUP, this.onGlobalKeyup); + + if (IS_TOUCH_DEVICE) { + $(document).off(EVENT_TOUCH_START, this.onTouchStart); + } } }, toggle: function toggle() { @@ -764,7 +773,7 @@ var handlers = { var target = _ref3.target; // Emulate click in touch devices to support hiding the picker automatically (#197). - if (this.isInput && target !== this.element && !$.contains(this.$picker, target)) { + if (this.isInput && target !== this.element && !$.contains(this.$picker[0], target)) { this.hide(); this.element.blur(); } @@ -1237,10 +1246,6 @@ function () { } else { $this.on(EVENT_CLICK, $.proxy(this.show, this)); } - - if (IS_TOUCH_DEVICE) { - $(document).on(EVENT_TOUCH_START, $.proxy(this.touchstart, this)); - } } } }, { @@ -1273,10 +1278,6 @@ function () { } else { $this.off(EVENT_CLICK, this.show); } - - if (IS_TOUCH_DEVICE) { - $(document).off(EVENT_TOUCH_START, this.touchstart); - } } } }, { diff --git a/dist/datepicker.js b/dist/datepicker.js index 8e64923..4167cf8 100644 --- a/dist/datepicker.js +++ b/dist/datepicker.js @@ -1,11 +1,11 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:06:03.574Z + * Date: 2019-01-19T09:15:49.236Z */ (function (global, factory) { @@ -271,6 +271,11 @@ $(window).on(EVENT_RESIZE, this.onResize = proxy(this.place, this)); $(document).on(EVENT_CLICK, this.onGlobalClick = proxy(this.globalClick, this)); $(document).on(EVENT_KEYUP, this.onGlobalKeyup = proxy(this.globalKeyup, this)); + + if (IS_TOUCH_DEVICE) { + $(document).on(EVENT_TOUCH_START, this.onTouchStart = proxy(this.touchstart, this)); + } + this.place(); } }, @@ -292,6 +297,10 @@ $(window).off(EVENT_RESIZE, this.onResize); $(document).off(EVENT_CLICK, this.onGlobalClick); $(document).off(EVENT_KEYUP, this.onGlobalKeyup); + + if (IS_TOUCH_DEVICE) { + $(document).off(EVENT_TOUCH_START, this.onTouchStart); + } } }, toggle: function toggle() { @@ -770,7 +779,7 @@ var target = _ref3.target; // Emulate click in touch devices to support hiding the picker automatically (#197). - if (this.isInput && target !== this.element && !$.contains(this.$picker, target)) { + if (this.isInput && target !== this.element && !$.contains(this.$picker[0], target)) { this.hide(); this.element.blur(); } @@ -1243,10 +1252,6 @@ } else { $this.on(EVENT_CLICK, $.proxy(this.show, this)); } - - if (IS_TOUCH_DEVICE) { - $(document).on(EVENT_TOUCH_START, $.proxy(this.touchstart, this)); - } } } }, { @@ -1279,10 +1284,6 @@ } else { $this.off(EVENT_CLICK, this.show); } - - if (IS_TOUCH_DEVICE) { - $(document).off(EVENT_TOUCH_START, this.touchstart); - } } } }, { diff --git a/dist/datepicker.min.css b/dist/datepicker.min.css index f2dc568..8dead12 100644 --- a/dist/datepicker.min.css +++ b/dist/datepicker.min.css @@ -1,9 +1,9 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:05:59.993Z + * Date: 2019-01-19T09:15:45.725Z */.datepicker-container{background-color:#fff;direction:ltr;font-size:12px;left:0;line-height:30px;position:fixed;-webkit-tap-highlight-color:transparent;top:0;-ms-touch-action:none;touch-action:none;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:210px;z-index:-1}.datepicker-container:after,.datepicker-container:before{border:5px solid rgba(0,0,0,0);content:" ";display:block;height:0;position:absolute;width:0}.datepicker-dropdown{border:1px solid #ccc;-webkit-box-shadow:0 3px 6px #ccc;box-shadow:0 3px 6px #ccc;-webkit-box-sizing:content-box;box-sizing:content-box;position:absolute;z-index:1}.datepicker-inline{position:static}.datepicker-top-left,.datepicker-top-right{border-top-color:#39f}.datepicker-top-left:after,.datepicker-top-left:before,.datepicker-top-right:after,.datepicker-top-right:before{border-top:0;left:10px;top:-5px}.datepicker-top-left:before,.datepicker-top-right:before{border-bottom-color:#39f}.datepicker-top-left:after,.datepicker-top-right:after{border-bottom-color:#fff;top:-4px}.datepicker-bottom-left,.datepicker-bottom-right{border-bottom-color:#39f}.datepicker-bottom-left:after,.datepicker-bottom-left:before,.datepicker-bottom-right:after,.datepicker-bottom-right:before{border-bottom:0;bottom:-5px;left:10px}.datepicker-bottom-left:before,.datepicker-bottom-right:before{border-top-color:#39f}.datepicker-bottom-left:after,.datepicker-bottom-right:after{border-top-color:#fff;bottom:-4px}.datepicker-bottom-right:after,.datepicker-bottom-right:before,.datepicker-top-right:after,.datepicker-top-right:before{left:auto;right:10px}.datepicker-panel>ul{margin:0;padding:0;width:102%}.datepicker-panel>ul:after,.datepicker-panel>ul:before{content:" ";display:table}.datepicker-panel>ul:after{clear:both}.datepicker-panel>ul>li{background-color:#fff;cursor:pointer;float:left;height:30px;list-style:none;margin:0;padding:0;text-align:center;width:30px}.datepicker-panel>ul>li:hover{background-color:#e5f2ff}.datepicker-panel>ul>li.muted,.datepicker-panel>ul>li.muted:hover{color:#999}.datepicker-panel>ul>li.highlighted{background-color:#e5f2ff}.datepicker-panel>ul>li.highlighted:hover{background-color:#cce5ff}.datepicker-panel>ul>li.picked,.datepicker-panel>ul>li.picked:hover{color:#39f}.datepicker-panel>ul>li.disabled,.datepicker-panel>ul>li.disabled:hover{background-color:#fff;color:#ccc;cursor:default}.datepicker-panel>ul>li.disabled.highlighted,.datepicker-panel>ul>li.disabled:hover.highlighted{background-color:#e5f2ff}.datepicker-panel>ul>li[data-view="month next"],.datepicker-panel>ul>li[data-view="month prev"],.datepicker-panel>ul>li[data-view="year next"],.datepicker-panel>ul>li[data-view="year prev"],.datepicker-panel>ul>li[data-view="years next"],.datepicker-panel>ul>li[data-view="years prev"],.datepicker-panel>ul>li[data-view=next]{font-size:18px}.datepicker-panel>ul>li[data-view="month current"],.datepicker-panel>ul>li[data-view="year current"],.datepicker-panel>ul>li[data-view="years current"]{width:150px}.datepicker-panel>ul[data-view=months]>li,.datepicker-panel>ul[data-view=years]>li{height:52.5px;line-height:52.5px;width:52.5px}.datepicker-panel>ul[data-view=week]>li,.datepicker-panel>ul[data-view=week]>li:hover{background-color:#fff;cursor:default}.datepicker-hide{display:none} \ No newline at end of file diff --git a/dist/datepicker.min.js b/dist/datepicker.min.js index ccbd2ad..bc24419 100644 --- a/dist/datepicker.min.js +++ b/dist/datepicker.min.js @@ -1,10 +1,10 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:06:03.574Z + * Date: 2019-01-19T09:15:49.236Z */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],e):e((t=t||self).jQuery)}(this,function(D){"use strict";function s(t,e){for(var i=0;i
',offset:10,zIndex:1e3,filter:null,show:null,hide:null,pick:null},t="undefined"!=typeof window,e=t?window:{},r=!!t&&"ontouchstart"in e.document.documentElement,c="datepicker",h="click.".concat(c),o="focus.".concat(c),l="hide.".concat(c),d="keyup.".concat(c),u="pick.".concat(c),i="resize.".concat(c),a="scroll.".concat(c),p="show.".concat(c),f="touchstart.".concat(c),g="".concat(c,"-hide"),y={},m=0,v=1,w=2,k=Object.prototype.toString;function b(t){return"string"==typeof t}var C=Number.isNaN||e.isNaN;function $(t){return"number"==typeof t&&!C(t)}function x(t){return void 0===t}function F(t){return"date"===(e=t,k.call(e).slice(8,-1).toLowerCase())&&!C(t.getTime());var e}function M(a,s){for(var t=arguments.length,n=new Array(2a.getFullYear(),6===t&&(u=f)),!f&&n&&(f=!1===n.call(this.$element,p,"year"));var g=h+t===l,y=g?"year picked":"year";c.push(this.createItem({picked:g,disabled:f,text:h+t,view:f?"year disabled":y,highlighted:p.getFullYear()===o}))}this.$yearsPrev.toggleClass(s,d),this.$yearsNext.toggleClass(s,u),this.$yearsCurrent.toggleClass(s,!0).html("".concat(h+-5+r," - ").concat(h+6).concat(r)),this.$years.html(c.join(""))},renderMonths:function(){var t,e=this.options,i=this.startDate,a=this.endDate,s=this.viewDate,n=e.disabledClass||"",r=e.monthsShort,h=D.isFunction(e.filter)&&e.filter,o=s.getFullYear(),l=new Date,c=l.getFullYear(),d=l.getMonth(),u=this.date.getFullYear(),p=this.date.getMonth(),f=[],g=!1,y=!1;for(t=0;t<=11;t+=1){var m=new Date(o,t,1),v=!1;i&&(v=(g=m.getFullYear()===i.getFullYear())&&m.getMonth()a.getMonth()),!v&&h&&(v=!1===h.call(this.$element,m,"month"));var w=o===u&&t===p,k=w?"month picked":"month";f.push(this.createItem({disabled:v,picked:w,highlighted:o===c&&m.getMonth()===d,index:t,text:r[t],view:v?"month disabled":k}))}this.$yearPrev.toggleClass(n,g),this.$yearNext.toggleClass(n,y),this.$yearCurrent.toggleClass(n,g&&y).html(o+e.yearSuffix||""),this.$months.html(f.join(""))},renderDays:function(){var t,e,i,a=this.$element,s=this.options,n=this.startDate,r=this.endDate,h=this.viewDate,o=this.date,l=s.disabledClass,c=s.filter,d=s.months,u=s.weekStart,p=s.yearSuffix,f=h.getFullYear(),g=h.getMonth(),y=new Date,m=y.getFullYear(),v=y.getMonth(),w=y.getDate(),k=o.getFullYear(),D=o.getMonth(),b=o.getDate(),C=[],$=f,x=g,F=!1;0===g?($-=1,x=11):x-=1,t=G($,x);var M=new Date(f,g,1);for((i=M.getDay()-parseInt(u,10)%7)<=0&&(i+=7),n&&(F=M.getTime()<=n.getTime()),e=t-(i-1);e<=t;e+=1){var Y=new Date($,x,e),V=!1;n&&(V=Y.getTime()=r.getTime()),e=1;e<=i;e+=1){var j=new Date(T,S,e),q=T===k&&S===D&&e===b,A=!1;r&&(A=j.getTime()>r.getTime()),!A&&c&&(A=!1===c.call(a,j,"day")),I.push(this.createItem({disabled:A,picked:q,highlighted:T===m&&S===v&&j.getDate()===w,muted:!0,text:e,view:"day next"}))}var O=[];for(e=1;e<=t;e+=1){var W=new Date(f,g,e),z=!1;n&&(z=W.getTime()r.getTime()),!z&&c&&(z=!1===c.call(a,W,"day"));var J=f===k&&g===D&&e===b,E=J?"day picked":"day";O.push(this.createItem({disabled:z,picked:J,highlighted:f===m&&g===v&&W.getDate()===w,text:e,view:z?"day disabled":E}))}this.$monthPrev.toggleClass(l,F),this.$monthNext.toggleClass(l,P),this.$monthCurrent.toggleClass(l,F&&P).html(s.yearFirst?"".concat(f+p," ").concat(d[g]):"".concat(d[g]," ").concat(f).concat(p)),this.$days.html(C.join("")+O.join("")+I.join(""))}},q="".concat(c,"-top-left"),A="".concat(c,"-top-right"),O="".concat(c,"-bottom-left"),W="".concat(c,"-bottom-right"),z=[q,A,O,W].join(" "),J=function(){function i(t){var e=1a.getTime()&&(s=new Date(a)),this.endDate=a),this.date=s,this.viewDate=new Date(s),this.initialDate=new Date(this.date),this.bind(),(e.autoShow||this.inline)&&this.show(),e.autoPick&&this.pick()}},{key:"build",value:function(){if(!this.built){this.built=!0;var t=this.$element,e=this.options,i=D(e.template);this.$picker=i,this.$week=i.find(Y("week")),this.$yearsPicker=i.find(Y("years picker")),this.$yearsPrev=i.find(Y("years prev")),this.$yearsNext=i.find(Y("years next")),this.$yearsCurrent=i.find(Y("years current")),this.$years=i.find(Y("years")),this.$monthsPicker=i.find(Y("months picker")),this.$yearPrev=i.find(Y("year prev")),this.$yearNext=i.find(Y("year next")),this.$yearCurrent=i.find(Y("year current")),this.$months=i.find(Y("months")),this.$daysPicker=i.find(Y("days picker")),this.$monthPrev=i.find(Y("month prev")),this.$monthNext=i.find(Y("month next")),this.$monthCurrent=i.find(Y("month current")),this.$days=i.find(Y("days")),this.inline?D(e.container||t).append(i.addClass("".concat(c,"-inline"))):(D(document.body).append(i.addClass("".concat(c,"-dropdown"))),i.addClass(g).css({zIndex:parseInt(e.zIndex,10)})),this.renderWeek()}}},{key:"unbuild",value:function(){this.built&&(this.built=!1,this.$picker.remove())}},{key:"bind",value:function(){var t=this.options,e=this.$element;D.isFunction(t.show)&&e.on(p,t.show),D.isFunction(t.hide)&&e.on(l,t.hide),D.isFunction(t.pick)&&e.on(u,t.pick),this.isInput&&e.on(d,D.proxy(this.keyup,this)),this.inline||(t.trigger?this.$trigger.on(h,D.proxy(this.toggle,this)):this.isInput?e.on(o,D.proxy(this.show,this)):e.on(h,D.proxy(this.show,this)),r&&D(document).on(f,D.proxy(this.touchstart,this)))}},{key:"unbind",value:function(){var t=this.$element,e=this.options;D.isFunction(e.show)&&t.off(p,e.show),D.isFunction(e.hide)&&t.off(l,e.hide),D.isFunction(e.pick)&&t.off(u,e.pick),this.isInput&&t.off(d,this.keyup),this.inline||(e.trigger?this.$trigger.off(h,this.toggle):this.isInput?t.off(o,this.show):t.off(h,this.show),r&&D(document).off(f,this.touchstart))}},{key:"showView",value:function(t){var e=this.$yearsPicker,i=this.$monthsPicker,a=this.$daysPicker,s=this.format;if(s.hasYear||s.hasMonth||s.hasDay)switch(Number(t)){case w:i.addClass(g),a.addClass(g),s.hasYear?(this.renderYears(),e.removeClass(g),this.place()):this.showView(m);break;case v:e.addClass(g),a.addClass(g),s.hasMonth?(this.renderMonths(),i.removeClass(g),this.place()):this.showView(w);break;default:e.addClass(g),i.addClass(g),s.hasDay?(this.renderDays(),a.removeClass(g),this.place()):this.showView(v)}}},{key:"hideView",value:function(){!this.inline&&this.options.autoHide&&this.hide()}},{key:"place",value:function(){if(!this.inline){var t=this.$element,e=this.options,i=this.$picker,a=D(document).outerWidth(),s=D(document).outerHeight(),n=t.outerWidth(),r=t.outerHeight(),h=i.width(),o=i.height(),l=t.offset(),c=l.left,d=l.top,u=parseFloat(e.offset),p=q;C(u)&&(u=10),o').concat(a.text,"")}},{key:"getValue",value:function(){var t=this.$element;return this.isInput?t.val():t.text()}},{key:"setValue",value:function(){var t=0
          ',offset:10,zIndex:1e3,filter:null,show:null,hide:null,pick:null},t="undefined"!=typeof window,e=t?window:{},i=!!t&&"ontouchstart"in e.document.documentElement,c="datepicker",r="click.".concat(c),h="focus.".concat(c),o="hide.".concat(c),l="keyup.".concat(c),d="pick.".concat(c),a="resize.".concat(c),u="scroll.".concat(c),p="show.".concat(c),f="touchstart.".concat(c),g="".concat(c,"-hide"),y={},m=0,v=1,w=2,k=Object.prototype.toString;function b(t){return"string"==typeof t}var C=Number.isNaN||e.isNaN;function $(t){return"number"==typeof t&&!C(t)}function x(t){return void 0===t}function F(t){return"date"===(e=t,k.call(e).slice(8,-1).toLowerCase())&&!C(t.getTime());var e}function M(a,s){for(var t=arguments.length,n=new Array(2a.getFullYear(),6===t&&(u=f)),!f&&n&&(f=!1===n.call(this.$element,p,"year"));var g=h+t===l,y=g?"year picked":"year";c.push(this.createItem({picked:g,disabled:f,text:h+t,view:f?"year disabled":y,highlighted:p.getFullYear()===o}))}this.$yearsPrev.toggleClass(s,d),this.$yearsNext.toggleClass(s,u),this.$yearsCurrent.toggleClass(s,!0).html("".concat(h+-5+r," - ").concat(h+6).concat(r)),this.$years.html(c.join(""))},renderMonths:function(){var t,e=this.options,i=this.startDate,a=this.endDate,s=this.viewDate,n=e.disabledClass||"",r=e.monthsShort,h=D.isFunction(e.filter)&&e.filter,o=s.getFullYear(),l=new Date,c=l.getFullYear(),d=l.getMonth(),u=this.date.getFullYear(),p=this.date.getMonth(),f=[],g=!1,y=!1;for(t=0;t<=11;t+=1){var m=new Date(o,t,1),v=!1;i&&(v=(g=m.getFullYear()===i.getFullYear())&&m.getMonth()a.getMonth()),!v&&h&&(v=!1===h.call(this.$element,m,"month"));var w=o===u&&t===p,k=w?"month picked":"month";f.push(this.createItem({disabled:v,picked:w,highlighted:o===c&&m.getMonth()===d,index:t,text:r[t],view:v?"month disabled":k}))}this.$yearPrev.toggleClass(n,g),this.$yearNext.toggleClass(n,y),this.$yearCurrent.toggleClass(n,g&&y).html(o+e.yearSuffix||""),this.$months.html(f.join(""))},renderDays:function(){var t,e,i,a=this.$element,s=this.options,n=this.startDate,r=this.endDate,h=this.viewDate,o=this.date,l=s.disabledClass,c=s.filter,d=s.months,u=s.weekStart,p=s.yearSuffix,f=h.getFullYear(),g=h.getMonth(),y=new Date,m=y.getFullYear(),v=y.getMonth(),w=y.getDate(),k=o.getFullYear(),D=o.getMonth(),b=o.getDate(),C=[],$=f,x=g,F=!1;0===g?($-=1,x=11):x-=1,t=G($,x);var M=new Date(f,g,1);for((i=M.getDay()-parseInt(u,10)%7)<=0&&(i+=7),n&&(F=M.getTime()<=n.getTime()),e=t-(i-1);e<=t;e+=1){var Y=new Date($,x,e),V=!1;n&&(V=Y.getTime()=r.getTime()),e=1;e<=i;e+=1){var j=new Date(S,I,e),q=S===k&&I===D&&e===b,A=!1;r&&(A=j.getTime()>r.getTime()),!A&&c&&(A=!1===c.call(a,j,"day")),T.push(this.createItem({disabled:A,picked:q,highlighted:S===m&&I===v&&j.getDate()===w,muted:!0,text:e,view:"day next"}))}var O=[];for(e=1;e<=t;e+=1){var W=new Date(f,g,e),z=!1;n&&(z=W.getTime()r.getTime()),!z&&c&&(z=!1===c.call(a,W,"day"));var J=f===k&&g===D&&e===b,E=J?"day picked":"day";O.push(this.createItem({disabled:z,picked:J,highlighted:f===m&&g===v&&W.getDate()===w,text:e,view:z?"day disabled":E}))}this.$monthPrev.toggleClass(l,F),this.$monthNext.toggleClass(l,P),this.$monthCurrent.toggleClass(l,F&&P).html(s.yearFirst?"".concat(f+p," ").concat(d[g]):"".concat(d[g]," ").concat(f).concat(p)),this.$days.html(C.join("")+O.join("")+T.join(""))}},q="".concat(c,"-top-left"),A="".concat(c,"-top-right"),O="".concat(c,"-bottom-left"),W="".concat(c,"-bottom-right"),z=[q,A,O,W].join(" "),J=function(){function i(t){var e=1a.getTime()&&(s=new Date(a)),this.endDate=a),this.date=s,this.viewDate=new Date(s),this.initialDate=new Date(this.date),this.bind(),(e.autoShow||this.inline)&&this.show(),e.autoPick&&this.pick()}},{key:"build",value:function(){if(!this.built){this.built=!0;var t=this.$element,e=this.options,i=D(e.template);this.$picker=i,this.$week=i.find(Y("week")),this.$yearsPicker=i.find(Y("years picker")),this.$yearsPrev=i.find(Y("years prev")),this.$yearsNext=i.find(Y("years next")),this.$yearsCurrent=i.find(Y("years current")),this.$years=i.find(Y("years")),this.$monthsPicker=i.find(Y("months picker")),this.$yearPrev=i.find(Y("year prev")),this.$yearNext=i.find(Y("year next")),this.$yearCurrent=i.find(Y("year current")),this.$months=i.find(Y("months")),this.$daysPicker=i.find(Y("days picker")),this.$monthPrev=i.find(Y("month prev")),this.$monthNext=i.find(Y("month next")),this.$monthCurrent=i.find(Y("month current")),this.$days=i.find(Y("days")),this.inline?D(e.container||t).append(i.addClass("".concat(c,"-inline"))):(D(document.body).append(i.addClass("".concat(c,"-dropdown"))),i.addClass(g).css({zIndex:parseInt(e.zIndex,10)})),this.renderWeek()}}},{key:"unbuild",value:function(){this.built&&(this.built=!1,this.$picker.remove())}},{key:"bind",value:function(){var t=this.options,e=this.$element;D.isFunction(t.show)&&e.on(p,t.show),D.isFunction(t.hide)&&e.on(o,t.hide),D.isFunction(t.pick)&&e.on(d,t.pick),this.isInput&&e.on(l,D.proxy(this.keyup,this)),this.inline||(t.trigger?this.$trigger.on(r,D.proxy(this.toggle,this)):this.isInput?e.on(h,D.proxy(this.show,this)):e.on(r,D.proxy(this.show,this)))}},{key:"unbind",value:function(){var t=this.$element,e=this.options;D.isFunction(e.show)&&t.off(p,e.show),D.isFunction(e.hide)&&t.off(o,e.hide),D.isFunction(e.pick)&&t.off(d,e.pick),this.isInput&&t.off(l,this.keyup),this.inline||(e.trigger?this.$trigger.off(r,this.toggle):this.isInput?t.off(h,this.show):t.off(r,this.show))}},{key:"showView",value:function(t){var e=this.$yearsPicker,i=this.$monthsPicker,a=this.$daysPicker,s=this.format;if(s.hasYear||s.hasMonth||s.hasDay)switch(Number(t)){case w:i.addClass(g),a.addClass(g),s.hasYear?(this.renderYears(),e.removeClass(g),this.place()):this.showView(m);break;case v:e.addClass(g),a.addClass(g),s.hasMonth?(this.renderMonths(),i.removeClass(g),this.place()):this.showView(w);break;default:e.addClass(g),i.addClass(g),s.hasDay?(this.renderDays(),a.removeClass(g),this.place()):this.showView(v)}}},{key:"hideView",value:function(){!this.inline&&this.options.autoHide&&this.hide()}},{key:"place",value:function(){if(!this.inline){var t=this.$element,e=this.options,i=this.$picker,a=D(document).outerWidth(),s=D(document).outerHeight(),n=t.outerWidth(),r=t.outerHeight(),h=i.width(),o=i.height(),l=t.offset(),c=l.left,d=l.top,u=parseFloat(e.offset),p=q;C(u)&&(u=10),o').concat(a.text,"")}},{key:"getValue",value:function(){var t=this.$element;return this.isInput?t.val():t.text()}},{key:"setValue",value:function(){var t=0
          -

          Datepicker v1.0.5

          +

          Datepicker v1.0.6

          A simple jQuery datepicker plugin.

          diff --git a/docs/js/datepicker.js b/docs/js/datepicker.js index 8e64923..4167cf8 100644 --- a/docs/js/datepicker.js +++ b/docs/js/datepicker.js @@ -1,11 +1,11 @@ /*! - * Datepicker v1.0.5 + * Datepicker v1.0.6 * https://fengyuanchen.github.io/datepicker * * Copyright 2014-present Chen Fengyuan * Released under the MIT license * - * Date: 2019-01-19T07:06:03.574Z + * Date: 2019-01-19T09:15:49.236Z */ (function (global, factory) { @@ -271,6 +271,11 @@ $(window).on(EVENT_RESIZE, this.onResize = proxy(this.place, this)); $(document).on(EVENT_CLICK, this.onGlobalClick = proxy(this.globalClick, this)); $(document).on(EVENT_KEYUP, this.onGlobalKeyup = proxy(this.globalKeyup, this)); + + if (IS_TOUCH_DEVICE) { + $(document).on(EVENT_TOUCH_START, this.onTouchStart = proxy(this.touchstart, this)); + } + this.place(); } }, @@ -292,6 +297,10 @@ $(window).off(EVENT_RESIZE, this.onResize); $(document).off(EVENT_CLICK, this.onGlobalClick); $(document).off(EVENT_KEYUP, this.onGlobalKeyup); + + if (IS_TOUCH_DEVICE) { + $(document).off(EVENT_TOUCH_START, this.onTouchStart); + } } }, toggle: function toggle() { @@ -770,7 +779,7 @@ var target = _ref3.target; // Emulate click in touch devices to support hiding the picker automatically (#197). - if (this.isInput && target !== this.element && !$.contains(this.$picker, target)) { + if (this.isInput && target !== this.element && !$.contains(this.$picker[0], target)) { this.hide(); this.element.blur(); } @@ -1243,10 +1252,6 @@ } else { $this.on(EVENT_CLICK, $.proxy(this.show, this)); } - - if (IS_TOUCH_DEVICE) { - $(document).on(EVENT_TOUCH_START, $.proxy(this.touchstart, this)); - } } } }, { @@ -1279,10 +1284,6 @@ } else { $this.off(EVENT_CLICK, this.show); } - - if (IS_TOUCH_DEVICE) { - $(document).off(EVENT_TOUCH_START, this.touchstart); - } } } }, { diff --git a/package-lock.json b/package-lock.json index 4fc4616..f11f9f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@chenfengyuan/datepicker", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 41f4421..b1cb082 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@chenfengyuan/datepicker", "description": "A simple jQuery datepicker plugin.", - "version": "1.0.5", + "version": "1.0.6", "main": "dist/datepicker.common.js", "module": "dist/datepicker.esm.js", "unpkg": "dist/datepicker.js",