@majidh1/jalalidatepicker
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -19,3 +19,3 @@ /* | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"NAMESPACE\": () => (/* binding */ NAMESPACE),\n/* harmony export */ \"CONTAINER_ELM_QUERY\": () => (/* binding */ CONTAINER_ELM_QUERY),\n/* harmony export */ \"YEARS_ELM_QUERY\": () => (/* binding */ YEARS_ELM_QUERY),\n/* harmony export */ \"YEAR_ELM_QUERY\": () => (/* binding */ YEAR_ELM_QUERY),\n/* harmony export */ \"MONTHS_ELM_QUERY\": () => (/* binding */ MONTHS_ELM_QUERY),\n/* harmony export */ \"MONTH_ELM_QUERY\": () => (/* binding */ MONTH_ELM_QUERY),\n/* harmony export */ \"DAYS_ELM_QUERY\": () => (/* binding */ DAYS_ELM_QUERY),\n/* harmony export */ \"DAY_ELM_QUERY\": () => (/* binding */ DAY_ELM_QUERY),\n/* harmony export */ \"DAY_NAME_ELM_QUERY\": () => (/* binding */ DAY_NAME_ELM_QUERY),\n/* harmony export */ \"PLUS_ICON_ELM_QUERY\": () => (/* binding */ PLUS_ICON_ELM_QUERY),\n/* harmony export */ \"MINUS_ICON_ELM_QUERY\": () => (/* binding */ MINUS_ICON_ELM_QUERY),\n/* harmony export */ \"FOOTER_ELM_QUERY\": () => (/* binding */ FOOTER_ELM_QUERY),\n/* harmony export */ \"TODAY_BTN_ELM_QUERY\": () => (/* binding */ TODAY_BTN_ELM_QUERY),\n/* harmony export */ \"EMPTY_BTN_ELM_QUERY\": () => (/* binding */ EMPTY_BTN_ELM_QUERY),\n/* harmony export */ \"SELECTED_CLASS_NAME\": () => (/* binding */ SELECTED_CLASS_NAME),\n/* harmony export */ \"TODAY_CLASS_NAME\": () => (/* binding */ TODAY_CLASS_NAME),\n/* harmony export */ \"LAST_WEEK_CLASS_NAME\": () => (/* binding */ LAST_WEEK_CLASS_NAME),\n/* harmony export */ \"DISABLE_CLASS_NAME\": () => (/* binding */ DISABLE_CLASS_NAME),\n/* harmony export */ \"EVENT_CHANGE_INPUT\": () => (/* binding */ EVENT_CHANGE_INPUT),\n/* harmony export */ \"EVENT_CHANGE_MONTH_DROPDOWN_STR\": () => (/* binding */ EVENT_CHANGE_MONTH_DROPDOWN_STR),\n/* harmony export */ \"EVENT_CHANGE_YEAR_INPUT_STR\": () => (/* binding */ EVENT_CHANGE_YEAR_INPUT_STR),\n/* harmony export */ \"EVENT_CLICK_STR\": () => (/* binding */ EVENT_CLICK_STR),\n/* harmony export */ \"EVENT_FOCUS_STR\": () => (/* binding */ EVENT_FOCUS_STR),\n/* harmony export */ \"MIN_MAX_TODAY_SETTING\": () => (/* binding */ MIN_MAX_TODAY_SETTING),\n/* harmony export */ \"MIN_MAX_ATTR_SETTING\": () => (/* binding */ MIN_MAX_ATTR_SETTING),\n/* harmony export */ \"MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME\": () => (/* binding */ MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME),\n/* harmony export */ \"MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME\": () => (/* binding */ MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME),\n/* harmony export */ \"DATA_ATTR\": () => (/* binding */ DATA_ATTR)\n/* harmony export */ });\nvar NAMESPACE = \"jdp\";\nvar CONTAINER_ELM_QUERY = \"\".concat(NAMESPACE, \"-container\");\nvar YEARS_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-years\");\nvar YEAR_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-year\");\nvar MONTHS_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-months\");\nvar MONTH_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-month\");\nvar DAYS_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-days\");\nvar DAY_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-day\");\nvar DAY_NAME_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-day-name\");\nvar PLUS_ICON_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-icon-plus\");\nvar MINUS_ICON_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-icon-minus\");\nvar FOOTER_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-footer\");\nvar TODAY_BTN_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-btn-today\");\nvar EMPTY_BTN_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-btn-empty\");\nvar SELECTED_CLASS_NAME = \"selected\";\nvar TODAY_CLASS_NAME = \"today\";\nvar LAST_WEEK_CLASS_NAME = \"last-week\";\nvar DISABLE_CLASS_NAME = \"not-in-range\";\nvar EVENT_CHANGE_INPUT = new Event(\"change\");\nvar EVENT_CHANGE_MONTH_DROPDOWN_STR = \"change\";\nvar EVENT_CHANGE_YEAR_INPUT_STR = \"keyup change\";\nvar EVENT_CLICK_STR = \"click\";\nvar EVENT_FOCUS_STR = \"focus\";\nvar MIN_MAX_TODAY_SETTING = \"today\";\nvar MIN_MAX_ATTR_SETTING = \"attr\";\nvar MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME = \"data-jdp-max-date\";\nvar MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME = \"data-jdp-min-date\";\nvar DATA_ATTR = \"data-\".concat(NAMESPACE);\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/constants.js?"); | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"NAMESPACE\": () => (/* binding */ NAMESPACE),\n/* harmony export */ \"CONTAINER_ELM_QUERY\": () => (/* binding */ CONTAINER_ELM_QUERY),\n/* harmony export */ \"YEARS_ELM_QUERY\": () => (/* binding */ YEARS_ELM_QUERY),\n/* harmony export */ \"YEAR_ELM_QUERY\": () => (/* binding */ YEAR_ELM_QUERY),\n/* harmony export */ \"MONTHS_ELM_QUERY\": () => (/* binding */ MONTHS_ELM_QUERY),\n/* harmony export */ \"MONTH_ELM_QUERY\": () => (/* binding */ MONTH_ELM_QUERY),\n/* harmony export */ \"DAYS_ELM_QUERY\": () => (/* binding */ DAYS_ELM_QUERY),\n/* harmony export */ \"DAY_ELM_QUERY\": () => (/* binding */ DAY_ELM_QUERY),\n/* harmony export */ \"DAY_NAME_ELM_QUERY\": () => (/* binding */ DAY_NAME_ELM_QUERY),\n/* harmony export */ \"PLUS_ICON_ELM_QUERY\": () => (/* binding */ PLUS_ICON_ELM_QUERY),\n/* harmony export */ \"MINUS_ICON_ELM_QUERY\": () => (/* binding */ MINUS_ICON_ELM_QUERY),\n/* harmony export */ \"FOOTER_ELM_QUERY\": () => (/* binding */ FOOTER_ELM_QUERY),\n/* harmony export */ \"TODAY_BTN_ELM_QUERY\": () => (/* binding */ TODAY_BTN_ELM_QUERY),\n/* harmony export */ \"EMPTY_BTN_ELM_QUERY\": () => (/* binding */ EMPTY_BTN_ELM_QUERY),\n/* harmony export */ \"SELECTED_CLASS_NAME\": () => (/* binding */ SELECTED_CLASS_NAME),\n/* harmony export */ \"TODAY_CLASS_NAME\": () => (/* binding */ TODAY_CLASS_NAME),\n/* harmony export */ \"LAST_WEEK_CLASS_NAME\": () => (/* binding */ LAST_WEEK_CLASS_NAME),\n/* harmony export */ \"DISABLE_CLASS_NAME\": () => (/* binding */ DISABLE_CLASS_NAME),\n/* harmony export */ \"EVENT_CHANGE_INPUT\": () => (/* binding */ EVENT_CHANGE_INPUT),\n/* harmony export */ \"EVENT_CHANGE_MONTH_DROPDOWN_STR\": () => (/* binding */ EVENT_CHANGE_MONTH_DROPDOWN_STR),\n/* harmony export */ \"EVENT_CHANGE_YEAR_INPUT_STR\": () => (/* binding */ EVENT_CHANGE_YEAR_INPUT_STR),\n/* harmony export */ \"EVENT_CLICK_STR\": () => (/* binding */ EVENT_CLICK_STR),\n/* harmony export */ \"EVENT_FOCUS_STR\": () => (/* binding */ EVENT_FOCUS_STR),\n/* harmony export */ \"MIN_MAX_TODAY_SETTING\": () => (/* binding */ MIN_MAX_TODAY_SETTING),\n/* harmony export */ \"MIN_MAX_ATTR_SETTING\": () => (/* binding */ MIN_MAX_ATTR_SETTING),\n/* harmony export */ \"MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME\": () => (/* binding */ MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME),\n/* harmony export */ \"MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME\": () => (/* binding */ MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME),\n/* harmony export */ \"DATA_ATTR\": () => (/* binding */ DATA_ATTR)\n/* harmony export */ });\nvar NAMESPACE = \"jdp\";\nvar CONTAINER_ELM_QUERY = \"\".concat(NAMESPACE, \"-container\");\nvar YEARS_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-years\");\nvar YEAR_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-year\");\nvar MONTHS_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-months\");\nvar MONTH_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-month\");\nvar DAYS_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-days\");\nvar DAY_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-day\");\nvar DAY_NAME_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-day-name\");\nvar PLUS_ICON_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-icon-plus\");\nvar MINUS_ICON_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-icon-minus\");\nvar FOOTER_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-footer\");\nvar TODAY_BTN_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-btn-today\");\nvar EMPTY_BTN_ELM_QUERY = \"div.\".concat(NAMESPACE, \"-btn-empty\");\nvar SELECTED_CLASS_NAME = \"selected\";\nvar TODAY_CLASS_NAME = \"today\";\nvar LAST_WEEK_CLASS_NAME = \"last-week\";\nvar DISABLE_CLASS_NAME = \"not-in-range\";\nvar EVENT_CHANGE_INPUT = new CustomEvent(\"\".concat(NAMESPACE, \":change\"));\nvar EVENT_CHANGE_MONTH_DROPDOWN_STR = \"change\";\nvar EVENT_CHANGE_YEAR_INPUT_STR = \"keyup change\";\nvar EVENT_CLICK_STR = \"click\";\nvar EVENT_FOCUS_STR = \"focus\";\nvar MIN_MAX_TODAY_SETTING = \"today\";\nvar MIN_MAX_ATTR_SETTING = \"attr\";\nvar MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME = \"data-jdp-max-date\";\nvar MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME = \"data-jdp-min-date\";\nvar DATA_ATTR = \"data-\".concat(NAMESPACE);\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/constants.js?"); | ||
@@ -22,0 +22,0 @@ /***/ }), |
@@ -1,1 +0,1 @@ | ||
(()=>{"use strict";(()=>{var t=void 0;function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var e=Number.isNaN||window.isNaN,i=function(t){return void 0===t},a=function(t){return"string"==typeof t},o=function(t){return JSON.parse(JSON.stringify(t))},r=function(t){return 682*((t-474)%2820+512)%2816<682},s=function(t,n){return t<8?31*(t-1)+n:186+30*(t-7)+n},h=function(t,n,e){return i=function(t,n,e,i,a,o){for(var h=s(a,o)-s(n,e),u=t<i?i:t,c=t<i?t:i;c<u;c++)r(c)?h+=t<i?366:-366:h+=t<i?365:-365;return h}(1392,3,25,t,n,e),a=7,window.Math.abs(i-a*window.Math.floor(i/a));var i,a},u=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=String(Math.abs(t)),i=e.length,a="";for(t<0&&(a+="-");i<n;)i+=1,a+="0";return a+e},c=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},d=function e(){for(var a,o,r,s,h,u=arguments.length,d=new Array(u),p=0;p<u;p++)d[p]=arguments[p];var y=d[0]||{},l=1,f=d.length,m=!1;for("boolean"==typeof y&&(m=y,y=d[l]||{},l+=1),"object"!==n(y)&&"function"!=typeof y&&(y={}),l===f&&(y=t,l-=1);l<f;l++)if(a=d[l],!i(a)&&null!==a)for(var v=0;v<window.Object.keys(a).length;v++){var D=window.Object.keys(a)[v];if(Object.prototype.hasOwnProperty.call(a,D)){if(r=a[D],"__proto__"===D||y===r)return!0;s=Array.isArray(r),m&&r&&(c(r)||s)?(o=y[D],h=s&&!Array.isArray(o)?[]:s||c(o)?o:{},y[D]=e(m,h,r)):i(r)||(y[D]=r)}}return y},p=function(t,n,e,o,r){var s=t.split(".");t=s.shift()||"div";var h=s,u=window.document.createElement(t);return a(n)?window.document.querySelector(n).appendChild(u):n.appendChild(u),h.length&&(u.className=h.join(" ")),e&&o&&y(u,e,o),i(r)||l(u,r),u},y=function(t,n,e){for(var i=n.split(" "),a=0,o=i.length;a<o;a++)t.addEventListener(i[a],e,!1)},l=function(t,n){t.innerHTML=n},f=function(t,n,i,a,o,r){return e(t)||t<1e3||t>1e4?t=a.year:t<o.year?t=o.year:t>r.year&&(t=r.year),e(n)||n<1||n>12?n=a.month:t<=o.year&&n<o.month?n=o.month:t>=r.year&&n>r.month&&(n=r.month),e(i)||i<1?i=a.day:n<=o.month&&i<o.day?i=o.day:n>=r.month&&i>r.day&&(i=r.day),{year:parseInt(t),month:parseInt(n),day:parseInt(i)}},m=function(t,n){if(!t)return!1;var e=t.split(n);return 3===e.length&&4===e[0].length&&2===e[1].length&&2===e[2].length},v=function(t,n){var e=t.split(n);return{year:parseInt(e[0]),month:parseInt(e[1]),day:parseInt(e[2])}},D=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return n.ownerDocument.body;if(n instanceof HTMLElement){var e=window.getComputedStyle(n),i=e.overflow,a=e.overflowX,o=e.overflowY;if(/auto|scroll|overlay/.test(i+o+a))return n}return t(n.parentNode)},g="jdp",w="".concat(g,"-container"),_="div.".concat(g,"-years"),C="div.".concat(g,"-year"),b="div.".concat(g,"-months"),x="div.".concat(g,"-month"),I="div.".concat(g,"-days"),M="div.".concat(g,"-day"),S="div.".concat(g,"-day-name"),N="div.".concat(g,"-icon-plus"),j="div.".concat(g,"-icon-minus"),O="div.".concat(g,"-footer"),E="div.".concat(g,"-btn-today"),Y="div.".concat(g,"-btn-empty"),H="not-in-range",P=new Event("change"),k="click",L="focus",A="today",T="attr",z=("data-".concat(g),function(t){return 6===t?".".concat("last-week"):""}),B=function(t,n){p(N+(n?F.options.maxDate.year===F.initDate.year?".".concat(H):"":F.options.maxDate.year===F.initDate.year&&F.options.maxDate.month===F.initDate.month?".".concat(H):""),t,k,n?function(){F.increaseYear()}:function(){F.increaseMonth()},F.options.plusHtml)},W=function(t,n){p(j+(n?F.options.minDate.year===F.initDate.year?".".concat(H):"":F.options.minDate.year===F.initDate.year&&F.options.minDate.month===F.initDate.month?".".concat(H):""),t,k,n?function(){F.decreaseYear()}:function(){F.decreaseMonth()},F.options.minusHtml)},V=function(){var t=p(_,F.dpContainer);B(t,!0);var n=p(C,t);W(t,!0);var e=p("input",n,"keyup change",(function(t){F.yearChange(t.target.value)}));e.tabIndex=-1,e.value=F.initDate.year,e.type="number"},J=function(){var t=p(b,F.dpContainer);B(t,!1);var n=p(x,t);W(t,!1);var e=p("select",n,"change",(function(t){F.monthChange(t.target.value)}));e.tabIndex=-1;for(var i=function(t,n,e){var i=[],a=1,o=12;t.year===n.year?(a=n.month,t.year===e.year&&(o=e.month)):t.year===e.year&&(a=1,o=e.month);for(var r=a;r<=o;r++)i.push(r);return i}(F.initDate,F.options.minDate,F.options.maxDate),a=F.options.months,o=0;o<i.length;o++){var r=p("option",e);r.value=i[o],r.text=a[i[o]-1],r.selected=i[o]===F.initDate.month}},R=function(){for(var t=p(I,F.dpContainer),n=0;n<7;n++)p(S+z(n),t,null,null,F.options.days[n]);for(var e,i,a=(e=F.initDate.year,i=F.initDate.month,[0,31,31,31,31,31,31,30,30,30,30,30,r(e)?30:29][i]),o=h(F.initDate.year,F.initDate.month,1),s=7*Math.ceil((o+a)/7)-1,u=1,d=function(n){var e,i,o,r,s=h(F.initDate.year,F.initDate.month,u),d=(e=F.initDate,i=u,o=F.options.minDate,r=F.options.maxDate,!(!c(o)||!c(r))||(o.year===r.year&&o.month===r.month?i>=o.day&&i<=r.day:e.year===o.year&&e.month===o.month?i>=o.day:e.year!==r.year||e.month!==r.month||i<=r.day));if(u<=s&&n<s||u>a)return p(M,t),"continue";if(!d)return p(M,t),u+=1,"continue";var y=z(s);F.valueDate.day===u&&F.valueDate.year===F.initDate.year&&F.valueDate.month===F.initDate.month&&(y+=".".concat("selected")),F.today.day===u&&F.today.year===F.initDate.year&&F.today.month===F.initDate.month&&(y+=".".concat("today"));var l=p(M+y,t,null,null,u);l.day=u,l.addEventListener(k,(function(){F.setValue(F.initDate.year,F.initDate.month,l.day)})),u+=1},y=0;y<=s;y++)d(y)},q=function(){var t=p(O,F.dpContainer);F.options.showTodayBtn&&p(E,t,k,(function(){F.setValue(F.today.year,F.today.month,F.today.day)}),"امروز"),F.options.showEmptyBtn&&p(Y,t,k,(function(){F.setValue()}),"خالی")},F=null;const X={days:["ش","ی","د","س","چ","پ","ج"],months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],initDate:null,minDate:{},maxDate:{},separatorChar:"/",zIndex:1e3,container:"body",dpContainer:null,selector:"input[data-jdp]",autoShow:!0,autoHide:!0,plusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-256v256h-84v-256h-256v-84h256v-256h84v256h256v84z"></path></g></svg>',minusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-596v-84h596v84z"></path></g></svg>',changeMonthRotateYear:!1,showTodayBtn:!0,showEmptyBtn:!0};var G="visible",K={init:function(t){var n;this.options=d(X,t),this.options=U(this.options),window.onresize=$,this.options.autoHide&&(document.body.onclick=Z),this.options.autoShow&&(n=this.options.selector,document.querySelectorAll(n).forEach((function(t){t.addEventListener(L,(function(){K.show(t)}))})))},options:X,input:null,get dpContainer(){return this._dpContainer=this._dpContainer||p(w,this.options.container),this._dpContainer},get today(){return this._today=this._today||function(){var t,n,e=new Date,i=parseInt(e.getFullYear()),a=parseInt(e.getMonth())+1,o=parseInt(e.getDate());i>1600?(t=979,i-=1600):(t=0,i-=621);var r=a>2?i+1:i;return n=365*i+parseInt((r+3)/4)-parseInt((r+99)/100)+parseInt((r+399)/400)-80+o+[0,31,59,90,120,151,181,212,243,273,304,334][a-1],t+=33*parseInt(n/12053),n%=12053,t+=4*parseInt(n/1461),(n%=1461)>365&&(t+=parseInt((n-1)/365),n=(n-1)%365),{year:t,month:n<186?1+parseInt(n/31):7+parseInt((n-186)/30),day:1+(n<186?n%31:(n-186)%30)}}(),this._today},get valueDate(){return this._valueDate=o(this.input.value),a(this._valueDate)&&(m(this._valueDate,this.options.separatorChar)?this._valueDate=v(this._valueDate,this.options.separatorChar):this._valueDate={}),this._valueDate},get initDate(){return this._initDate=this._initDate||o(this.valueDate),c(this._initDate)&&(this._initDate=this.options.initDate||o(this.today)),a(this._initDate)&&m(this._initDate,this.options.separatorChar)&&(this._initDate=v(this._initDate,this.options.separatorChar)),f(this._initDate.year,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate)},_draw:function(){l((F=this).dpContainer,""),V(),J(),R(),q()},show:function(t){this._initDate=null,this._valueDate=null,this.input=t,this._draw(),this.dpContainer.style.visibility=G,this.dpContainer.style.display="block",this.dpContainer.style.zIndex=this.options.zIndex,this.setPosition(),function(t){D(t).addEventListener("scroll",(function(){K.setPosition()}),{passive:!0})}(t)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display="none"},setPosition:function(){if(this.dpContainer.style.visibility===G){for(var t=0,n=0,e=this.input,i=D(this.input);e.offsetParent;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;t+this.dpContainer.offsetWidth>=window.document.body.offsetWidth&&(t-=t+this.dpContainer.offsetWidth-(window.document.body.offsetWidth+10)),i&&(n-=i.scrollTop),this.dpContainer.style.left=t+"px",this.dpContainer.style.top=n+this.input.offsetHeight+"px"}},setValue:function(t,n,e){var i,a,o,r;this._valueDate.year=t,this._valueDate.month=n,this._valueDate.day=e,this.hide(),isNaN(t+n+e)?this.input.value="":this.input.value=(i=t,a=n,o=e,r=this.options.separatorChar,i+r+u(a)+r+u(o)),this.input.dispatchEvent(P)},increaseMonth:function(){this.options.changeMonthRotateYear&&12===this._initDate.month&&this.increaseYear(),this.monthChange(12===this._initDate.month?1:this._initDate.month+1)},decreaseMonth:function(){this.options.changeMonthRotateYear&&1===this._initDate.month&&this.decreaseYear(),this.monthChange(1===this._initDate.month?12:this._initDate.month-1)},monthChange:function(t){this._initDate=f(this._initDate.year,t,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()},increaseYear:function(){this.yearChange(this._initDate.year+1)},decreaseYear:function(){this.yearChange(this._initDate.year-1)},yearChange:function(t){this._initDate=f(t,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()}},Q=function(t,n){var e=K.input.getAttribute(t);return e=e===A?o(K.today):a(e)&&m(e,n)?v(e,n):{}},U=function(t){return t.minDate===A&&(t.minDate=o(K.today)),t.maxDate===A&&(t.maxDate=o(K.today)),t.minDate===T&&(delete t.minDate,window.Object.defineProperty(t,"minDate",{get:function(){return Q("data-jdp-min-date",t.separatorChar)}})),t.maxDate===T&&(delete t.maxDate,window.Object.defineProperty(t,"maxDate",{get:function(){return Q("data-jdp-max-date",t.separatorChar)}})),t};function Z(t){K.dpContainer.style.visibility===G&&-1===t.path.indexOf(K.dpContainer)&&-1===t.path.indexOf(K.input)&&K.hide()}function $(){K.setPosition()}window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};K.init(t)},show:function(t){K.show(t)},hide:function(){K.hide()}}})()})(); | ||
(()=>{"use strict";(()=>{var t=void 0;function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var e=Number.isNaN||window.isNaN,i=function(t){return void 0===t},a=function(t){return"string"==typeof t},o=function(t){return JSON.parse(JSON.stringify(t))},r=function(t){return 682*((t-474)%2820+512)%2816<682},s=function(t,n){return t<8?31*(t-1)+n:186+30*(t-7)+n},h=function(t,n,e){return i=function(t,n,e,i,a,o){for(var h=s(a,o)-s(n,e),u=t<i?i:t,c=t<i?t:i;c<u;c++)r(c)?h+=t<i?366:-366:h+=t<i?365:-365;return h}(1392,3,25,t,n,e),a=7,window.Math.abs(i-a*window.Math.floor(i/a));var i,a},u=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=String(Math.abs(t)),i=e.length,a="";for(t<0&&(a+="-");i<n;)i+=1,a+="0";return a+e},c=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},d=function e(){for(var a,o,r,s,h,u=arguments.length,d=new Array(u),p=0;p<u;p++)d[p]=arguments[p];var y=d[0]||{},l=1,f=d.length,m=!1;for("boolean"==typeof y&&(m=y,y=d[l]||{},l+=1),"object"!==n(y)&&"function"!=typeof y&&(y={}),l===f&&(y=t,l-=1);l<f;l++)if(a=d[l],!i(a)&&null!==a)for(var v=0;v<window.Object.keys(a).length;v++){var D=window.Object.keys(a)[v];if(Object.prototype.hasOwnProperty.call(a,D)){if(r=a[D],"__proto__"===D||y===r)return!0;s=Array.isArray(r),m&&r&&(c(r)||s)?(o=y[D],h=s&&!Array.isArray(o)?[]:s||c(o)?o:{},y[D]=e(m,h,r)):i(r)||(y[D]=r)}}return y},p=function(t,n,e,o,r){var s=t.split(".");t=s.shift()||"div";var h=s,u=window.document.createElement(t);return a(n)?window.document.querySelector(n).appendChild(u):n.appendChild(u),h.length&&(u.className=h.join(" ")),e&&o&&y(u,e,o),i(r)||l(u,r),u},y=function(t,n,e){for(var i=n.split(" "),a=0,o=i.length;a<o;a++)t.addEventListener(i[a],e,!1)},l=function(t,n){t.innerHTML=n},f=function(t,n,i,a,o,r){return e(t)||t<1e3||t>1e4?t=a.year:t<o.year?t=o.year:t>r.year&&(t=r.year),e(n)||n<1||n>12?n=a.month:t<=o.year&&n<o.month?n=o.month:t>=r.year&&n>r.month&&(n=r.month),e(i)||i<1?i=a.day:n<=o.month&&i<o.day?i=o.day:n>=r.month&&i>r.day&&(i=r.day),{year:parseInt(t),month:parseInt(n),day:parseInt(i)}},m=function(t,n){if(!t)return!1;var e=t.split(n);return 3===e.length&&4===e[0].length&&2===e[1].length&&2===e[2].length},v=function(t,n){var e=t.split(n);return{year:parseInt(e[0]),month:parseInt(e[1]),day:parseInt(e[2])}},D=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return n.ownerDocument.body;if(n instanceof HTMLElement){var e=window.getComputedStyle(n),i=e.overflow,a=e.overflowX,o=e.overflowY;if(/auto|scroll|overlay/.test(i+o+a))return n}return t(n.parentNode)},g="jdp",w="".concat(g,"-container"),_="div.".concat(g,"-years"),C="div.".concat(g,"-year"),b="div.".concat(g,"-months"),x="div.".concat(g,"-month"),I="div.".concat(g,"-days"),M="div.".concat(g,"-day"),S="div.".concat(g,"-day-name"),N="div.".concat(g,"-icon-plus"),j="div.".concat(g,"-icon-minus"),O="div.".concat(g,"-footer"),E="div.".concat(g,"-btn-today"),Y="div.".concat(g,"-btn-empty"),H="not-in-range",P=new CustomEvent("".concat(g,":change")),k="click",L="focus",A="today",T="attr",z=("data-".concat(g),function(t){return 6===t?".".concat("last-week"):""}),B=function(t,n){p(N+(n?F.options.maxDate.year===F.initDate.year?".".concat(H):"":F.options.maxDate.year===F.initDate.year&&F.options.maxDate.month===F.initDate.month?".".concat(H):""),t,k,n?function(){F.increaseYear()}:function(){F.increaseMonth()},F.options.plusHtml)},W=function(t,n){p(j+(n?F.options.minDate.year===F.initDate.year?".".concat(H):"":F.options.minDate.year===F.initDate.year&&F.options.minDate.month===F.initDate.month?".".concat(H):""),t,k,n?function(){F.decreaseYear()}:function(){F.decreaseMonth()},F.options.minusHtml)},V=function(){var t=p(_,F.dpContainer);B(t,!0);var n=p(C,t);W(t,!0);var e=p("input",n,"keyup change",(function(t){F.yearChange(t.target.value)}));e.tabIndex=-1,e.value=F.initDate.year,e.type="number"},J=function(){var t=p(b,F.dpContainer);B(t,!1);var n=p(x,t);W(t,!1);var e=p("select",n,"change",(function(t){F.monthChange(t.target.value)}));e.tabIndex=-1;for(var i=function(t,n,e){var i=[],a=1,o=12;t.year===n.year?(a=n.month,t.year===e.year&&(o=e.month)):t.year===e.year&&(a=1,o=e.month);for(var r=a;r<=o;r++)i.push(r);return i}(F.initDate,F.options.minDate,F.options.maxDate),a=F.options.months,o=0;o<i.length;o++){var r=p("option",e);r.value=i[o],r.text=a[i[o]-1],r.selected=i[o]===F.initDate.month}},R=function(){for(var t=p(I,F.dpContainer),n=0;n<7;n++)p(S+z(n),t,null,null,F.options.days[n]);for(var e,i,a=(e=F.initDate.year,i=F.initDate.month,[0,31,31,31,31,31,31,30,30,30,30,30,r(e)?30:29][i]),o=h(F.initDate.year,F.initDate.month,1),s=7*Math.ceil((o+a)/7)-1,u=1,d=function(n){var e,i,o,r,s=h(F.initDate.year,F.initDate.month,u),d=(e=F.initDate,i=u,o=F.options.minDate,r=F.options.maxDate,!(!c(o)||!c(r))||(o.year===r.year&&o.month===r.month?i>=o.day&&i<=r.day:e.year===o.year&&e.month===o.month?i>=o.day:e.year!==r.year||e.month!==r.month||i<=r.day));if(u<=s&&n<s||u>a)return p(M,t),"continue";if(!d)return p(M,t),u+=1,"continue";var y=z(s);F.valueDate.day===u&&F.valueDate.year===F.initDate.year&&F.valueDate.month===F.initDate.month&&(y+=".".concat("selected")),F.today.day===u&&F.today.year===F.initDate.year&&F.today.month===F.initDate.month&&(y+=".".concat("today"));var l=p(M+y,t,null,null,u);l.day=u,l.addEventListener(k,(function(){F.setValue(F.initDate.year,F.initDate.month,l.day)})),u+=1},y=0;y<=s;y++)d(y)},q=function(){var t=p(O,F.dpContainer);F.options.showTodayBtn&&p(E,t,k,(function(){F.setValue(F.today.year,F.today.month,F.today.day)}),"امروز"),F.options.showEmptyBtn&&p(Y,t,k,(function(){F.setValue()}),"خالی")},F=null;const X={days:["ش","ی","د","س","چ","پ","ج"],months:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],initDate:null,minDate:{},maxDate:{},separatorChar:"/",zIndex:1e3,container:"body",dpContainer:null,selector:"input[data-jdp]",autoShow:!0,autoHide:!0,plusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-256v256h-84v-256h-256v-84h256v-256h84v256h256v84z"></path></g></svg>',minusHtml:'<svg viewBox="0 0 1024 1024"><g><path d="M810 554h-596v-84h596v84z"></path></g></svg>',changeMonthRotateYear:!1,showTodayBtn:!0,showEmptyBtn:!0};var G="visible",K={init:function(t){var n;this.options=d(X,t),this.options=U(this.options),window.onresize=$,this.options.autoHide&&(document.body.onclick=Z),this.options.autoShow&&(n=this.options.selector,document.querySelectorAll(n).forEach((function(t){t.addEventListener(L,(function(){K.show(t)}))})))},options:X,input:null,get dpContainer(){return this._dpContainer=this._dpContainer||p(w,this.options.container),this._dpContainer},get today(){return this._today=this._today||function(){var t,n,e=new Date,i=parseInt(e.getFullYear()),a=parseInt(e.getMonth())+1,o=parseInt(e.getDate());i>1600?(t=979,i-=1600):(t=0,i-=621);var r=a>2?i+1:i;return n=365*i+parseInt((r+3)/4)-parseInt((r+99)/100)+parseInt((r+399)/400)-80+o+[0,31,59,90,120,151,181,212,243,273,304,334][a-1],t+=33*parseInt(n/12053),n%=12053,t+=4*parseInt(n/1461),(n%=1461)>365&&(t+=parseInt((n-1)/365),n=(n-1)%365),{year:t,month:n<186?1+parseInt(n/31):7+parseInt((n-186)/30),day:1+(n<186?n%31:(n-186)%30)}}(),this._today},get valueDate(){return this._valueDate=o(this.input.value),a(this._valueDate)&&(m(this._valueDate,this.options.separatorChar)?this._valueDate=v(this._valueDate,this.options.separatorChar):this._valueDate={}),this._valueDate},get initDate(){return this._initDate=this._initDate||o(this.valueDate),c(this._initDate)&&(this._initDate=this.options.initDate||o(this.today)),a(this._initDate)&&m(this._initDate,this.options.separatorChar)&&(this._initDate=v(this._initDate,this.options.separatorChar)),f(this._initDate.year,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate)},_draw:function(){l((F=this).dpContainer,""),V(),J(),R(),q()},show:function(t){this._initDate=null,this._valueDate=null,this.input=t,this._draw(),this.dpContainer.style.visibility=G,this.dpContainer.style.display="block",this.dpContainer.style.zIndex=this.options.zIndex,this.setPosition(),function(t){D(t).addEventListener("scroll",(function(){K.setPosition()}),{passive:!0})}(t)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display="none"},setPosition:function(){if(this.dpContainer.style.visibility===G){for(var t=0,n=0,e=this.input,i=D(this.input);e.offsetParent;)t+=e.offsetLeft,n+=e.offsetTop,e=e.offsetParent;t+this.dpContainer.offsetWidth>=window.document.body.offsetWidth&&(t-=t+this.dpContainer.offsetWidth-(window.document.body.offsetWidth+10)),i&&(n-=i.scrollTop),this.dpContainer.style.left=t+"px",this.dpContainer.style.top=n+this.input.offsetHeight+"px"}},setValue:function(t,n,e){var i,a,o,r;this._valueDate.year=t,this._valueDate.month=n,this._valueDate.day=e,this.hide(),isNaN(t+n+e)?this.input.value="":this.input.value=(i=t,a=n,o=e,r=this.options.separatorChar,i+r+u(a)+r+u(o)),this.input.dispatchEvent(P)},increaseMonth:function(){this.options.changeMonthRotateYear&&12===this._initDate.month&&this.increaseYear(),this.monthChange(12===this._initDate.month?1:this._initDate.month+1)},decreaseMonth:function(){this.options.changeMonthRotateYear&&1===this._initDate.month&&this.decreaseYear(),this.monthChange(1===this._initDate.month?12:this._initDate.month-1)},monthChange:function(t){this._initDate=f(this._initDate.year,t,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()},increaseYear:function(){this.yearChange(this._initDate.year+1)},decreaseYear:function(){this.yearChange(this._initDate.year-1)},yearChange:function(t){this._initDate=f(t,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()}},Q=function(t,n){var e=K.input.getAttribute(t);return e=e===A?o(K.today):a(e)&&m(e,n)?v(e,n):{}},U=function(t){return t.minDate===A&&(t.minDate=o(K.today)),t.maxDate===A&&(t.maxDate=o(K.today)),t.minDate===T&&(delete t.minDate,window.Object.defineProperty(t,"minDate",{get:function(){return Q("data-jdp-min-date",t.separatorChar)}})),t.maxDate===T&&(delete t.maxDate,window.Object.defineProperty(t,"maxDate",{get:function(){return Q("data-jdp-max-date",t.separatorChar)}})),t};function Z(t){K.dpContainer.style.visibility===G&&-1===t.path.indexOf(K.dpContainer)&&-1===t.path.indexOf(K.input)&&K.hide()}function $(){K.setPosition()}window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};K.init(t)},show:function(t){K.show(t)},hide:function(){K.hide()}}})()})(); |
@@ -9,3 +9,3 @@ { | ||
"main": "dist/jalaliDatepicker.min.js", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"keywords": [ | ||
@@ -12,0 +12,0 @@ "date", |
# JalaliDatePicker | ||
[![npm version](https://badge.fury.io/js/%40majidh1%2Fjalalidatepicker.svg)](https://badge.fury.io/js/%40majidh1%2Fjalalidatepicker) | ||
[![npm version](https://badge.fury.io/js/%40majidh1%2Fjalalidatepicker.svg)](https://www.npmjs.com/package/@majidh1/jalalidatepicker) | ||
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=plastic)](https://raw.githubusercontent.com/majidh1/JalaliDatePicker/main/LICENSE) | ||
@@ -4,0 +4,0 @@ <div dir="rtl"> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67704