@majidh1/jalalidatepicker
Advanced tools
Comparing version 0.2.7 to 0.2.8
@@ -29,3 +29,3 @@ /* | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n days: [\"ش\", \"ی\", \"د\", \"س\", \"چ\", \"پ\", \"ج\"],\n months: [\"فروردین\", \"اردیبهشت\", \"خرداد\", \"تیر\", \"مرداد\", \"شهریور\", \"مهر\", \"آبان\", \"آذر\", \"دی\", \"بهمن\", \"اسفند\"],\n initDate: null,\n //sample {year:1399,month:11,day:29} || today || attr\n minDate: {},\n //sample {year:1400,month:11,day:29} || today || attr\n maxDate: {},\n separatorChar: \"/\",\n zIndex: 1000,\n container: \"body\",\n dpContainer: null,\n selector: \"input[data-jdp]\",\n autoShow: true,\n autoHide: true,\n plusHtml: \"<svg viewBox=\\\"0 0 1024 1024\\\"><g><path d=\\\"M810 554h-256v256h-84v-256h-256v-84h256v-256h84v256h256v84z\\\"></path></g></svg>\",\n minusHtml: \"<svg viewBox=\\\"0 0 1024 1024\\\"><g><path d=\\\"M810 554h-596v-84h596v84z\\\"></path></g></svg>\",\n changeMonthRotateYear: false,\n showTodayBtn: true,\n showEmptyBtn: true\n});\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/defaults.js?"); | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n days: [\"ش\", \"ی\", \"د\", \"س\", \"چ\", \"پ\", \"ج\"],\n months: [\"فروردین\", \"اردیبهشت\", \"خرداد\", \"تیر\", \"مرداد\", \"شهریور\", \"مهر\", \"آبان\", \"آذر\", \"دی\", \"بهمن\", \"اسفند\"],\n initDate: null,\n //sample {year:1399,month:11,day:29} || today || attr\n minDate: {},\n //sample {year:1400,month:11,day:29} || today || attr\n maxDate: {},\n separatorChar: \"/\",\n zIndex: 1000,\n container: \"body\",\n dpContainer: null,\n selector: \"input[data-jdp]\",\n autoShow: true,\n autoHide: true,\n plusHtml: \"<svg viewBox=\\\"0 0 1024 1024\\\"><g><path d=\\\"M810 554h-256v256h-84v-256h-256v-84h256v-256h84v256h256v84z\\\"></path></g></svg>\",\n minusHtml: \"<svg viewBox=\\\"0 0 1024 1024\\\"><g><path d=\\\"M810 554h-596v-84h596v84z\\\"></path></g></svg>\",\n changeMonthRotateYear: false,\n showTodayBtn: true,\n showEmptyBtn: true,\n autoReadOnlyInput: window.innerWidth <= 800 && window.innerHeight <= 600\n});\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/defaults.js?"); | ||
@@ -50,3 +50,3 @@ /***/ }), | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n/* harmony import */ var _draw__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./draw */ \"./src/draw.js\");\n/* harmony import */ var _defaults__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./defaults */ \"./src/defaults.js\");\n\n\n\n\nvar jalaliDatepicker = {\n init: function init(options) {\n this.options = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.extend)(_defaults__WEBPACK_IMPORTED_MODULE_3__.default, options);\n this.options = normalizeOptions(this.options);\n window.onresize = windowResize;\n if (this.options.autoHide) document.body.onclick = documentClick;\n if (this.options.autoShow) addEventListenerOnInputs(this.options.selector);\n },\n options: _defaults__WEBPACK_IMPORTED_MODULE_3__.default,\n input: null,\n\n get dpContainer() {\n this._dpContainer = this._dpContainer || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.createElement)(_constants__WEBPACK_IMPORTED_MODULE_1__.CONTAINER_ELM_QUERY, this.options.container);\n return this._dpContainer;\n },\n\n get today() {\n this._today = this._today || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.jalaliToday)();\n return this._today;\n },\n\n get valueDate() {\n this._valueDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(this.input.value);\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(this._valueDate)) {\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isValidDateString)(this._valueDate, this.options.separatorChar)) {\n this._valueDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateFromString)(this._valueDate, this.options.separatorChar);\n } else {\n this._valueDate = {};\n }\n }\n\n return this._valueDate;\n },\n\n get initDate() {\n this._initDate = this._initDate || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(this.valueDate);\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(this._initDate)) {\n this._initDate = this.options.initDate || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(this.today);\n }\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(this._initDate) && (0,_utils__WEBPACK_IMPORTED_MODULE_0__.isValidDateString)(this._initDate, this.options.separatorChar)) {\n this._initDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateFromString)(this._initDate, this.options.separatorChar);\n }\n\n return (0,_utils__WEBPACK_IMPORTED_MODULE_0__.normalizeMinMaxDate)(this._initDate.year, this._initDate.month, this._initDate.day, this._initDate, this.options.minDate, this.options.maxDate);\n },\n\n _draw: _draw__WEBPACK_IMPORTED_MODULE_2__.default,\n show: function show(input) {\n this._initDate = null;\n this._valueDate = null;\n this.input = input;\n\n this._draw();\n\n this.dpContainer.style.visibility = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_VISIBLE;\n this.dpContainer.style.display = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_DISPLAY_BLOCK;\n this.dpContainer.style.zIndex = this.options.zIndex;\n this.setPosition();\n setScrollOnParent(input);\n },\n hide: function hide() {\n this.dpContainer.style.visibility = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_HIDDEN;\n this.dpContainer.style.display = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_DISPLAY_HIDDEN;\n },\n setPosition: function setPosition() {\n if (this.dpContainer.style.visibility !== _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_VISIBLE) {\n return;\n }\n\n var inputBounds = this.input.getBoundingClientRect();\n var left = inputBounds.left;\n var top = inputBounds.top;\n var inputHeight = inputBounds.height;\n\n if (left + this.dpContainer.offsetWidth >= window.document.body.offsetWidth) {\n left -= left + this.dpContainer.offsetWidth - (window.document.body.offsetWidth + 10);\n }\n\n if (top + this.dpContainer.offsetHeight >= window.innerHeight) {\n top -= this.dpContainer.offsetHeight + inputHeight;\n }\n\n this.dpContainer.style.position = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_POSITION_FIXED;\n this.dpContainer.style.left = left + \"px\";\n this.dpContainer.style.top = top + this.input.offsetHeight + \"px\";\n },\n setValue: function setValue(year, month, day) {\n this._valueDate.year = year;\n this._valueDate.month = month;\n this._valueDate.day = day;\n this.hide();\n\n if (isNaN(year + month + day)) {\n this.input.value = \"\";\n } else {\n this.input.value = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateToString)(year, month, day, this.options.separatorChar);\n }\n\n (0,_utils__WEBPACK_IMPORTED_MODULE_0__.triggerEvent)(this.input, _constants__WEBPACK_IMPORTED_MODULE_1__.EVENT_CHANGE_INPUT_STR);\n },\n increaseMonth: function increaseMonth() {\n var isLastMonth = this._initDate.month === 12;\n\n if (this.options.changeMonthRotateYear && isLastMonth) {\n this.increaseYear();\n }\n\n this.monthChange(isLastMonth ? 1 : this._initDate.month + 1);\n },\n decreaseMonth: function decreaseMonth() {\n var isFirstMonth = this._initDate.month === 1;\n\n if (this.options.changeMonthRotateYear && isFirstMonth) {\n this.decreaseYear();\n }\n\n this.monthChange(isFirstMonth ? 12 : this._initDate.month - 1);\n },\n monthChange: function monthChange(month) {\n this._initDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.normalizeMinMaxDate)(this._initDate.year, month, this._initDate.day, this._initDate, this.options.minDate, this.options.maxDate);\n\n this._draw();\n },\n increaseYear: function increaseYear() {\n this.yearChange(this._initDate.year + 1);\n },\n decreaseYear: function decreaseYear() {\n this.yearChange(this._initDate.year - 1);\n },\n yearChange: function yearChange(year) {\n this._initDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.normalizeMinMaxDate)(year, this._initDate.month, this._initDate.day, this._initDate, this.options.minDate, this.options.maxDate);\n\n this._draw();\n }\n};\n\nvar getDefaultFromAttr = function getDefaultFromAttr(attrName, sepChar) {\n var dateAttrVal = jalaliDatepicker.input.getAttribute(attrName);\n\n if (dateAttrVal === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_TODAY_SETTING) {\n dateAttrVal = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(jalaliDatepicker.today);\n } else if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(dateAttrVal) && (0,_utils__WEBPACK_IMPORTED_MODULE_0__.isValidDateString)(dateAttrVal, sepChar)) {\n dateAttrVal = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateFromString)(dateAttrVal, sepChar);\n } else {\n dateAttrVal = {};\n }\n\n return dateAttrVal;\n};\n\nvar normalizeOptions = function normalizeOptions(options) {\n if (options.minDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_TODAY_SETTING) options.minDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(jalaliDatepicker.today);\n if (options.maxDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_TODAY_SETTING) options.maxDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(jalaliDatepicker.today);\n\n if (options.minDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING) {\n delete options.minDate;\n window.Object.defineProperty(options, \"minDate\", {\n get: function get() {\n return getDefaultFromAttr(_constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME, options.separatorChar);\n }\n });\n }\n\n if (options.maxDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING) {\n delete options.maxDate;\n window.Object.defineProperty(options, \"maxDate\", {\n get: function get() {\n return getDefaultFromAttr(_constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME, options.separatorChar);\n }\n });\n }\n\n return options;\n};\n\nfunction documentClick(e) {\n if (jalaliDatepicker.dpContainer.style.visibility !== _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_VISIBLE || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.containsDom)(jalaliDatepicker.dpContainer, e) || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getEventTarget)(e) === jalaliDatepicker.input) {\n return;\n }\n\n jalaliDatepicker.hide();\n}\n\nfunction windowResize() {\n jalaliDatepicker.setPosition();\n}\n\nfunction setScrollOnParent(input) {\n (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getScrollParent)(input).addEventListener(\"scroll\", function () {\n jalaliDatepicker.setPosition();\n }, {\n passive: true\n });\n}\n\nfunction addEventListenerOnInputs(querySelector) {\n Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;\n document.body.addEventListener(_constants__WEBPACK_IMPORTED_MODULE_1__.EVENT_FOCUS_STR, function (e) {\n if (e.target && e.target.matches(querySelector)) {\n jalaliDatepicker.show(e.target);\n }\n });\n}\n\nwindow.jalaliDatepicker = {\n startWatch: function startWatch() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n jalaliDatepicker.init(options);\n },\n show: function show(input) {\n jalaliDatepicker.show(input);\n },\n hide: function hide() {\n jalaliDatepicker.hide();\n }\n};\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/index.js?"); | ||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./constants */ \"./src/constants.js\");\n/* harmony import */ var _draw__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./draw */ \"./src/draw.js\");\n/* harmony import */ var _defaults__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./defaults */ \"./src/defaults.js\");\n\n\n\n\nvar jalaliDatepicker = {\n init: function init(options) {\n this.options = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.extend)(_defaults__WEBPACK_IMPORTED_MODULE_3__.default, options);\n this.options = normalizeOptions(this.options);\n window.onresize = windowResize;\n if (this.options.autoHide) document.body.onclick = documentClick;\n if (this.options.autoShow) addEventListenerOnInputs(this.options.selector);\n },\n options: _defaults__WEBPACK_IMPORTED_MODULE_3__.default,\n input: null,\n\n get dpContainer() {\n this._dpContainer = this._dpContainer || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.createElement)(_constants__WEBPACK_IMPORTED_MODULE_1__.CONTAINER_ELM_QUERY, this.options.container);\n return this._dpContainer;\n },\n\n get today() {\n this._today = this._today || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.jalaliToday)();\n return this._today;\n },\n\n get valueDate() {\n this._valueDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(this.input.value);\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(this._valueDate)) {\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isValidDateString)(this._valueDate, this.options.separatorChar)) {\n this._valueDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateFromString)(this._valueDate, this.options.separatorChar);\n } else {\n this._valueDate = {};\n }\n }\n\n return this._valueDate;\n },\n\n get initDate() {\n this._initDate = this._initDate || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(this.valueDate);\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isPlainObject)(this._initDate)) {\n this._initDate = this.options.initDate || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(this.today);\n }\n\n if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(this._initDate) && (0,_utils__WEBPACK_IMPORTED_MODULE_0__.isValidDateString)(this._initDate, this.options.separatorChar)) {\n this._initDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateFromString)(this._initDate, this.options.separatorChar);\n }\n\n return (0,_utils__WEBPACK_IMPORTED_MODULE_0__.normalizeMinMaxDate)(this._initDate.year, this._initDate.month, this._initDate.day, this._initDate, this.options.minDate, this.options.maxDate);\n },\n\n _draw: _draw__WEBPACK_IMPORTED_MODULE_2__.default,\n show: function show(input) {\n this._initDate = null;\n this._valueDate = null;\n this.input = input;\n\n this._draw();\n\n this.dpContainer.style.visibility = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_VISIBLE;\n this.dpContainer.style.display = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_DISPLAY_BLOCK;\n this.dpContainer.style.zIndex = this.options.zIndex;\n this.setPosition();\n setScrollOnParent(input);\n setReadOnly(input, this.options);\n },\n hide: function hide() {\n this.dpContainer.style.visibility = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_HIDDEN;\n this.dpContainer.style.display = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_DISPLAY_HIDDEN;\n },\n setPosition: function setPosition() {\n if (this.dpContainer.style.visibility !== _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_VISIBLE) {\n return;\n }\n\n var inputBounds = this.input.getBoundingClientRect();\n var left = inputBounds.left;\n var top = inputBounds.top;\n var inputHeight = inputBounds.height;\n var windowHeight = window.document.body.offsetWidth;\n var dpContainerWidth = this.dpContainer.offsetWidth;\n var dpContainerHeight = this.dpContainer.offsetHeight;\n\n if (left + dpContainerWidth >= windowHeight) {\n left -= left + dpContainerWidth - (windowHeight + 10);\n }\n\n if (top >= dpContainerHeight && top + dpContainerHeight >= window.innerHeight) {\n top -= dpContainerHeight + inputHeight;\n }\n\n this.dpContainer.style.position = _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_POSITION_FIXED;\n this.dpContainer.style.left = left + \"px\";\n this.dpContainer.style.top = top + this.input.offsetHeight + \"px\";\n },\n setValue: function setValue(year, month, day) {\n this._valueDate.year = year;\n this._valueDate.month = month;\n this._valueDate.day = day;\n this.hide();\n\n if (isNaN(year + month + day)) {\n this.input.value = \"\";\n } else {\n this.input.value = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateToString)(year, month, day, this.options.separatorChar);\n }\n\n (0,_utils__WEBPACK_IMPORTED_MODULE_0__.triggerEvent)(this.input, _constants__WEBPACK_IMPORTED_MODULE_1__.EVENT_CHANGE_INPUT_STR);\n },\n increaseMonth: function increaseMonth() {\n var isLastMonth = this._initDate.month === 12;\n\n if (this.options.changeMonthRotateYear && isLastMonth) {\n this.increaseYear();\n }\n\n this.monthChange(isLastMonth ? 1 : this._initDate.month + 1);\n },\n decreaseMonth: function decreaseMonth() {\n var isFirstMonth = this._initDate.month === 1;\n\n if (this.options.changeMonthRotateYear && isFirstMonth) {\n this.decreaseYear();\n }\n\n this.monthChange(isFirstMonth ? 12 : this._initDate.month - 1);\n },\n monthChange: function monthChange(month) {\n this._initDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.normalizeMinMaxDate)(this._initDate.year, month, this._initDate.day, this._initDate, this.options.minDate, this.options.maxDate);\n\n this._draw();\n },\n increaseYear: function increaseYear() {\n this.yearChange(this._initDate.year + 1);\n },\n decreaseYear: function decreaseYear() {\n this.yearChange(this._initDate.year - 1);\n },\n yearChange: function yearChange(year) {\n this._initDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.normalizeMinMaxDate)(year, this._initDate.month, this._initDate.day, this._initDate, this.options.minDate, this.options.maxDate);\n\n this._draw();\n }\n};\n\nvar getDefaultFromAttr = function getDefaultFromAttr(attrName, sepChar) {\n var dateAttrVal = jalaliDatepicker.input.getAttribute(attrName);\n\n if (dateAttrVal === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_TODAY_SETTING) {\n dateAttrVal = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(jalaliDatepicker.today);\n } else if ((0,_utils__WEBPACK_IMPORTED_MODULE_0__.isString)(dateAttrVal) && (0,_utils__WEBPACK_IMPORTED_MODULE_0__.isValidDateString)(dateAttrVal, sepChar)) {\n dateAttrVal = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getDateFromString)(dateAttrVal, sepChar);\n } else {\n dateAttrVal = {};\n }\n\n return dateAttrVal;\n};\n\nvar normalizeOptions = function normalizeOptions(options) {\n if (options.minDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_TODAY_SETTING) options.minDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(jalaliDatepicker.today);\n if (options.maxDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_TODAY_SETTING) options.maxDate = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.clon)(jalaliDatepicker.today);\n\n if (options.minDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING) {\n delete options.minDate;\n window.Object.defineProperty(options, \"minDate\", {\n get: function get() {\n return getDefaultFromAttr(_constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING_MIN_ATTR_NAME, options.separatorChar);\n }\n });\n }\n\n if (options.maxDate === _constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING) {\n delete options.maxDate;\n window.Object.defineProperty(options, \"maxDate\", {\n get: function get() {\n return getDefaultFromAttr(_constants__WEBPACK_IMPORTED_MODULE_1__.MIN_MAX_ATTR_SETTING_MAX_ATTR_NAME, options.separatorChar);\n }\n });\n }\n\n return options;\n};\n\nfunction documentClick(e) {\n if (jalaliDatepicker.dpContainer.style.visibility !== _constants__WEBPACK_IMPORTED_MODULE_1__.STYLE_VISIBILITY_VISIBLE || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.containsDom)(jalaliDatepicker.dpContainer, e) || (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getEventTarget)(e) === jalaliDatepicker.input) {\n return;\n }\n\n jalaliDatepicker.hide();\n}\n\nfunction windowResize() {\n jalaliDatepicker.setPosition();\n}\n\nfunction setScrollOnParent(input) {\n (0,_utils__WEBPACK_IMPORTED_MODULE_0__.getScrollParent)(input).addEventListener(\"scroll\", function () {\n jalaliDatepicker.setPosition();\n }, {\n passive: true\n });\n}\n\nfunction setReadOnly(input, options) {\n if (options.autoReadOnlyInput && !input.readOnly) input.readOnly = true;\n}\n\nfunction addEventListenerOnInputs(querySelector) {\n Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector;\n document.body.addEventListener(_constants__WEBPACK_IMPORTED_MODULE_1__.EVENT_FOCUS_STR, function (e) {\n if (e.target && e.target.matches(querySelector)) {\n jalaliDatepicker.show(e.target);\n }\n });\n}\n\nwindow.jalaliDatepicker = {\n startWatch: function startWatch() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n jalaliDatepicker.init(options);\n },\n show: function show(input) {\n jalaliDatepicker.show(input);\n },\n hide: function hide() {\n jalaliDatepicker.hide();\n }\n};\n\n//# sourceURL=webpack://@majidh1/jalalidatepicker/./src/index.js?"); | ||
@@ -53,0 +53,0 @@ /***/ }), |
@@ -1,1 +0,1 @@ | ||
!function(){"use strict";!function(){var t="jdp",n="".concat(t,"-container"),e="div.".concat(t,"-years"),i="div.".concat(t,"-year"),a="div.".concat(t,"-months"),o="div.".concat(t,"-month"),r="div.".concat(t,"-days"),s="div.".concat(t,"-day"),h="div.".concat(t,"-day-name"),c="div.".concat(t,"-icon-plus"),u="div.".concat(t,"-icon-minus"),d="div.".concat(t,"-footer"),p="div.".concat(t,"-btn-today"),y="div.".concat(t,"-btn-empty"),l="not-in-range",f="".concat(t,":change"),m="click",v="focusin",D="today",g="attr",w=("data-".concat(t),"visible"),_=void 0;function C(t){return(C="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 b=Number.isNaN||window.isNaN,x=function(t){return void 0===t},I=function(t){return"function"==typeof t},M=function(t){return"string"==typeof t},E=function(t){return JSON.parse(JSON.stringify(t))},S=function(t){return 682*((t-474)%2820+512)%2816<682},H=function(t,n){return t<8?31*(t-1)+n:186+30*(t-7)+n},N=function(t,n,e){return i=function(t,n,e,i,a,o){for(var r=H(a,o)-H(n,e),s=t<i?i:t,h=t<i?t:i;h<s;h++)S(h)?r+=t<i?366:-366:r+=t<i?365:-365;return r}(1392,3,25,t,n,e),a=7,window.Math.abs(i-a*window.Math.floor(i/a));var i,a},j=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},O=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},P=function t(){for(var n,e,i,a,o,r=arguments.length,s=new Array(r),h=0;h<r;h++)s[h]=arguments[h];var c=s[0]||{},u=1,d=s.length,p=!1;for("boolean"==typeof c&&(p=c,c=s[u]||{},u+=1),"object"!==C(c)&&I(c)&&(c={}),u===d&&(c=_,u-=1);u<d;u++)if(n=s[u],!x(n)&&null!==n)for(var y=0;y<window.Object.keys(n).length;y++){var l=window.Object.keys(n)[y];if(Object.prototype.hasOwnProperty.call(n,l)){if(i=n[l],"__proto__"===l||c===i)return!0;a=Array.isArray(i),p&&i&&(O(i)||a)?(e=c[l],o=a&&!Array.isArray(e)?[]:a||O(e)?e:{},c[l]=t(p,o,i)):x(i)||(c[l]=i)}}return c},Y=function(t,n,e,i,a){var o=t.split(".");t=o.shift()||"div";var r=o,s=window.document.createElement(t);return M(n)?window.document.querySelector(n).appendChild(s):n.appendChild(s),r.length&&(s.className=r.join(" ")),e&&i&&k(s,e,i),x(a)||L(s,a),s},k=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},z=function(t,n,e,i,a,o){return b(t)||t<1e3||t>1999?t=i.year:t<a.year?t=a.year:t>o.year&&(t=o.year),b(n)||n<1||n>12?n=i.month:t<=a.year&&n<a.month?n=a.month:t>=o.year&&n>o.month&&(n=o.month),b(e)||e<1?e=i.day:n<=a.month&&e<a.day?e=a.day:n>=o.month&&e>o.day&&(e=o.day),{year:parseInt(t),month:parseInt(n),day:parseInt(e)}},B=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},T=function(t,n){var e=t.split(n);return{year:parseInt(e[0]),month:parseInt(e[1]),day:parseInt(e[2])}},A=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return window;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)},W=function(t){var n=document.createEvent("Event");return n.initEvent(t,!0,!0),n},R=function(t){return 6===t?".".concat("last-week"):""},V=function(t,n){Y(c+(n?K.options.maxDate.year===K.initDate.year?".".concat(l):"":K.options.maxDate.year===K.initDate.year&&K.options.maxDate.month===K.initDate.month?".".concat(l):""),t,m,n?function(){K.increaseYear()}:function(){K.increaseMonth()},K.options.plusHtml)},J=function(t,n){Y(u+(n?K.options.minDate.year===K.initDate.year?".".concat(l):"":K.options.minDate.year===K.initDate.year&&K.options.minDate.month===K.initDate.month?".".concat(l):""),t,m,n?function(){K.decreaseYear()}:function(){K.decreaseMonth()},K.options.minusHtml)},q=function(){var t=Y(e,K.dpContainer);V(t,!0);var n=Y(i,t);J(t,!0);var a=Y("input",n,"keyup change",(function(t){K.yearChange(t.target.value)}));a.tabIndex=-1,a.value=K.initDate.year,a.type="number"},F=function(){var t=Y(a,K.dpContainer);V(t,!1);var n=Y(o,t);J(t,!1);var e=Y("select",n,"change",(function(t){K.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}(K.initDate,K.options.minDate,K.options.maxDate),r=K.options.months,s=0;s<i.length;s++){var h=Y("option",e);h.value=i[s],h.text=r[i[s]-1],h.selected=i[s]===K.initDate.month}},X=function(){for(var t=Y(r,K.dpContainer),n=0;n<7;n++)Y(h+R(n),t,null,null,K.options.days[n]);for(var e,i,a=(e=K.initDate.year,i=K.initDate.month,[0,31,31,31,31,31,31,30,30,30,30,30,S(e)?30:29][i]),o=N(K.initDate.year,K.initDate.month,1),c=7*Math.ceil((o+a)/7)-1,u=1,d=function(n){var e,i,o,r,h=N(K.initDate.year,K.initDate.month,u),c=(e=K.initDate,i=u,o=K.options.minDate,r=K.options.maxDate,!(!O(o)||!O(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<=h&&n<h||u>a)return Y(s,t),"continue";if(!c)return Y(s,t),u+=1,"continue";var d=R(h);K.valueDate.day===u&&K.valueDate.year===K.initDate.year&&K.valueDate.month===K.initDate.month&&(d+=".".concat("selected")),K.today.day===u&&K.today.year===K.initDate.year&&K.today.month===K.initDate.month&&(d+=".".concat("today"));var p=Y(s+d,t,null,null,u);p.day=u,p.addEventListener(m,(function(){K.setValue(K.initDate.year,K.initDate.month,p.day)})),u+=1},p=0;p<=c;p++)d(p)},G=function(){var t=Y(d,K.dpContainer);K.options.showTodayBtn&&Y(p,t,m,(function(){K.setValue(K.today.year,K.today.month,K.today.day)}),"امروز"),K.options.showEmptyBtn&&Y(y,t,m,(function(){K.setValue()}),"خالی")},K=null;var Q={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},U={init:function(t){var n;this.options=P(Q,t),this.options=$(this.options),window.onresize=nt,this.options.autoHide&&(document.body.onclick=tt),this.options.autoShow&&(n=this.options.selector,Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector,document.body.addEventListener(v,(function(t){t.target&&t.target.matches(n)&&U.show(t.target)})))},options:Q,input:null,get dpContainer(){return this._dpContainer=this._dpContainer||Y(n,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=E(this.input.value),M(this._valueDate)&&(B(this._valueDate,this.options.separatorChar)?this._valueDate=T(this._valueDate,this.options.separatorChar):this._valueDate={}),this._valueDate},get initDate(){return this._initDate=this._initDate||E(this.valueDate),O(this._initDate)&&(this._initDate=this.options.initDate||E(this.today)),M(this._initDate)&&B(this._initDate,this.options.separatorChar)&&(this._initDate=T(this._initDate,this.options.separatorChar)),z(this._initDate.year,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate)},_draw:function(){L((K=this).dpContainer,""),q(),F(),X(),G()},show:function(t){this._initDate=null,this._valueDate=null,this.input=t,this._draw(),this.dpContainer.style.visibility=w,this.dpContainer.style.display="block",this.dpContainer.style.zIndex=this.options.zIndex,this.setPosition(),function(t){A(t).addEventListener("scroll",(function(){U.setPosition()}),{passive:!0})}(t)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display="none"},setPosition:function(){if(this.dpContainer.style.visibility===w){var t=this.input.getBoundingClientRect(),n=t.left,e=t.top,i=t.height;n+this.dpContainer.offsetWidth>=window.document.body.offsetWidth&&(n-=n+this.dpContainer.offsetWidth-(window.document.body.offsetWidth+10)),e+this.dpContainer.offsetHeight>=window.innerHeight&&(e-=this.dpContainer.offsetHeight+i),this.dpContainer.style.position="fixed",this.dpContainer.style.left=n+"px",this.dpContainer.style.top=e+this.input.offsetHeight+"px"}},setValue:function(t,n,e){var i,a,o,r,s,h;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+j(a)+r+j(o)),s=this.input,h=f,s&&(s.dispatchEvent(W(h)),h===f&&(s.dispatchEvent(W("change")),s.dispatchEvent(W("input"))))},increaseMonth:function(){var t=12===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.increaseYear(),this.monthChange(t?1:this._initDate.month+1)},decreaseMonth:function(){var t=1===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.decreaseYear(),this.monthChange(t?12:this._initDate.month-1)},monthChange:function(t){this._initDate=z(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=z(t,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()}},Z=function(t,n){var e=U.input.getAttribute(t);return e=e===D?E(U.today):M(e)&&B(e,n)?T(e,n):{}},$=function(t){return t.minDate===D&&(t.minDate=E(U.today)),t.maxDate===D&&(t.maxDate=E(U.today)),t.minDate===g&&(delete t.minDate,window.Object.defineProperty(t,"minDate",{get:function(){return Z("data-jdp-min-date",t.separatorChar)}})),t.maxDate===g&&(delete t.maxDate,window.Object.defineProperty(t,"maxDate",{get:function(){return Z("data-jdp-max-date",t.separatorChar)}})),t};function tt(t){var n,e,i;U.dpContainer.style.visibility!==w||(n=U.dpContainer,(i=(e=t).path||e.composedPath&&e.composedPath()||!1)?-1!==i.indexOf(n):n.outerHTML.indexOf(e.target.outerHTML)>-1)||function(t){try{return I(t.composedPath)?t.composedPath()[0]:t.target}catch(n){return t.target}}(t)===U.input||U.hide()}function nt(){U.setPosition()}window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};U.init(t)},show:function(t){U.show(t)},hide:function(){U.hide()}}}()}(); | ||
!function(){"use strict";!function(){var t="jdp",n="".concat(t,"-container"),e="div.".concat(t,"-years"),i="div.".concat(t,"-year"),a="div.".concat(t,"-months"),o="div.".concat(t,"-month"),r="div.".concat(t,"-days"),s="div.".concat(t,"-day"),h="div.".concat(t,"-day-name"),c="div.".concat(t,"-icon-plus"),u="div.".concat(t,"-icon-minus"),d="div.".concat(t,"-footer"),p="div.".concat(t,"-btn-today"),y="div.".concat(t,"-btn-empty"),l="not-in-range",f="".concat(t,":change"),m="click",v="focusin",D="today",g="attr",w=("data-".concat(t),"visible"),_=void 0;function C(t){return(C="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 b=Number.isNaN||window.isNaN,x=function(t){return void 0===t},I=function(t){return"function"==typeof t},M=function(t){return"string"==typeof t},E=function(t){return JSON.parse(JSON.stringify(t))},S=function(t){return 682*((t-474)%2820+512)%2816<682},O=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 r=O(a,o)-O(n,e),s=t<i?i:t,h=t<i?t:i;h<s;h++)S(h)?r+=t<i?366:-366:r+=t<i?365:-365;return r}(1392,3,25,t,n,e),a=7,window.Math.abs(i-a*window.Math.floor(i/a));var i,a},N=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},j=function(t){if(!t||!t.constructor||t.nodeType)return!1;try{return"{}"===JSON.stringify(t)}catch(t){return!0}},P=function t(){for(var n,e,i,a,o,r=arguments.length,s=new Array(r),h=0;h<r;h++)s[h]=arguments[h];var c=s[0]||{},u=1,d=s.length,p=!1;for("boolean"==typeof c&&(p=c,c=s[u]||{},u+=1),"object"!==C(c)&&I(c)&&(c={}),u===d&&(c=_,u-=1);u<d;u++)if(n=s[u],!x(n)&&null!==n)for(var y=0;y<window.Object.keys(n).length;y++){var l=window.Object.keys(n)[y];if(Object.prototype.hasOwnProperty.call(n,l)){if(i=n[l],"__proto__"===l||c===i)return!0;a=Array.isArray(i),p&&i&&(j(i)||a)?(e=c[l],o=a&&!Array.isArray(e)?[]:a||j(e)?e:{},c[l]=t(p,o,i)):x(i)||(c[l]=i)}}return c},Y=function(t,n,e,i,a){var o=t.split(".");t=o.shift()||"div";var r=o,s=window.document.createElement(t);return M(n)?window.document.querySelector(n).appendChild(s):n.appendChild(s),r.length&&(s.className=r.join(" ")),e&&i&&k(s,e,i),x(a)||L(s,a),s},k=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},z=function(t,n,e,i,a,o){return b(t)||t<1e3||t>1999?t=i.year:t<a.year?t=a.year:t>o.year&&(t=o.year),b(n)||n<1||n>12?n=i.month:t<=a.year&&n<a.month?n=a.month:t>=o.year&&n>o.month&&(n=o.month),b(e)||e<1?e=i.day:n<=a.month&&e<a.day?e=a.day:n>=o.month&&e>o.day&&(e=o.day),{year:parseInt(t),month:parseInt(n),day:parseInt(e)}},B=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},T=function(t,n){var e=t.split(n);return{year:parseInt(e[0]),month:parseInt(e[1]),day:parseInt(e[2])}},A=function t(n){if(["html","body","#document"].indexOf((n.nodeName||"").toLowerCase())>=0)return window;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)},R=function(t){var n=document.createEvent("Event");return n.initEvent(t,!0,!0),n},V=function(t){return 6===t?".".concat("last-week"):""},W=function(t,n){Y(c+(n?K.options.maxDate.year===K.initDate.year?".".concat(l):"":K.options.maxDate.year===K.initDate.year&&K.options.maxDate.month===K.initDate.month?".".concat(l):""),t,m,n?function(){K.increaseYear()}:function(){K.increaseMonth()},K.options.plusHtml)},J=function(t,n){Y(u+(n?K.options.minDate.year===K.initDate.year?".".concat(l):"":K.options.minDate.year===K.initDate.year&&K.options.minDate.month===K.initDate.month?".".concat(l):""),t,m,n?function(){K.decreaseYear()}:function(){K.decreaseMonth()},K.options.minusHtml)},q=function(){var t=Y(e,K.dpContainer);W(t,!0);var n=Y(i,t);J(t,!0);var a=Y("input",n,"keyup change",(function(t){K.yearChange(t.target.value)}));a.tabIndex=-1,a.value=K.initDate.year,a.type="number"},F=function(){var t=Y(a,K.dpContainer);W(t,!1);var n=Y(o,t);J(t,!1);var e=Y("select",n,"change",(function(t){K.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}(K.initDate,K.options.minDate,K.options.maxDate),r=K.options.months,s=0;s<i.length;s++){var h=Y("option",e);h.value=i[s],h.text=r[i[s]-1],h.selected=i[s]===K.initDate.month}},X=function(){for(var t=Y(r,K.dpContainer),n=0;n<7;n++)Y(h+V(n),t,null,null,K.options.days[n]);for(var e,i,a=(e=K.initDate.year,i=K.initDate.month,[0,31,31,31,31,31,31,30,30,30,30,30,S(e)?30:29][i]),o=H(K.initDate.year,K.initDate.month,1),c=7*Math.ceil((o+a)/7)-1,u=1,d=function(n){var e,i,o,r,h=H(K.initDate.year,K.initDate.month,u),c=(e=K.initDate,i=u,o=K.options.minDate,r=K.options.maxDate,!(!j(o)||!j(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<=h&&n<h||u>a)return Y(s,t),"continue";if(!c)return Y(s,t),u+=1,"continue";var d=V(h);K.valueDate.day===u&&K.valueDate.year===K.initDate.year&&K.valueDate.month===K.initDate.month&&(d+=".".concat("selected")),K.today.day===u&&K.today.year===K.initDate.year&&K.today.month===K.initDate.month&&(d+=".".concat("today"));var p=Y(s+d,t,null,null,u);p.day=u,p.addEventListener(m,(function(){K.setValue(K.initDate.year,K.initDate.month,p.day)})),u+=1},p=0;p<=c;p++)d(p)},G=function(){var t=Y(d,K.dpContainer);K.options.showTodayBtn&&Y(p,t,m,(function(){K.setValue(K.today.year,K.today.month,K.today.day)}),"امروز"),K.options.showEmptyBtn&&Y(y,t,m,(function(){K.setValue()}),"خالی")},K=null;var Q={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,autoReadOnlyInput:window.innerWidth<=800&&window.innerHeight<=600},U={init:function(t){var n;this.options=P(Q,t),this.options=$(this.options),window.onresize=nt,this.options.autoHide&&(document.body.onclick=tt),this.options.autoShow&&(n=this.options.selector,Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector,document.body.addEventListener(v,(function(t){t.target&&t.target.matches(n)&&U.show(t.target)})))},options:Q,input:null,get dpContainer(){return this._dpContainer=this._dpContainer||Y(n,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=E(this.input.value),M(this._valueDate)&&(B(this._valueDate,this.options.separatorChar)?this._valueDate=T(this._valueDate,this.options.separatorChar):this._valueDate={}),this._valueDate},get initDate(){return this._initDate=this._initDate||E(this.valueDate),j(this._initDate)&&(this._initDate=this.options.initDate||E(this.today)),M(this._initDate)&&B(this._initDate,this.options.separatorChar)&&(this._initDate=T(this._initDate,this.options.separatorChar)),z(this._initDate.year,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate)},_draw:function(){L((K=this).dpContainer,""),q(),F(),X(),G()},show:function(t){this._initDate=null,this._valueDate=null,this.input=t,this._draw(),this.dpContainer.style.visibility=w,this.dpContainer.style.display="block",this.dpContainer.style.zIndex=this.options.zIndex,this.setPosition(),function(t){A(t).addEventListener("scroll",(function(){U.setPosition()}),{passive:!0})}(t),function(t,n){n.autoReadOnlyInput&&!t.readOnly&&(t.readOnly=!0)}(t,this.options)},hide:function(){this.dpContainer.style.visibility="hidden",this.dpContainer.style.display="none"},setPosition:function(){if(this.dpContainer.style.visibility===w){var t=this.input.getBoundingClientRect(),n=t.left,e=t.top,i=t.height,a=window.document.body.offsetWidth,o=this.dpContainer.offsetWidth,r=this.dpContainer.offsetHeight;n+o>=a&&(n-=n+o-(a+10)),e>=r&&e+r>=window.innerHeight&&(e-=r+i),this.dpContainer.style.position="fixed",this.dpContainer.style.left=n+"px",this.dpContainer.style.top=e+this.input.offsetHeight+"px"}},setValue:function(t,n,e){var i,a,o,r,s,h;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+N(a)+r+N(o)),s=this.input,h=f,s&&(s.dispatchEvent(R(h)),h===f&&(s.dispatchEvent(R("change")),s.dispatchEvent(R("input"))))},increaseMonth:function(){var t=12===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.increaseYear(),this.monthChange(t?1:this._initDate.month+1)},decreaseMonth:function(){var t=1===this._initDate.month;this.options.changeMonthRotateYear&&t&&this.decreaseYear(),this.monthChange(t?12:this._initDate.month-1)},monthChange:function(t){this._initDate=z(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=z(t,this._initDate.month,this._initDate.day,this._initDate,this.options.minDate,this.options.maxDate),this._draw()}},Z=function(t,n){var e=U.input.getAttribute(t);return e=e===D?E(U.today):M(e)&&B(e,n)?T(e,n):{}},$=function(t){return t.minDate===D&&(t.minDate=E(U.today)),t.maxDate===D&&(t.maxDate=E(U.today)),t.minDate===g&&(delete t.minDate,window.Object.defineProperty(t,"minDate",{get:function(){return Z("data-jdp-min-date",t.separatorChar)}})),t.maxDate===g&&(delete t.maxDate,window.Object.defineProperty(t,"maxDate",{get:function(){return Z("data-jdp-max-date",t.separatorChar)}})),t};function tt(t){var n,e,i;U.dpContainer.style.visibility!==w||(n=U.dpContainer,(i=(e=t).path||e.composedPath&&e.composedPath()||!1)?-1!==i.indexOf(n):n.outerHTML.indexOf(e.target.outerHTML)>-1)||function(t){try{return I(t.composedPath)?t.composedPath()[0]:t.target}catch(n){return t.target}}(t)===U.input||U.hide()}function nt(){U.setPosition()}window.jalaliDatepicker={startWatch:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};U.init(t)},show:function(t){U.show(t)},hide:function(){U.hide()}}}()}(); |
@@ -9,3 +9,3 @@ { | ||
"main": "dist/jalaliDatepicker.min.js", | ||
"version": "0.2.7", | ||
"version": "0.2.8", | ||
"keywords": [ | ||
@@ -42,3 +42,3 @@ "date", | ||
"css-loader": "^5.2.0", | ||
"css-minimizer-webpack-plugin": "^1.3.0", | ||
"css-minimizer-webpack-plugin": "^3.0.2", | ||
"eslint": "^7.23.0", | ||
@@ -45,0 +45,0 @@ "imports-loader": "^2.0.0", |
# JalaliDatePicker | ||
[![npm version](https://badge.fury.io/js/%40majidh1%2Fjalalidatepicker.svg)](https://www.npmjs.com/package/@majidh1/jalalidatepicker) | ||
<img src="res/filesizegzip.svg" width="102px"/> | ||
<img src="res/filesize.svg" width="87px"/> | ||
@@ -4,0 +5,0 @@ <img src="https://shields.io/badge/build-passing-blue"/> |
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
73025
456
97