Guest User

Untitled

a guest
Jan 28th, 2016
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * @preserve jQuery DateTimePicker plugin v2.4.5
  3.  * @homepage http://xdsoft.net/jqplugins/datetimepicker/
  4.  * (c) 2014, Chupurnov Valeriy.
  5.  */
  6. /*global document,window,jQuery,setTimeout,clearTimeout,HighlightedDate,getCurrentValue*/
  7. ;(function (factory) {
  8.     if ( typeof define === 'function' && define.amd ) {
  9.         // AMD. Register as an anonymous module.
  10.         define(['jquery', 'jquery-mousewheel', 'date-functions'], factory);
  11.     } else if (typeof exports === 'object') {
  12.         // Node/CommonJS style for Browserify
  13.         module.exports = factory;
  14.     } else {
  15.         // Browser globals
  16.         factory(jQuery);
  17.     }
  18. }(function ($) {
  19.     'use strict';
  20.     var default_options  = {
  21.         i18n: {
  22.             ar: { // Arabic
  23.                 months: [
  24.                     "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
  25.                 ],
  26.                 dayOfWeekShort: [
  27.                     "ن", "ث", "ع", "خ", "ج", "س", "ح"
  28.                 ],
  29.                 dayOfWeek: ["الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت", "الأحد"]
  30.             },
  31.             ro: { // Romanian
  32.                 months: [
  33.                     "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"
  34.                 ],
  35.                 dayOfWeekShort: [
  36.                     "Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ"
  37.                 ],
  38.                 dayOfWeek: ["Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă"]
  39.             },
  40.             id: { // Indonesian
  41.                 months: [
  42.                     "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
  43.                 ],
  44.                 dayOfWeekShort: [
  45.                     "Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
  46.                 ],
  47.                 dayOfWeek: ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
  48.             },
  49.             is: { // Icelandic
  50.                 months: [
  51.                     "Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"
  52.                 ],
  53.                 dayOfWeekShort: [
  54.                     "Sun", "Mán", "Þrið", "Mið", "Fim", "Fös", "Lau"
  55.                 ],
  56.                 dayOfWeek: ["Sunnudagur", "Mánudagur", "Þriðjudagur", "Miðvikudagur", "Fimmtudagur", "Föstudagur", "Laugardagur"]
  57.             },
  58.             bg: { // Bulgarian
  59.                 months: [
  60.                     "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
  61.                 ],
  62.                 dayOfWeekShort: [
  63.                     "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  64.                 ],
  65.                 dayOfWeek: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"]
  66.             },
  67.             fa: { // Persian/Farsi
  68.                 months: [
  69.                     'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
  70.                 ],
  71.                 dayOfWeekShort: [
  72.                     'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
  73.                 ],
  74.                 dayOfWeek: ["یک‌شنبه", "دوشنبه", "سه‌شنبه", "چهارشنبه", "پنج‌شنبه", "جمعه", "شنبه", "یک‌شنبه"]
  75.             },
  76.             ru: { // Russian
  77.                 months: [
  78.                     'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
  79.                 ],
  80.                 dayOfWeekShort: [
  81.                     "Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  82.                 ],
  83.                 dayOfWeek: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"]
  84.             },
  85.             uk: { // Ukrainian
  86.                 months: [
  87.                     'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
  88.                 ],
  89.                 dayOfWeekShort: [
  90.                     "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
  91.                 ],
  92.                 dayOfWeek: ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота"]
  93.             },
  94.             en: { // English
  95.                 months: [
  96.                     "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  97.                 ],
  98.                 dayOfWeekShort: [
  99.                     "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  100.                 ],
  101.                 dayOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  102.             },
  103.             el: { // Ελληνικά
  104.                 months: [
  105.                     "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
  106.                 ],
  107.                 dayOfWeekShort: [
  108.                     "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
  109.                 ],
  110.                 dayOfWeek: ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"]
  111.             },
  112.             de: { // German
  113.                 months: [
  114.                     'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
  115.                 ],
  116.                 dayOfWeekShort: [
  117.                     "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
  118.                 ],
  119.                 dayOfWeek: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
  120.             },
  121.             nl: { // Dutch
  122.                 months: [
  123.                     "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
  124.                 ],
  125.                 dayOfWeekShort: [
  126.                     "zo", "ma", "di", "wo", "do", "vr", "za"
  127.                 ],
  128.                 dayOfWeek: ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"]
  129.             },
  130.             tr: { // Turkish
  131.                 months: [
  132.                     "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
  133.                 ],
  134.                 dayOfWeekShort: [
  135.                     "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
  136.                 ],
  137.                 dayOfWeek: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"]
  138.             },
  139.             fr: { //French
  140.                 months: [
  141.                     "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
  142.                 ],
  143.                 dayOfWeekShort: [
  144.                     "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
  145.                 ],
  146.                 dayOfWeek: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
  147.             },
  148.             es: { // Spanish
  149.                 months: [
  150.                     "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
  151.                 ],
  152.                 dayOfWeekShort: [
  153.                     "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
  154.                 ],
  155.                 dayOfWeek: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"]
  156.             },
  157.             th: { // Thai
  158.                 months: [
  159.                     'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
  160.                 ],
  161.                 dayOfWeekShort: [
  162.                     'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
  163.                 ],
  164.                 dayOfWeek: ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์", "อาทิตย์"]
  165.             },
  166.             pl: { // Polish
  167.                 months: [
  168.                     "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
  169.                 ],
  170.                 dayOfWeekShort: [
  171.                     "nd", "pn", "wt", "śr", "cz", "pt", "sb"
  172.                 ],
  173.                 dayOfWeek: ["niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"]
  174.             },
  175.             pt: { // Portuguese
  176.                 months: [
  177.                     "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  178.                 ],
  179.                 dayOfWeekShort: [
  180.                     "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
  181.                 ],
  182.                 dayOfWeek: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
  183.             },
  184.             ch: { // Simplified Chinese
  185.                 months: [
  186.                     "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  187.                 ],
  188.                 dayOfWeekShort: [
  189.                     "日", "一", "二", "三", "四", "五", "六"
  190.                 ]
  191.             },
  192.             se: { // Swedish
  193.                 months: [
  194.                     "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September",  "Oktober", "November", "December"
  195.                 ],
  196.                 dayOfWeekShort: [
  197.                     "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  198.                 ]
  199.             },
  200.             kr: { // Korean
  201.                 months: [
  202.                     "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  203.                 ],
  204.                 dayOfWeekShort: [
  205.                     "일", "월", "화", "수", "목", "금", "토"
  206.                 ],
  207.                 dayOfWeek: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"]
  208.             },
  209.             it: { // Italian
  210.                 months: [
  211.                     "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
  212.                 ],
  213.                 dayOfWeekShort: [
  214.                     "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
  215.                 ],
  216.                 dayOfWeek: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"]
  217.             },
  218.             da: { // Dansk
  219.                 months: [
  220.                     "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
  221.                 ],
  222.                 dayOfWeekShort: [
  223.                     "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  224.                 ],
  225.                 dayOfWeek: ["søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"]
  226.             },
  227.             no: { // Norwegian
  228.                 months: [
  229.                     "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
  230.                 ],
  231.                 dayOfWeekShort: [
  232.                     "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  233.                 ],
  234.                 dayOfWeek: ['Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag']
  235.             },
  236.             ja: { // Japanese
  237.                 months: [
  238.                     "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
  239.                 ],
  240.                 dayOfWeekShort: [
  241.                     "日", "月", "火", "水", "木", "金", "土"
  242.                 ],
  243.                 dayOfWeek: ["日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜"]
  244.             },
  245.             vi: { // Vietnamese
  246.                 months: [
  247.                     "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12"
  248.                 ],
  249.                 dayOfWeekShort: [
  250.                     "CN", "T2", "T3", "T4", "T5", "T6", "T7"
  251.                 ],
  252.                 dayOfWeek: ["Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"]
  253.             },
  254.             sl: { // Slovenščina
  255.                 months: [
  256.                     "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
  257.                 ],
  258.                 dayOfWeekShort: [
  259.                     "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
  260.                 ],
  261.                 dayOfWeek: ["Nedelja", "Ponedeljek", "Torek", "Sreda", "Četrtek", "Petek", "Sobota"]
  262.             },
  263.             cs: { // Čeština
  264.                 months: [
  265.                     "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
  266.                 ],
  267.                 dayOfWeekShort: [
  268.                     "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
  269.                 ]
  270.             },
  271.             hu: { // Hungarian
  272.                 months: [
  273.                     "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
  274.                 ],
  275.                 dayOfWeekShort: [
  276.                     "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
  277.                 ],
  278.                 dayOfWeek: ["vasárnap", "hétfő", "kedd", "szerda", "csütörtök", "péntek", "szombat"]
  279.             },
  280.             az: { //Azerbaijanian (Azeri)
  281.                 months: [
  282.                     "Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
  283.                 ],
  284.                 dayOfWeekShort: [
  285.                     "B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
  286.                 ],
  287.                 dayOfWeek: ["Bazar", "Bazar ertəsi", "Çərşənbə axşamı", "Çərşənbə", "Cümə axşamı", "Cümə", "Şənbə"]
  288.             },
  289.             bs: { //Bosanski
  290.                 months: [
  291.                     "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  292.                 ],
  293.                 dayOfWeekShort: [
  294.                     "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  295.                 ],
  296.                 dayOfWeek: ["Nedjelja","Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"]
  297.             },
  298.             ca: { //Català
  299.                 months: [
  300.                     "Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
  301.                 ],
  302.                 dayOfWeekShort: [
  303.                     "Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
  304.                 ],
  305.                 dayOfWeek: ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte"]
  306.             },
  307.             'en-GB': { //English (British)
  308.                 months: [
  309.                     "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  310.                 ],
  311.                 dayOfWeekShort: [
  312.                     "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  313.                 ],
  314.                 dayOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  315.             },
  316.             et: { //"Eesti"
  317.                 months: [
  318.                     "Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
  319.                 ],
  320.                 dayOfWeekShort: [
  321.                     "P", "E", "T", "K", "N", "R", "L"
  322.                 ],
  323.                 dayOfWeek: ["Pühapäev", "Esmaspäev", "Teisipäev", "Kolmapäev", "Neljapäev", "Reede", "Laupäev"]
  324.             },
  325.             eu: { //Euskara
  326.                 months: [
  327.                     "Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
  328.                 ],
  329.                 dayOfWeekShort: [
  330.                     "Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
  331.                 ],
  332.                 dayOfWeek: ['Igandea', 'Astelehena', 'Asteartea', 'Asteazkena', 'Osteguna', 'Ostirala', 'Larunbata']
  333.             },
  334.             fi: { //Finnish (Suomi)
  335.                 months: [
  336.                     "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
  337.                 ],
  338.                 dayOfWeekShort: [
  339.                     "Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
  340.                 ],
  341.                 dayOfWeek: ["sunnuntai", "maanantai", "tiistai", "keskiviikko", "torstai", "perjantai", "lauantai"]
  342.             },
  343.             gl: { //Galego
  344.                 months: [
  345.                     "Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
  346.                 ],
  347.                 dayOfWeekShort: [
  348.                     "Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
  349.                 ],
  350.                 dayOfWeek: ["Domingo", "Luns", "Martes", "Mércores", "Xoves", "Venres", "Sábado"]
  351.             },
  352.             hr: { //Hrvatski
  353.                 months: [
  354.                     "Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
  355.                 ],
  356.                 dayOfWeekShort: [
  357.                     "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  358.                 ],
  359.                 dayOfWeek: ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"]
  360.             },
  361.             ko: { //Korean (한국어)
  362.                 months: [
  363.                     "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  364.                 ],
  365.                 dayOfWeekShort: [
  366.                     "일", "월", "화", "수", "목", "금", "토"
  367.                 ],
  368.                 dayOfWeek: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"]
  369.             },
  370.             lt: { //Lithuanian (lietuvių)
  371.                 months: [
  372.                     "Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
  373.                 ],
  374.                 dayOfWeekShort: [
  375.                     "Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
  376.                 ],
  377.                 dayOfWeek: ["Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis"]
  378.             },
  379.             lv: { //Latvian (Latviešu)
  380.                 months: [
  381.                     "Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
  382.                 ],
  383.                 dayOfWeekShort: [
  384.                     "Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
  385.                 ],
  386.                 dayOfWeek: ["Svētdiena", "Pirmdiena", "Otrdiena", "Trešdiena", "Ceturtdiena", "Piektdiena", "Sestdiena"]
  387.             },
  388.             mk: { //Macedonian (Македонски)
  389.                 months: [
  390.                     "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
  391.                 ],
  392.                 dayOfWeekShort: [
  393.                     "нед", "пон", "вто", "сре", "чет", "пет", "саб"
  394.                 ],
  395.                 dayOfWeek: ["Недела", "Понеделник", "Вторник", "Среда", "Четврток", "Петок", "Сабота"]
  396.             },
  397.             mn: { //Mongolian (Монгол)
  398.                 months: [
  399.                     "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
  400.                 ],
  401.                 dayOfWeekShort: [
  402.                     "Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
  403.                 ],
  404.                 dayOfWeek: ["Даваа", "Мягмар", "Лхагва", "Пүрэв", "Баасан", "Бямба", "Ням"]
  405.             },
  406.             'pt-BR': { //Português(Brasil)
  407.                 months: [
  408.                     "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  409.                 ],
  410.                 dayOfWeekShort: [
  411.                     "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
  412.                 ],
  413.                 dayOfWeek: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
  414.             },
  415.             sk: { //Slovenčina
  416.                 months: [
  417.                     "Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
  418.                 ],
  419.                 dayOfWeekShort: [
  420.                     "Ne", "Po", "Ut", "St", "Št", "Pi", "So"
  421.                 ],
  422.                 dayOfWeek: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota"]
  423.             },
  424.             sq: { //Albanian (Shqip)
  425.                 months: [
  426.                     "Janar", "Shkurt", "Mars", "Prill", "Maj", "Qershor", "Korrik", "Gusht", "Shtator", "Tetor", "Nëntor", "Dhjetor"
  427.                 ],
  428.                 dayOfWeekShort: [
  429.                     "Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Shtu"
  430.                 ],
  431.                 dayOfWeek: ["E Diel", "E Hënë", "E Martē", "E Mërkurë", "E Enjte", "E Premte", "E Shtunë"]
  432.             },
  433.             'sr-YU': { //Serbian (Srpski)
  434.                 months: [
  435.                     "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  436.                 ],
  437.                 dayOfWeekShort: [
  438.                     "Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
  439.                 ],
  440.                 dayOfWeek: ["Nedelja","Ponedeljak", "Utorak", "Sreda", "Četvrtak", "Petak", "Subota"]
  441.             },
  442.             sr: { //Serbian Cyrillic (Српски)
  443.                 months: [
  444.                     "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
  445.                 ],
  446.                 dayOfWeekShort: [
  447.                     "нед", "пон", "уто", "сре", "чет", "пет", "суб"
  448.                 ],
  449.                 dayOfWeek: ["Недеља","Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота"]
  450.             },
  451.             sv: { //Svenska
  452.                 months: [
  453.                     "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  454.                 ],
  455.                 dayOfWeekShort: [
  456.                     "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  457.                 ],
  458.                 dayOfWeek: ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"]
  459.             },
  460.             'zh-TW': { //Traditional Chinese (繁體中文)
  461.                 months: [
  462.                     "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  463.                 ],
  464.                 dayOfWeekShort: [
  465.                     "日", "一", "二", "三", "四", "五", "六"
  466.                 ],
  467.                 dayOfWeek: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  468.             },
  469.             zh: { //Simplified Chinese (简体中文)
  470.                 months: [
  471.                     "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  472.                 ],
  473.                 dayOfWeekShort: [
  474.                     "日", "一", "二", "三", "四", "五", "六"
  475.                 ],
  476.                 dayOfWeek: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  477.             },
  478.             he: { //Hebrew (עברית)
  479.                 months: [
  480.                     'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
  481.                 ],
  482.                 dayOfWeekShort: [
  483.                     \'', \'', \'', \'', \'', \'', 'שבת'
  484.                 ],
  485.                 dayOfWeek: ["ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שבת", "ראשון"]
  486.             },
  487.             hy: { // Armenian
  488.                 months: [
  489.                     "Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
  490.                 ],
  491.                 dayOfWeekShort: [
  492.                     "Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
  493.                 ],
  494.                 dayOfWeek: ["Կիրակի", "Երկուշաբթի", "Երեքշաբթի", "Չորեքշաբթի", "Հինգշաբթի", "Ուրբաթ", "Շաբաթ"]
  495.             },
  496.             kg: { // Kyrgyz
  497.                 months: [
  498.                     'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
  499.                 ],
  500.                 dayOfWeekShort: [
  501.                     "Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
  502.                 ],
  503.                 dayOfWeek: [
  504.                     "Жекшемб", "Дүйшөмб", "Шейшемб", "Шаршемб", "Бейшемби", "Жума", "Ишенб"
  505.                 ]
  506.             }
  507.         },
  508.         value: '',
  509.         rtl: false,
  510.  
  511.         format: 'Y/m/d H:i',
  512.         formatTime: 'H:i',
  513.         formatDate: 'Y/m/d',
  514.  
  515.         startDate:  false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
  516.         step: 60,
  517.         monthChangeSpinner: true,
  518.  
  519.         closeOnDateSelect: false,
  520.         closeOnTimeSelect: true,
  521.         closeOnWithoutClick: true,
  522.         closeOnInputClick: true,
  523.  
  524.         timepicker: true,
  525.         datepicker: true,
  526.         weeks: false,
  527.  
  528.         defaultTime: false, // use formatTime format (ex. '10:00' for formatTime:   'H:i')
  529.         defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
  530.  
  531.         minDate: false,
  532.         maxDate: false,
  533.         minTime: false,
  534.         maxTime: false,
  535.         disabledMinTime: false,
  536.         disabledMaxTime: false,
  537.  
  538.         allowTimes: [],
  539.         opened: false,
  540.         initTime: true,
  541.         inline: false,
  542.         theme: '',
  543.  
  544.         onSelectDate: function () {},
  545.         onSelectTime: function () {},
  546.         onChangeMonth: function () {},
  547.         onChangeYear: function () {},
  548.         onChangeDateTime: function () {},
  549.         onShow: function () {},
  550.         onClose: function () {},
  551.         onGenerate: function () {},
  552.  
  553.         withoutCopyright: true,
  554.         inverseButton: false,
  555.         hours12: false,
  556.         next: 'xdsoft_next',
  557.         prev : 'xdsoft_prev',
  558.         dayOfWeekStart: 0,
  559.         parentID: 'body',
  560.         timeHeightInTimePicker: 25,
  561.         timepickerScrollbar: true,
  562.         todayButton: true,
  563.         prevButton: true,
  564.         nextButton: true,
  565.         defaultSelect: true,
  566.  
  567.         scrollMonth: true,
  568.         scrollTime: true,
  569.         scrollInput: true,
  570.  
  571.         lazyInit: false,
  572.         mask: false,
  573.         validateOnBlur: true,
  574.         allowBlank: true,
  575.         yearStart: 1950,
  576.         yearEnd: 2050,
  577.         monthStart: 0,
  578.         monthEnd: 11,
  579.         style: '',
  580.         id: '',
  581.         fixed: false,
  582.         roundTime: 'round', // ceil, floor
  583.         className: '',
  584.         weekends: [],
  585.         highlightedDates: [],
  586.         highlightedPeriods: [],
  587.         disabledDates : [],
  588.         disabledWeekDays: [],
  589.         yearOffset: 0,
  590.         beforeShowDay: null,
  591.  
  592.         enterLikeTab: true,
  593.         showApplyButton: false
  594.     };
  595.  
  596.     var globalLocaleDefault = 'en',
  597.         globalLocale = 'en';
  598.     // for locale settings
  599.     $.datetimepicker = {
  600.         setLocale: function(locale){
  601.             globalLocale = default_options.i18n[locale]?locale:globalLocaleDefault;
  602.             // Override Parse and Format Library entities
  603.             Date.monthNames = default_options.i18n[globalLocale].months;
  604.             Date.dayNames = default_options.i18n[globalLocale].dayOfWeek;
  605.         }
  606.     };
  607.  
  608.     // fix for ie8
  609.     if (!window.getComputedStyle) {
  610.         window.getComputedStyle = function (el, pseudo) {
  611.             this.el = el;
  612.             this.getPropertyValue = function (prop) {
  613.                 var re = /(\-([a-z]){1})/g;
  614.                 if (prop === 'float') {
  615.                     prop = 'styleFloat';
  616.                 }
  617.                 if (re.test(prop)) {
  618.                     prop = prop.replace(re, function (a, b, c) {
  619.                         return c.toUpperCase();
  620.                     });
  621.                 }
  622.                 return el.currentStyle[prop] || null;
  623.             };
  624.             return this;
  625.         };
  626.     }
  627.     if (!Array.prototype.indexOf) {
  628.         Array.prototype.indexOf = function (obj, start) {
  629.             var i, j;
  630.             for (i = (start || 0), j = this.length; i < j; i += 1) {
  631.                 if (this[i] === obj) { return i; }
  632.             }
  633.             return -1;
  634.         };
  635.     }
  636.     Date.prototype.countDaysInMonth = function () {
  637.         return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
  638.     };
  639.     $.fn.xdsoftScroller = function (percent) {
  640.         return this.each(function () {
  641.             var timeboxparent = $(this),
  642.                 pointerEventToXY = function (e) {
  643.                     var out = {x: 0, y: 0},
  644.                         touch;
  645.                     if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
  646.                         touch  = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
  647.                         out.x = touch.clientX;
  648.                         out.y = touch.clientY;
  649.                     } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
  650.                         out.x = e.clientX;
  651.                         out.y = e.clientY;
  652.                     }
  653.                     return out;
  654.                 },
  655.                 move = 0,
  656.                 timebox,
  657.                 parentHeight,
  658.                 height,
  659.                 scrollbar,
  660.                 scroller,
  661.                 maximumOffset = 100,
  662.                 start = false,
  663.                 startY = 0,
  664.                 startTop = 0,
  665.                 h1 = 0,
  666.                 touchStart = false,
  667.                 startTopScroll = 0,
  668.                 calcOffset = function () {};
  669.             if (percent === 'hide') {
  670.                 timeboxparent.find('.xdsoft_scrollbar').hide();
  671.                 return;
  672.             }
  673.             if (!$(this).hasClass('xdsoft_scroller_box')) {
  674.                 timebox = timeboxparent.children().eq(0);
  675.                 parentHeight = timeboxparent[0].clientHeight;
  676.                 height = timebox[0].offsetHeight;
  677.                 scrollbar = $('<div class="xdsoft_scrollbar"></div>');
  678.                 scroller = $('<div class="xdsoft_scroller"></div>');
  679.                 scrollbar.append(scroller);
  680.  
  681.                 timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
  682.                 calcOffset = function calcOffset(event) {
  683.                     var offset = pointerEventToXY(event).y - startY + startTopScroll;
  684.                     if (offset < 0) {
  685.                         offset = 0;
  686.                     }
  687.                     if (offset + scroller[0].offsetHeight > h1) {
  688.                         offset = h1 - scroller[0].offsetHeight;
  689.                     }
  690.                     timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
  691.                 };
  692.  
  693.                 scroller
  694.                     .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
  695.                         if (!parentHeight) {
  696.                             timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  697.                         }
  698.  
  699.                         startY = pointerEventToXY(event).y;
  700.                         startTopScroll = parseInt(scroller.css('margin-top'), 10);
  701.                         h1 = scrollbar[0].offsetHeight;
  702.  
  703.                         if (event.type === 'mousedown') {
  704.                             if (document) {
  705.                                 $(document.body).addClass('xdsoft_noselect');
  706.                             }
  707.                             $([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
  708.                                 $([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
  709.                                     .off('mousemove.xdsoft_scroller', calcOffset)
  710.                                     .removeClass('xdsoft_noselect');
  711.                             });
  712.                             $(document.body).on('mousemove.xdsoft_scroller', calcOffset);
  713.                         } else {
  714.                             touchStart = true;
  715.                             event.stopPropagation();
  716.                             event.preventDefault();
  717.                         }
  718.                     })
  719.                     .on('touchmove', function (event) {
  720.                         if (touchStart) {
  721.                             event.preventDefault();
  722.                             calcOffset(event);
  723.                         }
  724.                     })
  725.                     .on('touchend touchcancel', function (event) {
  726.                         touchStart =  false;
  727.                         startTopScroll = 0;
  728.                     });
  729.  
  730.                 timeboxparent
  731.                     .on('scroll_element.xdsoft_scroller', function (event, percentage) {
  732.                         if (!parentHeight) {
  733.                             timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
  734.                         }
  735.                         percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
  736.  
  737.                         scroller.css('margin-top', maximumOffset * percentage);
  738.  
  739.                         setTimeout(function () {
  740.                             timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
  741.                         }, 10);
  742.                     })
  743.                     .on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
  744.                         var percent, sh;
  745.                         parentHeight = timeboxparent[0].clientHeight;
  746.                         height = timebox[0].offsetHeight;
  747.                         percent = parentHeight / height;
  748.                         sh = percent * scrollbar[0].offsetHeight;
  749.                         if (percent > 1) {
  750.                             scroller.hide();
  751.                         } else {
  752.                             scroller.show();
  753.                             scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
  754.                             maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
  755.                             if (noTriggerScroll !== true) {
  756.                                 timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
  757.                             }
  758.                         }
  759.                     });
  760.  
  761.                 timeboxparent.on('mousewheel', function (event) {
  762.                     var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  763.  
  764.                     top = top - (event.deltaY * 20);
  765.                     if (top < 0) {
  766.                         top = 0;
  767.                     }
  768.  
  769.                     timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
  770.                     event.stopPropagation();
  771.                     return false;
  772.                 });
  773.  
  774.                 timeboxparent.on('touchstart', function (event) {
  775.                     start = pointerEventToXY(event);
  776.                     startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
  777.                 });
  778.  
  779.                 timeboxparent.on('touchmove', function (event) {
  780.                     if (start) {
  781.                         event.preventDefault();
  782.                         var coord = pointerEventToXY(event);
  783.                         timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
  784.                     }
  785.                 });
  786.  
  787.                 timeboxparent.on('touchend touchcancel', function (event) {
  788.                     start = false;
  789.                     startTop = 0;
  790.                 });
  791.             }
  792.             timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  793.         });
  794.     };
  795.  
  796.     $.fn.datetimepicker = function (opt) {
  797.         var KEY0 = 48,
  798.             KEY9 = 57,
  799.             _KEY0 = 96,
  800.             _KEY9 = 105,
  801.             CTRLKEY = 17,
  802.             DEL = 46,
  803.             ENTER = 13,
  804.             ESC = 27,
  805.             BACKSPACE = 8,
  806.             ARROWLEFT = 37,
  807.             ARROWUP = 38,
  808.             ARROWRIGHT = 39,
  809.             ARROWDOWN = 40,
  810.             TAB = 9,
  811.             F5 = 116,
  812.             AKEY = 65,
  813.             CKEY = 67,
  814.             VKEY = 86,
  815.             ZKEY = 90,
  816.             YKEY = 89,
  817.             ctrlDown    =   false,
  818.             options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
  819.  
  820.             lazyInitTimer = 0,
  821.             createDateTimePicker,
  822.             destroyDateTimePicker,
  823.  
  824.             lazyInit = function (input) {
  825.                 input
  826.                     .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
  827.                         if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
  828.                             return;
  829.                         }
  830.                         clearTimeout(lazyInitTimer);
  831.                         lazyInitTimer = setTimeout(function () {
  832.  
  833.                             if (!input.data('xdsoft_datetimepicker')) {
  834.                                 createDateTimePicker(input);
  835.                             }
  836.                             input
  837.                                 .off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
  838.                                 .trigger('open.xdsoft');
  839.                         }, 100);
  840.                     });
  841.             };
  842.  
  843.         createDateTimePicker = function (input) {
  844.             var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
  845.                 xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
  846.                 datepicker = $('<div class="xdsoft_datepicker active"></div>'),
  847.                 mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
  848.                     '<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
  849.                     '<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
  850.                     '<button type="button" class="xdsoft_next"></button></div>'),
  851.                 calendar = $('<div class="xdsoft_calendar"></div>'),
  852.                 timepicker = $('<div class="xdsoft_timepicker active"><button type="button" class="xdsoft_prev"></button><div class="xdsoft_time_box"></div><button type="button" class="xdsoft_next"></button></div>'),
  853.                 timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
  854.                 timebox = $('<div class="xdsoft_time_variant"></div>'),
  855.                 applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
  856.                 /*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
  857.                 scroller = $('<div class="xdsoft_scroller"></div>'),*/
  858.                 monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
  859.                 yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
  860.                 triggerAfterOpen = false,
  861.                 XDSoft_datetime,
  862.                 //scroll_element,
  863.                 xchangeTimer,
  864.                 timerclick,
  865.                 current_time_index,
  866.                 setPos,
  867.                 timer = 0,
  868.                 timer1 = 0,
  869.                 _xdsoft_datetime;
  870.  
  871.             if (options.id) {
  872.                 datetimepicker.attr('id', options.id);
  873.             }
  874.             if (options.style) {
  875.                 datetimepicker.attr('style', options.style);
  876.             }
  877.             if (options.weeks) {
  878.                 datetimepicker.addClass('xdsoft_showweeks');
  879.             }
  880.             if (options.rtl) {
  881.                 datetimepicker.addClass('xdsoft_rtl');
  882.             }
  883.  
  884.             datetimepicker.addClass('xdsoft_' + options.theme);
  885.             datetimepicker.addClass(options.className);
  886.  
  887.             mounth_picker
  888.                 .find('.xdsoft_month span')
  889.                     .after(monthselect);
  890.             mounth_picker
  891.                 .find('.xdsoft_year span')
  892.                     .after(yearselect);
  893.  
  894.             mounth_picker
  895.                 .find('.xdsoft_month,.xdsoft_year')
  896.                     .on('mousedown.xdsoft', function (event) {
  897.                     var select = $(this).find('.xdsoft_select').eq(0),
  898.                         val = 0,
  899.                         top = 0,
  900.                         visible = select.is(':visible'),
  901.                         items,
  902.                         i;
  903.  
  904.                     mounth_picker
  905.                         .find('.xdsoft_select')
  906.                             .hide();
  907.                     if (_xdsoft_datetime.currentTime) {
  908.                         val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
  909.                     }
  910.  
  911.                     select[visible ? 'hide' : 'show']();
  912.                     for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
  913.                         if (items.eq(i).data('value') === val) {
  914.                             break;
  915.                         } else {
  916.                             top += items[0].offsetHeight;
  917.                         }
  918.                     }
  919.  
  920.                     select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
  921.                     event.stopPropagation();
  922.                     return false;
  923.                 });
  924.  
  925.             mounth_picker
  926.                 .find('.xdsoft_select')
  927.                     .xdsoftScroller()
  928.                 .on('mousedown.xdsoft', function (event) {
  929.                     event.stopPropagation();
  930.                     event.preventDefault();
  931.                 })
  932.                 .on('mousedown.xdsoft', '.xdsoft_option', function (event) {
  933.  
  934.                     if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  935.                         _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  936.                     }
  937.  
  938.                     var year = _xdsoft_datetime.currentTime.getFullYear();
  939.                     if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
  940.                         _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
  941.                     }
  942.  
  943.                     $(this).parent().parent().hide();
  944.  
  945.                     datetimepicker.trigger('xchange.xdsoft');
  946.                     if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  947.                         options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  948.                     }
  949.  
  950.                     if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  951.                         options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  952.                     }
  953.                 });
  954.  
  955.             datetimepicker.setOptions = function (_options) {
  956.                 var highlightedDates = {},
  957.                     getCaretPos = function (input) {
  958.                         try {
  959.                             if (document.selection && document.selection.createRange) {
  960.                                 var range = document.selection.createRange();
  961.                                 return range.getBookmark().charCodeAt(2) - 2;
  962.                             }
  963.                             if (input.setSelectionRange) {
  964.                                 return input.selectionStart;
  965.                             }
  966.                         } catch (e) {
  967.                             return 0;
  968.                         }
  969.                     },
  970.                     setCaretPos = function (node, pos) {
  971.                         node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
  972.                         if (!node) {
  973.                             return false;
  974.                         }
  975.                         if (node.createTextRange) {
  976.                             var textRange = node.createTextRange();
  977.                             textRange.collapse(true);
  978.                             textRange.moveEnd('character', pos);
  979.                             textRange.moveStart('character', pos);
  980.                             textRange.select();
  981.                             return true;
  982.                         }
  983.                         if (node.setSelectionRange) {
  984.                             node.setSelectionRange(pos, pos);
  985.                             return true;
  986.                         }
  987.                         return false;
  988.                     },
  989.                     isValidValue = function (mask, value) {
  990.                         var reg = mask
  991.                             .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
  992.                             .replace(/_/g, '{digit+}')
  993.                             .replace(/([0-9]{1})/g, '{digit$1}')
  994.                             .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
  995.                             .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
  996.                         return (new RegExp(reg)).test(value);
  997.                     };
  998.                 options = $.extend(true, {}, options, _options);
  999.  
  1000.                 if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
  1001.                     options.allowTimes = $.extend(true, [], _options.allowTimes);
  1002.                 }
  1003.  
  1004.                 if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
  1005.                     options.weekends = $.extend(true, [], _options.weekends);
  1006.                 }
  1007.  
  1008.                 if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
  1009.                     $.each(_options.highlightedDates, function (index, value) {
  1010.                         var splitData = $.map(value.split(','), $.trim),
  1011.                             exDesc,
  1012.                             hDate = new HighlightedDate(Date.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
  1013.                             keyDate = hDate.date.dateFormat(options.formatDate);
  1014.                         if (highlightedDates[keyDate] !== undefined) {
  1015.                             exDesc = highlightedDates[keyDate].desc;
  1016.                             if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  1017.                                 highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  1018.                             }
  1019.                         } else {
  1020.                             highlightedDates[keyDate] = hDate;
  1021.                         }
  1022.                     });
  1023.  
  1024.                     options.highlightedDates = $.extend(true, [], highlightedDates);
  1025.                 }
  1026.  
  1027.                 if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
  1028.                     highlightedDates = $.extend(true, [], options.highlightedDates);
  1029.                     $.each(_options.highlightedPeriods, function (index, value) {
  1030.                         var dateTest, // start date
  1031.                             dateEnd,
  1032.                             desc,
  1033.                             hDate,
  1034.                             keyDate,
  1035.                             exDesc,
  1036.                             style;
  1037.                         if ($.isArray(value)) {
  1038.                             dateTest = value[0];
  1039.                             dateEnd = value[1];
  1040.                             desc = value[2];
  1041.                             style = value[3];
  1042.                         }
  1043.                         else {
  1044.                             var splitData = $.map(value.split(','), $.trim);
  1045.                             dateTest = Date.parseDate(splitData[0], options.formatDate);
  1046.                             dateEnd = Date.parseDate(splitData[1], options.formatDate);
  1047.                             desc = splitData[2];
  1048.                             style = splitData[3];
  1049.                         }
  1050.  
  1051.                         while (dateTest <= dateEnd) {
  1052.                             hDate = new HighlightedDate(dateTest, desc, style);
  1053.                             keyDate = dateTest.dateFormat(options.formatDate);
  1054.                             dateTest.setDate(dateTest.getDate() + 1);
  1055.                             if (highlightedDates[keyDate] !== undefined) {
  1056.                                 exDesc = highlightedDates[keyDate].desc;
  1057.                                 if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  1058.                                     highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  1059.                                 }
  1060.                             } else {
  1061.                                 highlightedDates[keyDate] = hDate;
  1062.                             }
  1063.                         }
  1064.                     });
  1065.  
  1066.                     options.highlightedDates = $.extend(true, [], highlightedDates);
  1067.                 }
  1068.  
  1069.                 if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
  1070.                     options.disabledDates = $.extend(true, [], _options.disabledDates);
  1071.                 }
  1072.  
  1073.                 if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
  1074.                     options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
  1075.                 }
  1076.  
  1077.                 if ((options.open || options.opened) && (!options.inline)) {
  1078.                     input.trigger('open.xdsoft');
  1079.                 }
  1080.  
  1081.                 if (options.inline) {
  1082.                     triggerAfterOpen = true;
  1083.                     datetimepicker.addClass('xdsoft_inline');
  1084.                     input.after(datetimepicker).hide();
  1085.                 }
  1086.  
  1087.                 if (options.inverseButton) {
  1088.                     options.next = 'xdsoft_prev';
  1089.                     options.prev = 'xdsoft_next';
  1090.                 }
  1091.  
  1092.                 if (options.datepicker) {
  1093.                     datepicker.addClass('active');
  1094.                 } else {
  1095.                     datepicker.removeClass('active');
  1096.                 }
  1097.  
  1098.                 if (options.timepicker) {
  1099.                     timepicker.addClass('active');
  1100.                 } else {
  1101.                     timepicker.removeClass('active');
  1102.                 }
  1103.  
  1104.                 if (options.value) {
  1105.                     _xdsoft_datetime.setCurrentTime(options.value);
  1106.                     if (input && input.val) {
  1107.                         input.val(_xdsoft_datetime.str);
  1108.                     }
  1109.                 }
  1110.  
  1111.                 if (isNaN(options.dayOfWeekStart)) {
  1112.                     options.dayOfWeekStart = 0;
  1113.                 } else {
  1114.                     options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
  1115.                 }
  1116.  
  1117.                 if (!options.timepickerScrollbar) {
  1118.                     timeboxparent.xdsoftScroller('hide');
  1119.                 }
  1120.  
  1121.                 if (options.minDate && /^[\+\-](.*)$/.test(options.minDate)) {
  1122.                     options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
  1123.                 }
  1124.  
  1125.                 if (options.maxDate &&  /^[\+\-](.*)$/.test(options.maxDate)) {
  1126.                     options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
  1127.                 }
  1128.  
  1129.                 applyButton.toggle(options.showApplyButton);
  1130.  
  1131.                 mounth_picker
  1132.                     .find('.xdsoft_today_button')
  1133.                         .css('visibility', !options.todayButton ? 'hidden' : 'visible');
  1134.  
  1135.                 mounth_picker
  1136.                     .find('.' + options.prev)
  1137.                         .css('visibility', !options.prevButton ? 'hidden' : 'visible');
  1138.  
  1139.                 mounth_picker
  1140.                     .find('.' + options.next)
  1141.                         .css('visibility', !options.nextButton ? 'hidden' : 'visible');
  1142.  
  1143.                 if (options.mask) {
  1144.                     input.off('keydown.xdsoft');
  1145.  
  1146.                     if (options.mask === true) {
  1147.                         options.mask = options.format
  1148.                             .replace(/Y/g, '9999')
  1149.                             .replace(/F/g, '9999')
  1150.                             .replace(/m/g, '19')
  1151.                             .replace(/d/g, '39')
  1152.                             .replace(/H/g, '29')
  1153.                             .replace(/i/g, '59')
  1154.                             .replace(/s/g, '59');
  1155.                     }
  1156.  
  1157.                     if ($.type(options.mask) === 'string') {
  1158.                         if (!isValidValue(options.mask, input.val())) {
  1159.                             input.val(options.mask.replace(/[0-9]/g, '_'));
  1160.                         }
  1161.  
  1162.                         input.on('keydown.xdsoft', function (event) {
  1163.                             var val = this.value,
  1164.                                 key = event.which,
  1165.                                 pos,
  1166.                                 digit;
  1167.  
  1168.                             if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
  1169.                                 pos = getCaretPos(this);
  1170.                                 digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
  1171.  
  1172.                                 if ((key === BACKSPACE || key === DEL) && pos) {
  1173.                                     pos -= 1;
  1174.                                     digit = '_';
  1175.                                 }
  1176.  
  1177.                                 while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  1178.                                     pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
  1179.                                 }
  1180.  
  1181.                                 val = val.substr(0, pos) + digit + val.substr(pos + 1);
  1182.                                 if ($.trim(val) === '') {
  1183.                                     val = options.mask.replace(/[0-9]/g, '_');
  1184.                                 } else {
  1185.                                     if (pos === options.mask.length) {
  1186.                                         event.preventDefault();
  1187.                                         return false;
  1188.                                     }
  1189.                                 }
  1190.  
  1191.                                 pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
  1192.                                 while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  1193.                                     pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
  1194.                                 }
  1195.  
  1196.                                 if (isValidValue(options.mask, val)) {
  1197.                                     this.value = val;
  1198.                                     setCaretPos(this, pos);
  1199.                                 } else if ($.trim(val) === '') {
  1200.                                     this.value = options.mask.replace(/[0-9]/g, '_');
  1201.                                 } else {
  1202.                                     input.trigger('error_input.xdsoft');
  1203.                                 }
  1204.                             } else {
  1205.                                 if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
  1206.                                     return true;
  1207.                                 }
  1208.                             }
  1209.  
  1210.                             event.preventDefault();
  1211.                             return false;
  1212.                         });
  1213.                     }
  1214.                 }
  1215.                 if (options.validateOnBlur) {
  1216.                     input
  1217.                         .off('blur.xdsoft')
  1218.                         .on('blur.xdsoft', function () {
  1219.                             if (options.allowBlank && !$.trim($(this).val()).length) {
  1220.                                 $(this).val(null);
  1221.                                 datetimepicker.data('xdsoft_datetime').empty();
  1222.                             } else if (!Date.parseDate($(this).val(), options.format)) {
  1223.                                 var splittedHours   = +([$(this).val()[0], $(this).val()[1]].join('')),
  1224.                                     splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
  1225.  
  1226.                                 // parse the numbers as 0312 => 03:12
  1227.                                 if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
  1228.                                     $(this).val([splittedHours, splittedMinutes].map(function (item) {
  1229.                                         return item > 9 ? item : '0' + item;
  1230.                                     }).join(':'));
  1231.                                 } else {
  1232.                                     $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
  1233.                                 }
  1234.  
  1235.                                 datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1236.                             } else {
  1237.                                 datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1238.                             }
  1239.  
  1240.                             datetimepicker.trigger('changedatetime.xdsoft');
  1241.                         });
  1242.                 }
  1243.                 options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
  1244.  
  1245.                 datetimepicker
  1246.                     .trigger('xchange.xdsoft')
  1247.                     .trigger('afterOpen.xdsoft');
  1248.             };
  1249.  
  1250.             datetimepicker
  1251.                 .data('options', options)
  1252.                 .on('mousedown.xdsoft', function (event) {
  1253.                     event.stopPropagation();
  1254.                     event.preventDefault();
  1255.                     yearselect.hide();
  1256.                     monthselect.hide();
  1257.                     return false;
  1258.                 });
  1259.  
  1260.             //scroll_element = timepicker.find('.xdsoft_time_box');
  1261.             timeboxparent.append(timebox);
  1262.             timeboxparent.xdsoftScroller();
  1263.  
  1264.             datetimepicker.on('afterOpen.xdsoft', function () {
  1265.                 timeboxparent.xdsoftScroller();
  1266.             });
  1267.  
  1268.             datetimepicker
  1269.                 .append(datepicker)
  1270.                 .append(timepicker);
  1271.  
  1272.             if (options.withoutCopyright !== true) {
  1273.                 datetimepicker
  1274.                     .append(xdsoft_copyright);
  1275.             }
  1276.  
  1277.             datepicker
  1278.                 .append(mounth_picker)
  1279.                 .append(calendar)
  1280.                 .append(applyButton);
  1281.  
  1282.             $(options.parentID)
  1283.                 .append(datetimepicker);
  1284.  
  1285.             XDSoft_datetime = function () {
  1286.                 var _this = this;
  1287.                 _this.now = function (norecursion) {
  1288.                     var d = new Date(),
  1289.                         date,
  1290.                         time;
  1291.  
  1292.                     if (!norecursion && options.defaultDate) {
  1293.                         date = _this.strToDateTime(options.defaultDate);
  1294.                         d.setFullYear(date.getFullYear());
  1295.                         d.setMonth(date.getMonth());
  1296.                         d.setDate(date.getDate());
  1297.                     }
  1298.  
  1299.                     if (options.yearOffset) {
  1300.                         d.setFullYear(d.getFullYear() + options.yearOffset);
  1301.                     }
  1302.  
  1303.                     if (!norecursion && options.defaultTime) {
  1304.                         time = _this.strtotime(options.defaultTime);
  1305.                         d.setHours(time.getHours());
  1306.                         d.setMinutes(time.getMinutes());
  1307.                     }
  1308.                     return d;
  1309.                 };
  1310.  
  1311.                 _this.isValidDate = function (d) {
  1312.                     if (Object.prototype.toString.call(d) !== "[object Date]") {
  1313.                         return false;
  1314.                     }
  1315.                     return !isNaN(d.getTime());
  1316.                 };
  1317.  
  1318.                 _this.setCurrentTime = function (dTime) {
  1319.                     _this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
  1320.                     datetimepicker.trigger('xchange.xdsoft');
  1321.                 };
  1322.  
  1323.                 _this.empty = function () {
  1324.                     _this.currentTime = null;
  1325.                 };
  1326.  
  1327.                 _this.getCurrentTime = function (dTime) {
  1328.                     return _this.currentTime;
  1329.                 };
  1330.  
  1331.                 _this.nextMonth = function () {
  1332.  
  1333.                     if (_this.currentTime === undefined || _this.currentTime === null) {
  1334.                         _this.currentTime = _this.now();
  1335.                     }
  1336.  
  1337.                     var month = _this.currentTime.getMonth() + 1,
  1338.                         year;
  1339.                     if (month === 12) {
  1340.                         _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
  1341.                         month = 0;
  1342.                     }
  1343.  
  1344.                     year = _this.currentTime.getFullYear();
  1345.  
  1346.                     _this.currentTime.setDate(
  1347.                         Math.min(
  1348.                             new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1349.                             _this.currentTime.getDate()
  1350.                         )
  1351.                     );
  1352.                     _this.currentTime.setMonth(month);
  1353.  
  1354.                     if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1355.                         options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1356.                     }
  1357.  
  1358.                     if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1359.                         options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1360.                     }
  1361.  
  1362.                     datetimepicker.trigger('xchange.xdsoft');
  1363.                     return month;
  1364.                 };
  1365.  
  1366.                 _this.prevMonth = function () {
  1367.  
  1368.                     if (_this.currentTime === undefined || _this.currentTime === null) {
  1369.                         _this.currentTime = _this.now();
  1370.                     }
  1371.  
  1372.                     var month = _this.currentTime.getMonth() - 1;
  1373.                     if (month === -1) {
  1374.                         _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
  1375.                         month = 11;
  1376.                     }
  1377.                     _this.currentTime.setDate(
  1378.                         Math.min(
  1379.                             new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1380.                             _this.currentTime.getDate()
  1381.                         )
  1382.                     );
  1383.                     _this.currentTime.setMonth(month);
  1384.                     if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1385.                         options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1386.                     }
  1387.                     datetimepicker.trigger('xchange.xdsoft');
  1388.                     return month;
  1389.                 };
  1390.  
  1391.                 _this.getWeekOfYear = function (datetime) {
  1392.                     var onejan = new Date(datetime.getFullYear(), 0, 1);
  1393.                     return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
  1394.                 };
  1395.  
  1396.                 _this.strToDateTime = function (sDateTime) {
  1397.                     var tmpDate = [], timeOffset, currentTime;
  1398.  
  1399.                     if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
  1400.                         return sDateTime;
  1401.                     }
  1402.  
  1403.                     tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
  1404.                     if (tmpDate) {
  1405.                         tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
  1406.                     }
  1407.                     if (tmpDate  && tmpDate[2]) {
  1408.                         timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
  1409.                         currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
  1410.                     } else {
  1411.                         currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
  1412.                     }
  1413.  
  1414.                     if (!_this.isValidDate(currentTime)) {
  1415.                         currentTime = _this.now();
  1416.                     }
  1417.  
  1418.                     return currentTime;
  1419.                 };
  1420.  
  1421.                 _this.strToDate = function (sDate) {
  1422.                     if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
  1423.                         return sDate;
  1424.                     }
  1425.  
  1426.                     var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
  1427.                     if (!_this.isValidDate(currentTime)) {
  1428.                         currentTime = _this.now(true);
  1429.                     }
  1430.                     return currentTime;
  1431.                 };
  1432.  
  1433.                 _this.strtotime = function (sTime) {
  1434.                     if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
  1435.                         return sTime;
  1436.                     }
  1437.                     var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
  1438.                     if (!_this.isValidDate(currentTime)) {
  1439.                         currentTime = _this.now(true);
  1440.                     }
  1441.                     return currentTime;
  1442.                 };
  1443.  
  1444.                 _this.str = function () {
  1445.                     return _this.currentTime.dateFormat(options.format);
  1446.                 };
  1447.                 _this.currentTime = this.now();
  1448.             };
  1449.  
  1450.             _xdsoft_datetime = new XDSoft_datetime();
  1451.  
  1452.             applyButton.on('click', function (e) {//pathbrite
  1453.                 e.preventDefault();
  1454.                 datetimepicker.data('changed', true);
  1455.                 _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1456.                 input.val(_xdsoft_datetime.str());
  1457.                 datetimepicker.trigger('close.xdsoft');
  1458.             });
  1459.             mounth_picker
  1460.                 .find('.xdsoft_today_button')
  1461.                 .on('mousedown.xdsoft', function () {
  1462.                     datetimepicker.data('changed', true);
  1463.                     _xdsoft_datetime.setCurrentTime(0);
  1464.                     datetimepicker.trigger('afterOpen.xdsoft');
  1465.                 }).on('dblclick.xdsoft', function () {
  1466.                     var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
  1467.                     currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
  1468.                     minDate = _xdsoft_datetime.strToDate(options.minDate);
  1469.                     minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1470.                     if (currentDate < minDate) {
  1471.                         return;
  1472.                     }
  1473.                     maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1474.                     maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
  1475.                     if (currentDate > maxDate) {
  1476.                         return;
  1477.                     }
  1478.                     input.val(_xdsoft_datetime.str());
  1479.                     input.trigger('change');
  1480.                     datetimepicker.trigger('close.xdsoft');
  1481.                 });
  1482.             mounth_picker
  1483.                 .find('.xdsoft_prev,.xdsoft_next')
  1484.                 .on('mousedown.xdsoft', function () {
  1485.                     var $this = $(this),
  1486.                         timer = 0,
  1487.                         stop = false;
  1488.  
  1489.                     (function arguments_callee1(v) {
  1490.                         if ($this.hasClass(options.next)) {
  1491.                             _xdsoft_datetime.nextMonth();
  1492.                         } else if ($this.hasClass(options.prev)) {
  1493.                             _xdsoft_datetime.prevMonth();
  1494.                         }
  1495.                         if (options.monthChangeSpinner) {
  1496.                             if (!stop) {
  1497.                                 timer = setTimeout(arguments_callee1, v || 100);
  1498.                             }
  1499.                         }
  1500.                     }(500));
  1501.  
  1502.                     $([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
  1503.                         clearTimeout(timer);
  1504.                         stop = true;
  1505.                         $([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
  1506.                     });
  1507.                 });
  1508.  
  1509.             timepicker
  1510.                 .find('.xdsoft_prev,.xdsoft_next')
  1511.                 .on('mousedown.xdsoft', function () {
  1512.                     var $this = $(this),
  1513.                         timer = 0,
  1514.                         stop = false,
  1515.                         period = 110;
  1516.                     (function arguments_callee4(v) {
  1517.                         var pheight = timeboxparent[0].clientHeight,
  1518.                             height = timebox[0].offsetHeight,
  1519.                             top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  1520.                         if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
  1521.                             timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
  1522.                         } else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
  1523.                             timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
  1524.                         }
  1525.                         timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
  1526.                         period = (period > 10) ? 10 : period - 10;
  1527.                         if (!stop) {
  1528.                             timer = setTimeout(arguments_callee4, v || period);
  1529.                         }
  1530.                     }(500));
  1531.                     $([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
  1532.                         clearTimeout(timer);
  1533.                         stop = true;
  1534.                         $([document.body, window])
  1535.                             .off('mouseup.xdsoft', arguments_callee5);
  1536.                     });
  1537.                 });
  1538.  
  1539.             xchangeTimer = 0;
  1540.             // base handler - generating a calendar and timepicker
  1541.             datetimepicker
  1542.                 .on('xchange.xdsoft', function (event) {
  1543.                     clearTimeout(xchangeTimer);
  1544.                     xchangeTimer = setTimeout(function () {
  1545.  
  1546.                         if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1547.                             _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1548.                         }
  1549.  
  1550.                         var table = '',
  1551.                             start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
  1552.                             i = 0,
  1553.                             j,
  1554.                             today = _xdsoft_datetime.now(),
  1555.                             maxDate = false,
  1556.                             minDate = false,
  1557.                             hDate,
  1558.                             day,
  1559.                             d,
  1560.                             y,
  1561.                             m,
  1562.                             w,
  1563.                             classes = [],
  1564.                             customDateSettings,
  1565.                             newRow = true,
  1566.                             time = '',
  1567.                             h = '',
  1568.                             line_time,
  1569.                             description;
  1570.  
  1571.                         while (start.getDay() !== options.dayOfWeekStart) {
  1572.                             start.setDate(start.getDate() - 1);
  1573.                         }
  1574.  
  1575.                         table += '<table><thead><tr>';
  1576.  
  1577.                         if (options.weeks) {
  1578.                             table += '<th></th>';
  1579.                         }
  1580.  
  1581.                         for (j = 0; j < 7; j += 1) {
  1582.                             table += '<th>' + options.i18n[globalLocale].dayOfWeekShort[(j + options.dayOfWeekStart) % 7] + '</th>';
  1583.                         }
  1584.  
  1585.                         table += '</tr></thead>';
  1586.                         table += '<tbody>';
  1587.  
  1588.                         if (options.maxDate !== false) {
  1589.                             maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1590.                             maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
  1591.                         }
  1592.  
  1593.                         if (options.minDate !== false) {
  1594.                             minDate = _xdsoft_datetime.strToDate(options.minDate);
  1595.                             minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1596.                         }
  1597.  
  1598.                         while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
  1599.                             classes = [];
  1600.                             i += 1;
  1601.  
  1602.                             day = start.getDay();
  1603.                             d = start.getDate();
  1604.                             y = start.getFullYear();
  1605.                             m = start.getMonth();
  1606.                             w = _xdsoft_datetime.getWeekOfYear(start);
  1607.                             description = '';
  1608.  
  1609.                             classes.push('xdsoft_date');
  1610.  
  1611.                             if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
  1612.                                 customDateSettings = options.beforeShowDay.call(datetimepicker, start);
  1613.                             } else {
  1614.                                 customDateSettings = null;
  1615.                             }
  1616.  
  1617.                             if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
  1618.                                 classes.push('xdsoft_disabled');
  1619.                             } else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
  1620.                                 classes.push('xdsoft_disabled');
  1621.                             } else if (options.disabledWeekDays.indexOf(day) !== -1) {
  1622.                                 classes.push('xdsoft_disabled');
  1623.                             }
  1624.  
  1625.                             if (customDateSettings && customDateSettings[1] !== "") {
  1626.                                 classes.push(customDateSettings[1]);
  1627.                             }
  1628.  
  1629.                             if (_xdsoft_datetime.currentTime.getMonth() !== m) {
  1630.                                 classes.push('xdsoft_other_month');
  1631.                             }
  1632.  
  1633.                             if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
  1634.                                 classes.push('xdsoft_current');
  1635.                             }
  1636.  
  1637.                             if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
  1638.                                 classes.push('xdsoft_today');
  1639.                             }
  1640.  
  1641.                             if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) !== -1) {
  1642.                                 classes.push('xdsoft_weekend');
  1643.                             }
  1644.  
  1645.                             if (options.highlightedDates[start.dateFormat(options.formatDate)] !== undefined) {
  1646.                                 hDate = options.highlightedDates[start.dateFormat(options.formatDate)];
  1647.                                 classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
  1648.                                 description = hDate.desc === undefined ? '' : hDate.desc;
  1649.                             }
  1650.  
  1651.                             if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
  1652.                                 classes.push(options.beforeShowDay(start));
  1653.                             }
  1654.  
  1655.                             if (newRow) {
  1656.                                 table += '<tr>';
  1657.                                 newRow = false;
  1658.                                 if (options.weeks) {
  1659.                                     table += '<th>' + w + '</th>';
  1660.                                 }
  1661.                             }
  1662.  
  1663.                             table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
  1664.                                         '<div>' + d + '</div>' +
  1665.                                     '</td>';
  1666.  
  1667.                             if (start.getDay() === options.dayOfWeekStartPrev) {
  1668.                                 table += '</tr>';
  1669.                                 newRow = true;
  1670.                             }
  1671.  
  1672.                             start.setDate(d + 1);
  1673.                         }
  1674.                         table += '</tbody></table>';
  1675.  
  1676.                         calendar.html(table);
  1677.  
  1678.                         mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[globalLocale].months[_xdsoft_datetime.currentTime.getMonth()]);
  1679.                         mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
  1680.  
  1681.                         // generate timebox
  1682.                         time = '';
  1683.                         h = '';
  1684.                         m = '';
  1685.  
  1686.                         line_time = function line_time(h, m) {
  1687.                             var now = _xdsoft_datetime.now(), optionDateTime, current_time,
  1688.                                 isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
  1689.                             now.setHours(h);
  1690.                             h = parseInt(now.getHours(), 10);
  1691.                             now.setMinutes(m);
  1692.                             m = parseInt(now.getMinutes(), 10);
  1693.                             optionDateTime = new Date(_xdsoft_datetime.currentTime);
  1694.                             optionDateTime.setHours(h);
  1695.                             optionDateTime.setMinutes(m);
  1696.                             classes = [];
  1697.                             if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || (options.maxTime !== false && _xdsoft_datetime.strtotime(options.maxTime).getTime() < now.getTime()) || (options.minTime !== false && _xdsoft_datetime.strtotime(options.minTime).getTime() > now.getTime())) {
  1698.                                 classes.push('xdsoft_disabled');
  1699.                             }
  1700.                             if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
  1701.                                 classes.push('xdsoft_disabled');
  1702.                             }
  1703.  
  1704.                             current_time = new Date(_xdsoft_datetime.currentTime);
  1705.                             current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
  1706.  
  1707.                             if (!isALlowTimesInit) {
  1708.                                 current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
  1709.                             }
  1710.  
  1711.                             if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && ((!isALlowTimesInit && options.step > 59) || current_time.getMinutes() === parseInt(m, 10))) {
  1712.                                 if (options.defaultSelect || datetimepicker.data('changed')) {
  1713.                                     classes.push('xdsoft_current');
  1714.                                 } else if (options.initTime) {
  1715.                                     classes.push('xdsoft_init_time');
  1716.                                 }
  1717.                             }
  1718.                             if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
  1719.                                 classes.push('xdsoft_today');
  1720.                             }
  1721.                             time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + now.dateFormat(options.formatTime) + '</div>';
  1722.                         };
  1723.  
  1724.                         if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
  1725.                             for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
  1726.                                 for (j = 0; j < 60; j += options.step) {
  1727.                                     h = (i < 10 ? '0' : '') + i;
  1728.                                     m = (j < 10 ? '0' : '') + j;
  1729.                                     line_time(h, m);
  1730.                                 }
  1731.                             }
  1732.                         } else {
  1733.                             for (i = 0; i < options.allowTimes.length; i += 1) {
  1734.                                 h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
  1735.                                 m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
  1736.                                 line_time(h, m);
  1737.                             }
  1738.                         }
  1739.  
  1740.                         timebox.html(time);
  1741.  
  1742.                         opt = '';
  1743.                         i = 0;
  1744.  
  1745.                         for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
  1746.                             opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + i + '</div>';
  1747.                         }
  1748.                         yearselect.children().eq(0)
  1749.                                                 .html(opt);
  1750.  
  1751.                         for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
  1752.                             opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[globalLocale].months[i] + '</div>';
  1753.                         }
  1754.                         monthselect.children().eq(0).html(opt);
  1755.                         $(datetimepicker)
  1756.                             .trigger('generate.xdsoft');
  1757.                     }, 10);
  1758.                     event.stopPropagation();
  1759.                 })
  1760.                 .on('afterOpen.xdsoft', function () {
  1761.                     if (options.timepicker) {
  1762.                         var classType, pheight, height, top;
  1763.                         if (timebox.find('.xdsoft_current').length) {
  1764.                             classType = '.xdsoft_current';
  1765.                         } else if (timebox.find('.xdsoft_init_time').length) {
  1766.                             classType = '.xdsoft_init_time';
  1767.                         }
  1768.                         if (classType) {
  1769.                             pheight = timeboxparent[0].clientHeight;
  1770.                             height = timebox[0].offsetHeight;
  1771.                             top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
  1772.                             if ((height - pheight) < top) {
  1773.                                 top = height - pheight;
  1774.                             }
  1775.                             timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
  1776.                         } else {
  1777.                             timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
  1778.                         }
  1779.                     }
  1780.                 });
  1781.  
  1782.             timerclick = 0;
  1783.             calendar
  1784.                 .on('click.xdsoft', 'td', function (xdevent) {
  1785.                     xdevent.stopPropagation();  // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
  1786.                     timerclick += 1;
  1787.                     var $this = $(this),
  1788.                         currentTime = _xdsoft_datetime.currentTime;
  1789.  
  1790.                     if (currentTime === undefined || currentTime === null) {
  1791.                         _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1792.                         currentTime = _xdsoft_datetime.currentTime;
  1793.                     }
  1794.  
  1795.                     if ($this.hasClass('xdsoft_disabled')) {
  1796.                         return false;
  1797.                     }
  1798.  
  1799.                     currentTime.setDate(1);
  1800.                     currentTime.setFullYear($this.data('year'));
  1801.                     currentTime.setMonth($this.data('month'));
  1802.                     currentTime.setDate($this.data('date'));
  1803.  
  1804.                     datetimepicker.trigger('select.xdsoft', [currentTime]);
  1805.  
  1806.                     input.val(_xdsoft_datetime.str());
  1807.  
  1808.                     if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
  1809.                         options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1810.                     }
  1811.  
  1812.                     datetimepicker.data('changed', true);
  1813.                     datetimepicker.trigger('xchange.xdsoft');
  1814.                     datetimepicker.trigger('changedatetime.xdsoft');
  1815.                     if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
  1816.                         datetimepicker.trigger('close.xdsoft');
  1817.                     }
  1818.                     setTimeout(function () {
  1819.                         timerclick = 0;
  1820.                     }, 200);
  1821.                 });
  1822.  
  1823.             timebox
  1824.                 .on('click.xdsoft', 'div', function (xdevent) {
  1825.                     xdevent.stopPropagation();
  1826.                     var $this = $(this),
  1827.                         currentTime = _xdsoft_datetime.currentTime;
  1828.  
  1829.                     if (currentTime === undefined || currentTime === null) {
  1830.                         _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1831.                         currentTime = _xdsoft_datetime.currentTime;
  1832.                     }
  1833.  
  1834.                     if ($this.hasClass('xdsoft_disabled')) {
  1835.                         return false;
  1836.                     }
  1837.                     currentTime.setHours($this.data('hour'));
  1838.                     currentTime.setMinutes($this.data('minute'));
  1839.                     datetimepicker.trigger('select.xdsoft', [currentTime]);
  1840.  
  1841.                     datetimepicker.data('input').val(_xdsoft_datetime.str());
  1842.  
  1843.                     if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
  1844.                         options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1845.                     }
  1846.                     datetimepicker.data('changed', true);
  1847.                     datetimepicker.trigger('xchange.xdsoft');
  1848.                     datetimepicker.trigger('changedatetime.xdsoft');
  1849.                     if (options.inline !== true && options.closeOnTimeSelect === true) {
  1850.                         datetimepicker.trigger('close.xdsoft');
  1851.                     }
  1852.                 });
  1853.  
  1854.  
  1855.             datepicker
  1856.                 .on('mousewheel.xdsoft', function (event) {
  1857.                     if (!options.scrollMonth) {
  1858.                         return true;
  1859.                     }
  1860.                     if (event.deltaY < 0) {
  1861.                         _xdsoft_datetime.nextMonth();
  1862.                     } else {
  1863.                         _xdsoft_datetime.prevMonth();
  1864.                     }
  1865.                     return false;
  1866.                 });
  1867.  
  1868.             input
  1869.                 .on('mousewheel.xdsoft', function (event) {
  1870.                     if (!options.scrollInput) {
  1871.                         return true;
  1872.                     }
  1873.                     if (!options.datepicker && options.timepicker) {
  1874.                         current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
  1875.                         if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
  1876.                             current_time_index += event.deltaY;
  1877.                         }
  1878.                         if (timebox.children().eq(current_time_index).length) {
  1879.                             timebox.children().eq(current_time_index).trigger('mousedown');
  1880.                         }
  1881.                         return false;
  1882.                     }
  1883.                     if (options.datepicker && !options.timepicker) {
  1884.                         datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
  1885.                         if (input.val) {
  1886.                             input.val(_xdsoft_datetime.str());
  1887.                         }
  1888.                         datetimepicker.trigger('changedatetime.xdsoft');
  1889.                         return false;
  1890.                     }
  1891.                 });
  1892.  
  1893.             datetimepicker
  1894.                 .on('changedatetime.xdsoft', function (event) {
  1895.                     if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
  1896.                         var $input = datetimepicker.data('input');
  1897.                         options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
  1898.                         delete options.value;
  1899.                         $input.trigger('change');
  1900.                     }
  1901.                 })
  1902.                 .on('generate.xdsoft', function () {
  1903.                     if (options.onGenerate && $.isFunction(options.onGenerate)) {
  1904.                         options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1905.                     }
  1906.                     if (triggerAfterOpen) {
  1907.                         datetimepicker.trigger('afterOpen.xdsoft');
  1908.                         triggerAfterOpen = false;
  1909.                     }
  1910.                 })
  1911.                 .on('click.xdsoft', function (xdevent) {
  1912.                     xdevent.stopPropagation();
  1913.                 });
  1914.  
  1915.             current_time_index = 0;
  1916.  
  1917.             setPos = function () {
  1918.                 var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute", node;
  1919.                 if (datetimepicker.data('input').parent().css('direction') == 'rtl')
  1920.                     left -= (datetimepicker.outerWidth() - datetimepicker.data('input').outerWidth());
  1921.                 if (options.fixed) {
  1922.                     top -= $(window).scrollTop();
  1923.                     left -= $(window).scrollLeft();
  1924.                     position = "fixed";
  1925.                 } else {
  1926.                     if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
  1927.                         top = offset.top - datetimepicker[0].offsetHeight + 1;
  1928.                     }
  1929.                     if (top < 0) {
  1930.                         top = 0;
  1931.                     }
  1932.                     if (left + datetimepicker[0].offsetWidth > $(window).width()) {
  1933.                         left = $(window).width() - datetimepicker[0].offsetWidth;
  1934.                     }
  1935.                 }
  1936.  
  1937.                 node = datetimepicker[0];
  1938.                 do {
  1939.                     node = node.parentNode;
  1940.                     if (window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
  1941.                         left = left - (($(window).width() - node.offsetWidth) / 2);
  1942.                         break;
  1943.                     }
  1944.                 } while (node.nodeName !== 'HTML');
  1945.                 datetimepicker.css({
  1946.                     left: left,
  1947.                     top: top,
  1948.                     position: position
  1949.                 });
  1950.             };
  1951.             datetimepicker
  1952.                 .on('open.xdsoft', function (event) {
  1953.                     var onShow = true;
  1954.                     if (options.onShow && $.isFunction(options.onShow)) {
  1955.                         onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1956.                     }
  1957.                     if (onShow !== false) {
  1958.                         datetimepicker.show();
  1959.                         setPos();
  1960.                         $(window)
  1961.                             .off('resize.xdsoft', setPos)
  1962.                             .on('resize.xdsoft', setPos);
  1963.  
  1964.                         if (options.closeOnWithoutClick) {
  1965.                             $([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
  1966.                                 datetimepicker.trigger('close.xdsoft');
  1967.                                 $([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
  1968.                             });
  1969.                         }
  1970.                     }
  1971.                 })
  1972.                 .on('close.xdsoft', function (event) {
  1973.                     var onClose = true;
  1974.                     mounth_picker
  1975.                         .find('.xdsoft_month,.xdsoft_year')
  1976.                             .find('.xdsoft_select')
  1977.                                 .hide();
  1978.                     if (options.onClose && $.isFunction(options.onClose)) {
  1979.                         onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1980.                     }
  1981.                     if (onClose !== false && !options.opened && !options.inline) {
  1982.                         datetimepicker.hide();
  1983.                     }
  1984.                     event.stopPropagation();
  1985.                 })
  1986.                 .on('toggle.xdsoft', function (event) {
  1987.                     if (datetimepicker.is(':visible')) {
  1988.                         datetimepicker.trigger('close.xdsoft');
  1989.                     } else {
  1990.                         datetimepicker.trigger('open.xdsoft');
  1991.                     }
  1992.                 })
  1993.                 .data('input', input);
  1994.  
  1995.             timer = 0;
  1996.             timer1 = 0;
  1997.  
  1998.             datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
  1999.             datetimepicker.setOptions(options);
  2000.  
  2001.             function getCurrentValue() {
  2002.                 var ct = false, time;
  2003.  
  2004.                 if (options.startDate) {
  2005.                     ct = _xdsoft_datetime.strToDate(options.startDate);
  2006.                 } else {
  2007.                     ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
  2008.                     if (ct) {
  2009.                         ct = _xdsoft_datetime.strToDateTime(ct);
  2010.                     } else if (options.defaultDate) {
  2011.                         ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
  2012.                         if (options.defaultTime) {
  2013.                             time = _xdsoft_datetime.strtotime(options.defaultTime);
  2014.                             ct.setHours(time.getHours());
  2015.                             ct.setMinutes(time.getMinutes());
  2016.                         }
  2017.                     }
  2018.                 }
  2019.  
  2020.                 if (ct && _xdsoft_datetime.isValidDate(ct)) {
  2021.                     datetimepicker.data('changed', true);
  2022.                 } else {
  2023.                     ct = '';
  2024.                 }
  2025.  
  2026.                 return ct || 0;
  2027.             }
  2028.  
  2029.             _xdsoft_datetime.setCurrentTime(getCurrentValue());
  2030.  
  2031.             input
  2032.                 .data('xdsoft_datetimepicker', datetimepicker)
  2033.                 .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
  2034.                     if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
  2035.                         return;
  2036.                     }
  2037.                     clearTimeout(timer);
  2038.                     timer = setTimeout(function () {
  2039.                         if (input.is(':disabled')) {
  2040.                             return;
  2041.                         }
  2042.  
  2043.                         triggerAfterOpen = true;
  2044.                         _xdsoft_datetime.setCurrentTime(getCurrentValue());
  2045.  
  2046.                         datetimepicker.trigger('open.xdsoft');
  2047.                     }, 100);
  2048.                 })
  2049.                 .on('keydown.xdsoft', function (event) {
  2050.                     var val = this.value, elementSelector,
  2051.                         key = event.which;
  2052.                     if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
  2053.                         elementSelector = $("input:visible,textarea:visible");
  2054.                         datetimepicker.trigger('close.xdsoft');
  2055.                         elementSelector.eq(elementSelector.index(this) + 1).focus();
  2056.                         return false;
  2057.                     }
  2058.                     if ([TAB].indexOf(key) !== -1) {
  2059.                         datetimepicker.trigger('close.xdsoft');
  2060.                         return true;
  2061.                     }
  2062.                 });
  2063.         };
  2064.         destroyDateTimePicker = function (input) {
  2065.             var datetimepicker = input.data('xdsoft_datetimepicker');
  2066.             if (datetimepicker) {
  2067.                 datetimepicker.data('xdsoft_datetime', null);
  2068.                 datetimepicker.remove();
  2069.                 input
  2070.                     .data('xdsoft_datetimepicker', null)
  2071.                     .off('.xdsoft');
  2072.                 $(window).off('resize.xdsoft');
  2073.                 $([window, document.body]).off('mousedown.xdsoft');
  2074.                 if (input.unmousewheel) {
  2075.                     input.unmousewheel();
  2076.                 }
  2077.             }
  2078.         };
  2079.         $(document)
  2080.             .off('keydown.xdsoftctrl keyup.xdsoftctrl')
  2081.             .on('keydown.xdsoftctrl', function (e) {
  2082.                 if (e.keyCode === CTRLKEY) {
  2083.                     ctrlDown = true;
  2084.                 }
  2085.             })
  2086.             .on('keyup.xdsoftctrl', function (e) {
  2087.                 if (e.keyCode === CTRLKEY) {
  2088.                     ctrlDown = false;
  2089.                 }
  2090.             });
  2091.         return this.each(function () {
  2092.             var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
  2093.             if (datetimepicker) {
  2094.                 if ($.type(opt) === 'string') {
  2095.                     switch (opt) {
  2096.                     case 'show':
  2097.                         $(this).select().focus();
  2098.                         datetimepicker.trigger('open.xdsoft');
  2099.                         break;
  2100.                     case 'hide':
  2101.                         datetimepicker.trigger('close.xdsoft');
  2102.                         break;
  2103.                     case 'toggle':
  2104.                         datetimepicker.trigger('toggle.xdsoft');
  2105.                         break;
  2106.                     case 'destroy':
  2107.                         destroyDateTimePicker($(this));
  2108.                         break;
  2109.                     case 'reset':
  2110.                         this.value = this.defaultValue;
  2111.                         if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
  2112.                             datetimepicker.data('changed', false);
  2113.                         }
  2114.                         datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
  2115.                         break;
  2116.                     case 'validate':
  2117.                         $input = datetimepicker.data('input');
  2118.                         $input.trigger('blur.xdsoft');
  2119.                         break;
  2120.                     }
  2121.                 } else {
  2122.                     datetimepicker
  2123.                         .setOptions(opt);
  2124.                 }
  2125.                 return 0;
  2126.             }
  2127.             if ($.type(opt) !== 'string') {
  2128.                 if (!options.lazyInit || options.open || options.inline) {
  2129.                     createDateTimePicker($(this));
  2130.                 } else {
  2131.                     lazyInit($(this));
  2132.                 }
  2133.             }
  2134.         });
  2135.     };
  2136.     $.fn.datetimepicker.defaults = default_options;
  2137.  
  2138.     function HighlightedDate(date, desc, style) {
  2139.         "use strict";
  2140.         this.date = date;
  2141.         this.desc = desc;
  2142.         this.style = style;
  2143.     }
  2144.  
  2145. }));
  2146. /*!
  2147.  * jQuery Mousewheel 3.1.13
  2148.  *
  2149.  * Copyright jQuery Foundation and other contributors
  2150.  * Released under the MIT license
  2151.  * http://jquery.org/license
  2152.  */
  2153.  
  2154. (function (factory) {
  2155.     if ( typeof define === 'function' && define.amd ) {
  2156.         // AMD. Register as an anonymous module.
  2157.         define(['jquery'], factory);
  2158.     } else if (typeof exports === 'object') {
  2159.         // Node/CommonJS style for Browserify
  2160.         module.exports = factory;
  2161.     } else {
  2162.         // Browser globals
  2163.         factory(jQuery);
  2164.     }
  2165. }(function ($) {
  2166.  
  2167.     var toFix  = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
  2168.         toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
  2169.                     ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
  2170.         slice  = Array.prototype.slice,
  2171.         nullLowestDeltaTimeout, lowestDelta;
  2172.  
  2173.     if ( $.event.fixHooks ) {
  2174.         for ( var i = toFix.length; i; ) {
  2175.             $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
  2176.         }
  2177.     }
  2178.  
  2179.     var special = $.event.special.mousewheel = {
  2180.         version: '3.1.12',
  2181.  
  2182.         setup: function() {
  2183.             if ( this.addEventListener ) {
  2184.                 for ( var i = toBind.length; i; ) {
  2185.                     this.addEventListener( toBind[--i], handler, false );
  2186.                 }
  2187.             } else {
  2188.                 this.onmousewheel = handler;
  2189.             }
  2190.             // Store the line height and page height for this particular element
  2191.             $.data(this, 'mousewheel-line-height', special.getLineHeight(this));
  2192.             $.data(this, 'mousewheel-page-height', special.getPageHeight(this));
  2193.         },
  2194.  
  2195.         teardown: function() {
  2196.             if ( this.removeEventListener ) {
  2197.                 for ( var i = toBind.length; i; ) {
  2198.                     this.removeEventListener( toBind[--i], handler, false );
  2199.                 }
  2200.             } else {
  2201.                 this.onmousewheel = null;
  2202.             }
  2203.             // Clean up the data we added to the element
  2204.             $.removeData(this, 'mousewheel-line-height');
  2205.             $.removeData(this, 'mousewheel-page-height');
  2206.         },
  2207.  
  2208.         getLineHeight: function(elem) {
  2209.             var $elem = $(elem),
  2210.                 $parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
  2211.             if (!$parent.length) {
  2212.                 $parent = $('body');
  2213.             }
  2214.             return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
  2215.         },
  2216.  
  2217.         getPageHeight: function(elem) {
  2218.             return $(elem).height();
  2219.         },
  2220.  
  2221.         settings: {
  2222.             adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
  2223.             normalizeOffset: true  // calls getBoundingClientRect for each event
  2224.         }
  2225.     };
  2226.  
  2227.     $.fn.extend({
  2228.         mousewheel: function(fn) {
  2229.             return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
  2230.         },
  2231.  
  2232.         unmousewheel: function(fn) {
  2233.             return this.unbind('mousewheel', fn);
  2234.         }
  2235.     });
  2236.  
  2237.  
  2238.     function handler(event) {
  2239.         var orgEvent   = event || window.event,
  2240.             args       = slice.call(arguments, 1),
  2241.             delta      = 0,
  2242.             deltaX     = 0,
  2243.             deltaY     = 0,
  2244.             absDelta   = 0,
  2245.             offsetX    = 0,
  2246.             offsetY    = 0;
  2247.         event = $.event.fix(orgEvent);
  2248.         event.type = 'mousewheel';
  2249.  
  2250.         // Old school scrollwheel delta
  2251.         if ( 'detail'      in orgEvent ) { deltaY = orgEvent.detail * -1;      }
  2252.         if ( 'wheelDelta'  in orgEvent ) { deltaY = orgEvent.wheelDelta;       }
  2253.         if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY;      }
  2254.         if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
  2255.  
  2256.         // Firefox < 17 horizontal scrolling related to DOMMouseScroll event
  2257.         if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
  2258.             deltaX = deltaY * -1;
  2259.             deltaY = 0;
  2260.         }
  2261.  
  2262.         // Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
  2263.         delta = deltaY === 0 ? deltaX : deltaY;
  2264.  
  2265.         // New school wheel delta (wheel event)
  2266.         if ( 'deltaY' in orgEvent ) {
  2267.             deltaY = orgEvent.deltaY * -1;
  2268.             delta  = deltaY;
  2269.         }
  2270.         if ( 'deltaX' in orgEvent ) {
  2271.             deltaX = orgEvent.deltaX;
  2272.             if ( deltaY === 0 ) { delta  = deltaX * -1; }
  2273.         }
  2274.  
  2275.         // No change actually happened, no reason to go any further
  2276.         if ( deltaY === 0 && deltaX === 0 ) { return; }
  2277.  
  2278.         // Need to convert lines and pages to pixels if we aren't already in pixels
  2279.         // There are three delta modes:
  2280.         //   * deltaMode 0 is by pixels, nothing to do
  2281.         //   * deltaMode 1 is by lines
  2282.         //   * deltaMode 2 is by pages
  2283.         if ( orgEvent.deltaMode === 1 ) {
  2284.             var lineHeight = $.data(this, 'mousewheel-line-height');
  2285.             delta  *= lineHeight;
  2286.             deltaY *= lineHeight;
  2287.             deltaX *= lineHeight;
  2288.         } else if ( orgEvent.deltaMode === 2 ) {
  2289.             var pageHeight = $.data(this, 'mousewheel-page-height');
  2290.             delta  *= pageHeight;
  2291.             deltaY *= pageHeight;
  2292.             deltaX *= pageHeight;
  2293.         }
  2294.  
  2295.         // Store lowest absolute delta to normalize the delta values
  2296.         absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
  2297.  
  2298.         if ( !lowestDelta || absDelta < lowestDelta ) {
  2299.             lowestDelta = absDelta;
  2300.  
  2301.             // Adjust older deltas if necessary
  2302.             if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  2303.                 lowestDelta /= 40;
  2304.             }
  2305.         }
  2306.  
  2307.         // Adjust older deltas if necessary
  2308.         if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
  2309.             // Divide all the things by 40!
  2310.             delta  /= 40;
  2311.             deltaX /= 40;
  2312.             deltaY /= 40;
  2313.         }
  2314.  
  2315.         // Get a whole, normalized value for the deltas
  2316.         delta  = Math[ delta  >= 1 ? 'floor' : 'ceil' ](delta  / lowestDelta);
  2317.         deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
  2318.         deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
  2319.  
  2320.         // Normalise offsetX and offsetY properties
  2321.         if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
  2322.             var boundingRect = this.getBoundingClientRect();
  2323.             offsetX = event.clientX - boundingRect.left;
  2324.             offsetY = event.clientY - boundingRect.top;
  2325.         }
  2326.  
  2327.         // Add information to the event object
  2328.         event.deltaX = deltaX;
  2329.         event.deltaY = deltaY;
  2330.         event.deltaFactor = lowestDelta;
  2331.         event.offsetX = offsetX;
  2332.         event.offsetY = offsetY;
  2333.         // Go ahead and set deltaMode to 0 since we converted to pixels
  2334.         // Although this is a little odd since we overwrite the deltaX/Y
  2335.         // properties with normalized deltas.
  2336.         event.deltaMode = 0;
  2337.  
  2338.         // Add event and delta to the front of the arguments
  2339.         args.unshift(event, delta, deltaX, deltaY);
  2340.  
  2341.         // Clearout lowestDelta after sometime to better
  2342.         // handle multiple device types that give different
  2343.         // a different lowestDelta
  2344.         // Ex: trackpad = 3 and mouse wheel = 120
  2345.         if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
  2346.         nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
  2347.  
  2348.         return ($.event.dispatch || $.event.handle).apply(this, args);
  2349.     }
  2350.  
  2351.     function nullLowestDelta() {
  2352.         lowestDelta = null;
  2353.     }
  2354.  
  2355.     function shouldAdjustOldDeltas(orgEvent, absDelta) {
  2356.         // If this is an older event and the delta is divisable by 120,
  2357.         // then we are assuming that the browser is treating this as an
  2358.         // older mouse wheel event and that we should divide the deltas
  2359.         // by 40 to try and get a more usable deltaFactor.
  2360.         // Side note, this actually impacts the reported scroll distance
  2361.         // in older browsers and can cause scrolling to be slower than native.
  2362.         // Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
  2363.         return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
  2364.     }
  2365.  
  2366. }));
  2367. /*
  2368.  * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
  2369.  * Modified by Jonathan Gotti aka malko <jgotti at jgotti dot org>
  2370.  *
  2371.  * This program is free software; you can redistribute it and/or modify it
  2372.  * under the terms of the GNU Lesser General Public License as published by the
  2373.  * Free Software Foundation, version 2.1.
  2374.  *
  2375.  * This program is distributed in the hope that it will be useful, but WITHOUT
  2376.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  2377.  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
  2378.  * details.
  2379.  */
  2380. /* jshint laxbreak:true*/
  2381. !(function (factory) {
  2382.     if ( typeof define === 'function' && define.amd ) {
  2383.         define([], factory);
  2384.     } else if (typeof exports === 'object') {
  2385.         module.exports = factory;
  2386.     } else {
  2387.         factory();
  2388.     }
  2389. }(function(){
  2390.     "use strict";
  2391.     var parseFunctions = {};
  2392.     var parseRegexes = [];
  2393.     var formatFunctions = {};
  2394.     var charFormatters = {
  2395.         d: function(date) { return stringLeftPad(date.getDate(), 2, '0'); },
  2396.         D: function(date) { return Date.dayNames[date.getDay()].substring(0, 3); },
  2397.         j: function(date) { return date.getDate(); },
  2398.         l: function(date) { return Date.dayNames[date.getDay()]; },
  2399.         S: function(date) { return date.getSuffix(); },
  2400.         w: function(date) { return date.getDay(); },
  2401.         z: function(date) { return date.getDayOfYear(); },
  2402.         W: function(date) { return date.getWeekOfYear(); },
  2403.         F: function(date) { return Date.monthNames[date.getMonth()]; },
  2404.         m: function(date) { return stringLeftPad(date.getMonth() + 1, 2, '0'); },
  2405.         M: function(date) { return Date.monthNames[date.getMonth()].substring(0, 3); },
  2406.         n: function(date) { return (date.getMonth() + 1); },
  2407.         t: function(date) { return date.getDaysInMonth(); },
  2408.         L: function(date) { return (date.isLeapYear() ? 1 : 0); },
  2409.         Y: function(date) { return date.getFullYear(); },
  2410.         y: function(date) { return ('' + date.getFullYear()).substring(2, 4); },
  2411.         a: function(date) { return (date.getHours() < 12 ? 'am' : 'pm'); },
  2412.         A: function(date) { return (date.getHours() < 12 ? 'AM' : 'PM'); },
  2413.         g: function(date) { return ((date.getHours() %12) ? date.getHours() % 12 : 12); },
  2414.         G: function(date) { return date.getHours(); },
  2415.         h: function(date) { return stringLeftPad((date.getHours() %12) ? date.getHours() % 12 : 12, 2, '0'); },
  2416.         H: function(date) { return stringLeftPad(date.getHours(), 2, '0'); },
  2417.         i: function(date) { return stringLeftPad(date.getMinutes(), 2, '0'); },
  2418.         s: function(date) { return stringLeftPad(date.getSeconds(), 2, '0'); },
  2419.         O: function(date) { return date.getGMTOffset(); },
  2420.         T: function(date) { return date.getTimezone(); },
  2421.         Z: function(date) { return (date.getTimezoneOffset() * -60); }
  2422.     };
  2423.  
  2424.     Date.prototype.dateFormat = function(format) {
  2425.         formatFunctions[format]  || createNewFormat(format);
  2426.         return formatFunctions[format](this);
  2427.     };
  2428.  
  2429.     function createNewFormat(format) {
  2430.         var formatters = [];
  2431.         var special = false;
  2432.         var ch = '';
  2433.         for (var i = 0; i < format.length; ++i) {
  2434.             ch = format.charAt(i);
  2435.             if (!special && ch === "\\") {
  2436.                 special = true;
  2437.             } else if (special) {
  2438.                 special = false;
  2439.                 formatters.push(stringEscape(ch));
  2440.             } else {
  2441.                 formatters.push(charFormatters[ch] || stringEscape(ch));
  2442.             }
  2443.         }
  2444.         formatFunctions[format] = getFormatter(formatters);
  2445.     }
  2446.  
  2447.     function getFormatter(formatters) {
  2448.         return function(date) {
  2449.             var res = [];
  2450.             for (var i=0, l=formatters.length; i < l; i++) {
  2451.                 res.push(typeof formatters[i] === 'string' ? formatters[i] : formatters[i](date));
  2452.             }
  2453.             return res.join('');
  2454.         };
  2455.     }
  2456.  
  2457.     Date.parseDate = function(input, format) {
  2458.         parseFunctions[format] || createParser(format);
  2459.         return parseFunctions[format](input);
  2460.     };
  2461.  
  2462.     function getParser(format, regexNum, assigns) {
  2463.         return function(input){
  2464.             var d = new Date();
  2465.             var results = input.match(parseRegexes[regexNum]);
  2466.             if (results && results.length > 0) {
  2467.                 results.y = d.getFullYear();
  2468.                 results.m = d.getMonth();
  2469.                 results.d = d.getDate();
  2470.                 results.h = -1;
  2471.                 results.i = -1;
  2472.                 results.s = -1;
  2473.                 for ( var i = 0, l = assigns.length; i < l; i++) {
  2474.                     assigns[i](results);
  2475.                 }
  2476.                 if (results.y > 0 && results.m >= 0 && results.d > 0 && results.h >= 0 && results.i >= 0 && results.s >= 0){
  2477.                     return new Date(results.y, results.m, results.d, results.h, results.i, results.s);
  2478.                 } else if (results.y > 0 && results.m >= 0 && results.d > 0 && results.h >= 0 && results.i >= 0) {
  2479.                     return new Date(results.y, results.m, results.d, results.h, results.i);
  2480.                 } else if (results.y > 0 && results.m >= 0 && results.d > 0 && results.h >= 0) {
  2481.                     return new Date(results.y, results.m, results.d, results.h);
  2482.                 } else if (results.y > 0 && results.m >= 0 && results.d > 0) {
  2483.                     return new Date(results.y, results.m, results.d);
  2484.                 } else if (results.y > 0 && results.m >= 0) {
  2485.                     return new Date(results.y, results.m);
  2486.                 } else if (results.y > 0) {
  2487.                     return new Date(results.y);
  2488.                 }
  2489.             }
  2490.             return null;
  2491.         };
  2492.     }
  2493.  
  2494.     function createParser(format) {
  2495.         var regexNum = parseRegexes.length;
  2496.         var currentGroup = 1;
  2497.         var regex = "";
  2498.         var special = false;
  2499.         var ch = '';
  2500.         var assigns=[];
  2501.         var obj;
  2502.         for (var i = 0; i < format.length; ++i) {
  2503.             ch = format.charAt(i);
  2504.             if (!special && ch === "\\") {
  2505.                 special = true;
  2506.             } else if (special) {
  2507.                 special = false;
  2508.                 regex += stringEscape(ch);
  2509.             } else {
  2510.                 obj = formatCodeToRegex(ch, currentGroup);
  2511.                 currentGroup += obj.g;
  2512.                 regex += obj.s;
  2513.                 if (obj.g && obj.a) {
  2514.                     assigns.push(obj.a);
  2515.                 }
  2516.             }
  2517.         }
  2518.  
  2519.         parseRegexes[regexNum] = new RegExp("^" + regex + "$");
  2520.         parseFunctions[format] = getParser(format, regexNum, assigns);
  2521.     }
  2522.  
  2523.     function formatCodeToRegex(character, currentGroup) {
  2524.         switch (character) {
  2525.         case "D":
  2526.             return {g:0,
  2527.             s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};
  2528.         case "j":
  2529.         case "d":
  2530.             return {g:1,
  2531.                 a: function(results){ results.d = parseInt(results[currentGroup], 10);},
  2532.                 s:"(\\d{1,2})"
  2533.             };
  2534.         case "l":
  2535.             return {g:0,
  2536.                 s:"(?:" + Date.dayNames.join("|") + ")"};
  2537.         case "S":
  2538.             return {g:0,
  2539.                 s:"(?:st|nd|rd|th)"};
  2540.         case "w":
  2541.             return {g:0,
  2542.                 s:"\\d"};
  2543.         case "z":
  2544.             return {g:0,
  2545.                 s:"(?:\\d{1,3})"};
  2546.         case "W":
  2547.             return {g:0,
  2548.                 s:"(?:\\d{2})"};
  2549.         case "F":
  2550.             return {g:1,
  2551.                 a: function(results) { results.m = parseInt(Date.monthNumbers[results[currentGroup].substring(0, 3)], 10);},
  2552.                 s:"(" + Date.monthNames.join("|") + ")"};
  2553.         case "M":
  2554.             return {g:1,
  2555.                 a: function(results) { results.m = parseInt(Date.monthNumbers[results[currentGroup]], 10);},
  2556.                 s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};
  2557.         case "n":
  2558.         case "m":
  2559.             return {g:1,
  2560.                 a: function(results) { results.m = parseInt(results[currentGroup], 10) - 1;},
  2561.                 s:"(\\d{1,2})"};
  2562.         case "t":
  2563.             return {g:0,
  2564.                 s:"\\d{1,2}"};
  2565.         case "L":
  2566.             return {g:0,
  2567.                 s:"(?:1|0)"};
  2568.         case "Y":
  2569.             return {g:1,
  2570.                 a: function(results) { results.y = parseInt(results[currentGroup], 10);},
  2571.                 s:"(\\d{4})"};
  2572.         case "y":
  2573.             return {g:1,
  2574.                 a: function(results) {
  2575.                     var ty = parseInt(results[currentGroup], 10);
  2576.                     results.y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;
  2577.                 },
  2578.                 s:"(\\d{1,2})"};
  2579.         case "a":
  2580.             return {g:1,
  2581.                 a: function(results) {
  2582.                     if (results[currentGroup] === 'am') {
  2583.                         if (results.h == 12) { results.h = 0; }
  2584.                     } else {
  2585.                         if (results.h < 12) { results.h += 12; }
  2586.                     }
  2587.                 },
  2588.                 s:"(am|pm)"};
  2589.         case "A":
  2590.             return {g:1,
  2591.                 a: function(results){
  2592.                     if (results[currentGroup] === 'AM') {
  2593.                         if (results.h == 12) { results.h = 0; }
  2594.                     } else {
  2595.                         if (results.h < 12) { results.h += 12; }
  2596.                     }
  2597.                 },
  2598.                 s:"(AM|PM)"};
  2599.         case "g":
  2600.         case "G":
  2601.         case "h":
  2602.         case "H":
  2603.             return {g:1,
  2604.                 a: function(results) {results.h = parseInt(results[currentGroup], 10);},
  2605.                 s:"(\\d{1,2})"};
  2606.         case "i":
  2607.             return {g:1,
  2608.                 a: function(results) {results.i = parseInt(results[currentGroup], 10);},
  2609.                 s:"(\\d{2})"};
  2610.         case "s":
  2611.             return {g:1,
  2612.                 a: function(results) {results.s = parseInt(results[currentGroup], 10);},
  2613.                 s:"(\\d{2})"};
  2614.         case "O":
  2615.             return {g:0,
  2616.                 s:"[+-]\\d{4}"};
  2617.         case "T":
  2618.             return {g:0,
  2619.                 s:"[A-Z]{3}"};
  2620.         case "Z":
  2621.             return {g:0,
  2622.                 s:"[+-]\\d{1,5}"};
  2623.         default:
  2624.             return {g:0,
  2625.                 s:stringEscape(character)};
  2626.          }
  2627.     }
  2628.  
  2629.     Date.prototype.getTimezone = function() {
  2630.         return this.toString().replace(
  2631.             /^.*? ([A-Z]{3}) [0-9]{4}.*$/, "$1").replace(
  2632.             /^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/, "$1$2$3");
  2633.     };
  2634.  
  2635.     Date.prototype.getGMTOffset = function() {
  2636.         return (this.getTimezoneOffset() > 0 ? "-" : "+")
  2637.             + stringLeftPad(Math.floor(this.getTimezoneOffset() / 60), 2, "0")
  2638.             + stringLeftPad(this.getTimezoneOffset() % 60, 2, "0");
  2639.     };
  2640.  
  2641.     Date.prototype.getDayOfYear = function() {
  2642.         var num = 0;
  2643.         Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
  2644.         for (var i = 0; i < this.getMonth(); ++i) {
  2645.             num += Date.daysInMonth[i];
  2646.         }
  2647.         return num + this.getDate() - 1;
  2648.     };
  2649.  
  2650.     Date.prototype.getWeekOfYear = function() {
  2651.         // Skip to Thursday of this week
  2652.         var now = this.getDayOfYear() + (4 - this.getDay());
  2653.         // Find the first Thursday of the year
  2654.         var jan1 = new Date(this.getFullYear(), 0, 1);
  2655.         var then = (7 - jan1.getDay() + 4);
  2656.         return stringLeftPad(((now - then) / 7) + 1, 2, "0");
  2657.     };
  2658.  
  2659.     Date.prototype.isLeapYear = function() {
  2660.         var year = this.getFullYear();
  2661.         return !!((year & 3) === 0 && (year % 100 || (year % 400 === 0 && year)));
  2662.     };
  2663.  
  2664.     Date.prototype.getFirstDayOfMonth = function() {
  2665.         var day = (this.getDay() - (this.getDate() - 1)) % 7;
  2666.         return (day < 0) ? (day + 7) : day;
  2667.     };
  2668.  
  2669.     Date.prototype.getLastDayOfMonth = function() {
  2670.         var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
  2671.         return (day < 0) ? (day + 7) : day;
  2672.     };
  2673.  
  2674.     Date.prototype.getDaysInMonth = function() {
  2675.         Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
  2676.         return Date.daysInMonth[this.getMonth()];
  2677.     };
  2678.  
  2679.     Date.prototype.getSuffix = function() {
  2680.         switch (this.getDate()) {
  2681.             case 1:
  2682.             case 21:
  2683.             case 31:
  2684.                 return "st";
  2685.             case 2:
  2686.             case 22:
  2687.                 return "nd";
  2688.             case 3:
  2689.             case 23:
  2690.                 return "rd";
  2691.             default:
  2692.                 return "th";
  2693.         }
  2694.     };
  2695.  
  2696.     function stringEscape(string) {
  2697.         return string.replace(/('|\\)/g, "\\$1");
  2698.     }
  2699.  
  2700.     function stringLeftPad(val, size, ch) {
  2701.         var result = "" + val;
  2702.         ch = ("" + ch) || " ";
  2703.         while (result.length < size) {
  2704.             result = ch + result;
  2705.         }
  2706.         return result;
  2707.     }
  2708.  
  2709.     Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
  2710.     Date.monthNames =
  2711.         ["January",
  2712.             "February",
  2713.             "March",
  2714.             "April",
  2715.             "May",
  2716.             "June",
  2717.             "July",
  2718.             "August",
  2719.             "September",
  2720.             "October",
  2721.             "November",
  2722.             "December"];
  2723.     Date.dayNames =
  2724.         ["Sunday",
  2725.             "Monday",
  2726.             "Tuesday",
  2727.             "Wednesday",
  2728.             "Thursday",
  2729.             "Friday",
  2730.             "Saturday"];
  2731.     Date.y2kYear = 50;
  2732.     Date.monthNumbers = {
  2733.         Jan:0,
  2734.         Feb:1,
  2735.         Mar:2,
  2736.         Apr:3,
  2737.         May:4,
  2738.         Jun:5,
  2739.         Jul:6,
  2740.         Aug:7,
  2741.         Sep:8,
  2742.         Oct:9,
  2743.         Nov:10,
  2744.         Dec:11};
  2745.     Date.patterns = {
  2746.         ISO8601LongPattern:"Y-m-d H:i:s",
  2747.         ISO8601ShortPattern:"Y-m-d",
  2748.         ShortDatePattern: "n/j/Y",
  2749.         LongDatePattern: "l, F d, Y",
  2750.         FullDateTimePattern: "l, F d, Y g:i:s A",
  2751.         MonthDayPattern: "F d",
  2752.         ShortTimePattern: "g:i A",
  2753.         LongTimePattern: "g:i:s A",
  2754.         SortableDateTimePattern: "Y-m-d\\TH:i:s",
  2755.         UniversalSortableDateTimePattern: "Y-m-d H:i:sO",
  2756.         YearMonthPattern: "F, Y"};
  2757. }));
Advertisement
Add Comment
Please, Sign In to add comment