jquery.datetimepicker.js 78 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073
  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 ($) {
  8. 'use strict';
  9. var default_options = {
  10. i18n: {
  11. ar: { // Arabic
  12. months: [
  13. "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
  14. ],
  15. dayOfWeek: [
  16. "ن", "ث", "ع", "خ", "ج", "س", "ح"
  17. ]
  18. },
  19. ro: { // Romanian
  20. months: [
  21. "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie"
  22. ],
  23. dayOfWeek: [
  24. "l", "ma", "mi", "j", "v", "s", "d"
  25. ]
  26. },
  27. id: { // Indonesian
  28. months: [
  29. "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
  30. ],
  31. dayOfWeek: [
  32. "Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
  33. ]
  34. },
  35. is: { // Icelandic
  36. months: [
  37. "Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"
  38. ],
  39. dayOfWeek: [
  40. "Sun", "Mán", "Þrið", "Mið", "Fim", "Fös", "Lau"
  41. ]
  42. },
  43. bg: { // Bulgarian
  44. months: [
  45. "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
  46. ],
  47. dayOfWeek: [
  48. "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  49. ]
  50. },
  51. fa: { // Persian/Farsi
  52. months: [
  53. 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
  54. ],
  55. dayOfWeek: [
  56. 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
  57. ]
  58. },
  59. ru: { // Russian
  60. months: [
  61. 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
  62. ],
  63. dayOfWeek: [
  64. "Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  65. ]
  66. },
  67. uk: { // Ukrainian
  68. months: [
  69. 'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
  70. ],
  71. dayOfWeek: [
  72. "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
  73. ]
  74. },
  75. en: { // English
  76. months: [
  77. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  78. ],
  79. dayOfWeek: [
  80. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  81. ]
  82. },
  83. el: { // Ελληνικά
  84. months: [
  85. "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
  86. ],
  87. dayOfWeek: [
  88. "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
  89. ]
  90. },
  91. de: { // German
  92. months: [
  93. 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
  94. ],
  95. dayOfWeek: [
  96. "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
  97. ]
  98. },
  99. nl: { // Dutch
  100. months: [
  101. "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
  102. ],
  103. dayOfWeek: [
  104. "zo", "ma", "di", "wo", "do", "vr", "za"
  105. ]
  106. },
  107. tr: { // Turkish
  108. months: [
  109. "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
  110. ],
  111. dayOfWeek: [
  112. "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
  113. ]
  114. },
  115. fr: { //French
  116. months: [
  117. "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
  118. ],
  119. dayOfWeek: [
  120. "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
  121. ]
  122. },
  123. es: { // Spanish
  124. months: [
  125. "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
  126. ],
  127. dayOfWeek: [
  128. "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
  129. ]
  130. },
  131. th: { // Thai
  132. months: [
  133. 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
  134. ],
  135. dayOfWeek: [
  136. 'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
  137. ]
  138. },
  139. pl: { // Polish
  140. months: [
  141. "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
  142. ],
  143. dayOfWeek: [
  144. "nd", "pn", "wt", "śr", "cz", "pt", "sb"
  145. ]
  146. },
  147. pt: { // Portuguese
  148. months: [
  149. "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  150. ],
  151. dayOfWeek: [
  152. "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
  153. ]
  154. },
  155. ch: { // Simplified Chinese
  156. months: [
  157. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  158. ],
  159. dayOfWeek: [
  160. "日", "一", "二", "三", "四", "五", "六"
  161. ]
  162. },
  163. se: { // Swedish
  164. months: [
  165. "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  166. ],
  167. dayOfWeek: [
  168. "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  169. ]
  170. },
  171. kr: { // Korean
  172. months: [
  173. "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  174. ],
  175. dayOfWeek: [
  176. "일", "월", "화", "수", "목", "금", "토"
  177. ]
  178. },
  179. it: { // Italian
  180. months: [
  181. "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
  182. ],
  183. dayOfWeek: [
  184. "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
  185. ]
  186. },
  187. da: { // Dansk
  188. months: [
  189. "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December"
  190. ],
  191. dayOfWeek: [
  192. "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  193. ]
  194. },
  195. no: { // Norwegian
  196. months: [
  197. "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
  198. ],
  199. dayOfWeek: [
  200. "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  201. ]
  202. },
  203. ja: { // Japanese
  204. months: [
  205. "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
  206. ],
  207. dayOfWeek: [
  208. "日", "月", "火", "水", "木", "金", "土"
  209. ]
  210. },
  211. vi: { // Vietnamese
  212. months: [
  213. "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"
  214. ],
  215. dayOfWeek: [
  216. "CN", "T2", "T3", "T4", "T5", "T6", "T7"
  217. ]
  218. },
  219. sl: { // Slovenščina
  220. months: [
  221. "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
  222. ],
  223. dayOfWeek: [
  224. "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
  225. ]
  226. },
  227. cs: { // Čeština
  228. months: [
  229. "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
  230. ],
  231. dayOfWeek: [
  232. "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
  233. ]
  234. },
  235. hu: { // Hungarian
  236. months: [
  237. "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
  238. ],
  239. dayOfWeek: [
  240. "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
  241. ]
  242. },
  243. az: { //Azerbaijanian (Azeri)
  244. months: [
  245. "Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
  246. ],
  247. dayOfWeek: [
  248. "B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
  249. ]
  250. },
  251. bs: { //Bosanski
  252. months: [
  253. "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  254. ],
  255. dayOfWeek: [
  256. "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  257. ]
  258. },
  259. ca: { //Català
  260. months: [
  261. "Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
  262. ],
  263. dayOfWeek: [
  264. "Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
  265. ]
  266. },
  267. 'en-GB': { //English (British)
  268. months: [
  269. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  270. ],
  271. dayOfWeek: [
  272. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  273. ]
  274. },
  275. et: { //"Eesti"
  276. months: [
  277. "Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
  278. ],
  279. dayOfWeek: [
  280. "P", "E", "T", "K", "N", "R", "L"
  281. ]
  282. },
  283. eu: { //Euskara
  284. months: [
  285. "Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
  286. ],
  287. dayOfWeek: [
  288. "Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
  289. ]
  290. },
  291. fi: { //Finnish (Suomi)
  292. months: [
  293. "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
  294. ],
  295. dayOfWeek: [
  296. "Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
  297. ]
  298. },
  299. gl: { //Galego
  300. months: [
  301. "Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
  302. ],
  303. dayOfWeek: [
  304. "Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
  305. ]
  306. },
  307. hr: { //Hrvatski
  308. months: [
  309. "Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
  310. ],
  311. dayOfWeek: [
  312. "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  313. ]
  314. },
  315. ko: { //Korean (한국어)
  316. months: [
  317. "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  318. ],
  319. dayOfWeek: [
  320. "일", "월", "화", "수", "목", "금", "토"
  321. ]
  322. },
  323. lt: { //Lithuanian (lietuvių)
  324. months: [
  325. "Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
  326. ],
  327. dayOfWeek: [
  328. "Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
  329. ]
  330. },
  331. lv: { //Latvian (Latviešu)
  332. months: [
  333. "Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
  334. ],
  335. dayOfWeek: [
  336. "Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
  337. ]
  338. },
  339. mk: { //Macedonian (Македонски)
  340. months: [
  341. "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
  342. ],
  343. dayOfWeek: [
  344. "нед", "пон", "вто", "сре", "чет", "пет", "саб"
  345. ]
  346. },
  347. mn: { //Mongolian (Монгол)
  348. months: [
  349. "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
  350. ],
  351. dayOfWeek: [
  352. "Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
  353. ]
  354. },
  355. 'pt-BR': { //Português(Brasil)
  356. months: [
  357. "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  358. ],
  359. dayOfWeek: [
  360. "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
  361. ]
  362. },
  363. sk: { //Slovenčina
  364. months: [
  365. "Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
  366. ],
  367. dayOfWeek: [
  368. "Ne", "Po", "Ut", "St", "Št", "Pi", "So"
  369. ]
  370. },
  371. sq: { //Albanian (Shqip)
  372. months: [
  373. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  374. ],
  375. dayOfWeek: [
  376. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  377. ]
  378. },
  379. 'sr-YU': { //Serbian (Srpski)
  380. months: [
  381. "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  382. ],
  383. dayOfWeek: [
  384. "Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
  385. ]
  386. },
  387. sr: { //Serbian Cyrillic (Српски)
  388. months: [
  389. "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
  390. ],
  391. dayOfWeek: [
  392. "нед", "пон", "уто", "сре", "чет", "пет", "суб"
  393. ]
  394. },
  395. sv: { //Svenska
  396. months: [
  397. "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  398. ],
  399. dayOfWeek: [
  400. "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  401. ]
  402. },
  403. 'zh-TW': { //Traditional Chinese (繁體中文)
  404. months: [
  405. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  406. ],
  407. dayOfWeek: [
  408. "日", "一", "二", "三", "四", "五", "六"
  409. ]
  410. },
  411. zh: { //Simplified Chinese (简体中文)
  412. months: [
  413. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  414. ],
  415. dayOfWeek: [
  416. "日", "一", "二", "三", "四", "五", "六"
  417. ]
  418. },
  419. he: { //Hebrew (עברית)
  420. months: [
  421. 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
  422. ],
  423. dayOfWeek: [
  424. 'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
  425. ]
  426. },
  427. hy: { // Armenian
  428. months: [
  429. "Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
  430. ],
  431. dayOfWeek: [
  432. "Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
  433. ]
  434. },
  435. kg: { // Kyrgyz
  436. months: [
  437. 'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
  438. ],
  439. dayOfWeek: [
  440. "Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
  441. ]
  442. }
  443. },
  444. value: '',
  445. lang: 'en',
  446. format: 'Y/m/d H:i',
  447. formatTime: 'H:i',
  448. formatDate: 'Y/m/d',
  449. startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
  450. step: 60,
  451. monthChangeSpinner: true,
  452. closeOnDateSelect: false,
  453. closeOnTimeSelect: true,
  454. closeOnWithoutClick: true,
  455. closeOnInputClick: true,
  456. timepicker: true,
  457. datepicker: true,
  458. weeks: false,
  459. defaultTime: false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
  460. defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
  461. minDate: false,
  462. maxDate: false,
  463. minTime: false,
  464. maxTime: false,
  465. disabledMinTime: false,
  466. disabledMaxTime: false,
  467. allowTimes: [],
  468. opened: false,
  469. initTime: true,
  470. inline: false,
  471. theme: '',
  472. onSelectDate: function () {},
  473. onSelectTime: function () {},
  474. onChangeMonth: function () {},
  475. onChangeYear: function () {},
  476. onChangeDateTime: function () {},
  477. onShow: function () {},
  478. onClose: function () {},
  479. onGenerate: function () {},
  480. withoutCopyright: true,
  481. inverseButton: false,
  482. hours12: false,
  483. next: 'xdsoft_next',
  484. prev : 'xdsoft_prev',
  485. dayOfWeekStart: 0,
  486. parentID: 'body',
  487. timeHeightInTimePicker: 25,
  488. timepickerScrollbar: true,
  489. todayButton: true,
  490. prevButton: true,
  491. nextButton: true,
  492. defaultSelect: true,
  493. scrollMonth: true,
  494. scrollTime: true,
  495. scrollInput: true,
  496. lazyInit: false,
  497. mask: false,
  498. validateOnBlur: true,
  499. allowBlank: true,
  500. yearStart: 1950,
  501. yearEnd: 2050,
  502. monthStart: 0,
  503. monthEnd: 11,
  504. style: '',
  505. id: '',
  506. fixed: false,
  507. roundTime: 'round', // ceil, floor
  508. className: '',
  509. weekends: [],
  510. highlightedDates: [],
  511. highlightedPeriods: [],
  512. disabledDates : [],
  513. disabledWeekDays: [],
  514. yearOffset: 0,
  515. beforeShowDay: null,
  516. enterLikeTab: true,
  517. showApplyButton: false
  518. };
  519. // fix for ie8
  520. if (!window.getComputedStyle) {
  521. window.getComputedStyle = function (el, pseudo) {
  522. this.el = el;
  523. this.getPropertyValue = function (prop) {
  524. var re = /(\-([a-z]){1})/g;
  525. if (prop === 'float') {
  526. prop = 'styleFloat';
  527. }
  528. if (re.test(prop)) {
  529. prop = prop.replace(re, function (a, b, c) {
  530. return c.toUpperCase();
  531. });
  532. }
  533. return el.currentStyle[prop] || null;
  534. };
  535. return this;
  536. };
  537. }
  538. if (!Array.prototype.indexOf) {
  539. Array.prototype.indexOf = function (obj, start) {
  540. var i, j;
  541. for (i = (start || 0), j = this.length; i < j; i += 1) {
  542. if (this[i] === obj) { return i; }
  543. }
  544. return -1;
  545. };
  546. }
  547. Date.prototype.countDaysInMonth = function () {
  548. return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
  549. };
  550. $.fn.xdsoftScroller = function (percent) {
  551. return this.each(function () {
  552. var timeboxparent = $(this),
  553. pointerEventToXY = function (e) {
  554. var out = {x: 0, y: 0},
  555. touch;
  556. if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
  557. touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
  558. out.x = touch.clientX;
  559. out.y = touch.clientY;
  560. } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
  561. out.x = e.clientX;
  562. out.y = e.clientY;
  563. }
  564. return out;
  565. },
  566. move = 0,
  567. timebox,
  568. parentHeight,
  569. height,
  570. scrollbar,
  571. scroller,
  572. maximumOffset = 100,
  573. start = false,
  574. startY = 0,
  575. startTop = 0,
  576. h1 = 0,
  577. touchStart = false,
  578. startTopScroll = 0,
  579. calcOffset = function () {};
  580. if (percent === 'hide') {
  581. timeboxparent.find('.xdsoft_scrollbar').hide();
  582. return;
  583. }
  584. if (!$(this).hasClass('xdsoft_scroller_box')) {
  585. timebox = timeboxparent.children().eq(0);
  586. parentHeight = timeboxparent[0].clientHeight;
  587. height = timebox[0].offsetHeight;
  588. scrollbar = $('<div class="xdsoft_scrollbar"></div>');
  589. scroller = $('<div class="xdsoft_scroller"></div>');
  590. scrollbar.append(scroller);
  591. timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
  592. calcOffset = function calcOffset(event) {
  593. var offset = pointerEventToXY(event).y - startY + startTopScroll;
  594. if (offset < 0) {
  595. offset = 0;
  596. }
  597. if (offset + scroller[0].offsetHeight > h1) {
  598. offset = h1 - scroller[0].offsetHeight;
  599. }
  600. timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
  601. };
  602. scroller
  603. .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
  604. if (!parentHeight) {
  605. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  606. }
  607. startY = pointerEventToXY(event).y;
  608. startTopScroll = parseInt(scroller.css('margin-top'), 10);
  609. h1 = scrollbar[0].offsetHeight;
  610. if (event.type === 'mousedown') {
  611. if (document) {
  612. $(document.body).addClass('xdsoft_noselect');
  613. }
  614. $([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
  615. $([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
  616. .off('mousemove.xdsoft_scroller', calcOffset)
  617. .removeClass('xdsoft_noselect');
  618. });
  619. $(document.body).on('mousemove.xdsoft_scroller', calcOffset);
  620. } else {
  621. touchStart = true;
  622. event.stopPropagation();
  623. event.preventDefault();
  624. }
  625. })
  626. .on('touchmove', function (event) {
  627. if (touchStart) {
  628. event.preventDefault();
  629. calcOffset(event);
  630. }
  631. })
  632. .on('touchend touchcancel', function (event) {
  633. touchStart = false;
  634. startTopScroll = 0;
  635. });
  636. timeboxparent
  637. .on('scroll_element.xdsoft_scroller', function (event, percentage) {
  638. if (!parentHeight) {
  639. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
  640. }
  641. percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
  642. scroller.css('margin-top', maximumOffset * percentage);
  643. setTimeout(function () {
  644. timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
  645. }, 10);
  646. })
  647. .on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
  648. var percent, sh;
  649. parentHeight = timeboxparent[0].clientHeight;
  650. height = timebox[0].offsetHeight;
  651. percent = parentHeight / height;
  652. sh = percent * scrollbar[0].offsetHeight;
  653. if (percent > 1) {
  654. scroller.hide();
  655. } else {
  656. scroller.show();
  657. scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
  658. maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
  659. if (noTriggerScroll !== true) {
  660. timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
  661. }
  662. }
  663. });
  664. timeboxparent.on('mousewheel', function (event) {
  665. var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  666. top = top - (event.deltaY * 20);
  667. if (top < 0) {
  668. top = 0;
  669. }
  670. timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
  671. event.stopPropagation();
  672. return false;
  673. });
  674. timeboxparent.on('touchstart', function (event) {
  675. start = pointerEventToXY(event);
  676. startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
  677. });
  678. timeboxparent.on('touchmove', function (event) {
  679. if (start) {
  680. event.preventDefault();
  681. var coord = pointerEventToXY(event);
  682. timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
  683. }
  684. });
  685. timeboxparent.on('touchend touchcancel', function (event) {
  686. start = false;
  687. startTop = 0;
  688. });
  689. }
  690. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  691. });
  692. };
  693. $.fn.datetimepicker = function (opt) {
  694. var KEY0 = 48,
  695. KEY9 = 57,
  696. _KEY0 = 96,
  697. _KEY9 = 105,
  698. CTRLKEY = 17,
  699. DEL = 46,
  700. ENTER = 13,
  701. ESC = 27,
  702. BACKSPACE = 8,
  703. ARROWLEFT = 37,
  704. ARROWUP = 38,
  705. ARROWRIGHT = 39,
  706. ARROWDOWN = 40,
  707. TAB = 9,
  708. F5 = 116,
  709. AKEY = 65,
  710. CKEY = 67,
  711. VKEY = 86,
  712. ZKEY = 90,
  713. YKEY = 89,
  714. ctrlDown = false,
  715. options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
  716. lazyInitTimer = 0,
  717. createDateTimePicker,
  718. destroyDateTimePicker,
  719. lazyInit = function (input) {
  720. input
  721. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
  722. if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
  723. return;
  724. }
  725. clearTimeout(lazyInitTimer);
  726. lazyInitTimer = setTimeout(function () {
  727. if (!input.data('xdsoft_datetimepicker')) {
  728. createDateTimePicker(input);
  729. }
  730. input
  731. .off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
  732. .trigger('open.xdsoft');
  733. }, 100);
  734. });
  735. };
  736. createDateTimePicker = function (input) {
  737. var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
  738. xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
  739. datepicker = $('<div class="xdsoft_datepicker active"></div>'),
  740. mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
  741. '<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
  742. '<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
  743. '<button type="button" class="xdsoft_next"></button></div>'),
  744. calendar = $('<div class="xdsoft_calendar"></div>'),
  745. 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>'),
  746. timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
  747. timebox = $('<div class="xdsoft_time_variant"></div>'),
  748. applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
  749. /*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
  750. scroller = $('<div class="xdsoft_scroller"></div>'),*/
  751. monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
  752. yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
  753. triggerAfterOpen = false,
  754. XDSoft_datetime,
  755. //scroll_element,
  756. xchangeTimer,
  757. timerclick,
  758. current_time_index,
  759. setPos,
  760. timer = 0,
  761. timer1 = 0,
  762. _xdsoft_datetime;
  763. if (options.id) {
  764. datetimepicker.attr('id', options.id);
  765. }
  766. if (options.style) {
  767. datetimepicker.attr('style', options.style);
  768. }
  769. if (options.weeks) {
  770. datetimepicker.addClass('xdsoft_showweeks');
  771. }
  772. datetimepicker.addClass('xdsoft_' + options.theme);
  773. datetimepicker.addClass(options.className);
  774. mounth_picker
  775. .find('.xdsoft_month span')
  776. .after(monthselect);
  777. mounth_picker
  778. .find('.xdsoft_year span')
  779. .after(yearselect);
  780. mounth_picker
  781. .find('.xdsoft_month,.xdsoft_year')
  782. .on('mousedown.xdsoft', function (event) {
  783. var select = $(this).find('.xdsoft_select').eq(0),
  784. val = 0,
  785. top = 0,
  786. visible = select.is(':visible'),
  787. items,
  788. i;
  789. mounth_picker
  790. .find('.xdsoft_select')
  791. .hide();
  792. if (_xdsoft_datetime.currentTime) {
  793. val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
  794. }
  795. select[visible ? 'hide' : 'show']();
  796. for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
  797. if (items.eq(i).data('value') === val) {
  798. break;
  799. } else {
  800. top += items[0].offsetHeight;
  801. }
  802. }
  803. select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
  804. event.stopPropagation();
  805. return false;
  806. });
  807. mounth_picker
  808. .find('.xdsoft_select')
  809. .xdsoftScroller()
  810. .on('mousedown.xdsoft', function (event) {
  811. event.stopPropagation();
  812. event.preventDefault();
  813. })
  814. .on('mousedown.xdsoft', '.xdsoft_option', function (event) {
  815. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  816. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  817. }
  818. var year = _xdsoft_datetime.currentTime.getFullYear();
  819. if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
  820. _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
  821. }
  822. $(this).parent().parent().hide();
  823. datetimepicker.trigger('xchange.xdsoft');
  824. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  825. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  826. }
  827. if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  828. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  829. }
  830. });
  831. datetimepicker.setOptions = function (_options) {
  832. var highlightedDates = {},
  833. getCaretPos = function (input) {
  834. try {
  835. if (document.selection && document.selection.createRange) {
  836. var range = document.selection.createRange();
  837. return range.getBookmark().charCodeAt(2) - 2;
  838. }
  839. if (input.setSelectionRange) {
  840. return input.selectionStart;
  841. }
  842. } catch (e) {
  843. return 0;
  844. }
  845. },
  846. setCaretPos = function (node, pos) {
  847. node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
  848. if (!node) {
  849. return false;
  850. }
  851. if (node.createTextRange) {
  852. var textRange = node.createTextRange();
  853. textRange.collapse(true);
  854. textRange.moveEnd('character', pos);
  855. textRange.moveStart('character', pos);
  856. textRange.select();
  857. return true;
  858. }
  859. if (node.setSelectionRange) {
  860. node.setSelectionRange(pos, pos);
  861. return true;
  862. }
  863. return false;
  864. },
  865. isValidValue = function (mask, value) {
  866. var reg = mask
  867. .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
  868. .replace(/_/g, '{digit+}')
  869. .replace(/([0-9]{1})/g, '{digit$1}')
  870. .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
  871. .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
  872. return (new RegExp(reg)).test(value);
  873. };
  874. options = $.extend(true, {}, options, _options);
  875. if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
  876. options.allowTimes = $.extend(true, [], _options.allowTimes);
  877. }
  878. if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
  879. options.weekends = $.extend(true, [], _options.weekends);
  880. }
  881. if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
  882. $.each(_options.highlightedDates, function (index, value) {
  883. var splitData = $.map(value.split(','), $.trim),
  884. exDesc,
  885. hDate = new HighlightedDate(Date.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
  886. keyDate = hDate.date.dateFormat(options.formatDate);
  887. if (highlightedDates[keyDate] !== undefined) {
  888. exDesc = highlightedDates[keyDate].desc;
  889. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  890. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  891. }
  892. } else {
  893. highlightedDates[keyDate] = hDate;
  894. }
  895. });
  896. options.highlightedDates = $.extend(true, [], highlightedDates);
  897. }
  898. if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
  899. highlightedDates = $.extend(true, [], options.highlightedDates);
  900. $.each(_options.highlightedPeriods, function (index, value) {
  901. var splitData = $.map(value.split(','), $.trim),
  902. dateTest = Date.parseDate(splitData[0], options.formatDate), // start date
  903. dateEnd = Date.parseDate(splitData[1], options.formatDate),
  904. desc = splitData[2],
  905. hDate,
  906. keyDate,
  907. exDesc,
  908. style = splitData[3];
  909. while (dateTest <= dateEnd) {
  910. hDate = new HighlightedDate(dateTest, desc, style);
  911. keyDate = dateTest.dateFormat(options.formatDate);
  912. dateTest.setDate(dateTest.getDate() + 1);
  913. if (highlightedDates[keyDate] !== undefined) {
  914. exDesc = highlightedDates[keyDate].desc;
  915. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  916. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  917. }
  918. } else {
  919. highlightedDates[keyDate] = hDate;
  920. }
  921. }
  922. });
  923. options.highlightedDates = $.extend(true, [], highlightedDates);
  924. }
  925. if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
  926. options.disabledDates = $.extend(true, [], _options.disabledDates);
  927. }
  928. if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
  929. options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
  930. }
  931. if ((options.open || options.opened) && (!options.inline)) {
  932. input.trigger('open.xdsoft');
  933. }
  934. if (options.inline) {
  935. triggerAfterOpen = true;
  936. datetimepicker.addClass('xdsoft_inline');
  937. input.after(datetimepicker).hide();
  938. }
  939. if (options.inverseButton) {
  940. options.next = 'xdsoft_prev';
  941. options.prev = 'xdsoft_next';
  942. }
  943. if (options.datepicker) {
  944. datepicker.addClass('active');
  945. } else {
  946. datepicker.removeClass('active');
  947. }
  948. if (options.timepicker) {
  949. timepicker.addClass('active');
  950. } else {
  951. timepicker.removeClass('active');
  952. }
  953. if (options.value) {
  954. _xdsoft_datetime.setCurrentTime(options.value);
  955. if (input && input.val) {
  956. input.val(_xdsoft_datetime.str);
  957. }
  958. }
  959. if (isNaN(options.dayOfWeekStart)) {
  960. options.dayOfWeekStart = 0;
  961. } else {
  962. options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
  963. }
  964. if (!options.timepickerScrollbar) {
  965. timeboxparent.xdsoftScroller('hide');
  966. }
  967. if (options.minDate && /^-(.*)$/.test(options.minDate)) {
  968. options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
  969. }
  970. if (options.maxDate && /^\+(.*)$/.test(options.maxDate)) {
  971. options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
  972. }
  973. applyButton.toggle(options.showApplyButton);
  974. mounth_picker
  975. .find('.xdsoft_today_button')
  976. .css('visibility', !options.todayButton ? 'hidden' : 'visible');
  977. mounth_picker
  978. .find('.' + options.prev)
  979. .css('visibility', !options.prevButton ? 'hidden' : 'visible');
  980. mounth_picker
  981. .find('.' + options.next)
  982. .css('visibility', !options.nextButton ? 'hidden' : 'visible');
  983. if (options.mask) {
  984. input.off('keydown.xdsoft');
  985. if (options.mask === true) {
  986. options.mask = options.format
  987. .replace(/Y/g, '9999')
  988. .replace(/F/g, '9999')
  989. .replace(/m/g, '19')
  990. .replace(/d/g, '39')
  991. .replace(/H/g, '29')
  992. .replace(/i/g, '59')
  993. .replace(/s/g, '59');
  994. }
  995. if ($.type(options.mask) === 'string') {
  996. if (!isValidValue(options.mask, input.val())) {
  997. input.val(options.mask.replace(/[0-9]/g, '_'));
  998. }
  999. input.on('keydown.xdsoft', function (event) {
  1000. var val = this.value,
  1001. key = event.which,
  1002. pos,
  1003. digit;
  1004. if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
  1005. pos = getCaretPos(this);
  1006. digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
  1007. if ((key === BACKSPACE || key === DEL) && pos) {
  1008. pos -= 1;
  1009. digit = '_';
  1010. }
  1011. while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  1012. pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
  1013. }
  1014. val = val.substr(0, pos) + digit + val.substr(pos + 1);
  1015. if ($.trim(val) === '') {
  1016. val = options.mask.replace(/[0-9]/g, '_');
  1017. } else {
  1018. if (pos === options.mask.length) {
  1019. event.preventDefault();
  1020. return false;
  1021. }
  1022. }
  1023. pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
  1024. while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  1025. pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
  1026. }
  1027. if (isValidValue(options.mask, val)) {
  1028. this.value = val;
  1029. setCaretPos(this, pos);
  1030. } else if ($.trim(val) === '') {
  1031. this.value = options.mask.replace(/[0-9]/g, '_');
  1032. } else {
  1033. input.trigger('error_input.xdsoft');
  1034. }
  1035. } else {
  1036. if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
  1037. return true;
  1038. }
  1039. }
  1040. event.preventDefault();
  1041. return false;
  1042. });
  1043. }
  1044. }
  1045. if (options.validateOnBlur) {
  1046. input
  1047. .off('blur.xdsoft')
  1048. .on('blur.xdsoft', function () {
  1049. if (options.allowBlank && !$.trim($(this).val()).length) {
  1050. $(this).val(null);
  1051. datetimepicker.data('xdsoft_datetime').empty();
  1052. } else if (!Date.parseDate($(this).val(), options.format)) {
  1053. var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
  1054. splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
  1055. // parse the numbers as 0312 => 03:12
  1056. if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
  1057. $(this).val([splittedHours, splittedMinutes].map(function (item) {
  1058. return item > 9 ? item : '0' + item;
  1059. }).join(':'));
  1060. } else {
  1061. $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
  1062. }
  1063. datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1064. } else {
  1065. datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1066. }
  1067. datetimepicker.trigger('changedatetime.xdsoft');
  1068. });
  1069. }
  1070. options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
  1071. datetimepicker
  1072. .trigger('xchange.xdsoft')
  1073. .trigger('afterOpen.xdsoft');
  1074. };
  1075. datetimepicker
  1076. .data('options', options)
  1077. .on('mousedown.xdsoft', function (event) {
  1078. event.stopPropagation();
  1079. event.preventDefault();
  1080. yearselect.hide();
  1081. monthselect.hide();
  1082. return false;
  1083. });
  1084. //scroll_element = timepicker.find('.xdsoft_time_box');
  1085. timeboxparent.append(timebox);
  1086. timeboxparent.xdsoftScroller();
  1087. datetimepicker.on('afterOpen.xdsoft', function () {
  1088. timeboxparent.xdsoftScroller();
  1089. });
  1090. datetimepicker
  1091. .append(datepicker)
  1092. .append(timepicker);
  1093. if (options.withoutCopyright !== true) {
  1094. datetimepicker
  1095. .append(xdsoft_copyright);
  1096. }
  1097. datepicker
  1098. .append(mounth_picker)
  1099. .append(calendar)
  1100. .append(applyButton);
  1101. $(options.parentID)
  1102. .append(datetimepicker);
  1103. XDSoft_datetime = function () {
  1104. var _this = this;
  1105. _this.now = function (norecursion) {
  1106. var d = new Date(),
  1107. date,
  1108. time;
  1109. if (!norecursion && options.defaultDate) {
  1110. date = _this.strToDateTime(options.defaultDate);
  1111. d.setFullYear(date.getFullYear());
  1112. d.setMonth(date.getMonth());
  1113. d.setDate(date.getDate());
  1114. }
  1115. if (options.yearOffset) {
  1116. d.setFullYear(d.getFullYear() + options.yearOffset);
  1117. }
  1118. if (!norecursion && options.defaultTime) {
  1119. time = _this.strtotime(options.defaultTime);
  1120. d.setHours(time.getHours());
  1121. d.setMinutes(time.getMinutes());
  1122. }
  1123. return d;
  1124. };
  1125. _this.isValidDate = function (d) {
  1126. if (Object.prototype.toString.call(d) !== "[object Date]") {
  1127. return false;
  1128. }
  1129. return !isNaN(d.getTime());
  1130. };
  1131. _this.setCurrentTime = function (dTime) {
  1132. _this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
  1133. datetimepicker.trigger('xchange.xdsoft');
  1134. };
  1135. _this.empty = function () {
  1136. _this.currentTime = null;
  1137. };
  1138. _this.getCurrentTime = function (dTime) {
  1139. return _this.currentTime;
  1140. };
  1141. _this.nextMonth = function () {
  1142. if (_this.currentTime === undefined || _this.currentTime === null) {
  1143. _this.currentTime = _this.now();
  1144. }
  1145. var month = _this.currentTime.getMonth() + 1,
  1146. year;
  1147. if (month === 12) {
  1148. _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
  1149. month = 0;
  1150. }
  1151. year = _this.currentTime.getFullYear();
  1152. _this.currentTime.setDate(
  1153. Math.min(
  1154. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1155. _this.currentTime.getDate()
  1156. )
  1157. );
  1158. _this.currentTime.setMonth(month);
  1159. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1160. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1161. }
  1162. if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1163. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1164. }
  1165. datetimepicker.trigger('xchange.xdsoft');
  1166. return month;
  1167. };
  1168. _this.prevMonth = function () {
  1169. if (_this.currentTime === undefined || _this.currentTime === null) {
  1170. _this.currentTime = _this.now();
  1171. }
  1172. var month = _this.currentTime.getMonth() - 1;
  1173. if (month === -1) {
  1174. _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
  1175. month = 11;
  1176. }
  1177. _this.currentTime.setDate(
  1178. Math.min(
  1179. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1180. _this.currentTime.getDate()
  1181. )
  1182. );
  1183. _this.currentTime.setMonth(month);
  1184. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1185. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1186. }
  1187. datetimepicker.trigger('xchange.xdsoft');
  1188. return month;
  1189. };
  1190. _this.getWeekOfYear = function (datetime) {
  1191. var onejan = new Date(datetime.getFullYear(), 0, 1);
  1192. return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
  1193. };
  1194. _this.strToDateTime = function (sDateTime) {
  1195. var tmpDate = [], timeOffset, currentTime;
  1196. if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
  1197. return sDateTime;
  1198. }
  1199. tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
  1200. if (tmpDate) {
  1201. tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
  1202. }
  1203. if (tmpDate && tmpDate[2]) {
  1204. timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
  1205. currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
  1206. } else {
  1207. currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
  1208. }
  1209. if (!_this.isValidDate(currentTime)) {
  1210. currentTime = _this.now();
  1211. }
  1212. return currentTime;
  1213. };
  1214. _this.strToDate = function (sDate) {
  1215. if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
  1216. return sDate;
  1217. }
  1218. var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
  1219. if (!_this.isValidDate(currentTime)) {
  1220. currentTime = _this.now(true);
  1221. }
  1222. return currentTime;
  1223. };
  1224. _this.strtotime = function (sTime) {
  1225. if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
  1226. return sTime;
  1227. }
  1228. var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
  1229. if (!_this.isValidDate(currentTime)) {
  1230. currentTime = _this.now(true);
  1231. }
  1232. return currentTime;
  1233. };
  1234. _this.str = function () {
  1235. return _this.currentTime.dateFormat(options.format);
  1236. };
  1237. _this.currentTime = this.now();
  1238. };
  1239. _xdsoft_datetime = new XDSoft_datetime();
  1240. applyButton.on('click', function (e) {//pathbrite
  1241. e.preventDefault();
  1242. datetimepicker.data('changed', true);
  1243. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1244. input.val(_xdsoft_datetime.str());
  1245. datetimepicker.trigger('close.xdsoft');
  1246. });
  1247. mounth_picker
  1248. .find('.xdsoft_today_button')
  1249. .on('mousedown.xdsoft', function () {
  1250. datetimepicker.data('changed', true);
  1251. _xdsoft_datetime.setCurrentTime(0);
  1252. datetimepicker.trigger('afterOpen.xdsoft');
  1253. }).on('dblclick.xdsoft', function () {
  1254. var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
  1255. currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
  1256. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1257. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1258. if (currentDate < minDate) {
  1259. return;
  1260. }
  1261. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1262. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
  1263. if (currentDate > maxDate) {
  1264. return;
  1265. }
  1266. input.val(_xdsoft_datetime.str());
  1267. datetimepicker.trigger('close.xdsoft');
  1268. });
  1269. mounth_picker
  1270. .find('.xdsoft_prev,.xdsoft_next')
  1271. .on('mousedown.xdsoft', function () {
  1272. var $this = $(this),
  1273. timer = 0,
  1274. stop = false;
  1275. (function arguments_callee1(v) {
  1276. if ($this.hasClass(options.next)) {
  1277. _xdsoft_datetime.nextMonth();
  1278. } else if ($this.hasClass(options.prev)) {
  1279. _xdsoft_datetime.prevMonth();
  1280. }
  1281. if (options.monthChangeSpinner) {
  1282. if (!stop) {
  1283. timer = setTimeout(arguments_callee1, v || 100);
  1284. }
  1285. }
  1286. }(500));
  1287. $([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
  1288. clearTimeout(timer);
  1289. stop = true;
  1290. $([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
  1291. });
  1292. });
  1293. timepicker
  1294. .find('.xdsoft_prev,.xdsoft_next')
  1295. .on('mousedown.xdsoft', function () {
  1296. var $this = $(this),
  1297. timer = 0,
  1298. stop = false,
  1299. period = 110;
  1300. (function arguments_callee4(v) {
  1301. var pheight = timeboxparent[0].clientHeight,
  1302. height = timebox[0].offsetHeight,
  1303. top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  1304. if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
  1305. timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
  1306. } else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
  1307. timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
  1308. }
  1309. timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
  1310. period = (period > 10) ? 10 : period - 10;
  1311. if (!stop) {
  1312. timer = setTimeout(arguments_callee4, v || period);
  1313. }
  1314. }(500));
  1315. $([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
  1316. clearTimeout(timer);
  1317. stop = true;
  1318. $([document.body, window])
  1319. .off('mouseup.xdsoft', arguments_callee5);
  1320. });
  1321. });
  1322. xchangeTimer = 0;
  1323. // base handler - generating a calendar and timepicker
  1324. datetimepicker
  1325. .on('xchange.xdsoft', function (event) {
  1326. clearTimeout(xchangeTimer);
  1327. xchangeTimer = setTimeout(function () {
  1328. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1329. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1330. }
  1331. var table = '',
  1332. start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
  1333. i = 0,
  1334. j,
  1335. today = _xdsoft_datetime.now(),
  1336. maxDate = false,
  1337. minDate = false,
  1338. hDate,
  1339. day,
  1340. d,
  1341. y,
  1342. m,
  1343. w,
  1344. classes = [],
  1345. customDateSettings,
  1346. newRow = true,
  1347. time = '',
  1348. h = '',
  1349. line_time,
  1350. description;
  1351. while (start.getDay() !== options.dayOfWeekStart) {
  1352. start.setDate(start.getDate() - 1);
  1353. }
  1354. table += '<table><thead><tr>';
  1355. if (options.weeks) {
  1356. table += '<th></th>';
  1357. }
  1358. for (j = 0; j < 7; j += 1) {
  1359. table += '<th>' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + '</th>';
  1360. }
  1361. table += '</tr></thead>';
  1362. table += '<tbody>';
  1363. if (options.maxDate !== false) {
  1364. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1365. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
  1366. }
  1367. if (options.minDate !== false) {
  1368. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1369. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1370. }
  1371. while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
  1372. classes = [];
  1373. i += 1;
  1374. day = start.getDay();
  1375. d = start.getDate();
  1376. y = start.getFullYear();
  1377. m = start.getMonth();
  1378. w = _xdsoft_datetime.getWeekOfYear(start);
  1379. description = '';
  1380. classes.push('xdsoft_date');
  1381. if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
  1382. customDateSettings = options.beforeShowDay.call(datetimepicker, start);
  1383. } else {
  1384. customDateSettings = null;
  1385. }
  1386. if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
  1387. classes.push('xdsoft_disabled');
  1388. } else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
  1389. classes.push('xdsoft_disabled');
  1390. } else if (options.disabledWeekDays.indexOf(day) !== -1) {
  1391. classes.push('xdsoft_disabled');
  1392. }
  1393. if (customDateSettings && customDateSettings[1] !== "") {
  1394. classes.push(customDateSettings[1]);
  1395. }
  1396. if (_xdsoft_datetime.currentTime.getMonth() !== m) {
  1397. classes.push('xdsoft_other_month');
  1398. }
  1399. if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
  1400. classes.push('xdsoft_current');
  1401. }
  1402. if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
  1403. classes.push('xdsoft_today');
  1404. }
  1405. if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) !== -1) {
  1406. classes.push('xdsoft_weekend');
  1407. }
  1408. if (options.highlightedDates[start.dateFormat(options.formatDate)] !== undefined) {
  1409. hDate = options.highlightedDates[start.dateFormat(options.formatDate)];
  1410. classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
  1411. description = hDate.desc === undefined ? '' : hDate.desc;
  1412. }
  1413. if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
  1414. classes.push(options.beforeShowDay(start));
  1415. }
  1416. if (newRow) {
  1417. table += '<tr>';
  1418. newRow = false;
  1419. if (options.weeks) {
  1420. table += '<th>' + w + '</th>';
  1421. }
  1422. }
  1423. table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
  1424. '<div>' + d + '</div>' +
  1425. '</td>';
  1426. if (start.getDay() === options.dayOfWeekStartPrev) {
  1427. table += '</tr>';
  1428. newRow = true;
  1429. }
  1430. start.setDate(d + 1);
  1431. }
  1432. table += '</tbody></table>';
  1433. calendar.html(table);
  1434. mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
  1435. mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
  1436. // generate timebox
  1437. time = '';
  1438. h = '';
  1439. m = '';
  1440. line_time = function line_time(h, m) {
  1441. var now = _xdsoft_datetime.now(), optionDateTime, current_time;
  1442. now.setHours(h);
  1443. h = parseInt(now.getHours(), 10);
  1444. now.setMinutes(m);
  1445. m = parseInt(now.getMinutes(), 10);
  1446. optionDateTime = new Date(_xdsoft_datetime.currentTime);
  1447. optionDateTime.setHours(h);
  1448. optionDateTime.setMinutes(m);
  1449. classes = [];
  1450. 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())) {
  1451. classes.push('xdsoft_disabled');
  1452. }
  1453. 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()))) {
  1454. classes.push('xdsoft_disabled');
  1455. }
  1456. current_time = new Date(_xdsoft_datetime.currentTime);
  1457. current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
  1458. current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
  1459. if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && (options.step > 59 || current_time.getMinutes() === parseInt(m, 10))) {
  1460. if (options.defaultSelect || datetimepicker.data('changed')) {
  1461. classes.push('xdsoft_current');
  1462. } else if (options.initTime) {
  1463. classes.push('xdsoft_init_time');
  1464. }
  1465. }
  1466. if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
  1467. classes.push('xdsoft_today');
  1468. }
  1469. time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + now.dateFormat(options.formatTime) + '</div>';
  1470. };
  1471. if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
  1472. for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
  1473. for (j = 0; j < 60; j += options.step) {
  1474. h = (i < 10 ? '0' : '') + i;
  1475. m = (j < 10 ? '0' : '') + j;
  1476. line_time(h, m);
  1477. }
  1478. }
  1479. } else {
  1480. for (i = 0; i < options.allowTimes.length; i += 1) {
  1481. h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
  1482. m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
  1483. line_time(h, m);
  1484. }
  1485. }
  1486. timebox.html(time);
  1487. opt = '';
  1488. i = 0;
  1489. for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
  1490. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + i + '</div>';
  1491. }
  1492. yearselect.children().eq(0)
  1493. .html(opt);
  1494. for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
  1495. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[options.lang].months[i] + '</div>';
  1496. }
  1497. monthselect.children().eq(0).html(opt);
  1498. $(datetimepicker)
  1499. .trigger('generate.xdsoft');
  1500. }, 10);
  1501. event.stopPropagation();
  1502. })
  1503. .on('afterOpen.xdsoft', function () {
  1504. if (options.timepicker) {
  1505. var classType, pheight, height, top;
  1506. if (timebox.find('.xdsoft_current').length) {
  1507. classType = '.xdsoft_current';
  1508. } else if (timebox.find('.xdsoft_init_time').length) {
  1509. classType = '.xdsoft_init_time';
  1510. }
  1511. if (classType) {
  1512. pheight = timeboxparent[0].clientHeight;
  1513. height = timebox[0].offsetHeight;
  1514. top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
  1515. if ((height - pheight) < top) {
  1516. top = height - pheight;
  1517. }
  1518. timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
  1519. } else {
  1520. timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
  1521. }
  1522. }
  1523. });
  1524. timerclick = 0;
  1525. calendar
  1526. .on('click.xdsoft', 'td', function (xdevent) {
  1527. xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
  1528. timerclick += 1;
  1529. var $this = $(this),
  1530. currentTime = _xdsoft_datetime.currentTime;
  1531. if (currentTime === undefined || currentTime === null) {
  1532. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1533. currentTime = _xdsoft_datetime.currentTime;
  1534. }
  1535. if ($this.hasClass('xdsoft_disabled')) {
  1536. return false;
  1537. }
  1538. currentTime.setDate(1);
  1539. currentTime.setFullYear($this.data('year'));
  1540. currentTime.setMonth($this.data('month'));
  1541. currentTime.setDate($this.data('date'));
  1542. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1543. input.val(_xdsoft_datetime.str());
  1544. if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
  1545. datetimepicker.trigger('close.xdsoft');
  1546. }
  1547. if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
  1548. options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1549. }
  1550. datetimepicker.data('changed', true);
  1551. datetimepicker.trigger('xchange.xdsoft');
  1552. datetimepicker.trigger('changedatetime.xdsoft');
  1553. setTimeout(function () {
  1554. timerclick = 0;
  1555. }, 200);
  1556. });
  1557. timebox
  1558. .on('click.xdsoft', 'div', function (xdevent) {
  1559. xdevent.stopPropagation();
  1560. var $this = $(this),
  1561. currentTime = _xdsoft_datetime.currentTime;
  1562. if (currentTime === undefined || currentTime === null) {
  1563. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1564. currentTime = _xdsoft_datetime.currentTime;
  1565. }
  1566. if ($this.hasClass('xdsoft_disabled')) {
  1567. return false;
  1568. }
  1569. currentTime.setHours($this.data('hour'));
  1570. currentTime.setMinutes($this.data('minute'));
  1571. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1572. datetimepicker.data('input').val(_xdsoft_datetime.str());
  1573. if (options.inline !== true && options.closeOnTimeSelect === true) {
  1574. datetimepicker.trigger('close.xdsoft');
  1575. }
  1576. if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
  1577. options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1578. }
  1579. datetimepicker.data('changed', true);
  1580. datetimepicker.trigger('xchange.xdsoft');
  1581. datetimepicker.trigger('changedatetime.xdsoft');
  1582. });
  1583. datepicker
  1584. .on('mousewheel.xdsoft', function (event) {
  1585. if (!options.scrollMonth) {
  1586. return true;
  1587. }
  1588. if (event.deltaY < 0) {
  1589. _xdsoft_datetime.nextMonth();
  1590. } else {
  1591. _xdsoft_datetime.prevMonth();
  1592. }
  1593. return false;
  1594. });
  1595. input
  1596. .on('mousewheel.xdsoft', function (event) {
  1597. if (!options.scrollInput) {
  1598. return true;
  1599. }
  1600. if (!options.datepicker && options.timepicker) {
  1601. current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
  1602. if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
  1603. current_time_index += event.deltaY;
  1604. }
  1605. if (timebox.children().eq(current_time_index).length) {
  1606. timebox.children().eq(current_time_index).trigger('mousedown');
  1607. }
  1608. return false;
  1609. }
  1610. if (options.datepicker && !options.timepicker) {
  1611. datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
  1612. if (input.val) {
  1613. input.val(_xdsoft_datetime.str());
  1614. }
  1615. datetimepicker.trigger('changedatetime.xdsoft');
  1616. return false;
  1617. }
  1618. });
  1619. datetimepicker
  1620. .on('changedatetime.xdsoft', function (event) {
  1621. if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
  1622. var $input = datetimepicker.data('input');
  1623. options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
  1624. delete options.value;
  1625. $input.trigger('change');
  1626. }
  1627. })
  1628. .on('generate.xdsoft', function () {
  1629. if (options.onGenerate && $.isFunction(options.onGenerate)) {
  1630. options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1631. }
  1632. if (triggerAfterOpen) {
  1633. datetimepicker.trigger('afterOpen.xdsoft');
  1634. triggerAfterOpen = false;
  1635. }
  1636. })
  1637. .on('click.xdsoft', function (xdevent) {
  1638. xdevent.stopPropagation();
  1639. });
  1640. current_time_index = 0;
  1641. setPos = function () {
  1642. var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute", node;
  1643. if (options.fixed) {
  1644. top -= $(window).scrollTop();
  1645. left -= $(window).scrollLeft();
  1646. position = "fixed";
  1647. } else {
  1648. if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
  1649. top = offset.top - datetimepicker[0].offsetHeight + 1;
  1650. }
  1651. if (top < 0) {
  1652. top = 0;
  1653. }
  1654. if (left + datetimepicker[0].offsetWidth > $(window).width()) {
  1655. left = $(window).width() - datetimepicker[0].offsetWidth;
  1656. }
  1657. }
  1658. node = datetimepicker[0];
  1659. do {
  1660. node = node.parentNode;
  1661. if (window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
  1662. left = left - (($(window).width() - node.offsetWidth) / 2);
  1663. break;
  1664. }
  1665. } while (node.nodeName !== 'HTML');
  1666. datetimepicker.css({
  1667. left: left,
  1668. top: top,
  1669. position: position
  1670. });
  1671. };
  1672. datetimepicker
  1673. .on('open.xdsoft', function (event) {
  1674. var onShow = true;
  1675. if (options.onShow && $.isFunction(options.onShow)) {
  1676. onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1677. }
  1678. if (onShow !== false) {
  1679. datetimepicker.show();
  1680. setPos();
  1681. $(window)
  1682. .off('resize.xdsoft', setPos)
  1683. .on('resize.xdsoft', setPos);
  1684. if (options.closeOnWithoutClick) {
  1685. $([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
  1686. datetimepicker.trigger('close.xdsoft');
  1687. $([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
  1688. });
  1689. }
  1690. }
  1691. })
  1692. .on('close.xdsoft', function (event) {
  1693. var onClose = true;
  1694. mounth_picker
  1695. .find('.xdsoft_month,.xdsoft_year')
  1696. .find('.xdsoft_select')
  1697. .hide();
  1698. if (options.onClose && $.isFunction(options.onClose)) {
  1699. onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1700. }
  1701. if (onClose !== false && !options.opened && !options.inline) {
  1702. datetimepicker.hide();
  1703. }
  1704. event.stopPropagation();
  1705. })
  1706. .on('toggle.xdsoft', function (event) {
  1707. if (datetimepicker.is(':visible')) {
  1708. datetimepicker.trigger('close.xdsoft');
  1709. } else {
  1710. datetimepicker.trigger('open.xdsoft');
  1711. }
  1712. })
  1713. .data('input', input);
  1714. timer = 0;
  1715. timer1 = 0;
  1716. datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
  1717. datetimepicker.setOptions(options);
  1718. function getCurrentValue() {
  1719. var ct = false, time;
  1720. if (options.startDate) {
  1721. ct = _xdsoft_datetime.strToDate(options.startDate);
  1722. } else {
  1723. ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
  1724. if (ct) {
  1725. ct = _xdsoft_datetime.strToDateTime(ct);
  1726. } else if (options.defaultDate) {
  1727. ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
  1728. if (options.defaultTime) {
  1729. time = _xdsoft_datetime.strtotime(options.defaultTime);
  1730. ct.setHours(time.getHours());
  1731. ct.setMinutes(time.getMinutes());
  1732. }
  1733. }
  1734. }
  1735. if (ct && _xdsoft_datetime.isValidDate(ct)) {
  1736. datetimepicker.data('changed', true);
  1737. } else {
  1738. ct = '';
  1739. }
  1740. return ct || 0;
  1741. }
  1742. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1743. input
  1744. .data('xdsoft_datetimepicker', datetimepicker)
  1745. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
  1746. if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
  1747. return;
  1748. }
  1749. clearTimeout(timer);
  1750. timer = setTimeout(function () {
  1751. if (input.is(':disabled')) {
  1752. return;
  1753. }
  1754. triggerAfterOpen = true;
  1755. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1756. datetimepicker.trigger('open.xdsoft');
  1757. }, 100);
  1758. })
  1759. .on('keydown.xdsoft', function (event) {
  1760. var val = this.value, elementSelector,
  1761. key = event.which;
  1762. if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
  1763. elementSelector = $("input:visible,textarea:visible");
  1764. datetimepicker.trigger('close.xdsoft');
  1765. elementSelector.eq(elementSelector.index(this) + 1).focus();
  1766. return false;
  1767. }
  1768. if ([TAB].indexOf(key) !== -1) {
  1769. datetimepicker.trigger('close.xdsoft');
  1770. return true;
  1771. }
  1772. });
  1773. };
  1774. destroyDateTimePicker = function (input) {
  1775. var datetimepicker = input.data('xdsoft_datetimepicker');
  1776. if (datetimepicker) {
  1777. datetimepicker.data('xdsoft_datetime', null);
  1778. datetimepicker.remove();
  1779. input
  1780. .data('xdsoft_datetimepicker', null)
  1781. .off('.xdsoft');
  1782. $(window).off('resize.xdsoft');
  1783. $([window, document.body]).off('mousedown.xdsoft');
  1784. if (input.unmousewheel) {
  1785. input.unmousewheel();
  1786. }
  1787. }
  1788. };
  1789. $(document)
  1790. .off('keydown.xdsoftctrl keyup.xdsoftctrl')
  1791. .on('keydown.xdsoftctrl', function (e) {
  1792. if (e.keyCode === CTRLKEY) {
  1793. ctrlDown = true;
  1794. }
  1795. })
  1796. .on('keyup.xdsoftctrl', function (e) {
  1797. if (e.keyCode === CTRLKEY) {
  1798. ctrlDown = false;
  1799. }
  1800. });
  1801. return this.each(function () {
  1802. var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
  1803. if (datetimepicker) {
  1804. if ($.type(opt) === 'string') {
  1805. switch (opt) {
  1806. case 'show':
  1807. $(this).select().focus();
  1808. datetimepicker.trigger('open.xdsoft');
  1809. break;
  1810. case 'hide':
  1811. datetimepicker.trigger('close.xdsoft');
  1812. break;
  1813. case 'toggle':
  1814. datetimepicker.trigger('toggle.xdsoft');
  1815. break;
  1816. case 'destroy':
  1817. destroyDateTimePicker($(this));
  1818. break;
  1819. case 'reset':
  1820. this.value = this.defaultValue;
  1821. if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
  1822. datetimepicker.data('changed', false);
  1823. }
  1824. datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
  1825. break;
  1826. case 'validate':
  1827. $input = datetimepicker.data('input');
  1828. $input.trigger('blur.xdsoft');
  1829. break;
  1830. }
  1831. } else {
  1832. datetimepicker
  1833. .setOptions(opt);
  1834. }
  1835. return 0;
  1836. }
  1837. if ($.type(opt) !== 'string') {
  1838. if (!options.lazyInit || options.open || options.inline) {
  1839. createDateTimePicker($(this));
  1840. } else {
  1841. lazyInit($(this));
  1842. }
  1843. }
  1844. });
  1845. };
  1846. $.fn.datetimepicker.defaults = default_options;
  1847. }(jQuery));
  1848. function HighlightedDate(date, desc, style) {
  1849. "use strict";
  1850. this.date = date;
  1851. this.desc = desc;
  1852. this.style = style;
  1853. }
  1854. (function () {
  1855. /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
  1856. * Licensed under the MIT License (LICENSE.txt).
  1857. *
  1858. * Version: 3.1.12
  1859. *
  1860. * Requires: jQuery 1.2.2+
  1861. */
  1862. !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});
  1863. // Parse and Format Library
  1864. //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
  1865. /*
  1866. * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
  1867. *
  1868. * This program is free software; you can redistribute it and/or modify it
  1869. * under the terms of the GNU Lesser General Public License as published by the
  1870. * Free Software Foundation, version 2.1.
  1871. *
  1872. * This program is distributed in the hope that it will be useful, but WITHOUT
  1873. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1874. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  1875. * details.
  1876. */
  1877. Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var codePrefix="Date.prototype."+funcName+" = function() {return ";var code="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}if(code.length==0){code="\"\"";}else{code=code.substring(0,code.length-3);}eval(codePrefix+code+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$",'i');eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};
  1878. }());