diff --git a/bundleconfig.json b/bundleconfig.json new file mode 100644 index 0000000..650a81a --- /dev/null +++ b/bundleconfig.json @@ -0,0 +1,8 @@ +[ + { + "outputFileName": "dist/ADM-dateTimePicker.min.js", + "inputFiles": [ + "dist/ADM-dateTimePicker.js" + ] + } +] diff --git a/dist/ADM-dateTimePicker.css b/dist/ADM-dateTimePicker.css index c1e0ec6..b71b99d 100644 --- a/dist/ADM-dateTimePicker.css +++ b/dist/ADM-dateTimePicker.css @@ -850,3 +850,29 @@ a:hover { -webkit-transform: rotateY(90deg) translateX(-10px); transform: rotateY(90deg) translateX(-10px); } + +.ADMdtpDays .hasEvent { + position: relative; +} + +.ADMdtpDays .hasEvent > span { + color: #fff; + background-color: #fc5f2a; +} + .ADMdtpDays .hasEvent:hover .ADMdtpTooltip { + display: inline; + } + +.ADMdtpDays .hasEvent .ADMdtpTooltip { + text-align: center; + position: absolute; + display: none; + padding: 5px; + right: -25px; + top: 40px; + background-color: #fff; + border: 1px solid #eee; + border-radius: 4px; + width: 100px; + z-index: 999; +} \ No newline at end of file diff --git a/dist/ADM-dateTimePicker.js b/dist/ADM-dateTimePicker.js index 6a3bdce..a3141af 100644 --- a/dist/ADM-dateTimePicker.js +++ b/dist/ADM-dateTimePicker.js @@ -8,56 +8,56 @@ * © 2017 Amirkabir Data Miners - www.adm-co.net */ -(function(angular) { +(function (angular) { 'use strict'; - + if (!angular.merge) angular.merge = angular.extend; - String.prototype.toPersianDigits = function(){ - var id= ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹']; - return this.replace(/[0-9]/g, function(w){ + String.prototype.toPersianDigits = function () { + var id = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; + return this.replace(/[0-9]/g, function (w) { return id[+w] }); }; - String.prototype.toEnglishDigits = function(){ - var id= {'۰':'0','۱':'1','۲':'2','۳':'3','۴':'4','۵':'5','۶':'6','۷':'7','۸':'8','۹':'9'}; - return this.replace(/[^0-9.]/g, function(w){ - return id[w]||w; + String.prototype.toEnglishDigits = function () { + var id = { '۰': '0', '۱': '1', '۲': '2', '۳': '3', '۴': '4', '۵': '5', '۶': '6', '۷': '7', '۸': '8', '۹': '9' }; + return this.replace(/[^0-9.]/g, function (w) { + return id[w] || w; }); }; - String.prototype.lZero = function() { - return (this.length<2 ? '0'+this : this); + String.prototype.lZero = function () { + return (this.length < 2 ? '0' + this : this); }; - Array.prototype.toNumber = function() { - return this.map(function(item) {return Number(item);}); + Array.prototype.toNumber = function () { + return this.map(function (item) { return Number(item); }); }; - Array.prototype.dtp_toDate = function(type) { + function dtp_toDate(array, type) { var splitter = '-'; if (/invalid/i.test(new Date('1991-9-12'))) splitter = '/'; - - var date = this.join(splitter); - if (this.length == 5) - date = this.slice(0,3).join(splitter) +' '+ this.slice(3,5).join(':') + + var date = array.join(splitter); + if (array.length == 5) + date = array.slice(0, 3).join(splitter) + ' ' + array.slice(3, 5).join(':') if (!type) return date; date = new Date(date); if (type == 'unix') return date.getTime(); return date; }; - Number.prototype.lZero = function() { - return (this<10 ? '0'+this : this); + Number.prototype.lZero = function () { + return (this < 10 ? '0' + this : this); }; Date.prototype.dtp_shortDate = function () { - return [this.getFullYear(), this.getMonth() + 1, this.getDate()].dtp_toDate(); + return dtp_toDate([this.getFullYear(), this.getMonth() + 1, this.getDate()]); } - - var ADMdtpProvider = function() { + + var ADMdtpProvider = function () { var options = { calType: 'gregorian', - format: 'YYYY/MM/DD hh:mm', + format: 'YYYY/MM/DD hh:mm', multiple: true, autoClose: false, transition: true, @@ -80,13 +80,13 @@ }; var ADMdtp = { - getOptions: function(type) { + getOptions: function (type) { var typeOptions = type && options[type] || options; return typeOptions; } }; - this.setOptions = function(type, customOptions) { + this.setOptions = function (type, customOptions) { if (!customOptions) { customOptions = type; options = angular.merge(options, customOptions); @@ -95,20 +95,20 @@ options[type] = angular.merge(options[type] || {}, customOptions); }; - this.$get = function() { + this.$get = function () { return ADMdtp; }; }; - - var ADMdtpDigitTypeFilter = function() { - return function(input, type) { - return type=='jalali' ? String(input).toPersianDigits() : input; + + var ADMdtpDigitTypeFilter = function () { + return function (input, type) { + return type == 'jalali' ? String(input).toPersianDigits() : input; }; }; - - var ADMdtpConvertor = function() { - + + var ADMdtpConvertor = function () { + function getJalaliDate(date) { var daysPassedInGregorianCalender = getDaysPassedInGregorianCalender(date); daysPassedInGregorianCalender -= 226894; @@ -121,11 +121,11 @@ var dayOfMonth = getDayJalaliCalender(daysPassedInJalaliCalender, yearOfDay, monthOfDay); var date = - { - day: dayOfMonth, - month: monthOfDay, - year: yearOfDay - }; + { + day: dayOfMonth, + month: monthOfDay, + year: yearOfDay + }; return date; } function getDayJalaliCalender(daysPassedInJalaliCalender, yearOfDay, monthOfDay) { @@ -269,7 +269,7 @@ } return leapsCount; } - + function getDaysPassedInGregorianCalender(date) { var gregorianMonths = getGregorianMonths(); var passedLeapYears = howManyGregorianLeapsYearPassed(date.year); @@ -403,8 +403,7 @@ var day = getGregorianDayOfMonthByPassedDay(daysPassed); var month = getGregorianMonth(daysPassed); var year = getGregorianYear(daysPassed); - if (day == 0) - { + if (day == 0) { day = 31; month = 12; year--; @@ -416,7 +415,7 @@ }; } - var isLeapYearInJalaliCalender = function(years) { + var isLeapYearInJalaliCalender = function (years) { if (years == 1 || years == 5 || years == 9 || years == 13 || years == 17 || years == 22) { return true; } @@ -427,78 +426,78 @@ var siosesal = Math.floor(year / 33); return ((year - (siosesal * 33)) % 4 == 0) && (year - (siosesal * 33)) / 4 != 8; } - var getPersianDate = function(year, month, day) { - year = (year<=99)?(2000+year):year; + var getPersianDate = function (year, month, day) { + year = (year <= 99) ? (2000 + year) : year; var date = { year: year, month: month, day: day }; date = getJalaliDate(date); return date; } - var getGregorianDates = function(year, mont, day) { - year = (year<=99)?(1300+year):year; - var date= getGregorianDate( { + var getGregorianDates = function (year, mont, day) { + year = (year <= 99) ? (1300 + year) : year; + var date = getGregorianDate({ day: day, month: mont, year: year }); return date; } - + return { toJalali: getPersianDate, toGregorian: getGregorianDates, isLeapJalali: isLeapYearInJalaliCalender } } - - var ADMdtpFactory = function(ADMdtpConvertor) { - this.dateFormat = function(date, time, format, notView) { + var ADMdtpFactory = function (ADMdtpConvertor) { + + this.dateFormat = function (date, time, format, notView) { if (!date.year) return ''; var year = date.year; - var halfYear = notView ? date.year : date.year%100; + var halfYear = notView ? date.year : date.year % 100; var month = date.month.lZero(); var day = date.day.lZero(); var hour = time.hour.lZero(); var minute = time.minute.lZero(); - + var replaceMap = [ - {key: 'YYYY', value: year}, - {key: 'YY', value: halfYear}, - {key: 'MM', value: month}, - {key: 'DD', value: day}, - {key: 'hh', value: hour}, - {key: 'mm', value: minute} + { key: 'YYYY', value: year }, + { key: 'YY', value: halfYear }, + { key: 'MM', value: month }, + { key: 'DD', value: day }, + { key: 'hh', value: hour }, + { key: 'mm', value: minute } ] - - for(var i=0,j=replaceMap.length;i=0; + return diff >= 0; }; - this.isMonthBigger = function(date1, date2) { + this.isMonthBigger = function (date1, date2) { var diff = new Date(date1.year, date1.month) - new Date(date2.year, date2.month); - return diff>=0; + return diff >= 0; }; - this.joinTime = function(date, time) { + this.joinTime = function (date, time) { return new Date(new Date(new Date(date).setHours(time.hour)).setMinutes(time.minute)); }; - this.removeTime = function(date) { - return [date.getFullYear(), date.getMonth()+1, date.getDate()].dtp_toDate('date'); + this.removeTime = function (date) { + return dtp_toDate([date.getFullYear(), date.getMonth() + 1, date.getDate()], 'date'); } - this.validateJalaliDateSeparate = function(date, time) { - if (date.length!=3 || time.length!=2) + this.validateJalaliDateSeparate = function (date, time) { + if (date.length != 3 || time.length != 2) return false; - - if (time[0]>23 || time[0]<0 || time[1]>59 || time[1]<0 || date[0]<0 || date[1]<1 || date[1]>12) + + if (time[0] > 23 || time[0] < 0 || time[1] > 59 || time[1] < 0 || date[0] < 0 || date[1] < 1 || date[1] > 12) return false; - - if (date[1]>0 && date[1]<7) { - if (date[2]<1 || date[2]>31) + + if (date[1] > 0 && date[1] < 7) { + if (date[2] < 1 || date[2] > 31) return false; } - else if (date[1]>6 && date[1]<12) { - if (date[2]<1 || date[2]>30) + else if (date[1] > 6 && date[1] < 12) { + if (date[2] < 1 || date[2] > 30) return false; } else if (date[1] == 12) { var isLeap = ADMdtpConvertor.isLeapJalali(date[0]); - if ((isLeap && (date[2]<1 || date[2]>30)) || (!isLeap && (date[2]<1 || date[2]>29))) + if ((isLeap && (date[2] < 1 || date[2] > 30)) || (!isLeap && (date[2] < 1 || date[2] > 29))) return false; } return true; } - this.validateJalaliDate = function(input, format) { + this.validateJalaliDate = function (input, format) { var _dateTime; - + if (typeof input == "number") { var _gDate = new Date(input); if (/invalid/i.test(_gDate)) return false; var _pDate = this.convertToJalali(_gDate); - _dateTime = angular.merge(_pDate, {hour: _gDate.getHours(), minute: _gDate.getMinutes()}); + _dateTime = angular.merge(_pDate, { hour: _gDate.getHours(), minute: _gDate.getMinutes() }); } else if (typeof input == "string") _dateTime = this.parseString(input, format); - + else if (input instanceof Object) _dateTime = input; - + if (!_dateTime) return false; - + var _date = [_dateTime.year, _dateTime.month, _dateTime.day]; var _time = [_dateTime.hour, _dateTime.minute]; - + if (this.validateJalaliDateSeparate(_date, _time)) { - var _gDateC = ADMdtpConvertor.toGregorian(_date[0],_date[1],_date[2]); - var _gDate = [_gDateC.year, _gDateC.month, _gDateC.day, _time[0], _time[1]].dtp_toDate('date'); - + var _gDateC = ADMdtpConvertor.toGregorian(_date[0], _date[1], _date[2]); + var _gDate = dtp_toDate([_gDateC.year, _gDateC.month, _gDateC.day, _time[0], _time[1]], 'date'); + return { year: _date[0], month: _date[1], @@ -613,71 +612,71 @@ return false; }; - this.convertToUnix = function(value, type, format) { + this.convertToUnix = function (value, type, format) { if (!value) return null; if (typeof value == "number") return value; - + if (typeof value == "string") { value = this.parseString(value, format); } else if (value instanceof Date) - value = {year: value.getFullYear(), month: value.getMonth()+1, day: value.getDate(), hour: value.getHours(), minute: value.getMinutes()}; + value = { year: value.getFullYear(), month: value.getMonth() + 1, day: value.getDate(), hour: value.getHours(), minute: value.getMinutes() }; else return null; - - if (value.year<=99) - value.year = ((type == 'jalali') ? 1300+value.year : 2000+value.year); - - + + if (value.year <= 99) + value.year = ((type == 'jalali') ? 1300 + value.year : 2000 + value.year); + + if (type == 'jalali') { var _dateTime = this.validateJalaliDate(value, format); return _dateTime.unix || null; } else if (type == 'gregorian') { var _dateTime = new Date(this.toRegularFormat(value, type)); - return (/invalid/i.test(_dateTime))?null:_dateTime.getTime(); + return (/invalid/i.test(_dateTime)) ? null : _dateTime.getTime(); } - + return null; }; - this.convertFromUnix = function(unix, type) { + this.convertFromUnix = function (unix, type) { var _gDate = new Date(unix); if (type == 'jalali') return this.convertToJalali(_gDate); else if (type == 'gregorian') return { year: _gDate.getFullYear(), - month: _gDate.getMonth()+1, + month: _gDate.getMonth() + 1, day: _gDate.getDate(), unix: unix }; }; - this.convertToJalali = function(date) { - + this.convertToJalali = function (date) { + if (date instanceof Date) { var _date = { year: date.getFullYear(), - month: date.getMonth()+1, + month: date.getMonth() + 1, day: date.getDate(), unix: date.getTime() } date = _date; } if (date instanceof Object) { - return angular.merge(ADMdtpConvertor.toJalali(date.year, date.month, date.day), {unix: date.unix}); + return angular.merge(ADMdtpConvertor.toJalali(date.year, date.month, date.day), { unix: date.unix }); } }; - this.parseDisablePattern = function(options) { + this.parseDisablePattern = function (options) { var arr = options.disabled, smart = options.smartDisabling, calType = options.calType, format = options.format; - - var _inWeek = Array.apply(null, Array(7)).map(Number.prototype.valueOf,0); - var _inMonth = Array.apply(null, Array(31)).map(Number.prototype.valueOf,0); + + var _inWeek = Array.apply(null, Array(7)).map(Number.prototype.valueOf, 0); + var _inMonth = Array.apply(null, Array(31)).map(Number.prototype.valueOf, 0); var _static = {}; - + if (arr instanceof Array) { - for (var i=0,j=arr.length; i

{{current.year | digitType:calType}}

{{yearName | digitType:calType}} {{monthName}}
{{time.hour}}:{{time.minute}}
{{current.monthDscr}} {{current.year | digitType:calType}}
{{dayName}}

{{day.day | digitType:calType}}

{{option.gregorianDic.title}}

{{option.jalaliDic.title}}

' + template: '

{{current.year | digitType:calType}}

{{yearName | digitType:calType}} {{monthName}}
{{time.hour}}:{{time.minute}}
{{current.monthDscr}} {{current.year | digitType:calType}}
{{dayName}}

{{day.day | digitType:calType}}
{{getEventsTooltip(day)}}

{{option.gregorianDic.title}}

{{option.jalaliDic.title}}

' } } - var ADMdtpDirective = function(ADMdtp, ADMdtpConvertor, ADMdtpFactory, constants, $compile, $timeout) { + var ADMdtpDirective = function (ADMdtp, ADMdtpConvertor, ADMdtpFactory, constants, $compile, $timeout) { return { restrict: 'E', @@ -1041,17 +1066,18 @@ onTimechange: '&?', onOpen: '&?', onClose: '&?', + events: '=?', }, - link: function(scope, element, attrs, ctrls) { + link: function (scope, element, attrs, ctrls) { var ngModel = ctrls[0], admDtp = ctrls[1]; scope.api = admDtp; scope.dtpId = 'adm-' + (++ADMdtpFactory.counter); - + if (!element.find('ng-transclude').children().length) { scope.defaultTemplate = true; element.find('ng-transclude').remove(); } - + var _options = scope.options; if (!(_options instanceof Object)) _options = {}; @@ -1059,32 +1085,32 @@ scope.option.minuteStep = Math.max(Math.min(scope.option.minuteStep, 60), 1); var dayNames = angular.copy(scope.option.gregorianDic.daysNames); scope.option.gregorianDic.daysNamesUntouched = dayNames; - scope.option.gregorianDic.daysNames = dayNames.slice(scope.option.gregorianStartDay,7).concat(dayNames.slice(0,scope.option.gregorianStartDay)); - + scope.option.gregorianDic.daysNames = dayNames.slice(scope.option.gregorianStartDay, 7).concat(dayNames.slice(0, scope.option.gregorianStartDay)); + scope.disableDays = ADMdtpFactory.parseDisablePattern(scope.option); scope.calType = scope.option.calType; scope.monthNames = scope.option[scope.calType + 'Dic'].monthsNames; scope.daysNames = scope.option[scope.calType + 'Dic'].daysNames; - scope.timeoutValue = [0,0]; + scope.timeoutValue = [0, 0]; scope.dtpValue = {}; - scope.minDate = scope.mindate?new Date(scope.mindate):null; - scope.maxDate = scope.maxdate?new Date(scope.maxdate):null; - + scope.minDate = scope.mindate ? new Date(scope.mindate) : null; + scope.maxDate = scope.maxdate ? new Date(scope.maxdate) : null; + scope.current = { year: '', month: '', monthDscr: '', days: [] }; - - scope.updateMasterValue = function(newDate, releaseTheBeast) { + + scope.updateMasterValue = function (newDate, releaseTheBeast) { if (!newDate) newDate = (scope.dtpValue.unix ? scope.dtpValue : {}); - - scope.$applyAsync(function() { + + scope.$applyAsync(function () { scope.dtpValue = newDate; var minute = Number(scope.time.minute); minute -= minute % scope.option.minuteStep; @@ -1107,29 +1133,29 @@ format: scope.option.format } - ngModel.$setViewValue( scope.dtpValue.formated ); + ngModel.$setViewValue(scope.dtpValue.formated); ngModel.$render(); - + if (scope.hasInputDtp) element[0].querySelector('[dtp-input]').value = scope.dtpValue.formated; if (releaseTheBeast) { if (scope.onChange) - scope.onChange({date:scope.fullData}); + scope.onChange({ date: scope.fullData }); if (releaseTheBeast == 'time' && scope.onTimechange) - scope.onTimechange({date:scope.fullData}); + scope.onTimechange({ date: scope.fullData }); else if (releaseTheBeast == 'day' && scope.onDatechange) - scope.onDatechange({date:scope.fullData}); + scope.onDatechange({ date: scope.fullData }); } }); } - - scope.parseInputValue = function(valueStr, resetTime, releaseTheBeast) { + + scope.parseInputValue = function (valueStr, resetTime, releaseTheBeast) { if (valueStr == 'today') { valueStr = ADMdtpFactory.removeTime(new Date()).getTime(); } - + var _dateTime = false; if (valueStr) { @@ -1140,27 +1166,27 @@ else { if (typeof valueStr == "string") valueStr = ADMdtpFactory.toRegularFormat(valueStr, scope.calType, scope.option.format); - + _dateTime = new Date(valueStr); - _dateTime = (/invalid/i.test(_dateTime))?false:_dateTime; + _dateTime = (/invalid/i.test(_dateTime)) ? false : _dateTime; } } if (_dateTime) { scope.dtpValue = { year: _dateTime.year || _dateTime.getFullYear(), - month: _dateTime.month || _dateTime.getMonth()+1, + month: _dateTime.month || _dateTime.getMonth() + 1, day: _dateTime.day || _dateTime.getDate(), unix: _dateTime.unix || _dateTime.getTime(), fullDate: _dateTime.gDate || _dateTime } - + scope.dtpValue.fullDate = ADMdtpFactory.removeTime(scope.dtpValue.fullDate); scope.dtpValue.unix = scope.dtpValue.fullDate.getTime(); scope.time = { - hour: ( _dateTime.getHours?_dateTime.getHours():_dateTime.hour ).lZero(), - minute: ( _dateTime.getMinutes?_dateTime.getMinutes():_dateTime.minute ).lZero() + hour: (_dateTime.getHours ? _dateTime.getHours() : _dateTime.hour).lZero(), + minute: (_dateTime.getMinutes ? _dateTime.getMinutes() : _dateTime.minute).lZero() } scope.updateMasterValue(false, releaseTheBeast); @@ -1171,10 +1197,10 @@ hour: '00', minute: '00' } - } + } } scope.parseInputValue(ngModel.$viewValue || scope.option.default, true, false); - + ngModel.$formatters.push(function (val) { if (!val && scope.dtpValue.unix) { scope.destroy(); @@ -1187,71 +1213,71 @@ return val; }); - + if (scope.option.watchingOptions) { //return; - scope.$watch('options', function(nuVal, old) { + scope.$watch('options', function (nuVal, old) { if (!nuVal || typeof nuVal != 'object') return; if (old && JSON.stringify(old) == JSON.stringify(nuVal)) return; - + var daysNamesUntouched = scope.option.gregorianDic.daysNamesUntouched; scope.option = angular.merge(angular.copy(ADMdtp.getOptions()), nuVal); scope.option.minuteStep = Math.max(Math.min(scope.option.minuteStep, 60), 1); - + if (nuVal.gregorianDic && nuVal.gregorianDic.daysNames) scope.option.gregorianDic.daysNamesUntouched = nuVal.gregorianDic.daysNames; else scope.option.gregorianDic.daysNamesUntouched = daysNamesUntouched; - + var dayNames = angular.copy(scope.option.gregorianDic.daysNamesUntouched); - scope.option.gregorianDic.daysNames = dayNames.slice(scope.option.gregorianStartDay,7).concat(dayNames.slice(0,scope.option.gregorianStartDay)); + scope.option.gregorianDic.daysNames = dayNames.slice(scope.option.gregorianStartDay, 7).concat(dayNames.slice(0, scope.option.gregorianStartDay)); scope.disableDays = ADMdtpFactory.parseDisablePattern(scope.option); if (scope.calTypeChanged) scope.calTypeChanged(scope.option.calType); }, true); - } - + } + attrs.$observe("disable", function (_newVal) { - scope.$applyAsync(function() { + scope.$applyAsync(function () { _newVal = scope.$eval(_newVal); scope.disable = _newVal; }); }); - + attrs.$observe("mindate", function (_newVal) { - scope.$applyAsync(function() { + scope.$applyAsync(function () { _newVal = scope.$eval(_newVal); scope.minDate = ADMdtpFactory.convertToUnix(_newVal, scope.calType, scope.option.format); }); }); - + attrs.$observe("maxdate", function (_newVal) { - scope.$applyAsync(function() { + scope.$applyAsync(function () { _newVal = scope.$eval(_newVal); scope.maxDate = ADMdtpFactory.convertToUnix(_newVal, scope.calType, scope.option.format); }); - }); + }); - scope.onKeydown = function(e) { + scope.onKeydown = function (e) { if (e.keyCode == 9) scope.closeCalendar(); } - - scope.openCalendar = function() { + + scope.openCalendar = function () { if (scope.showCalendarStat || scope.disable) return; - + scope.timeoutValue[0] = 0; scope.showCalendarStat = true; - - var _admDtpCalendarHtml = angular.element(''); + + var _admDtpCalendarHtml = angular.element(''); angular.element(document.body).append(_admDtpCalendarHtml); scope.$applyAsync(function () { $compile(_admDtpCalendarHtml)(scope); }); - - $timeout(function() { + + $timeout(function () { var top = document.documentElement.scrollTop || document.body.scrollTop; var popup = document.getElementById(scope.dtpId); var popupBound = popup.getBoundingClientRect(); @@ -1266,7 +1292,7 @@ width: popupBound.width + _corner.x, height: popupBound.height + _corner.y } - + var _pos = { top: '', bottom: '', @@ -1277,54 +1303,54 @@ _pos.top = (top + _inputBound.top - popupBound.height) + 'px'; else _pos.top = (top + _inputBound.top + _inputBound.height) + 'px'; - + if (_totalSize.width > window.innerWidth) _pos.left = (_corner.x + window.innerWidth - _totalSize.width - 20) + 'px'; else _pos.left = _corner.x + 'px'; - - angular.element(popup).css({top: _pos.top, bottom: _pos.bottom, left: _pos.left, opacity: 1}); - + + angular.element(popup).css({ top: _pos.top, bottom: _pos.bottom, left: _pos.left, opacity: 1 }); + }, 70); - + if (scope.onOpen) scope.onOpen(); } - - scope.closeCalendar = function() { + + scope.closeCalendar = function () { if (!scope.showCalendarStat) return; - - scope.$applyAsync(function() { + + scope.$applyAsync(function () { scope.monthPickerStat = false; scope.timePickerStat = false; scope.showCalendarStat = false; }); - + var popup = document.getElementById(scope.dtpId); if (popup) { angular.element(popup).remove(); - + if (scope.onClose) scope.onClose(); } - + } - - scope.toggleCalendar = function() { + + scope.toggleCalendar = function () { if (scope.showCalendarStat) scope.closeCalendar(); else scope.openCalendar(); } - scope.destroy = function(noRefresh) { + scope.destroy = function (noRefresh) { if (scope.disable) return; - + scope.monthPickerStat = false; scope.timePickerStat = false; - + scope.current = { year: '', month: '', @@ -1340,40 +1366,40 @@ hour: '00', minute: '00' } - var _standValue = new Date(); + var _standValue = new Date(); if (scope.calType == 'jalali') _standValue = ADMdtpFactory.convertToJalali(_standValue); ngModel.$setViewValue(''); ngModel.$render(); - + if (!noRefresh) admDtp.fillDays(_standValue, !scope.option.transition); - + if (scope.onChange) - scope.onChange({date:scope.fullData}); + scope.onChange({ date: scope.fullData }); } - + var dtpOpen = element[0].querySelector('[dtp-open]') || {}; dtpOpen.onclick = scope.openCalendar; - + var dtpClose = element[0].querySelector('[dtp-close]') || {}; dtpClose.onclick = scope.closeCalendar; var dtpToggle = element[0].querySelector('[dtp-toggle]') || {}; dtpToggle.onclick = scope.toggleCalendar; - + var dtpDestroy = element[0].querySelector('[dtp-destroy]') || {}; dtpDestroy.onclick = scope.destroy; }, - controller: ['$scope', function($scope) { + controller: ['$scope', function ($scope) { - this.updateMasterValue = function(newDate, releaseTheBeast) { + this.updateMasterValue = function (newDate, releaseTheBeast) { $scope.updateMasterValue(newDate, releaseTheBeast); } - this.fillDays = function(date, noTransition) { + this.fillDays = function (date, noTransition) { if (noTransition) $scope.timeoutValue[0] = 0; @@ -1385,21 +1411,21 @@ if ($scope.calType == 'jalali') { var _gDate = ADMdtpConvertor.toGregorian(date.year, date.month, 29); - date = [_gDate.year, _gDate.month, _gDate.day].dtp_toDate('date'); + date = dtp_toDate([_gDate.year, _gDate.month, _gDate.day], 'date'); } var _input = { year: date.getFullYear(), - month: date.getMonth()+1, + month: date.getMonth() + 1, day: date.getDate() } - $scope.$applyAsync(function() { - var _month = _mainDate.month || (_mainDate.getMonth()+1); + $scope.$applyAsync(function () { + var _month = _mainDate.month || (_mainDate.getMonth() + 1); angular.merge($scope.current, { year: _mainDate.year || _mainDate.getFullYear(), month: _month, - monthDscr: $scope.monthNames[_month-1] + monthDscr: $scope.monthNames[_month - 1] }); }); @@ -1409,11 +1435,11 @@ shift = 0, startDay = 6; var _today = new Date(); - _today = [_today.getFullYear(), _today.getMonth()+1, _today.getDate(), 1, 0].dtp_toDate('unix'); + _today = dtp_toDate([_today.getFullYear(), _today.getMonth() + 1, _today.getDate(), 1, 0], 'unix'); var _selected = ($scope.dtpValue.unix || -1), _selectedIdx; - var _currDay = [_input.year, _input.month, _input.day, 1, 0].dtp_toDate('date'); + var _currDay = dtp_toDate([_input.year, _input.month, _input.day, 1, 0], 'date'); var _firstDayName = new Date(angular.copy(_currDay).setDate(1)).getDay(); var _days = []; @@ -1424,8 +1450,8 @@ if ($scope.calType == 'jalali') { var _ite_date = new Date(angular.copy(_currDay).setDate(_diff)); - var _pDate = ADMdtpConvertor.toJalali(_ite_date.getFullYear(), _ite_date.getMonth()+1, _ite_date.getDate()); - _diff -= (Math.ceil((_pDate.day-1)/7)*7 + 1); + var _pDate = ADMdtpConvertor.toJalali(_ite_date.getFullYear(), _ite_date.getMonth() + 1, _ite_date.getDate()); + _diff -= (Math.ceil((_pDate.day - 1) / 7) * 7 + 1); } @@ -1435,7 +1461,7 @@ var _pDate = false; if ($scope.calType == 'jalali') { - _pDate = ADMdtpConvertor.toJalali(_ite_date.getFullYear(), _ite_date.getMonth()+1, _ite_date.getDate()); + _pDate = ADMdtpConvertor.toJalali(_ite_date.getFullYear(), _ite_date.getMonth() + 1, _ite_date.getDate()); } var _thisDay = _pDate.day || _ite_date.getDate(); @@ -1451,11 +1477,11 @@ var _valid = 1; if ($scope.minDate || $scope.maxDate) { var _dateTime = ADMdtpFactory.joinTime(_ite_date, $scope.time); - if (($scope.minDate && !ADMdtpFactory.isDateBigger(_dateTime,$scope.minDate)) || ($scope.maxDate && !ADMdtpFactory.isDateBigger($scope.maxDate,_dateTime))) { + if (($scope.minDate && !ADMdtpFactory.isDateBigger(_dateTime, $scope.minDate)) || ($scope.maxDate && !ADMdtpFactory.isDateBigger($scope.maxDate, _dateTime))) { _valid = 0; if (_lastValidStat == 2) - _days[_days.length-1].isMax = true; + _days[_days.length - 1].isMax = true; } else { _valid = 2; @@ -1467,11 +1493,11 @@ } var _unix = _ite_date.getTime(); - var _dayName = _ite_date.getDay() + (($scope.calType=='jalali')?1:0); - + var _dayName = _ite_date.getDay() + (($scope.calType == 'jalali') ? 1 : 0); + var _day = { day: _thisDay, - month: _pDate.month || _ite_date.getMonth()+1, + month: _pDate.month || _ite_date.getMonth() + 1, year: _pDate.year || _ite_date.getFullYear(), dayName: _dayName, fullDate: _ite_date, @@ -1492,15 +1518,15 @@ _days.push(_day); } - $timeout(function() { + $timeout(function () { $scope.timeoutValue[0] = 500; - $scope.$applyAsync(function() { + $scope.$applyAsync(function () { $scope.current.days = _days; if (_selectedIdx) $scope.updateMasterValue($scope.current.days[_selectedIdx]); - $timeout(function() { + $timeout(function () { $scope.loadingDays = false; }, $scope.timeoutValue[1]); }); @@ -1508,10 +1534,10 @@ }, $scope.timeoutValue[0]); } - this.reload = function() { + this.reload = function () { var _cur = angular.copy($scope.current); _cur.day = 29; - var _date = [_cur.year, _cur.month, 8].dtp_toDate('date'); + var _date = dtp_toDate([_cur.year, _cur.month, 8], 'date'); if ($scope.calType == 'jalali') _date = _cur; this.fillDays(_date, !$scope.option.transition); @@ -1523,32 +1549,32 @@ template: '
' }; } - - var dtpInputDirective = function() { + + var dtpInputDirective = function () { return { require: ['^^admDtp', 'ngModel'], - link: function(scope, element, attrs, ctrls) { + link: function (scope, element, attrs, ctrls) { var admDtp = ctrls[0], ngModel = ctrls[1]; - ngModel.$parsers.push(function() { + ngModel.$parsers.push(function () { return ngModel.$modelValue; }) admDtp.vm.hasInputDtp = true; - element.on('focus', function() { + element.on('focus', function () { admDtp.vm.openCalendar(); }); - element.on('blur', function() { + element.on('blur', function () { admDtp.vm.modelChanged(element[0].value); }); - + } } } /* https://github.com/IamAdamJowett/angular-click-outside */ - var clickOutside = function($document) { + var clickOutside = function ($document) { return { restrict: 'A', scope: { @@ -1562,7 +1588,7 @@ element; if (!e.target) return; - + var classList = (attr.alias !== undefined) ? attr.alias.replace(', ', ',').split(',') : []; classList.push(attr.id); @@ -1584,23 +1610,23 @@ } }; } - - var ADMdtpConfig = function(ADMdtp) { - - ADMdtp.setOptions({isDeviceTouch: ('ontouchstart' in window || navigator.maxTouchPoints)}); - + + var ADMdtpConfig = function (ADMdtp) { + + ADMdtp.setOptions({ isDeviceTouch: ('ontouchstart' in window || navigator.maxTouchPoints) }); + var style = document.createElement('style'); style.type = 'text/css'; - - var vendor = function(css) { + + var vendor = function (css) { return '-moz-' + css + '-o-' + css + '-webkit-' + css + css; } - - for (var i=1; i<51; i++) - style.innerHTML += '.ADMdtpDays>span:nth-child('+ i +')>span {'+ vendor('transition: all .5s, transform 0.2s '+ i*.01 +'s cubic-bezier(0.680, -0.550, 0.265, 1.550); ') +'}'; + + for (var i = 1; i < 51; i++) + style.innerHTML += '.ADMdtpDays>span:nth-child(' + i + ')>span {' + vendor('transition: all .5s, transform 0.2s ' + i * .01 + 's cubic-bezier(0.680, -0.550, 0.265, 1.550); ') + '}'; document.getElementsByTagName('head')[0].appendChild(style); - + } return angular.module('ADM-dateTimePicker', []) diff --git a/dist/ADM-dateTimePicker.min.js b/dist/ADM-dateTimePicker.min.js index 49e9d7d..ab30c04 100644 --- a/dist/ADM-dateTimePicker.min.js +++ b/dist/ADM-dateTimePicker.min.js @@ -1,11 +1 @@ -/* -* Picking date & time in AngularJS is easier than ever. -* -* Demo: http://amirkabirdataminers.github.io/ADM-dateTimePicker -* -* @version 1.2.0 -* -* © 2017 Amirkabir Data Miners - www.adm-co.net -*/ - -!function(e){"use strict";e.merge||(e.merge=e.extend),String.prototype.toPersianDigits=function(){var e=["۰","۱","۲","۳","۴","۵","۶","۷","۸","۹"];return this.replace(/[0-9]/g,function(t){return e[+t]})},String.prototype.toEnglishDigits=function(){var e={"۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};return this.replace(/[^0-9.]/g,function(t){return e[t]||t})},String.prototype.lZero=function(){return this.length<2?"0"+this:this},Array.prototype.toNumber=function(){return this.map(function(e){return Number(e)})},Array.prototype.dtp_toDate=function(e){var t="-";/invalid/i.test(new Date("1991-9-12"))&&(t="/");var a=this.join(t);return 5==this.length&&(a=this.slice(0,3).join(t)+" "+this.slice(3,5).join(":")),e?(a=new Date(a),"unix"==e?a.getTime():a):a},Number.prototype.lZero=function(){return this<10?"0"+this:this},Date.prototype.dtp_shortDate=function(){return[this.getFullYear(),this.getMonth()+1,this.getDate()].dtp_toDate()};var t=function(){var t={calType:"gregorian",format:"YYYY/MM/DD hh:mm",multiple:!0,autoClose:!1,transition:!0,disabled:[],smartDisabling:!0,minuteStep:1,gregorianStartDay:0,gregorianDic:{title:"Gregorian",monthsNames:["January","February","March","April","May","June","July","August","September","October","November","December"],daysNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],todayBtn:"Today"},jalaliDic:{title:"جلالی",monthsNames:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],daysNames:["ش","ی","د","س","چ","پ","ج"],todayBtn:"امروز"}},a={getOptions:function(e){var a=e&&t[e]||t;return a}};this.setOptions=function(a,n){return n?void(t[a]=e.merge(t[a]||{},n)):(n=a,void(t=e.merge(t,n)))},this.$get=function(){return a}},a=function(){return function(e,t){return"jalali"==t?String(e).toPersianDigits():e}},n=function(){function e(e){var a=l(e);return a-=226894,t(a)}function t(e){var t=r(e),i=n(e,t),o=a(e,t,i),l={day:o,month:i,year:t};return l}function a(e,t,a){var n=o(t);e-=n+365*(t-1);for(var i=1;i22){var n=t-22-1,i=t-22,r=Math.floor(n/33),l=i-33*r;l>=28&&(l=28);var s=Math.floor(l/4),c=s+8*r+6,u=Math.floor((e-c)/365);return a=o(u),e-365*u-a-(D(u)?1:0)>0?(u++,u):e-365*u+a<=0?u:u}return a=t<1?0:t>=1&&t<=4?1:t>=5&&t<=8?2:t>=9&&t<=12?3:t>=13&&t<=16?4:t>=17&&t<22?5:6,t=Math.floor((e-a-1)/365),t+1}function o(e){if(e<23)switch(e){case 1:return 0;case 2:case 3:case 4:case 5:return 1;case 6:case 7:case 8:case 9:return 2;case 10:case 11:case 12:case 13:return 3;case 14:case 15:case 16:case 17:return 4;case 18:case 19:case 20:case 21:case 22:return 5}var t=e-22,a=Math.floor((t-1)/33),n=t-33*a;n>28&&(n=28);var i=Math.floor(n/4)+8*a+6;return D(e)&&t-33*a<=28&&i--,i}function l(e){var t=s(),a=u(e.year),n=a,i=c(e.year);n+=365*(e.year-1);for(var r=0;r2&&r++,a-365*(e-1)-n-r}function h(e){var t=e.day;return t+=y(e.month),t+=f(e.year)}function y(e){for(var t=0,a=i(),n=0;n=0},this.isMonthBigger=function(e,t){var a=new Date(e.year,e.month)-new Date(t.year,t.month);return a>=0},this.joinTime=function(e,t){return new Date(new Date(new Date(e).setHours(t.hour)).setMinutes(t.minute))},this.removeTime=function(e){return[e.getFullYear(),e.getMonth()+1,e.getDate()].dtp_toDate("date")},this.validateJalaliDateSeparate=function(e,a){if(3!=e.length||2!=a.length)return!1;if(a[0]>23||a[0]<0||a[1]>59||a[1]<0||e[0]<0||e[1]<1||e[1]>12)return!1;if(e[1]>0&&e[1]<7){if(e[2]<1||e[2]>31)return!1}else if(e[1]>6&&e[1]<12){if(e[2]<1||e[2]>30)return!1}else if(12==e[1]){var n=t.isLeapJalali(e[0]);if(n&&(e[2]<1||e[2]>30)||!n&&(e[2]<1||e[2]>29))return!1}return!0},this.validateJalaliDate=function(a,n){var i;if("number"==typeof a){var r=new Date(a);if(/invalid/i.test(r))return!1;var o=this.convertToJalali(r);i=e.merge(o,{hour:r.getHours(),minute:r.getMinutes()})}else"string"==typeof a?i=this.parseString(a,n):a instanceof Object&&(i=a);if(!i)return!1;var l=[i.year,i.month,i.day],s=[i.hour,i.minute];if(this.validateJalaliDateSeparate(l,s)){var c=t.toGregorian(l[0],l[1],l[2]),r=[c.year,c.month,c.day,s[0],s[1]].dtp_toDate("date");return{year:l[0],month:l[1],day:l[2],hour:s[0],minute:s[1],unix:r.getTime(),gDate:r}}return!1},this.convertToUnix=function(e,t,a){if(!e)return null;if("number"==typeof e)return e;if("string"==typeof e)e=this.parseString(e,a);else{if(!(e instanceof Date))return null;e={year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes()}}if(e.year<=99&&(e.year="jalali"==t?1300+e.year:2e3+e.year),"jalali"==t){var n=this.validateJalaliDate(e,a);return n.unix||null}if("gregorian"==t){var n=new Date(this.toRegularFormat(e,t));return/invalid/i.test(n)?null:n.getTime()}return null},this.convertFromUnix=function(e,t){var a=new Date(e);return"jalali"==t?this.convertToJalali(a):"gregorian"==t?{year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),unix:e}:void 0},this.convertToJalali=function(a){if(a instanceof Date){var n={year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate(),unix:a.getTime()};a=n}if(a instanceof Object)return e.merge(t.toJalali(a.year,a.month,a.day),{unix:a.unix})},this.parseDisablePattern=function(e){var t=e.disabled,a=e.smartDisabling,n=e.calType,i=e.format,r=Array.apply(null,Array(7)).map(Number.prototype.valueOf,0),o=Array.apply(null,Array(31)).map(Number.prototype.valueOf,0),l={};if(t instanceof Array)for(var s=0,c=t.length;s

{{current.year | digitType:calType}}

{{yearName | digitType:calType}} {{monthName}}
{{time.hour}}:{{time.minute}}
{{current.monthDscr}} {{current.year | digitType:calType}}
{{dayName}}

{{day.day | digitType:calType}}

{{option.gregorianDic.title}}

{{option.jalaliDic.title}}

'}},o=function(t,a,n,i,r,o){return{restrict:"E",replace:!0,transclude:!0,require:["ngModel","admDtp"],scope:{options:"=?",fullData:"=?",name:"=?",ngRequired:"=?",onChange:"&?",onDatechange:"&?",onTimechange:"&?",onOpen:"&?",onClose:"&?"},link:function(a,i,l,s){var c=s[0],u=s[1];a.api=u,a.dtpId="adm-"+ ++n.counter,i.find("ng-transclude").children().length||(a.defaultTemplate=!0,i.find("ng-transclude").remove());var d=a.options;d instanceof Object||(d={}),a.option=e.merge(e.copy(t.getOptions()),d),a.option.minuteStep=Math.max(Math.min(a.option.minuteStep,60),1);var p=e.copy(a.option.gregorianDic.daysNames);a.option.gregorianDic.daysNamesUntouched=p,a.option.gregorianDic.daysNames=p.slice(a.option.gregorianStartDay,7).concat(p.slice(0,a.option.gregorianStartDay)),a.disableDays=n.parseDisablePattern(a.option),a.calType=a.option.calType,a.monthNames=a.option[a.calType+"Dic"].monthsNames,a.daysNames=a.option[a.calType+"Dic"].daysNames,a.timeoutValue=[0,0],a.dtpValue={},a.minDate=a.mindate?new Date(a.mindate):null,a.maxDate=a.maxdate?new Date(a.maxdate):null,a.current={year:"",month:"",monthDscr:"",days:[]},a.updateMasterValue=function(e,t){e||(e=a.dtpValue.unix?a.dtpValue:{}),a.$applyAsync(function(){a.dtpValue=e;var r=Number(a.time.minute);r-=r%a.option.minuteStep,a.time.minute=r.lZero(),a.dtpValue.formated=n.dateFormat(e,a.time,a.option.format),a.dtpValue.fullDate=n.joinTime(e.unix,a.time),a.fullData={formated:a.dtpValue.formated,lDate:a.dtpValue.fullDate.dtp_shortDate(),gDate:a.dtpValue.fullDate,unix:a.dtpValue.fullDate.getTime(),year:e.year,month:e.month,day:e.day,hour:Number(a.time.hour),minute:Number(a.time.minute),minDate:a.minDate,maxDate:a.maxDate,calType:a.calType,format:a.option.format},c.$setViewValue(a.dtpValue.formated),c.$render(),a.hasInputDtp&&(i[0].querySelector("[dtp-input]").value=a.dtpValue.formated),t&&(a.onChange&&a.onChange({date:a.fullData}),"time"==t&&a.onTimechange?a.onTimechange({date:a.fullData}):"day"==t&&a.onDatechange&&a.onDatechange({date:a.fullData}))})},a.parseInputValue=function(e,t,i){"today"==e&&(e=n.removeTime(new Date).getTime());var r=!1;e&&("jalali"==a.calType?r=n.validateJalaliDate(e,a.option.format):("string"==typeof e&&(e=n.toRegularFormat(e,a.calType,a.option.format)),r=new Date(e),r=!/invalid/i.test(r)&&r)),r?(a.dtpValue={year:r.year||r.getFullYear(),month:r.month||r.getMonth()+1,day:r.day||r.getDate(),unix:r.unix||r.getTime(),fullDate:r.gDate||r},a.dtpValue.fullDate=n.removeTime(a.dtpValue.fullDate),a.dtpValue.unix=a.dtpValue.fullDate.getTime(),a.time={hour:(r.getHours?r.getHours():r.hour).lZero(),minute:(r.getMinutes?r.getMinutes():r.minute).lZero()},a.updateMasterValue(!1,i)):t&&(a.time={hour:"00",minute:"00"})},a.parseInputValue(c.$viewValue||a.option.default,!0,!1),c.$formatters.push(function(e){return!e&&a.dtpValue.unix?a.destroy():a.dtpValue&&e==a.dtpValue.formated||a.parseInputValue(e,!1,!0),e}),a.option.watchingOptions&&a.$watch("options",function(i,r){if(i&&"object"==typeof i&&(!r||JSON.stringify(r)!=JSON.stringify(i))){var o=a.option.gregorianDic.daysNamesUntouched;a.option=e.merge(e.copy(t.getOptions()),i),a.option.minuteStep=Math.max(Math.min(a.option.minuteStep,60),1),i.gregorianDic&&i.gregorianDic.daysNames?a.option.gregorianDic.daysNamesUntouched=i.gregorianDic.daysNames:a.option.gregorianDic.daysNamesUntouched=o;var l=e.copy(a.option.gregorianDic.daysNamesUntouched);a.option.gregorianDic.daysNames=l.slice(a.option.gregorianStartDay,7).concat(l.slice(0,a.option.gregorianStartDay)),a.disableDays=n.parseDisablePattern(a.option),a.calTypeChanged&&a.calTypeChanged(a.option.calType)}},!0),l.$observe("disable",function(e){a.$applyAsync(function(){e=a.$eval(e),a.disable=e})}),l.$observe("mindate",function(e){a.$applyAsync(function(){e=a.$eval(e),a.minDate=n.convertToUnix(e,a.calType,a.option.format)})}),l.$observe("maxdate",function(e){a.$applyAsync(function(){e=a.$eval(e),a.maxDate=n.convertToUnix(e,a.calType,a.option.format)})}),a.onKeydown=function(e){9==e.keyCode&&a.closeCalendar()},a.openCalendar=function(){if(!a.showCalendarStat&&!a.disable){a.timeoutValue[0]=0,a.showCalendarStat=!0;var t=e.element('');e.element(document.body).append(t),a.$applyAsync(function(){r(t)(a)}),o(function(){var t=document.documentElement.scrollTop||document.body.scrollTop,n=document.getElementById(a.dtpId),r=n.getBoundingClientRect(),o=i.children().children()[0],l=o.getBoundingClientRect(),s={x:l.left,y:l.top+l.height},c={width:r.width+s.x,height:r.height+s.y},u={top:"",bottom:"",left:"",right:""};c.height>window.innerHeight?u.top=t+l.top-r.height+"px":u.top=t+l.top+l.height+"px",c.width>window.innerWidth?u.left=s.x+window.innerWidth-c.width-20+"px":u.left=s.x+"px",e.element(n).css({top:u.top,bottom:u.bottom,left:u.left,opacity:1})},70),a.onOpen&&a.onOpen()}},a.closeCalendar=function(){if(a.showCalendarStat){a.$applyAsync(function(){a.monthPickerStat=!1,a.timePickerStat=!1,a.showCalendarStat=!1});var t=document.getElementById(a.dtpId);t&&(e.element(t).remove(),a.onClose&&a.onClose())}},a.toggleCalendar=function(){a.showCalendarStat?a.closeCalendar():a.openCalendar()},a.destroy=function(e){if(!a.disable){a.monthPickerStat=!1,a.timePickerStat=!1,a.current={year:"",month:"",monthDscr:"",days:[]},a.dtpValue={},a.fullData={minDate:a.minDate,maxDate:a.maxDate},a.time={hour:"00",minute:"00"};var t=new Date;"jalali"==a.calType&&(t=n.convertToJalali(t)),c.$setViewValue(""),c.$render(),e||u.fillDays(t,!a.option.transition),a.onChange&&a.onChange({date:a.fullData})}};var g=i[0].querySelector("[dtp-open]")||{};g.onclick=a.openCalendar;var m=i[0].querySelector("[dtp-close]")||{};m.onclick=a.closeCalendar;var h=i[0].querySelector("[dtp-toggle]")||{};h.onclick=a.toggleCalendar;var y=i[0].querySelector("[dtp-destroy]")||{};y.onclick=a.destroy},controller:["$scope",function(t){this.updateMasterValue=function(e,a){t.updateMasterValue(e,a)},this.fillDays=function(i,r){r?t.timeoutValue[0]=0:t.loadingDays=!0;var l=e.copy(i);if("jalali"==t.calType){var s=a.toGregorian(i.year,i.month,29);i=[s.year,s.month,s.day].dtp_toDate("date")}var c={year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate()};t.$applyAsync(function(){var a=l.month||l.getMonth()+1;e.merge(t.current,{year:l.year||l.getFullYear(),month:a,monthDscr:t.monthNames[a-1]})});var u,d=u=t.option.gregorianStartDay;"jalali"==t.calType&&(d=0,u=6);var p=new Date;p=[p.getFullYear(),p.getMonth()+1,p.getDate(),1,0].dtp_toDate("unix");var g,m,h=t.dtpValue.unix||-1,y=[c.year,c.month,c.day,1,0].dtp_toDate("date"),f=new Date(e.copy(y).setDate(1)).getDay(),v=[],D=-1*(f-d+7)%7,x=!0,M=-1;if("jalali"==t.calType){var m=new Date(e.copy(y).setDate(D)),T=a.toJalali(m.getFullYear(),m.getMonth()+1,m.getDate());D-=7*Math.ceil((T.day-1)/7)+1}for(;;){D++;var m=new Date(e.copy(y).setDate(D)),T=!1;"jalali"==t.calType&&(T=a.toJalali(m.getFullYear(),m.getMonth()+1,m.getDate()));var w=T.day||m.getDate();if(1==w&&(x=!x),x&&w<8&&m.getDay()==u)break;var k=!1,S=1;if(t.minDate||t.maxDate){var b=n.joinTime(m,t.time);t.minDate&&!n.isDateBigger(b,t.minDate)||t.maxDate&&!n.isDateBigger(t.maxDate,b)?(S=0,2==M&&(v[v.length-1].isMax=!0)):(S=2,0==M&&(k=!0)),M=S}var V=m.getTime(),Y=m.getDay()+("jalali"==t.calType?1:0),N={day:w,month:T.month||m.getMonth()+1,year:T.year||m.getFullYear(),dayName:Y,fullDate:m,disable:x,today:V==p,selected:V==h,unix:V,valid:S,isMin:k};n.isDayDisable(t.calType,t.disableDays,N)&&(N.valid=0),N.selected&&(g=v.length),v.push(N)}o(function(){t.timeoutValue[0]=500,t.$applyAsync(function(){t.current.days=v,g&&t.updateMasterValue(t.current.days[g]),o(function(){t.loadingDays=!1},t.timeoutValue[1])})},t.timeoutValue[0])},this.reload=function(){var a=e.copy(t.current);a.day=29;var n=[a.year,a.month,8].dtp_toDate("date");"jalali"==t.calType&&(n=a),this.fillDays(n,!t.option.transition)},this.vm=t}],template:'
'}},l=function(){return{require:["^^admDtp","ngModel"],link:function(e,t,a,n){var i=n[0],r=n[1];r.$parsers.push(function(){return r.$modelValue}),i.vm.hasInputDtp=!0,t.on("focus",function(){i.vm.openCalendar()}),t.on("blur",function(){i.vm.modelChanged(t[0].value)})}}},s=function(e){return{restrict:"A",scope:{clickOut:"&"},link:function(t,a,n){void 0==n.id&&n.$set("id","id_"+Math.random()),e.on("click contextmenu",function(e){var a,i=0;if(e.target){var r=void 0!==n.alias?n.alias.replace(", ",",").split(","):[];for(r.push(n.id),a=e.target;a;a=a.parentNode){var o=a.id,l=a.className;if(void 0!==o)for(i=0;i-1||"string"==typeof l&&l.indexOf(r[i])>-1)return}t.$eval(t.clickOut)}})}}},c=function(e){e.setOptions({isDeviceTouch:"ontouchstart"in window||navigator.maxTouchPoints});var t=document.createElement("style");t.type="text/css";for(var a=function(e){return"-moz-"+e+"-o-"+e+"-webkit-"+e+e},n=1;n<51;n++)t.innerHTML+=".ADMdtpDays>span:nth-child("+n+")>span {"+a("transition: all .5s, transform 0.2s "+.01*n+"s cubic-bezier(0.680, -0.550, 0.265, 1.550); ")+"}";document.getElementsByTagName("head")[0].appendChild(t)};return e.module("ADM-dateTimePicker",[]).constant("constants",{}).provider("ADMdtp",t).filter("digitType",[a]).factory("ADMdtpConvertor",[n]).factory("ADMdtpFactory",["ADMdtpConvertor",i]).directive("admDtp",["ADMdtp","ADMdtpConvertor","ADMdtpFactory","constants","$compile","$timeout",o]).directive("admDtpCalendar",["ADMdtp","ADMdtpConvertor","ADMdtpFactory","constants","$timeout",r]).directive("dtpInput",[l]).directive("clickOut",["$document",s]).config(["ADMdtpProvider",c])}(window.angular); \ No newline at end of file +(function(n){"use strict";function t(n,t){var r="-",i;return(/invalid/i.test(new Date("1991-9-12"))&&(r="/"),i=n.join(r),n.length==5&&(i=n.slice(0,3).join(r)+" "+n.slice(3,5).join(":")),!t)?i:(i=new Date(i),t=="unix")?i.getTime():i}n.merge||(n.merge=n.extend);String.prototype.toPersianDigits=function(){var n=["۰","۱","۲","۳","۴","۵","۶","۷","۸","۹"];return this.replace(/[0-9]/g,function(t){return n[+t]})};String.prototype.toEnglishDigits=function(){var n={"۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"};return this.replace(/[^0-9.]/g,function(t){return n[t]||t})};String.prototype.lZero=function(){return this.length<2?"0"+this:this};Array.prototype.toNumber=function(){return this.map(function(n){return Number(n)})};Number.prototype.lZero=function(){return this<10?"0"+this:this};Date.prototype.dtp_shortDate=function(){return t([this.getFullYear(),this.getMonth()+1,this.getDate()])};var i=function(){var t={calType:"gregorian",format:"YYYY/MM/DD hh:mm",multiple:!0,autoClose:!1,transition:!0,disabled:[],smartDisabling:!0,minuteStep:1,gregorianStartDay:0,gregorianDic:{title:"Gregorian",monthsNames:["January","February","March","April","May","June","July","August","September","October","November","December"],daysNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],todayBtn:"Today"},jalaliDic:{title:"جلالی",monthsNames:["فروردین","اردیبهشت","خرداد","تیر","مرداد","شهریور","مهر","آبان","آذر","دی","بهمن","اسفند"],daysNames:["ش","ی","د","س","چ","پ","ج"],todayBtn:"امروز"}},i={getOptions:function(n){return n&&t[n]||t}};this.setOptions=function(i,r){if(!r){r=i;t=n.merge(t,r);return}t[i]=n.merge(t[i]||{},r)};this.$get=function(){return i}},r=function(){return function(n,t){return t=="jalali"?String(n).toPersianDigits():n}},u=function(){function s(n){var t=v(n);return t-=226894,h(t)}function h(n){var t=a(n),i=l(n,t),r=c(n,t,i);return{day:r,month:i,year:t}}function c(t,i,r){var f=n(i),u;for(t-=f+(i-1)*365,u=1;u22){var s=i-23,h=i-22,o=Math.floor(s/33),e=h-o*33;e>=28&&(e=28);var c=Math.floor(e/4),l=c+o*8+6,r=Math.floor((t-l)/365);return(u=n(r),t-r*365-u-(f(r)?1:0)>0)?(r++,r):(t-r*365+u<=0,r)}return u=i<1?0:i>=1&&i<=4?1:i>=5&&i<=8?2:i>=9&&i<=12?3:i>=13&&i<=16?4:i>=17&&i<22?5:6,i=Math.floor((t-u-1)/365),i+1}function n(n){var u;if(n<23)switch(n){case 1:return 0;case 2:case 3:case 4:case 5:return 1;case 6:case 7:case 8:case 9:return 2;case 10:case 11:case 12:case 13:return 3;case 14:case 15:case 16:case 17:return 4;case 18:case 19:case 20:case 21:case 22:return 5}var t=n-22,i=Math.floor((t-1)/33),r=t-i*33;return r>28&&(r=28),u=Math.floor(r/4)+i*8+6,f(n)&&t-i*33<=28&&u--,u}function v(n){var e=r(),o=i(n.year),f=o,s=t(n.year),u;for(f+=(n.year-1)*365,u=0;u2&&s++,f-(n-1)*365-h-s}function w(n){var t=n.day;return t+=b(n.month),t+k(n.year)}function b(n){for(var i=0,r=e(),t=0;t=0},this.isMonthBigger=function(n,t){var i=new Date(n.year,n.month)-new Date(t.year,t.month);return i>=0},this.joinTime=function(n,t){return new Date(new Date(new Date(n).setHours(t.hour)).setMinutes(t.minute))},this.removeTime=function(n){return t([n.getFullYear(),n.getMonth()+1,n.getDate()],"date")},this.validateJalaliDateSeparate=function(n,t){if(n.length!=3||t.length!=2||t[0]>23||t[0]<0||t[1]>59||t[1]<0||n[0]<0||n[1]<1||n[1]>12)return!1;if(n[1]>0&&n[1]<7){if(n[2]<1||n[2]>31)return!1}else if(n[1]>6&&n[1]<12){if(n[2]<1||n[2]>30)return!1}else if(n[1]==12){var r=i.isLeapJalali(n[0]);if(r&&(n[2]<1||n[2]>30)||!r&&(n[2]<1||n[2]>29))return!1}return!0},this.validateJalaliDate=function(r,u){var f,c,o,s,h,e;if(typeof r=="number"){if(e=new Date(r),/invalid/i.test(e))return!1;c=this.convertToJalali(e);f=n.merge(c,{hour:e.getHours(),minute:e.getMinutes()})}else typeof r=="string"?f=this.parseString(r,u):r instanceof Object&&(f=r);return f?(o=[f.year,f.month,f.day],s=[f.hour,f.minute],this.validateJalaliDateSeparate(o,s))?(h=i.toGregorian(o[0],o[1],o[2]),e=t([h.year,h.month,h.day,s[0],s[1]],"date"),{year:o[0],month:o[1],day:o[2],hour:s[0],minute:s[1],unix:e.getTime(),gDate:e}):!1:!1},this.convertToUnix=function(n,t,i){var r;if(!n)return null;if(typeof n=="number")return n;if(typeof n=="string")n=this.parseString(n,i);else if(n instanceof Date)n={year:n.getFullYear(),month:n.getMonth()+1,day:n.getDate(),hour:n.getHours(),minute:n.getMinutes()};else return null;return(n.year<=99&&(n.year=t=="jalali"?1300+n.year:2e3+n.year),t=="jalali")?(r=this.validateJalaliDate(n,i),r.unix||null):t=="gregorian"?(r=new Date(this.toRegularFormat(n,t)),/invalid/i.test(r)?null:r.getTime()):null},this.convertFromUnix=function(n,t){var i=new Date(n);return t=="jalali"?this.convertToJalali(i):t=="gregorian"?{year:i.getFullYear(),month:i.getMonth()+1,day:i.getDate(),unix:n}:void 0},this.convertToJalali=function(t){if(t instanceof Date){var r={year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),unix:t.getTime()};t=r}if(t instanceof Object)return n.merge(i.toJalali(t.year,t.month,t.day),{unix:t.unix})},this.parseDisablePattern=function(n){var i=n.disabled,w=n.smartDisabling,y=n.calType,b=n.format,e=Array.apply(null,Array(7)).map(Number.prototype.valueOf,0),o=Array.apply(null,Array(31)).map(Number.prototype.valueOf,0),s={},t,p,h,c,l,a,f,v,u,r;if(i instanceof Array)for(t=0,p=i.length;t
<\/svg> <\/i>
<\/svg>

{{current.year | digitType:calType}}<\/p> <\/svg> <\/div> {{yearName | digitType:calType}}<\/span><\/span> {{monthName}}<\/span><\/span> <\/div> <\/div> <\/div>

<\/svg> <\/i>
<\/svg><\/span><\/span><\/svg><\/span>{{time.hour}}<\/span>:<\/span>{{time.minute}}<\/span><\/svg><\/span><\/span><\/svg><\/span> <\/div> <\/div> <\/div>
<\/svg>
{{current.monthDscr}} {{current.year | digitType:calType}}<\/span> <\/svg> <\/header>
{{dayName}}<\/span> <\/div>
{{day.day | digitType:calType}}<\/span>
{{getEventsTooltip(day)}}<\/div><\/span> <\/div>