mydatepicker
Version:
Angular date picker
1,033 lines (1,028 loc) • 95.7 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/forms'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/forms', '@angular/common'], factory) :
(factory((global.mydatepicker = global.mydatepicker || {}),global.ng.core,global.ng.forms,global.ng.common));
}(this, (function (exports,_angular_core,_angular_forms,_angular_common) { 'use strict';
var LocaleService = (function () {
function LocaleService() {
this.locales = {
"en": {
dayLabels: { su: "Sun", mo: "Mon", tu: "Tue", we: "Wed", th: "Thu", fr: "Fri", sa: "Sat" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec" },
dateFormat: "mm/dd/yyyy",
todayBtnTxt: "Today",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"he": {
dayLabels: { su: "רא", mo: "שנ", tu: "של", we: "רב", th: "חמ", fr: "שי", sa: "שב" },
monthLabels: { 1: "ינו", 2: "פבר", 3: "מרץ", 4: "אפר", 5: "מאי", 6: "יונ", 7: "יול", 8: "אוג", 9: "ספט", 10: "אוק", 11: "נוב", 12: "דצמ" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "היום",
firstDayOfWeek: "su",
sunHighlight: false
},
"ja": {
dayLabels: { su: "日", mo: "月", tu: "火", we: "水", th: "木", fr: "金", sa: "土" },
monthLabels: { 1: "1月", 2: "2月", 3: "3月", 4: "4月", 5: "5月", 6: "6月", 7: "7月", 8: "8月", 9: "9月", 10: "10月", 11: "11月", 12: "12月" },
dateFormat: "yyyy.mm.dd",
todayBtnTxt: "今日",
sunHighlight: false
},
"fr": {
dayLabels: { su: "Dim", mo: "Lun", tu: "Mar", we: "Mer", th: "Jeu", fr: "Ven", sa: "Sam" },
monthLabels: { 1: "Jan", 2: "Fév", 3: "Mar", 4: "Avr", 5: "Mai", 6: "Juin", 7: "Juil", 8: "Aoû", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Déc" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "Aujourd'hui",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"fr-ch": {
dayLabels: { su: "Dim", mo: "Lun", tu: "Mar", we: "Mer", th: "Jeu", fr: "Ven", sa: "Sam" },
monthLabels: { 1: "Jan", 2: "Fév", 3: "Mar", 4: "Avr", 5: "Mai", 6: "Juin", 7: "Juil", 8: "Aoû", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Déc" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Aujourd'hui",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"fi": {
dayLabels: { su: "Su", mo: "Ma", tu: "Ti", we: "Ke", th: "To", fr: "Pe", sa: "La" },
monthLabels: { 1: "Tam", 2: "Hel", 3: "Maa", 4: "Huh", 5: "Tou", 6: "Kes", 7: "Hei", 8: "Elo", 9: "Syy", 10: "Lok", 11: "Mar", 12: "Jou" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Tänään",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"es": {
dayLabels: { su: "Do", mo: "Lu", tu: "Ma", we: "Mi", th: "Ju", fr: "Vi", sa: "Sa" },
monthLabels: { 1: "Ene", 2: "Feb", 3: "Mar", 4: "Abr", 5: "May", 6: "Jun", 7: "Jul", 8: "Ago", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dic" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Hoy",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"hu": {
dayLabels: { su: "Vas", mo: "Hét", tu: "Kedd", we: "Sze", th: "Csü", fr: "Pén", sa: "Szo" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Már", 4: "Ápr", 5: "Máj", 6: "Jún", 7: "Júl", 8: "Aug", 9: "Szep", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "Ma",
firstDayOfWeek: "mo",
sunHighlight: true
},
"sv": {
dayLabels: { su: "Sön", mo: "Mån", tu: "Tis", we: "Ons", th: "Tor", fr: "Fre", sa: "Lör" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Maj", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "Idag",
firstDayOfWeek: "mo",
sunHighlight: false
},
"nl": {
dayLabels: { su: "Zon", mo: "Maa", tu: "Din", we: "Woe", th: "Don", fr: "Vri", sa: "Zat" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mei", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "dd-mm-yyyy",
todayBtnTxt: "Vandaag",
firstDayOfWeek: "mo",
sunHighlight: false
},
"ru": {
dayLabels: { su: "Вс", mo: "Пн", tu: "Вт", we: "Ср", th: "Чт", fr: "Пт", sa: "Сб" },
monthLabels: { 1: "Янв", 2: "Фев", 3: "Март", 4: "Апр", 5: "Май", 6: "Июнь", 7: "Июль", 8: "Авг", 9: "Сент", 10: "Окт", 11: "Ноя", 12: "Дек" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Сегодня",
firstDayOfWeek: "mo",
sunHighlight: true
},
"uk": {
dayLabels: { su: "Нд", mo: "Пн", tu: "Вт", we: "Ср", th: "Чт", fr: "Пт", sa: "Сб" },
monthLabels: { 1: "Січ", 2: "Лют", 3: "Бер", 4: "Кві", 5: "Тра", 6: "Чер", 7: "Лип", 8: "Сер", 9: "Вер", 10: "Жов", 11: "Лис", 12: "Гру" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Сьогодні",
firstDayOfWeek: "mo",
sunHighlight: true
},
"no": {
dayLabels: { su: "Søn", mo: "Man", tu: "Tir", we: "Ons", th: "Tor", fr: "Fre", sa: "Lør" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Des" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "I dag",
firstDayOfWeek: "mo",
sunHighlight: false
},
"tr": {
dayLabels: { su: "Paz", mo: "Pzt", tu: "Sal", we: "Çar", th: "Per", fr: "Cum", sa: "Cmt" },
monthLabels: { 1: "Oca", 2: "Şub", 3: "Mar", 4: "Nis", 5: "May", 6: "Haz", 7: "Tem", 8: "Ağu", 9: "Eyl", 10: "Eki", 11: "Kas", 12: "Ara" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Bugün",
firstDayOfWeek: "mo",
sunHighlight: false
},
"pt-br": {
dayLabels: { su: "Dom", mo: "Seg", tu: "Ter", we: "Qua", th: "Qui", fr: "Sex", sa: "Sab" },
monthLabels: { 1: "Jan", 2: "Fev", 3: "Mar", 4: "Abr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Ago", 9: "Set", 10: "Out", 11: "Nov", 12: "Dez" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "Hoje",
firstDayOfWeek: "su",
sunHighlight: true
},
"de": {
dayLabels: { su: "So", mo: "Mo", tu: "Di", we: "Mi", th: "Do", fr: "Fr", sa: "Sa" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mär", 4: "Apr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dez" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Heute",
firstDayOfWeek: "mo",
sunHighlight: true
},
"de-ch": {
dayLabels: { su: "So", mo: "Mo", tu: "Di", we: "Mi", th: "Do", fr: "Fr", sa: "Sa" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mär", 4: "Apr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dez" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Heute",
firstDayOfWeek: "mo",
sunHighlight: true
},
"it": {
dayLabels: { su: "Dom", mo: "Lun", tu: "Mar", we: "Mer", th: "Gio", fr: "Ven", sa: "Sab" },
monthLabels: { 1: "Gen", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mag", 6: "Giu", 7: "Lug", 8: "Ago", 9: "Set", 10: "Ott", 11: "Nov", 12: "Dic" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "Oggi",
firstDayOfWeek: "mo",
sunHighlight: true
},
"it-ch": {
dayLabels: { su: "Dom", mo: "Lun", tu: "Mar", we: "Mer", th: "Gio", fr: "Ven", sa: "Sab" },
monthLabels: { 1: "Gen", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mag", 6: "Giu", 7: "Lug", 8: "Ago", 9: "Set", 10: "Ott", 11: "Nov", 12: "Dic" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Oggi",
firstDayOfWeek: "mo",
sunHighlight: true
},
"pl": {
dayLabels: { su: "Nie", mo: "Pon", tu: "Wto", we: "Śro", th: "Czw", fr: "Pią", sa: "Sob" },
monthLabels: { 1: "Sty", 2: "Lut", 3: "Mar", 4: "Kwi", 5: "Maj", 6: "Cze", 7: "Lip", 8: "Sie", 9: "Wrz", 10: "Paź", 11: "Lis", 12: "Gru" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "Dzisiaj",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"my": {
dayLabels: { su: "တနင်္ဂနွေ", mo: "တနင်္လာ", tu: "အင်္ဂါ", we: "ဗုဒ္ဓဟူး", th: "ကြသပတေး", fr: "သောကြာ", sa: "စနေ" },
monthLabels: { 1: "ဇန်နဝါရီ", 2: "ဖေဖော်ဝါရီ", 3: "မတ်", 4: "ဧပြီ", 5: "မေ", 6: "ဇွန်", 7: "ဇူလိုင်", 8: "ဩဂုတ်", 9: "စက်တင်ဘာ", 10: "အောက်တိုဘာ", 11: "နိုဝင်ဘာ", 12: "ဒီဇင်ဘာ" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "ယနေ့",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"sk": {
dayLabels: { su: "Ne", mo: "Po", tu: "Ut", we: "St", th: "Št", fr: "Pi", sa: "So" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Máj", 6: "Jún", 7: "Júl", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Dnes",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"sl": {
dayLabels: { su: "Ned", mo: "Pon", tu: "Tor", we: "Sre", th: "Čet", fr: "Pet", sa: "Sob" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Maj", 6: "Jun", 7: "Jul", 8: "Avg", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "dd. mm. yyyy",
todayBtnTxt: "Danes",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"zh-cn": {
dayLabels: { su: "日", mo: "一", tu: "二", we: "三", th: "四", fr: "五", sa: "六" },
monthLabels: { 1: "1月", 2: "2月", 3: "3月", 4: "4月", 5: "5月", 6: "6月", 7: "7月", 8: "8月", 9: "9月", 10: "10月", 11: "11月", 12: "12月" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "今天",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"ro": {
dayLabels: { su: "du", mo: "lu", tu: "ma", we: "mi", th: "jo", fr: "vi", sa: "sa" },
monthLabels: { 1: "ian", 2: "feb", 3: "mart", 4: "apr", 5: "mai", 6: "iun", 7: "iul", 8: "aug", 9: "sept", 10: "oct", 11: "nov", 12: "dec" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Astăzi",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"ca": {
dayLabels: { su: "dg", mo: "dl", tu: "dt", we: "dc", th: "dj", fr: "dv", sa: "ds" },
monthLabels: { 1: "Gen", 2: "Febr", 3: "Març", 4: "Abr", 5: "Maig", 6: "Juny", 7: "Jul", 8: "Ag", 9: "Set", 10: "Oct", 11: "Nov", 12: "Des" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Avui",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"id": {
dayLabels: { su: "Min", mo: "Sen", tu: "Sel", we: "Rab", th: "Kam", fr: "Jum", sa: "Sab" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mei", 6: "Jun", 7: "Jul", 8: "Ags", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Des" },
dateFormat: "dd-mm-yyyy",
todayBtnTxt: "Hari ini",
firstDayOfWeek: "su",
sunHighlight: true
},
"en-au": {
dayLabels: { su: "Sun", mo: "Mon", tu: "Tue", we: "Wed", th: "Thu", fr: "Fri", sa: "Sat" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "Today",
firstDayOfWeek: "mo",
sunHighlight: true
},
"am-et": {
dayLabels: { su: "እሑድ", mo: "ሰኞ", tu: "ማክሰኞ", we: "ረቡዕ", th: "ሐሙስ", fr: "ዓርብ", sa: "ቅዳሜ" },
monthLabels: { 1: "ጃንዩ", 2: "ፌብሩ", 3: "ማርች", 4: "ኤፕረ", 5: "ሜይ", 6: "ጁን", 7: "ጁላይ", 8: "ኦገስ", 9: "ሴፕቴ", 10: "ኦክተ", 11: "ኖቬም", 12: "ዲሴም" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "ዛሬ",
firstDayOfWeek: "mo",
sunHighlight: true
},
"cs": {
dayLabels: { su: "Ne", mo: "Po", tu: "Út", we: "St", th: "Čt", fr: "Pá", sa: "So" },
monthLabels: { 1: "Led", 2: "Úno", 3: "Bře", 4: "Dub", 5: "Kvě", 6: "Čvn", 7: "Čvc", 8: "Srp", 9: "Zář", 10: "Říj", 11: "Lis", 12: "Pro" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Dnes",
firstDayOfWeek: "mo",
sunHighlight: true
},
"el": {
dayLabels: { su: "Κυρ", mo: "Δευ", tu: "Τρι", we: "Τετ", th: "Πεμ", fr: "Παρ", sa: "Σαβ" },
monthLabels: { 1: "Ιαν", 2: "Φεβ", 3: "Μαρ", 4: "Απρ", 5: "Μαι", 6: "Ιουν", 7: "Ιουλ", 8: "Αυγ", 9: "Σεπ", 10: "Οκτ", 11: "Νοε", 12: "Δεκ" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "Σήμερα",
firstDayOfWeek: "mo",
sunHighlight: true
},
"kk": {
dayLabels: { su: "Жк", mo: "Дс", tu: "Сс", we: "Ср", th: "Бс", fr: "Жм", sa: "Сб" },
monthLabels: { 1: "Қаң", 2: "Ақп", 3: "Нау", 4: "Сәу", 5: "Мам", 6: "Мау", 7: "Шіл", 8: "Там", 9: "Қырк", 10: "Қаз", 11: "Қар", 12: "Желт" },
dateFormat: "dd-mmm-yyyy",
todayBtnTxt: "Бүгін",
firstDayOfWeek: "mo",
sunHighlight: true
},
"th": {
dayLabels: { su: "อา", mo: "จ", tu: "อ", we: "พ", th: "พฤ", fr: "ศ", sa: "ส" },
monthLabels: { 1: "ม.ค", 2: "ก.พ.", 3: "มี.ค.", 4: "เม.ย.", 5: "พ.ค.", 6: "มิ.ย.", 7: "ก.ค.", 8: "ส.ค.", 9: "ก.ย.", 10: "ต.ค.", 11: "พ.ย.", 12: "ธ.ค." },
dateFormat: "dd-mm-yyyy",
todayBtnTxt: "วันนี้",
firstDayOfWeek: "su",
sunHighlight: true
},
"ko-kr": {
dayLabels: { su: "일", mo: "월", tu: "화", we: "수", th: "목", fr: "금", sa: "토" },
monthLabels: { 1: "1월", 2: "2월", 3: "3월", 4: "4월", 5: "5월", 6: "6월", 7: "7월", 8: "8월", 9: "9월", 10: "10월", 11: "11월", 12: "12월" },
dateFormat: "yyyy mm dd",
todayBtnTxt: "오늘",
firstDayOfWeek: "su",
sunHighlight: true
},
"da": {
dayLabels: { su: "Søn", mo: "Man", tu: "Tir", we: "Ons", th: "Tor", fr: "Fre", sa: "Lør" },
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Maj", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "dd-mm-yyyy",
todayBtnTxt: "I dag",
firstDayOfWeek: "mo",
sunHighlight: true
},
"lt": {
dayLabels: { su: "Sk", mo: "Pr", tu: "An", we: "Tr", th: "Kt", fr: "Pn", sa: "Št" },
monthLabels: { 1: "Saus.", 2: "Vas.", 3: "Kov.", 4: "Bal.", 5: "Geg.", 6: "Birž.", 7: "Liep.", 8: "Rugp.", 9: "Rugs.", 10: "Sapl.", 11: "Lapkr.", 12: "Gruod." },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "Šianien",
firstDayOfWeek: "mo",
sunHighlight: true
},
"vi": {
dayLabels: { su: "CN", mo: "T2", tu: "T3", we: "T4", th: "T5", fr: "T6", sa: "T7" },
monthLabels: { 1: "THG 1", 2: "THG 2", 3: "THG 3", 4: "THG 4", 5: "THG 5", 6: "THG 6", 7: "THG 7", 8: "THG 8", 9: "THG 9", 10: "THG 10", 11: "THG 11", 12: "THG 12" },
dateFormat: "dd/mm/yyyy",
todayBtnTxt: "Hôm nay",
firstDayOfWeek: "mo",
sunHighlight: true,
},
"bn": {
dayLabels: { su: "রবি", mo: "সোম", tu: "মঙ্গল", we: "বুধ", th: "বৃহঃ", fr: "শুক্র", sa: "শনি" },
monthLabels: { 1: "জানু", 2: "ফেব্রু", 3: "মার্চ", 4: "এপ্রিল", 5: "মে", 6: "জুন", 7: "জুলাই", 8: "আগস্ট", 9: "সেপ্টে", 10: "অক্টো", 11: "নভে", 12: "ডিসে" },
dateFormat: "dd-mm-yyyy",
todayBtnTxt: "আজ",
firstDayOfWeek: "su",
sunHighlight: true
},
"bg": {
dayLabels: { su: "нд", mo: "пн", tu: "вт", we: "ср", th: "чт", fr: "пт", sa: "сб" },
monthLabels: { 1: "яну.", 2: "фев.", 3: "март", 4: "апр.", 5: "май", 6: "юни", 7: "юли", 8: "авг.", 9: "сеп.", 10: "окт.", 11: "ное.", 12: "дек." },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "днес",
firstDayOfWeek: "mo",
sunHighlight: true
},
"hr": {
dayLabels: { su: "Ne", mo: "Po", tu: "Ul", we: "Sr", th: "Če", fr: "Pe", sa: "Su" },
monthLabels: { 1: "Sij", 2: "Vel", 3: "Ožu", 4: "Tra", 5: "Svi", 6: "Lip", 7: "Srp", 8: "Kol", 9: "Ruj", 10: "Lis", 11: "Stu", 12: "Pro" },
dateFormat: "dd.mm.yyyy.",
todayBtnTxt: "danas",
firstDayOfWeek: "su",
sunHighlight: true
},
"ar": {
dayLabels: { su: "الأحد", mo: "الاثنين", tu: "الثلاثاء", we: "الاربعاء", th: "الخميس", fr: "الجمعة", sa: "السبت" },
monthLabels: { 1: "يناير", 2: "فبراير", 3: "مارس", 4: "ابريل", 5: "مايو", 6: "يونيو", 7: "يوليو", 8: "أغسطس", 9: "سبتمبر", 10: "أكتوبر", 11: "نوفمبر", 12: "ديسمبر" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "اليوم",
firstDayOfWeek: "sa",
sunHighlight: true
},
"is": {
dayLabels: { su: "sun", mo: "mán", tu: "þri", we: "mið", th: "fim", fr: "fös", sa: "lau" },
monthLabels: { 1: "jan", 2: "feb", 3: "mar", 4: "apr", 5: "maí", 6: "jún", 7: "júl", 8: "ágú", 9: "sep", 10: "okt", 11: "nóv", 12: "des" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Í dag",
firstDayOfWeek: "su",
sunHighlight: true
},
"tw": {
dayLabels: { su: "週日", mo: "週一", tu: "週二", we: "週三", th: "週四", fr: "週五", sa: "週六" },
monthLabels: { 1: "一月", 2: "二月", 3: "三月", 4: "四月", 5: "五月", 6: "六月", 7: "七月", 8: "八月", 9: "九月", 10: "十月", 11: "十一月", 12: "十二月" },
dateFormat: "yyyy-mm-dd",
todayBtnTxt: "今天",
firstDayOfWeek: "mo",
sunHighlight: true
},
"lv": {
dayLabels: { su: "S", mo: "P", tu: "O", we: "T", th: "C", fr: "P", sa: "S" },
monthLabels: { 1: "Janv", 2: "Febr", 3: "Marts", 4: "Apr", 5: "Maijs", 6: "Jūn", 7: "Jūl", 8: "Aug", 9: "Sept", 10: "Okt", 11: "Nov", 12: "Dec" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Šodien",
firstDayOfWeek: "mo",
sunHighlight: true
},
"et": {
dayLabels: { su: "P", mo: "E", tu: "T", we: "K", th: "N", fr: "R", sa: "L" },
monthLabels: { 1: "Jaan", 2: "Veebr", 3: "Märts", 4: "Apr", 5: "Mai", 6: "Juuni", 7: "Juuli", 8: "Aug", 9: "Sept", 10: "Okt", 11: "Nov", 12: "Dets" },
dateFormat: "dd.mm.yyyy",
todayBtnTxt: "Täna",
firstDayOfWeek: "mo",
sunHighlight: true
}
};
}
LocaleService.prototype.getLocaleOptions = function (locale) {
if (locale && this.locales.hasOwnProperty(locale)) {
return this.locales[locale];
}
return this.locales["en"];
};
LocaleService.decorators = [
{ type: _angular_core.Injectable },
];
LocaleService.ctorParameters = [];
return LocaleService;
}());
var M = "m";
var MM = "mm";
var MMM = "mmm";
var D = "d";
var DD = "dd";
var YYYY = "yyyy";
var UtilService = (function () {
function UtilService() {
this.weekDays = ["su", "mo", "tu", "we", "th", "fr", "sa"];
}
UtilService.prototype.isDateValid = function (dateStr, dateFormat, minYear, maxYear, disableUntil, disableSince, disableWeekends, disableWeekDays, disableDays, disableDateRanges, monthLabels, enableDays) {
var returnDate = { day: 0, month: 0, year: 0 };
var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var isMonthStr = dateFormat.indexOf(MMM) !== -1;
var delimeters = this.getDateFormatDelimeters(dateFormat);
var dateValue = this.getDateValue(dateStr, dateFormat, delimeters);
var year = this.getNumberByValue(dateValue[0]);
var month = isMonthStr ? this.getMonthNumberByMonthName(dateValue[1], monthLabels) : this.getNumberByValue(dateValue[1]);
var day = this.getNumberByValue(dateValue[2]);
if (month !== -1 && day !== -1 && year !== -1) {
if (year < minYear || year > maxYear || month < 1 || month > 12) {
return returnDate;
}
var date = { year: year, month: month, day: day };
if (this.isDisabledDay(date, minYear, maxYear, disableUntil, disableSince, disableWeekends, disableWeekDays, disableDays, disableDateRanges, enableDays)) {
return returnDate;
}
if (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)) {
daysInMonth[1] = 29;
}
if (day < 1 || day > daysInMonth[month - 1]) {
return returnDate;
}
return date;
}
return returnDate;
};
UtilService.prototype.getDateValue = function (dateStr, dateFormat, delimeters) {
var del = delimeters[0];
if (delimeters[0] !== delimeters[1]) {
del = delimeters[0] + delimeters[1];
}
var re = new RegExp("[" + del + "]");
var ds = dateStr.split(re);
var df = dateFormat.split(re);
var da = [];
for (var i = 0; i < df.length; i++) {
if (df[i].indexOf(YYYY) !== -1) {
da[0] = { value: ds[i], format: df[i] };
}
if (df[i].indexOf(M) !== -1) {
da[1] = { value: ds[i], format: df[i] };
}
if (df[i].indexOf(D) !== -1) {
da[2] = { value: ds[i], format: df[i] };
}
}
return da;
};
UtilService.prototype.getMonthNumberByMonthName = function (df, monthLabels) {
if (df.value) {
for (var key = 1; key <= 12; key++) {
if (df.value.toLowerCase() === monthLabels[key].toLowerCase()) {
return key;
}
}
}
return -1;
};
UtilService.prototype.getNumberByValue = function (df) {
if (!/^\d+$/.test(df.value)) {
return -1;
}
var nbr = Number(df.value);
if (df.format.length === 1 && df.value.length !== 1 && nbr < 10 || df.format.length === 1 && df.value.length !== 2 && nbr >= 10) {
nbr = -1;
}
else if (df.format.length === 2 && df.value.length > 2) {
nbr = -1;
}
return nbr;
};
UtilService.prototype.getDateFormatDelimeters = function (dateFormat) {
return dateFormat.match(/[^(dmy)]{1,}/g);
};
UtilService.prototype.parseDefaultMonth = function (monthString) {
var month = { monthTxt: "", monthNbr: 0, year: 0 };
if (monthString !== "") {
var split = monthString.split(monthString.match(/[^0-9]/)[0]);
month.monthNbr = split[0].length === 2 ? parseInt(split[0]) : parseInt(split[1]);
month.year = split[0].length === 2 ? parseInt(split[1]) : parseInt(split[0]);
}
return month;
};
UtilService.prototype.formatDate = function (date, dateFormat, monthLabels) {
var formatted = dateFormat.replace(YYYY, String(date.year));
if (dateFormat.indexOf(MMM) !== -1) {
formatted = formatted.replace(MMM, monthLabels[date.month]);
}
else if (dateFormat.indexOf(MM) !== -1) {
formatted = formatted.replace(MM, this.preZero(date.month));
}
else {
formatted = formatted.replace(M, String(date.month));
}
if (dateFormat.indexOf(DD) !== -1) {
formatted = formatted.replace(DD, this.preZero(date.day));
}
else {
formatted = formatted.replace(D, String(date.day));
}
return formatted;
};
UtilService.prototype.preZero = function (val) {
return val < 10 ? "0" + val : String(val);
};
UtilService.prototype.isDisabledDay = function (date, minYear, maxYear, disableUntil, disableSince, disableWeekends, disableWeekDays, disableDays, disableDateRanges, enableDays) {
for (var _i = 0, enableDays_1 = enableDays; _i < enableDays_1.length; _i++) {
var e = enableDays_1[_i];
if (e.year === date.year && e.month === date.month && e.day === date.day) {
return false;
}
}
var dn = this.getDayNumber(date);
if (date.year < minYear && date.month === 12 || date.year > maxYear && date.month === 1) {
return true;
}
var dateMs = this.getTimeInMilliseconds(date);
if (this.isInitializedDate(disableUntil) && dateMs <= this.getTimeInMilliseconds(disableUntil)) {
return true;
}
if (this.isInitializedDate(disableSince) && dateMs >= this.getTimeInMilliseconds(disableSince)) {
return true;
}
if (disableWeekends) {
if (dn === 0 || dn === 6) {
return true;
}
}
if (disableWeekDays.length > 0) {
for (var _a = 0, disableWeekDays_1 = disableWeekDays; _a < disableWeekDays_1.length; _a++) {
var wd = disableWeekDays_1[_a];
if (dn === this.getWeekdayIndex(wd)) {
return true;
}
}
}
for (var _b = 0, disableDays_1 = disableDays; _b < disableDays_1.length; _b++) {
var d = disableDays_1[_b];
if (d.year === date.year && d.month === date.month && d.day === date.day) {
return true;
}
}
for (var _c = 0, disableDateRanges_1 = disableDateRanges; _c < disableDateRanges_1.length; _c++) {
var d = disableDateRanges_1[_c];
if (this.isInitializedDate(d.begin) && this.isInitializedDate(d.end) && dateMs >= this.getTimeInMilliseconds(d.begin) && dateMs <= this.getTimeInMilliseconds(d.end)) {
return true;
}
}
return false;
};
UtilService.prototype.isMarkedDate = function (date, markedDates, markWeekends) {
for (var _i = 0, markedDates_1 = markedDates; _i < markedDates_1.length; _i++) {
var md = markedDates_1[_i];
for (var _a = 0, _b = md.dates; _a < _b.length; _a++) {
var d = _b[_a];
if (d.year === date.year && d.month === date.month && d.day === date.day) {
return { marked: true, color: md.color };
}
}
}
if (markWeekends && markWeekends.marked) {
var dayNbr = this.getDayNumber(date);
if (dayNbr === 0 || dayNbr === 6) {
return { marked: true, color: markWeekends.color };
}
}
return { marked: false, color: "" };
};
UtilService.prototype.isHighlightedDate = function (date, sunHighlight, satHighlight, highlightDates) {
var dayNbr = this.getDayNumber(date);
if (sunHighlight && dayNbr === 0 || satHighlight && dayNbr === 6) {
return true;
}
for (var _i = 0, highlightDates_1 = highlightDates; _i < highlightDates_1.length; _i++) {
var d = highlightDates_1[_i];
if (d.year === date.year && d.month === date.month && d.day === date.day) {
return true;
}
}
return false;
};
UtilService.prototype.getWeekNumber = function (date) {
var d = new Date(date.year, date.month - 1, date.day, 0, 0, 0, 0);
d.setDate(d.getDate() + (d.getDay() === 0 ? -3 : 4 - d.getDay()));
return Math.round(((d.getTime() - new Date(d.getFullYear(), 0, 4).getTime()) / 86400000) / 7) + 1;
};
UtilService.prototype.isMonthDisabledByDisableUntil = function (date, disableUntil) {
return this.isInitializedDate(disableUntil) && this.getTimeInMilliseconds(date) <= this.getTimeInMilliseconds(disableUntil);
};
UtilService.prototype.isMonthDisabledByDisableSince = function (date, disableSince) {
return this.isInitializedDate(disableSince) && this.getTimeInMilliseconds(date) >= this.getTimeInMilliseconds(disableSince);
};
UtilService.prototype.isInitializedDate = function (date) {
return date.year !== 0 && date.month !== 0 && date.day !== 0;
};
UtilService.prototype.isSameDate = function (d1, d2) {
return d1.year === d2.year && d1.month === d2.month && d1.day === d2.day;
};
UtilService.prototype.getTimeInMilliseconds = function (date) {
return new Date(date.year, date.month - 1, date.day, 0, 0, 0, 0).getTime();
};
UtilService.prototype.getDayNumber = function (date) {
return new Date(date.year, date.month - 1, date.day, 0, 0, 0, 0).getDay();
};
UtilService.prototype.getWeekDays = function () {
return this.weekDays;
};
UtilService.prototype.getWeekdayIndex = function (wd) {
return this.weekDays.indexOf(wd);
};
UtilService.decorators = [
{ type: _angular_core.Injectable },
];
UtilService.ctorParameters = [];
return UtilService;
}());
var FocusDirective = (function () {
function FocusDirective(el) {
this.el = el;
}
FocusDirective.prototype.ngAfterViewInit = function () {
if (this.value === "0") {
return;
}
this.el.nativeElement.focus();
};
FocusDirective.decorators = [
{ type: _angular_core.Directive, args: [{
selector: "[mydpfocus]"
},] },
];
FocusDirective.ctorParameters = [
{ type: _angular_core.ElementRef, },
];
FocusDirective.propDecorators = {
'value': [{ type: _angular_core.Input, args: ["mydpfocus",] },],
};
return FocusDirective;
}());
var MYDP_VALUE_ACCESSOR = {
provide: _angular_forms.NG_VALUE_ACCESSOR,
useExisting: _angular_core.forwardRef(function () { return MyDatePicker; }),
multi: true
};
var CalToggle;
(function (CalToggle) {
CalToggle[CalToggle["Open"] = 1] = "Open";
CalToggle[CalToggle["CloseByDateSel"] = 2] = "CloseByDateSel";
CalToggle[CalToggle["CloseByCalBtn"] = 3] = "CloseByCalBtn";
CalToggle[CalToggle["CloseByOutClick"] = 4] = "CloseByOutClick";
CalToggle[CalToggle["CloseByEsc"] = 5] = "CloseByEsc";
CalToggle[CalToggle["CloseByApi"] = 6] = "CloseByApi";
})(CalToggle || (CalToggle = {}));
var Year;
(function (Year) {
Year[Year["min"] = 1000] = "min";
Year[Year["max"] = 9999] = "max";
})(Year || (Year = {}));
var InputFocusBlur;
(function (InputFocusBlur) {
InputFocusBlur[InputFocusBlur["focus"] = 1] = "focus";
InputFocusBlur[InputFocusBlur["blur"] = 2] = "blur";
})(InputFocusBlur || (InputFocusBlur = {}));
var KeyCode;
(function (KeyCode) {
KeyCode[KeyCode["enter"] = 13] = "enter";
KeyCode[KeyCode["esc"] = 27] = "esc";
KeyCode[KeyCode["space"] = 32] = "space";
})(KeyCode || (KeyCode = {}));
var MonthId;
(function (MonthId) {
MonthId[MonthId["prev"] = 1] = "prev";
MonthId[MonthId["curr"] = 2] = "curr";
MonthId[MonthId["next"] = 3] = "next";
})(MonthId || (MonthId = {}));
var MMM$1 = "mmm";
var MyDatePicker = (function () {
function MyDatePicker(elem, cdr, localeService, utilService) {
var _this = this;
this.elem = elem;
this.cdr = cdr;
this.localeService = localeService;
this.utilService = utilService;
this.dateChanged = new _angular_core.EventEmitter();
this.inputFieldChanged = new _angular_core.EventEmitter();
this.calendarViewChanged = new _angular_core.EventEmitter();
this.calendarToggle = new _angular_core.EventEmitter();
this.inputFocusBlur = new _angular_core.EventEmitter();
this.onChangeCb = function () { };
this.onTouchedCb = function () { };
this.showSelector = false;
this.visibleMonth = { monthTxt: "", monthNbr: 0, year: 0 };
this.selectedMonth = { monthTxt: "", monthNbr: 0, year: 0 };
this.selectedDate = { year: 0, month: 0, day: 0 };
this.weekDays = [];
this.dates = [];
this.months = [];
this.years = [];
this.selectionDayTxt = "";
this.invalidDate = false;
this.disableTodayBtn = false;
this.dayIdx = 0;
this.selectMonth = false;
this.selectYear = false;
this.prevMonthDisabled = false;
this.nextMonthDisabled = false;
this.prevYearDisabled = false;
this.nextYearDisabled = false;
this.prevYearsDisabled = false;
this.nextYearsDisabled = false;
this.prevMonthId = MonthId.prev;
this.currMonthId = MonthId.curr;
this.nextMonthId = MonthId.next;
this.opts = {
dayLabels: {},
monthLabels: {},
dateFormat: "",
showTodayBtn: true,
todayBtnTxt: "",
firstDayOfWeek: "",
satHighlight: false,
sunHighlight: true,
highlightDates: [],
markCurrentDay: true,
markCurrentMonth: true,
markCurrentYear: true,
disableUntil: { year: 0, month: 0, day: 0 },
disableSince: { year: 0, month: 0, day: 0 },
disableDays: [],
enableDays: [],
markDates: [],
markWeekends: {},
disableDateRanges: [],
disableWeekends: false,
disableWeekdays: [],
showWeekNumbers: false,
height: "34px",
width: "100%",
selectionTxtFontSize: "14px",
selectorHeight: "232px",
selectorWidth: "252px",
allowDeselectDate: false,
inline: false,
showClearDateBtn: true,
showDecreaseDateBtn: false,
showIncreaseDateBtn: false,
alignSelectorRight: false,
openSelectorTopOfInput: false,
indicateInvalidDate: true,
editableDateField: true,
monthSelector: true,
yearSelector: true,
disableHeaderButtons: true,
minYear: Year.min,
maxYear: Year.max,
componentDisabled: false,
showSelectorArrow: true,
showInputField: true,
openSelectorOnInputClick: false,
allowSelectionOnlyInCurrentMonth: true,
ariaLabelInputField: "Date input field",
ariaLabelClearDate: "Clear Date",
ariaLabelDecreaseDate: "Decrease Date",
ariaLabelIncreaseDate: "Increase Date",
ariaLabelOpenCalendar: "Open Calendar",
ariaLabelPrevMonth: "Previous Month",
ariaLabelNextMonth: "Next Month",
ariaLabelPrevYear: "Previous Year",
ariaLabelNextYear: "Next Year",
ariaLabelDay: "Select day"
};
this.onClickListener = function (evt) { return _this.onClickDocument(evt); };
this.setLocaleOptions();
}
MyDatePicker.prototype.setLocaleOptions = function () {
var _this = this;
var opts = this.localeService.getLocaleOptions(this.locale);
Object.keys(opts).forEach(function (k) {
_this.opts[k] = opts[k];
});
};
MyDatePicker.prototype.setOptions = function () {
var _this = this;
if (this.options !== undefined) {
Object.keys(this.options).forEach(function (k) {
_this.opts[k] = _this.options[k];
});
}
if (this.opts.minYear < Year.min) {
this.opts.minYear = Year.min;
}
if (this.opts.maxYear > Year.max) {
this.opts.maxYear = Year.max;
}
if (this.disabled !== undefined) {
this.opts.componentDisabled = this.disabled;
}
};
MyDatePicker.prototype.getSelectorTopPosition = function () {
if (this.opts.openSelectorTopOfInput) {
return this.elem.nativeElement.children[0].offsetHeight + "px";
}
};
MyDatePicker.prototype.resetMonthYearSelect = function () {
this.selectMonth = false;
this.selectYear = false;
};
MyDatePicker.prototype.onSelectMonthClicked = function (event) {
event.stopPropagation();
this.selectMonth = !this.selectMonth;
this.selectYear = false;
this.cdr.detectChanges();
if (this.selectMonth) {
var today = this.getToday();
this.months.length = 0;
for (var i = 1; i <= 12; i += 3) {
var row = [];
for (var j = i; j < i + 3; j++) {
var disabled = this.utilService.isMonthDisabledByDisableUntil({ year: this.visibleMonth.year, month: j, day: this.daysInMonth(j, this.visibleMonth.year) }, this.opts.disableUntil)
|| this.utilService.isMonthDisabledByDisableSince({ year: this.visibleMonth.year, month: j, day: 1 }, this.opts.disableSince);
row.push({ nbr: j, name: this.opts.monthLabels[j], currMonth: j === today.month && this.visibleMonth.year === today.year, selected: j === this.visibleMonth.monthNbr, disabled: disabled });
}
this.months.push(row);
}
}
};
MyDatePicker.prototype.onMonthCellClicked = function (cell) {
var mc = cell.nbr !== this.visibleMonth.monthNbr;
this.visibleMonth = { monthTxt: this.monthText(cell.nbr), monthNbr: cell.nbr, year: this.visibleMonth.year };
this.generateCalendar(cell.nbr, this.visibleMonth.year, mc);
this.selectMonth = false;
this.selectorEl.nativeElement.focus();
};
MyDatePicker.prototype.onMonthCellKeyDown = function (event, cell) {
if ((event.keyCode === KeyCode.enter || event.keyCode === KeyCode.space) && !cell.disabled) {
event.preventDefault();
this.onMonthCellClicked(cell);
}
};
MyDatePicker.prototype.onSelectYearClicked = function (event) {
event.stopPropagation();
this.selectYear = !this.selectYear;
this.selectMonth = false;
this.cdr.detectChanges();
if (this.selectYear) {
this.generateYears(Number(this.visibleMonth.year));
}
};
MyDatePicker.prototype.onYearCellClicked = function (cell) {
var yc = cell.year !== this.visibleMonth.year;
this.visibleMonth = { monthTxt: this.visibleMonth.monthTxt, monthNbr: this.visibleMonth.monthNbr, year: cell.year };
this.generateCalendar(this.visibleMonth.monthNbr, cell.year, yc);
this.selectYear = false;
this.selectorEl.nativeElement.focus();
};
MyDatePicker.prototype.onYearCellKeyDown = function (event, cell) {
if ((event.keyCode === KeyCode.enter || event.keyCode === KeyCode.space) && !cell.disabled) {
event.preventDefault();
this.onYearCellClicked(cell);
}
};
MyDatePicker.prototype.onPrevYears = function (event, year) {
event.stopPropagation();
this.generateYears(Number(year) - 25);
};
MyDatePicker.prototype.onNextYears = function (event, year) {
event.stopPropagation();
this.generateYears(Number(year) + 25);
};
MyDatePicker.prototype.generateYears = function (year) {
this.years.length = 0;
var today = this.getToday();
for (var i = year; i <= 20 + year; i += 5) {
var row = [];
for (var j = i; j < i + 5; j++) {
var disabled = this.utilService.isMonthDisabledByDisableUntil({ year: j, month: this.visibleMonth.monthNbr, day: this.daysInMonth(this.visibleMonth.monthNbr, j) }, this.opts.disableUntil)
|| this.utilService.isMonthDisabledByDisableSince({ year: j, month: this.visibleMonth.monthNbr, day: 1 }, this.opts.disableSince);
var minMax = j < this.opts.minYear || j > this.opts.maxYear;
row.push({ year: j, currYear: j === today.year, selected: j === this.visibleMonth.year, disabled: disabled || minMax });
}
this.years.push(row);
}
this.prevYearsDisabled = this.years[0][0].year <= this.opts.minYear || this.utilService.isMonthDisabledByDisableUntil({ year: this.years[0][0].year - 1, month: this.visibleMonth.monthNbr, day: this.daysInMonth(this.visibleMonth.monthNbr, this.years[0][0].year - 1) }, this.opts.disableUntil);
this.nextYearsDisabled = this.years[4][4].year >= this.opts.maxYear || this.utilService.isMonthDisabledByDisableSince({ year: this.years[4][4].year + 1, month: this.visibleMonth.monthNbr, day: 1 }, this.opts.disableSince);
};
MyDatePicker.prototype.onUserDateInput = function (value) {
if (value.length === 0) {
if (this.utilService.isInitializedDate(this.selectedDate)) {
this.clearDate();
}
else {
this.invalidInputFieldChanged(value);
}
}
else {
var date = this.utilService.isDateValid(value, this.opts.dateFormat, this.opts.minYear, this.opts.maxYear, this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableWeekdays, this.opts.disableDays, this.opts.disableDateRanges, this.opts.monthLabels, this.opts.enableDays);
if (this.utilService.isInitializedDate(date)) {
if (!this.utilService.isSameDate(date, this.selectedDate)) {
this.selectDate(date, CalToggle.CloseByDateSel);
}
else {
this.updateDateValue(date);
}
}
else {
this.invalidInputFieldChanged(value);
}
}
};
MyDatePicker.prototype.onFocusInput = function (event) {
this.inputFocusBlur.emit({ reason: InputFocusBlur.focus, value: event.target.value });
};
MyDatePicker.prototype.onBlurInput = function (event) {
this.selectionDayTxt = event.target.value;
this.onTouchedCb();
this.inputFocusBlur.emit({ reason: InputFocusBlur.blur, value: event.target.value });
};
MyDatePicker.prototype.onCloseSelector = function (event) {
if (event.keyCode === KeyCode.esc && this.showSelector && !this.opts.inline) {
this.removeGlobalListener();
this.calendarToggle.emit(CalToggle.CloseByEsc);
this.showSelector = false;
}
};
MyDatePicker.prototype.invalidInputFieldChanged = function (value) {
this.invalidDate = value.length > 0;
this.inputFieldChanged.emit({ value: value, dateFormat: this.opts.dateFormat, valid: false });
this.onChangeCb(null);
this.onTouchedCb();
};
MyDatePicker.prototype.isTodayDisabled = function () {
this.disableTodayBtn = this.utilService.isDisabledDay(this.getToday(), this.opts.minYear, this.opts.maxYear, this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableWeekdays, this.opts.disableDays, this.opts.disableDateRanges, this.opts.enableDays);
};
MyDatePicker.prototype.parseOptions = function () {
if (this.locale) {
this.setLocaleOptions();
}
this.setOptions();
var weekDays = this.utilService.getWeekDays();
this.isTodayDisabled();
this.dayIdx = weekDays.indexOf(this.opts.firstDayOfWeek);
if (this.dayIdx !== -1) {
var idx = this.dayIdx;
for (var i = 0; i < weekDays.length; i++) {
this.weekDays.push(this.opts.dayLabels[weekDays[idx]]);
idx = weekDays[idx] === "sa" ? 0 : idx + 1;
}
}
};
MyDatePicker.prototype.writeValue = function (value) {
if (value && (value["date"] || value["jsdate"] || value["formatted"])) {
this.selectedDate = value["date"] ? this.parseSelectedDate(value["date"]) : value["jsdate"] ? this.parseSelectedDate(this.jsDateToMyDate(value["jsdate"])) : this.parseSelectedDate(value["formatted"]);
var cvc = this.visibleMonth.year !== this.selectedDate.year || this.visibleMonth.monthNbr !== this.selectedDate.month;
if (cvc) {
this.visibleMonth = { monthTxt: this.opts.monthLabels[this.selectedDate.month], monthNbr: this.selectedDate.month, year: this.selectedDate.year };
this.generateCalendar(this.selectedDate.month, this.selectedDate.year, cvc);
}
this.selectionDayTxt = this.utilService.formatDate(this.selectedDate, this.opts.dateFormat, this.opts.monthLabels);
}
else if (value === null || value === "") {
this.selectedDate = { year: 0, month: 0, day: 0 };
this.selectionDayTxt = "";
}
this.inputFieldChanged.emit({ value: this.selectionDayTxt, dateFormat: this.opts.dateFormat, valid: this.selectionDayTxt.length > 0 });
this.invalidDate = false;
};
MyDatePicker.prototype.setDisabledState = function (disabled) {
this.opts.componentDisabled = disabled;
this.cdr.detectChanges();
};
MyDatePicker.prototype.registerOnChange = function (fn) {
this.onChangeCb = fn;
};
MyDatePicker.prototype.registerOnTouched = function (fn) {
this.onTouchedCb = fn;
};
MyDatePicker.prototype.ngOnDestroy = function () {
this.removeGlobalListener();
};
MyDatePicker.prototype.ngOnChanges = function (changes) {
var _this = this;
if (changes.hasOwnProperty("selector")) {
var s = changes["selector"].currentValue;
if (typeof s === "object") {
if (s.open) {
this.showSelector = true;
this.openSelector(CalToggle.Open);
}
else {
this.showSelector = false;
this.closeSelector(CalToggle.CloseByApi);
}
}
else if (s > 0) {
this.openBtnClicked();
}
}
if (changes.hasOwnProperty("placeholder")) {
this.placeholder = changes["placeholder"].currentValue;
}
if (changes.hasOwnProperty("locale")) {
this.locale = changes["locale"].currentValue;
}
if (changes.hasOwnProperty("disabled")) {
this.disabled = changes["disabled"].currentValue;
}
if (changes.hasOwnProperty("options")) {
this.options = changes["options"].currentValue;
}
this.weekDays.length = 0;
this.parseOptions();
var dmChange = false;
if (changes.hasOwnProperty("defaultMonth")) {
var dm = changes["defaultMonth"].currentValue;
if (typeof dm === "object") {
dm = dm.defMonth;
}
if (dm !== null && dm !== undefined && dm !== "") {
this.selectedMonth = this.parseSelectedMonth(dm);
}
else {
this.selectedMonth = { monthTxt: "", monthNbr: 0, year: 0 };
}
dmChange = true;
}
if (changes.hasOwnProperty("selDate")) {
var sd = changes["selDate"];
if (sd.currentValue !== null && sd.currentValue !== undefined && sd.currentValue !== "" && Object.keys(sd.currentValue).length !== 0) {
this.selectedDate = this.parseSelectedDate(sd.currentValue);
setTimeout(function () {
_this.onChangeCb(_this.getDateModel(_this.selectedDate));
});
}
else {
if (!sd.isFirstChange()) {
this.clearDate();