jquery.datetimepicker.js 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093
  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. rtl: false,
  447. format: 'Y/m/d H:i',
  448. formatTime: 'H:i',
  449. formatDate: 'Y/m/d',
  450. startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
  451. step: 60,
  452. monthChangeSpinner: true,
  453. closeOnDateSelect: false,
  454. closeOnTimeSelect: true,
  455. closeOnWithoutClick: true,
  456. closeOnInputClick: true,
  457. timepicker: true,
  458. datepicker: true,
  459. weeks: false,
  460. defaultTime: false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
  461. defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
  462. minDate: false,
  463. maxDate: false,
  464. minTime: false,
  465. maxTime: false,
  466. disabledMinTime: false,
  467. disabledMaxTime: false,
  468. allowTimes: [],
  469. opened: false,
  470. initTime: true,
  471. inline: false,
  472. theme: '',
  473. onSelectDate: function () {},
  474. onSelectTime: function () {},
  475. onChangeMonth: function () {},
  476. onChangeYear: function () {},
  477. onChangeDateTime: function () {},
  478. onShow: function () {},
  479. onClose: function () {},
  480. onGenerate: function () {},
  481. withoutCopyright: true,
  482. inverseButton: false,
  483. hours12: false,
  484. next: 'xdsoft_next',
  485. prev : 'xdsoft_prev',
  486. dayOfWeekStart: 0,
  487. parentID: 'body',
  488. timeHeightInTimePicker: 25,
  489. timepickerScrollbar: true,
  490. todayButton: true,
  491. prevButton: true,
  492. nextButton: true,
  493. defaultSelect: true,
  494. scrollMonth: true,
  495. scrollTime: true,
  496. scrollInput: true,
  497. lazyInit: false,
  498. mask: false,
  499. validateOnBlur: true,
  500. allowBlank: true,
  501. yearStart: 1950,
  502. yearEnd: 2050,
  503. monthStart: 0,
  504. monthEnd: 11,
  505. style: '',
  506. id: '',
  507. fixed: false,
  508. roundTime: 'round', // ceil, floor
  509. className: '',
  510. weekends: [],
  511. highlightedDates: [],
  512. highlightedPeriods: [],
  513. disabledDates : [],
  514. disabledWeekDays: [],
  515. yearOffset: 0,
  516. beforeShowDay: null,
  517. enterLikeTab: true,
  518. showApplyButton: false
  519. };
  520. // fix for ie8
  521. if (!window.getComputedStyle) {
  522. window.getComputedStyle = function (el, pseudo) {
  523. this.el = el;
  524. this.getPropertyValue = function (prop) {
  525. var re = /(\-([a-z]){1})/g;
  526. if (prop === 'float') {
  527. prop = 'styleFloat';
  528. }
  529. if (re.test(prop)) {
  530. prop = prop.replace(re, function (a, b, c) {
  531. return c.toUpperCase();
  532. });
  533. }
  534. return el.currentStyle[prop] || null;
  535. };
  536. return this;
  537. };
  538. }
  539. if (!Array.prototype.indexOf) {
  540. Array.prototype.indexOf = function (obj, start) {
  541. var i, j;
  542. for (i = (start || 0), j = this.length; i < j; i += 1) {
  543. if (this[i] === obj) { return i; }
  544. }
  545. return -1;
  546. };
  547. }
  548. Date.prototype.countDaysInMonth = function () {
  549. return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
  550. };
  551. $.fn.xdsoftScroller = function (percent) {
  552. return this.each(function () {
  553. var timeboxparent = $(this),
  554. pointerEventToXY = function (e) {
  555. var out = {x: 0, y: 0},
  556. touch;
  557. if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
  558. touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
  559. out.x = touch.clientX;
  560. out.y = touch.clientY;
  561. } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
  562. out.x = e.clientX;
  563. out.y = e.clientY;
  564. }
  565. return out;
  566. },
  567. move = 0,
  568. timebox,
  569. parentHeight,
  570. height,
  571. scrollbar,
  572. scroller,
  573. maximumOffset = 100,
  574. start = false,
  575. startY = 0,
  576. startTop = 0,
  577. h1 = 0,
  578. touchStart = false,
  579. startTopScroll = 0,
  580. calcOffset = function () {};
  581. if (percent === 'hide') {
  582. timeboxparent.find('.xdsoft_scrollbar').hide();
  583. return;
  584. }
  585. if (!$(this).hasClass('xdsoft_scroller_box')) {
  586. timebox = timeboxparent.children().eq(0);
  587. parentHeight = timeboxparent[0].clientHeight;
  588. height = timebox[0].offsetHeight;
  589. scrollbar = $('<div class="xdsoft_scrollbar"></div>');
  590. scroller = $('<div class="xdsoft_scroller"></div>');
  591. scrollbar.append(scroller);
  592. timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
  593. calcOffset = function calcOffset(event) {
  594. var offset = pointerEventToXY(event).y - startY + startTopScroll;
  595. if (offset < 0) {
  596. offset = 0;
  597. }
  598. if (offset + scroller[0].offsetHeight > h1) {
  599. offset = h1 - scroller[0].offsetHeight;
  600. }
  601. timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
  602. };
  603. scroller
  604. .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
  605. if (!parentHeight) {
  606. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  607. }
  608. startY = pointerEventToXY(event).y;
  609. startTopScroll = parseInt(scroller.css('margin-top'), 10);
  610. h1 = scrollbar[0].offsetHeight;
  611. if (event.type === 'mousedown') {
  612. if (document) {
  613. $(document.body).addClass('xdsoft_noselect');
  614. }
  615. $([document.body, window]).on('mouseup.xdsoft_scroller', function arguments_callee() {
  616. $([document.body, window]).off('mouseup.xdsoft_scroller', arguments_callee)
  617. .off('mousemove.xdsoft_scroller', calcOffset)
  618. .removeClass('xdsoft_noselect');
  619. });
  620. $(document.body).on('mousemove.xdsoft_scroller', calcOffset);
  621. } else {
  622. touchStart = true;
  623. event.stopPropagation();
  624. event.preventDefault();
  625. }
  626. })
  627. .on('touchmove', function (event) {
  628. if (touchStart) {
  629. event.preventDefault();
  630. calcOffset(event);
  631. }
  632. })
  633. .on('touchend touchcancel', function (event) {
  634. touchStart = false;
  635. startTopScroll = 0;
  636. });
  637. timeboxparent
  638. .on('scroll_element.xdsoft_scroller', function (event, percentage) {
  639. if (!parentHeight) {
  640. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
  641. }
  642. percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
  643. scroller.css('margin-top', maximumOffset * percentage);
  644. setTimeout(function () {
  645. timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
  646. }, 10);
  647. })
  648. .on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
  649. var percent, sh;
  650. parentHeight = timeboxparent[0].clientHeight;
  651. height = timebox[0].offsetHeight;
  652. percent = parentHeight / height;
  653. sh = percent * scrollbar[0].offsetHeight;
  654. if (percent > 1) {
  655. scroller.hide();
  656. } else {
  657. scroller.show();
  658. scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
  659. maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
  660. if (noTriggerScroll !== true) {
  661. timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
  662. }
  663. }
  664. });
  665. timeboxparent.on('mousewheel', function (event) {
  666. var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  667. top = top - (event.deltaY * 20);
  668. if (top < 0) {
  669. top = 0;
  670. }
  671. timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
  672. event.stopPropagation();
  673. return false;
  674. });
  675. timeboxparent.on('touchstart', function (event) {
  676. start = pointerEventToXY(event);
  677. startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
  678. });
  679. timeboxparent.on('touchmove', function (event) {
  680. if (start) {
  681. event.preventDefault();
  682. var coord = pointerEventToXY(event);
  683. timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
  684. }
  685. });
  686. timeboxparent.on('touchend touchcancel', function (event) {
  687. start = false;
  688. startTop = 0;
  689. });
  690. }
  691. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  692. });
  693. };
  694. $.fn.datetimepicker = function (opt) {
  695. var KEY0 = 48,
  696. KEY9 = 57,
  697. _KEY0 = 96,
  698. _KEY9 = 105,
  699. CTRLKEY = 17,
  700. DEL = 46,
  701. ENTER = 13,
  702. ESC = 27,
  703. BACKSPACE = 8,
  704. ARROWLEFT = 37,
  705. ARROWUP = 38,
  706. ARROWRIGHT = 39,
  707. ARROWDOWN = 40,
  708. TAB = 9,
  709. F5 = 116,
  710. AKEY = 65,
  711. CKEY = 67,
  712. VKEY = 86,
  713. ZKEY = 90,
  714. YKEY = 89,
  715. ctrlDown = false,
  716. options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
  717. lazyInitTimer = 0,
  718. createDateTimePicker,
  719. destroyDateTimePicker,
  720. lazyInit = function (input) {
  721. input
  722. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
  723. if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
  724. return;
  725. }
  726. clearTimeout(lazyInitTimer);
  727. lazyInitTimer = setTimeout(function () {
  728. if (!input.data('xdsoft_datetimepicker')) {
  729. createDateTimePicker(input);
  730. }
  731. input
  732. .off('open.xdsoft focusin.xdsoft mousedown.xdsoft', initOnActionCallback)
  733. .trigger('open.xdsoft');
  734. }, 100);
  735. });
  736. };
  737. createDateTimePicker = function (input) {
  738. var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
  739. xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
  740. datepicker = $('<div class="xdsoft_datepicker active"></div>'),
  741. mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
  742. '<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
  743. '<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
  744. '<button type="button" class="xdsoft_next"></button></div>'),
  745. calendar = $('<div class="xdsoft_calendar"></div>'),
  746. 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>'),
  747. timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
  748. timebox = $('<div class="xdsoft_time_variant"></div>'),
  749. applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
  750. /*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
  751. scroller = $('<div class="xdsoft_scroller"></div>'),*/
  752. monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
  753. yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
  754. triggerAfterOpen = false,
  755. XDSoft_datetime,
  756. //scroll_element,
  757. xchangeTimer,
  758. timerclick,
  759. current_time_index,
  760. setPos,
  761. timer = 0,
  762. timer1 = 0,
  763. _xdsoft_datetime;
  764. if (options.id) {
  765. datetimepicker.attr('id', options.id);
  766. }
  767. if (options.style) {
  768. datetimepicker.attr('style', options.style);
  769. }
  770. if (options.weeks) {
  771. datetimepicker.addClass('xdsoft_showweeks');
  772. }
  773. if (options.rtl) {
  774. datetimepicker.addClass('xdsoft_rtl');
  775. }
  776. datetimepicker.addClass('xdsoft_' + options.theme);
  777. datetimepicker.addClass(options.className);
  778. mounth_picker
  779. .find('.xdsoft_month span')
  780. .after(monthselect);
  781. mounth_picker
  782. .find('.xdsoft_year span')
  783. .after(yearselect);
  784. mounth_picker
  785. .find('.xdsoft_month,.xdsoft_year')
  786. .on('mousedown.xdsoft', function (event) {
  787. var select = $(this).find('.xdsoft_select').eq(0),
  788. val = 0,
  789. top = 0,
  790. visible = select.is(':visible'),
  791. items,
  792. i;
  793. mounth_picker
  794. .find('.xdsoft_select')
  795. .hide();
  796. if (_xdsoft_datetime.currentTime) {
  797. val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
  798. }
  799. select[visible ? 'hide' : 'show']();
  800. for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
  801. if (items.eq(i).data('value') === val) {
  802. break;
  803. } else {
  804. top += items[0].offsetHeight;
  805. }
  806. }
  807. select.xdsoftScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
  808. event.stopPropagation();
  809. return false;
  810. });
  811. mounth_picker
  812. .find('.xdsoft_select')
  813. .xdsoftScroller()
  814. .on('mousedown.xdsoft', function (event) {
  815. event.stopPropagation();
  816. event.preventDefault();
  817. })
  818. .on('mousedown.xdsoft', '.xdsoft_option', function (event) {
  819. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  820. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  821. }
  822. var year = _xdsoft_datetime.currentTime.getFullYear();
  823. if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
  824. _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
  825. }
  826. $(this).parent().parent().hide();
  827. datetimepicker.trigger('xchange.xdsoft');
  828. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  829. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  830. }
  831. if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  832. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  833. }
  834. });
  835. datetimepicker.setOptions = function (_options) {
  836. var highlightedDates = {},
  837. getCaretPos = function (input) {
  838. try {
  839. if (document.selection && document.selection.createRange) {
  840. var range = document.selection.createRange();
  841. return range.getBookmark().charCodeAt(2) - 2;
  842. }
  843. if (input.setSelectionRange) {
  844. return input.selectionStart;
  845. }
  846. } catch (e) {
  847. return 0;
  848. }
  849. },
  850. setCaretPos = function (node, pos) {
  851. node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
  852. if (!node) {
  853. return false;
  854. }
  855. if (node.createTextRange) {
  856. var textRange = node.createTextRange();
  857. textRange.collapse(true);
  858. textRange.moveEnd('character', pos);
  859. textRange.moveStart('character', pos);
  860. textRange.select();
  861. return true;
  862. }
  863. if (node.setSelectionRange) {
  864. node.setSelectionRange(pos, pos);
  865. return true;
  866. }
  867. return false;
  868. },
  869. isValidValue = function (mask, value) {
  870. var reg = mask
  871. .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
  872. .replace(/_/g, '{digit+}')
  873. .replace(/([0-9]{1})/g, '{digit$1}')
  874. .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
  875. .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
  876. return (new RegExp(reg)).test(value);
  877. };
  878. options = $.extend(true, {}, options, _options);
  879. if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
  880. options.allowTimes = $.extend(true, [], _options.allowTimes);
  881. }
  882. if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
  883. options.weekends = $.extend(true, [], _options.weekends);
  884. }
  885. if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
  886. $.each(_options.highlightedDates, function (index, value) {
  887. var splitData = $.map(value.split(','), $.trim),
  888. exDesc,
  889. hDate = new HighlightedDate(Date.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
  890. keyDate = hDate.date.dateFormat(options.formatDate);
  891. if (highlightedDates[keyDate] !== undefined) {
  892. exDesc = highlightedDates[keyDate].desc;
  893. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  894. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  895. }
  896. } else {
  897. highlightedDates[keyDate] = hDate;
  898. }
  899. });
  900. options.highlightedDates = $.extend(true, [], highlightedDates);
  901. }
  902. if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
  903. highlightedDates = $.extend(true, [], options.highlightedDates);
  904. $.each(_options.highlightedPeriods, function (index, value) {
  905. var dateTest, // start date
  906. dateEnd,
  907. desc,
  908. hDate,
  909. keyDate,
  910. exDesc,
  911. style;
  912. if ($.isArray(value)) {
  913. dateTest = value[0];
  914. dateEnd = value[1];
  915. desc = value[2];
  916. style = value[3];
  917. }
  918. else {
  919. var splitData = $.map(value.split(','), $.trim);
  920. dateTest = Date.parseDate(splitData[0], options.formatDate);
  921. dateEnd = Date.parseDate(splitData[1], options.formatDate);
  922. desc = splitData[2];
  923. style = splitData[3];
  924. }
  925. while (dateTest <= dateEnd) {
  926. hDate = new HighlightedDate(dateTest, desc, style);
  927. keyDate = dateTest.dateFormat(options.formatDate);
  928. dateTest.setDate(dateTest.getDate() + 1);
  929. if (highlightedDates[keyDate] !== undefined) {
  930. exDesc = highlightedDates[keyDate].desc;
  931. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  932. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  933. }
  934. } else {
  935. highlightedDates[keyDate] = hDate;
  936. }
  937. }
  938. });
  939. options.highlightedDates = $.extend(true, [], highlightedDates);
  940. }
  941. if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
  942. options.disabledDates = $.extend(true, [], _options.disabledDates);
  943. }
  944. if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
  945. options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
  946. }
  947. if ((options.open || options.opened) && (!options.inline)) {
  948. input.trigger('open.xdsoft');
  949. }
  950. if (options.inline) {
  951. triggerAfterOpen = true;
  952. datetimepicker.addClass('xdsoft_inline');
  953. input.after(datetimepicker).hide();
  954. }
  955. if (options.inverseButton) {
  956. options.next = 'xdsoft_prev';
  957. options.prev = 'xdsoft_next';
  958. }
  959. if (options.datepicker) {
  960. datepicker.addClass('active');
  961. } else {
  962. datepicker.removeClass('active');
  963. }
  964. if (options.timepicker) {
  965. timepicker.addClass('active');
  966. } else {
  967. timepicker.removeClass('active');
  968. }
  969. if (options.value) {
  970. _xdsoft_datetime.setCurrentTime(options.value);
  971. if (input && input.val) {
  972. input.val(_xdsoft_datetime.str);
  973. }
  974. }
  975. if (isNaN(options.dayOfWeekStart)) {
  976. options.dayOfWeekStart = 0;
  977. } else {
  978. options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
  979. }
  980. if (!options.timepickerScrollbar) {
  981. timeboxparent.xdsoftScroller('hide');
  982. }
  983. if (options.minDate && /^[\+\-](.*)$/.test(options.minDate)) {
  984. options.minDate = _xdsoft_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate);
  985. }
  986. if (options.maxDate && /^[\+\-](.*)$/.test(options.maxDate)) {
  987. options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
  988. }
  989. applyButton.toggle(options.showApplyButton);
  990. mounth_picker
  991. .find('.xdsoft_today_button')
  992. .css('visibility', !options.todayButton ? 'hidden' : 'visible');
  993. mounth_picker
  994. .find('.' + options.prev)
  995. .css('visibility', !options.prevButton ? 'hidden' : 'visible');
  996. mounth_picker
  997. .find('.' + options.next)
  998. .css('visibility', !options.nextButton ? 'hidden' : 'visible');
  999. if (options.mask) {
  1000. input.off('keydown.xdsoft');
  1001. if (options.mask === true) {
  1002. options.mask = options.format
  1003. .replace(/Y/g, '9999')
  1004. .replace(/F/g, '9999')
  1005. .replace(/m/g, '19')
  1006. .replace(/d/g, '39')
  1007. .replace(/H/g, '29')
  1008. .replace(/i/g, '59')
  1009. .replace(/s/g, '59');
  1010. }
  1011. if ($.type(options.mask) === 'string') {
  1012. if (!isValidValue(options.mask, input.val())) {
  1013. input.val(options.mask.replace(/[0-9]/g, '_'));
  1014. }
  1015. input.on('keydown.xdsoft', function (event) {
  1016. var val = this.value,
  1017. key = event.which,
  1018. pos,
  1019. digit;
  1020. if (((key >= KEY0 && key <= KEY9) || (key >= _KEY0 && key <= _KEY9)) || (key === BACKSPACE || key === DEL)) {
  1021. pos = getCaretPos(this);
  1022. digit = (key !== BACKSPACE && key !== DEL) ? String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key) : '_';
  1023. if ((key === BACKSPACE || key === DEL) && pos) {
  1024. pos -= 1;
  1025. digit = '_';
  1026. }
  1027. while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  1028. pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
  1029. }
  1030. val = val.substr(0, pos) + digit + val.substr(pos + 1);
  1031. if ($.trim(val) === '') {
  1032. val = options.mask.replace(/[0-9]/g, '_');
  1033. } else {
  1034. if (pos === options.mask.length) {
  1035. event.preventDefault();
  1036. return false;
  1037. }
  1038. }
  1039. pos += (key === BACKSPACE || key === DEL) ? 0 : 1;
  1040. while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  1041. pos += (key === BACKSPACE || key === DEL) ? -1 : 1;
  1042. }
  1043. if (isValidValue(options.mask, val)) {
  1044. this.value = val;
  1045. setCaretPos(this, pos);
  1046. } else if ($.trim(val) === '') {
  1047. this.value = options.mask.replace(/[0-9]/g, '_');
  1048. } else {
  1049. input.trigger('error_input.xdsoft');
  1050. }
  1051. } else {
  1052. if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
  1053. return true;
  1054. }
  1055. }
  1056. event.preventDefault();
  1057. return false;
  1058. });
  1059. }
  1060. }
  1061. if (options.validateOnBlur) {
  1062. input
  1063. .off('blur.xdsoft')
  1064. .on('blur.xdsoft', function () {
  1065. if (options.allowBlank && !$.trim($(this).val()).length) {
  1066. $(this).val(null);
  1067. datetimepicker.data('xdsoft_datetime').empty();
  1068. } else if (!Date.parseDate($(this).val(), options.format)) {
  1069. var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
  1070. splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
  1071. // parse the numbers as 0312 => 03:12
  1072. if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
  1073. $(this).val([splittedHours, splittedMinutes].map(function (item) {
  1074. return item > 9 ? item : '0' + item;
  1075. }).join(':'));
  1076. } else {
  1077. $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
  1078. }
  1079. datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1080. } else {
  1081. datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1082. }
  1083. datetimepicker.trigger('changedatetime.xdsoft');
  1084. });
  1085. }
  1086. options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
  1087. datetimepicker
  1088. .trigger('xchange.xdsoft')
  1089. .trigger('afterOpen.xdsoft');
  1090. };
  1091. datetimepicker
  1092. .data('options', options)
  1093. .on('mousedown.xdsoft', function (event) {
  1094. event.stopPropagation();
  1095. event.preventDefault();
  1096. yearselect.hide();
  1097. monthselect.hide();
  1098. return false;
  1099. });
  1100. //scroll_element = timepicker.find('.xdsoft_time_box');
  1101. timeboxparent.append(timebox);
  1102. timeboxparent.xdsoftScroller();
  1103. datetimepicker.on('afterOpen.xdsoft', function () {
  1104. timeboxparent.xdsoftScroller();
  1105. });
  1106. datetimepicker
  1107. .append(datepicker)
  1108. .append(timepicker);
  1109. if (options.withoutCopyright !== true) {
  1110. datetimepicker
  1111. .append(xdsoft_copyright);
  1112. }
  1113. datepicker
  1114. .append(mounth_picker)
  1115. .append(calendar)
  1116. .append(applyButton);
  1117. $(options.parentID)
  1118. .append(datetimepicker);
  1119. XDSoft_datetime = function () {
  1120. var _this = this;
  1121. _this.now = function (norecursion) {
  1122. var d = new Date(),
  1123. date,
  1124. time;
  1125. if (!norecursion && options.defaultDate) {
  1126. date = _this.strToDateTime(options.defaultDate);
  1127. d.setFullYear(date.getFullYear());
  1128. d.setMonth(date.getMonth());
  1129. d.setDate(date.getDate());
  1130. }
  1131. if (options.yearOffset) {
  1132. d.setFullYear(d.getFullYear() + options.yearOffset);
  1133. }
  1134. if (!norecursion && options.defaultTime) {
  1135. time = _this.strtotime(options.defaultTime);
  1136. d.setHours(time.getHours());
  1137. d.setMinutes(time.getMinutes());
  1138. }
  1139. return d;
  1140. };
  1141. _this.isValidDate = function (d) {
  1142. if (Object.prototype.toString.call(d) !== "[object Date]") {
  1143. return false;
  1144. }
  1145. return !isNaN(d.getTime());
  1146. };
  1147. _this.setCurrentTime = function (dTime) {
  1148. _this.currentTime = (typeof dTime === 'string') ? _this.strToDateTime(dTime) : _this.isValidDate(dTime) ? dTime : _this.now();
  1149. datetimepicker.trigger('xchange.xdsoft');
  1150. };
  1151. _this.empty = function () {
  1152. _this.currentTime = null;
  1153. };
  1154. _this.getCurrentTime = function (dTime) {
  1155. return _this.currentTime;
  1156. };
  1157. _this.nextMonth = function () {
  1158. if (_this.currentTime === undefined || _this.currentTime === null) {
  1159. _this.currentTime = _this.now();
  1160. }
  1161. var month = _this.currentTime.getMonth() + 1,
  1162. year;
  1163. if (month === 12) {
  1164. _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
  1165. month = 0;
  1166. }
  1167. year = _this.currentTime.getFullYear();
  1168. _this.currentTime.setDate(
  1169. Math.min(
  1170. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1171. _this.currentTime.getDate()
  1172. )
  1173. );
  1174. _this.currentTime.setMonth(month);
  1175. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1176. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1177. }
  1178. if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1179. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1180. }
  1181. datetimepicker.trigger('xchange.xdsoft');
  1182. return month;
  1183. };
  1184. _this.prevMonth = function () {
  1185. if (_this.currentTime === undefined || _this.currentTime === null) {
  1186. _this.currentTime = _this.now();
  1187. }
  1188. var month = _this.currentTime.getMonth() - 1;
  1189. if (month === -1) {
  1190. _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
  1191. month = 11;
  1192. }
  1193. _this.currentTime.setDate(
  1194. Math.min(
  1195. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1196. _this.currentTime.getDate()
  1197. )
  1198. );
  1199. _this.currentTime.setMonth(month);
  1200. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1201. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1202. }
  1203. datetimepicker.trigger('xchange.xdsoft');
  1204. return month;
  1205. };
  1206. _this.getWeekOfYear = function (datetime) {
  1207. var onejan = new Date(datetime.getFullYear(), 0, 1);
  1208. return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
  1209. };
  1210. _this.strToDateTime = function (sDateTime) {
  1211. var tmpDate = [], timeOffset, currentTime;
  1212. if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
  1213. return sDateTime;
  1214. }
  1215. tmpDate = /^(\+|\-)(.*)$/.exec(sDateTime);
  1216. if (tmpDate) {
  1217. tmpDate[2] = Date.parseDate(tmpDate[2], options.formatDate);
  1218. }
  1219. if (tmpDate && tmpDate[2]) {
  1220. timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
  1221. currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
  1222. } else {
  1223. currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
  1224. }
  1225. if (!_this.isValidDate(currentTime)) {
  1226. currentTime = _this.now();
  1227. }
  1228. return currentTime;
  1229. };
  1230. _this.strToDate = function (sDate) {
  1231. if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
  1232. return sDate;
  1233. }
  1234. var currentTime = sDate ? Date.parseDate(sDate, options.formatDate) : _this.now(true);
  1235. if (!_this.isValidDate(currentTime)) {
  1236. currentTime = _this.now(true);
  1237. }
  1238. return currentTime;
  1239. };
  1240. _this.strtotime = function (sTime) {
  1241. if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
  1242. return sTime;
  1243. }
  1244. var currentTime = sTime ? Date.parseDate(sTime, options.formatTime) : _this.now(true);
  1245. if (!_this.isValidDate(currentTime)) {
  1246. currentTime = _this.now(true);
  1247. }
  1248. return currentTime;
  1249. };
  1250. _this.str = function () {
  1251. return _this.currentTime.dateFormat(options.format);
  1252. };
  1253. _this.currentTime = this.now();
  1254. };
  1255. _xdsoft_datetime = new XDSoft_datetime();
  1256. applyButton.on('click', function (e) {//pathbrite
  1257. e.preventDefault();
  1258. datetimepicker.data('changed', true);
  1259. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1260. input.val(_xdsoft_datetime.str());
  1261. datetimepicker.trigger('close.xdsoft');
  1262. });
  1263. mounth_picker
  1264. .find('.xdsoft_today_button')
  1265. .on('mousedown.xdsoft', function () {
  1266. datetimepicker.data('changed', true);
  1267. _xdsoft_datetime.setCurrentTime(0);
  1268. datetimepicker.trigger('afterOpen.xdsoft');
  1269. }).on('dblclick.xdsoft', function () {
  1270. var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
  1271. currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
  1272. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1273. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1274. if (currentDate < minDate) {
  1275. return;
  1276. }
  1277. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1278. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
  1279. if (currentDate > maxDate) {
  1280. return;
  1281. }
  1282. input.val(_xdsoft_datetime.str());
  1283. input.trigger('change');
  1284. datetimepicker.trigger('close.xdsoft');
  1285. });
  1286. mounth_picker
  1287. .find('.xdsoft_prev,.xdsoft_next')
  1288. .on('mousedown.xdsoft', function () {
  1289. var $this = $(this),
  1290. timer = 0,
  1291. stop = false;
  1292. (function arguments_callee1(v) {
  1293. if ($this.hasClass(options.next)) {
  1294. _xdsoft_datetime.nextMonth();
  1295. } else if ($this.hasClass(options.prev)) {
  1296. _xdsoft_datetime.prevMonth();
  1297. }
  1298. if (options.monthChangeSpinner) {
  1299. if (!stop) {
  1300. timer = setTimeout(arguments_callee1, v || 100);
  1301. }
  1302. }
  1303. }(500));
  1304. $([document.body, window]).on('mouseup.xdsoft', function arguments_callee2() {
  1305. clearTimeout(timer);
  1306. stop = true;
  1307. $([document.body, window]).off('mouseup.xdsoft', arguments_callee2);
  1308. });
  1309. });
  1310. timepicker
  1311. .find('.xdsoft_prev,.xdsoft_next')
  1312. .on('mousedown.xdsoft', function () {
  1313. var $this = $(this),
  1314. timer = 0,
  1315. stop = false,
  1316. period = 110;
  1317. (function arguments_callee4(v) {
  1318. var pheight = timeboxparent[0].clientHeight,
  1319. height = timebox[0].offsetHeight,
  1320. top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  1321. if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
  1322. timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
  1323. } else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
  1324. timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
  1325. }
  1326. timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]);
  1327. period = (period > 10) ? 10 : period - 10;
  1328. if (!stop) {
  1329. timer = setTimeout(arguments_callee4, v || period);
  1330. }
  1331. }(500));
  1332. $([document.body, window]).on('mouseup.xdsoft', function arguments_callee5() {
  1333. clearTimeout(timer);
  1334. stop = true;
  1335. $([document.body, window])
  1336. .off('mouseup.xdsoft', arguments_callee5);
  1337. });
  1338. });
  1339. xchangeTimer = 0;
  1340. // base handler - generating a calendar and timepicker
  1341. datetimepicker
  1342. .on('xchange.xdsoft', function (event) {
  1343. clearTimeout(xchangeTimer);
  1344. xchangeTimer = setTimeout(function () {
  1345. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1346. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1347. }
  1348. var table = '',
  1349. start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
  1350. i = 0,
  1351. j,
  1352. today = _xdsoft_datetime.now(),
  1353. maxDate = false,
  1354. minDate = false,
  1355. hDate,
  1356. day,
  1357. d,
  1358. y,
  1359. m,
  1360. w,
  1361. classes = [],
  1362. customDateSettings,
  1363. newRow = true,
  1364. time = '',
  1365. h = '',
  1366. line_time,
  1367. description;
  1368. while (start.getDay() !== options.dayOfWeekStart) {
  1369. start.setDate(start.getDate() - 1);
  1370. }
  1371. table += '<table><thead><tr>';
  1372. if (options.weeks) {
  1373. table += '<th></th>';
  1374. }
  1375. for (j = 0; j < 7; j += 1) {
  1376. table += '<th>' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + '</th>';
  1377. }
  1378. table += '</tr></thead>';
  1379. table += '<tbody>';
  1380. if (options.maxDate !== false) {
  1381. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1382. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
  1383. }
  1384. if (options.minDate !== false) {
  1385. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1386. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1387. }
  1388. while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
  1389. classes = [];
  1390. i += 1;
  1391. day = start.getDay();
  1392. d = start.getDate();
  1393. y = start.getFullYear();
  1394. m = start.getMonth();
  1395. w = _xdsoft_datetime.getWeekOfYear(start);
  1396. description = '';
  1397. classes.push('xdsoft_date');
  1398. if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
  1399. customDateSettings = options.beforeShowDay.call(datetimepicker, start);
  1400. } else {
  1401. customDateSettings = null;
  1402. }
  1403. if ((maxDate !== false && start > maxDate) || (minDate !== false && start < minDate) || (customDateSettings && customDateSettings[0] === false)) {
  1404. classes.push('xdsoft_disabled');
  1405. } else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
  1406. classes.push('xdsoft_disabled');
  1407. } else if (options.disabledWeekDays.indexOf(day) !== -1) {
  1408. classes.push('xdsoft_disabled');
  1409. }
  1410. if (customDateSettings && customDateSettings[1] !== "") {
  1411. classes.push(customDateSettings[1]);
  1412. }
  1413. if (_xdsoft_datetime.currentTime.getMonth() !== m) {
  1414. classes.push('xdsoft_other_month');
  1415. }
  1416. if ((options.defaultSelect || datetimepicker.data('changed')) && _xdsoft_datetime.currentTime.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
  1417. classes.push('xdsoft_current');
  1418. }
  1419. if (today.dateFormat(options.formatDate) === start.dateFormat(options.formatDate)) {
  1420. classes.push('xdsoft_today');
  1421. }
  1422. if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) !== -1) {
  1423. classes.push('xdsoft_weekend');
  1424. }
  1425. if (options.highlightedDates[start.dateFormat(options.formatDate)] !== undefined) {
  1426. hDate = options.highlightedDates[start.dateFormat(options.formatDate)];
  1427. classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
  1428. description = hDate.desc === undefined ? '' : hDate.desc;
  1429. }
  1430. if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
  1431. classes.push(options.beforeShowDay(start));
  1432. }
  1433. if (newRow) {
  1434. table += '<tr>';
  1435. newRow = false;
  1436. if (options.weeks) {
  1437. table += '<th>' + w + '</th>';
  1438. }
  1439. }
  1440. table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
  1441. '<div>' + d + '</div>' +
  1442. '</td>';
  1443. if (start.getDay() === options.dayOfWeekStartPrev) {
  1444. table += '</tr>';
  1445. newRow = true;
  1446. }
  1447. start.setDate(d + 1);
  1448. }
  1449. table += '</tbody></table>';
  1450. calendar.html(table);
  1451. mounth_picker.find('.xdsoft_label span').eq(0).text(options.i18n[options.lang].months[_xdsoft_datetime.currentTime.getMonth()]);
  1452. mounth_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear());
  1453. // generate timebox
  1454. time = '';
  1455. h = '';
  1456. m = '';
  1457. line_time = function line_time(h, m) {
  1458. var now = _xdsoft_datetime.now(), optionDateTime, current_time;
  1459. now.setHours(h);
  1460. h = parseInt(now.getHours(), 10);
  1461. now.setMinutes(m);
  1462. m = parseInt(now.getMinutes(), 10);
  1463. optionDateTime = new Date(_xdsoft_datetime.currentTime);
  1464. optionDateTime.setHours(h);
  1465. optionDateTime.setMinutes(m);
  1466. classes = [];
  1467. 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())) {
  1468. classes.push('xdsoft_disabled');
  1469. }
  1470. 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()))) {
  1471. classes.push('xdsoft_disabled');
  1472. }
  1473. current_time = new Date(_xdsoft_datetime.currentTime);
  1474. current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
  1475. current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
  1476. if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && (options.step > 59 || current_time.getMinutes() === parseInt(m, 10))) {
  1477. if (options.defaultSelect || datetimepicker.data('changed')) {
  1478. classes.push('xdsoft_current');
  1479. } else if (options.initTime) {
  1480. classes.push('xdsoft_init_time');
  1481. }
  1482. }
  1483. if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
  1484. classes.push('xdsoft_today');
  1485. }
  1486. time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + now.dateFormat(options.formatTime) + '</div>';
  1487. };
  1488. if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
  1489. for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
  1490. for (j = 0; j < 60; j += options.step) {
  1491. h = (i < 10 ? '0' : '') + i;
  1492. m = (j < 10 ? '0' : '') + j;
  1493. line_time(h, m);
  1494. }
  1495. }
  1496. } else {
  1497. for (i = 0; i < options.allowTimes.length; i += 1) {
  1498. h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
  1499. m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
  1500. line_time(h, m);
  1501. }
  1502. }
  1503. timebox.html(time);
  1504. opt = '';
  1505. i = 0;
  1506. for (i = parseInt(options.yearStart, 10) + options.yearOffset; i <= parseInt(options.yearEnd, 10) + options.yearOffset; i += 1) {
  1507. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + i + '</div>';
  1508. }
  1509. yearselect.children().eq(0)
  1510. .html(opt);
  1511. for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
  1512. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[options.lang].months[i] + '</div>';
  1513. }
  1514. monthselect.children().eq(0).html(opt);
  1515. $(datetimepicker)
  1516. .trigger('generate.xdsoft');
  1517. }, 10);
  1518. event.stopPropagation();
  1519. })
  1520. .on('afterOpen.xdsoft', function () {
  1521. if (options.timepicker) {
  1522. var classType, pheight, height, top;
  1523. if (timebox.find('.xdsoft_current').length) {
  1524. classType = '.xdsoft_current';
  1525. } else if (timebox.find('.xdsoft_init_time').length) {
  1526. classType = '.xdsoft_init_time';
  1527. }
  1528. if (classType) {
  1529. pheight = timeboxparent[0].clientHeight;
  1530. height = timebox[0].offsetHeight;
  1531. top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
  1532. if ((height - pheight) < top) {
  1533. top = height - pheight;
  1534. }
  1535. timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
  1536. } else {
  1537. timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
  1538. }
  1539. }
  1540. });
  1541. timerclick = 0;
  1542. calendar
  1543. .on('click.xdsoft', 'td', function (xdevent) {
  1544. xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
  1545. timerclick += 1;
  1546. var $this = $(this),
  1547. currentTime = _xdsoft_datetime.currentTime;
  1548. if (currentTime === undefined || currentTime === null) {
  1549. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1550. currentTime = _xdsoft_datetime.currentTime;
  1551. }
  1552. if ($this.hasClass('xdsoft_disabled')) {
  1553. return false;
  1554. }
  1555. currentTime.setDate(1);
  1556. currentTime.setFullYear($this.data('year'));
  1557. currentTime.setMonth($this.data('month'));
  1558. currentTime.setDate($this.data('date'));
  1559. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1560. input.val(_xdsoft_datetime.str());
  1561. if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
  1562. datetimepicker.trigger('close.xdsoft');
  1563. }
  1564. if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
  1565. options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1566. }
  1567. datetimepicker.data('changed', true);
  1568. datetimepicker.trigger('xchange.xdsoft');
  1569. datetimepicker.trigger('changedatetime.xdsoft');
  1570. setTimeout(function () {
  1571. timerclick = 0;
  1572. }, 200);
  1573. });
  1574. timebox
  1575. .on('click.xdsoft', 'div', function (xdevent) {
  1576. xdevent.stopPropagation();
  1577. var $this = $(this),
  1578. currentTime = _xdsoft_datetime.currentTime;
  1579. if (currentTime === undefined || currentTime === null) {
  1580. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1581. currentTime = _xdsoft_datetime.currentTime;
  1582. }
  1583. if ($this.hasClass('xdsoft_disabled')) {
  1584. return false;
  1585. }
  1586. currentTime.setHours($this.data('hour'));
  1587. currentTime.setMinutes($this.data('minute'));
  1588. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1589. datetimepicker.data('input').val(_xdsoft_datetime.str());
  1590. if (options.inline !== true && options.closeOnTimeSelect === true) {
  1591. datetimepicker.trigger('close.xdsoft');
  1592. }
  1593. if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
  1594. options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1595. }
  1596. datetimepicker.data('changed', true);
  1597. datetimepicker.trigger('xchange.xdsoft');
  1598. datetimepicker.trigger('changedatetime.xdsoft');
  1599. });
  1600. datepicker
  1601. .on('mousewheel.xdsoft', function (event) {
  1602. if (!options.scrollMonth) {
  1603. return true;
  1604. }
  1605. if (event.deltaY < 0) {
  1606. _xdsoft_datetime.nextMonth();
  1607. } else {
  1608. _xdsoft_datetime.prevMonth();
  1609. }
  1610. return false;
  1611. });
  1612. input
  1613. .on('mousewheel.xdsoft', function (event) {
  1614. if (!options.scrollInput) {
  1615. return true;
  1616. }
  1617. if (!options.datepicker && options.timepicker) {
  1618. current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
  1619. if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
  1620. current_time_index += event.deltaY;
  1621. }
  1622. if (timebox.children().eq(current_time_index).length) {
  1623. timebox.children().eq(current_time_index).trigger('mousedown');
  1624. }
  1625. return false;
  1626. }
  1627. if (options.datepicker && !options.timepicker) {
  1628. datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
  1629. if (input.val) {
  1630. input.val(_xdsoft_datetime.str());
  1631. }
  1632. datetimepicker.trigger('changedatetime.xdsoft');
  1633. return false;
  1634. }
  1635. });
  1636. datetimepicker
  1637. .on('changedatetime.xdsoft', function (event) {
  1638. if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
  1639. var $input = datetimepicker.data('input');
  1640. options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
  1641. delete options.value;
  1642. $input.trigger('change');
  1643. }
  1644. })
  1645. .on('generate.xdsoft', function () {
  1646. if (options.onGenerate && $.isFunction(options.onGenerate)) {
  1647. options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1648. }
  1649. if (triggerAfterOpen) {
  1650. datetimepicker.trigger('afterOpen.xdsoft');
  1651. triggerAfterOpen = false;
  1652. }
  1653. })
  1654. .on('click.xdsoft', function (xdevent) {
  1655. xdevent.stopPropagation();
  1656. });
  1657. current_time_index = 0;
  1658. setPos = function () {
  1659. var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute", node;
  1660. if (datetimepicker.data('input').parent().css('direction') == 'rtl')
  1661. left -= (datetimepicker.outerWidth() - datetimepicker.data('input').outerWidth());
  1662. if (options.fixed) {
  1663. top -= $(window).scrollTop();
  1664. left -= $(window).scrollLeft();
  1665. position = "fixed";
  1666. } else {
  1667. if (top + datetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()) {
  1668. top = offset.top - datetimepicker[0].offsetHeight + 1;
  1669. }
  1670. if (top < 0) {
  1671. top = 0;
  1672. }
  1673. if (left + datetimepicker[0].offsetWidth > $(window).width()) {
  1674. left = $(window).width() - datetimepicker[0].offsetWidth;
  1675. }
  1676. }
  1677. node = datetimepicker[0];
  1678. do {
  1679. node = node.parentNode;
  1680. if (window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
  1681. left = left - (($(window).width() - node.offsetWidth) / 2);
  1682. break;
  1683. }
  1684. } while (node.nodeName !== 'HTML');
  1685. datetimepicker.css({
  1686. left: left,
  1687. top: top,
  1688. position: position
  1689. });
  1690. };
  1691. datetimepicker
  1692. .on('open.xdsoft', function (event) {
  1693. var onShow = true;
  1694. if (options.onShow && $.isFunction(options.onShow)) {
  1695. onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1696. }
  1697. if (onShow !== false) {
  1698. datetimepicker.show();
  1699. setPos();
  1700. $(window)
  1701. .off('resize.xdsoft', setPos)
  1702. .on('resize.xdsoft', setPos);
  1703. if (options.closeOnWithoutClick) {
  1704. $([document.body, window]).on('mousedown.xdsoft', function arguments_callee6() {
  1705. datetimepicker.trigger('close.xdsoft');
  1706. $([document.body, window]).off('mousedown.xdsoft', arguments_callee6);
  1707. });
  1708. }
  1709. }
  1710. })
  1711. .on('close.xdsoft', function (event) {
  1712. var onClose = true;
  1713. mounth_picker
  1714. .find('.xdsoft_month,.xdsoft_year')
  1715. .find('.xdsoft_select')
  1716. .hide();
  1717. if (options.onClose && $.isFunction(options.onClose)) {
  1718. onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1719. }
  1720. if (onClose !== false && !options.opened && !options.inline) {
  1721. datetimepicker.hide();
  1722. }
  1723. event.stopPropagation();
  1724. })
  1725. .on('toggle.xdsoft', function (event) {
  1726. if (datetimepicker.is(':visible')) {
  1727. datetimepicker.trigger('close.xdsoft');
  1728. } else {
  1729. datetimepicker.trigger('open.xdsoft');
  1730. }
  1731. })
  1732. .data('input', input);
  1733. timer = 0;
  1734. timer1 = 0;
  1735. datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
  1736. datetimepicker.setOptions(options);
  1737. function getCurrentValue() {
  1738. var ct = false, time;
  1739. if (options.startDate) {
  1740. ct = _xdsoft_datetime.strToDate(options.startDate);
  1741. } else {
  1742. ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
  1743. if (ct) {
  1744. ct = _xdsoft_datetime.strToDateTime(ct);
  1745. } else if (options.defaultDate) {
  1746. ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
  1747. if (options.defaultTime) {
  1748. time = _xdsoft_datetime.strtotime(options.defaultTime);
  1749. ct.setHours(time.getHours());
  1750. ct.setMinutes(time.getMinutes());
  1751. }
  1752. }
  1753. }
  1754. if (ct && _xdsoft_datetime.isValidDate(ct)) {
  1755. datetimepicker.data('changed', true);
  1756. } else {
  1757. ct = '';
  1758. }
  1759. return ct || 0;
  1760. }
  1761. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1762. input
  1763. .data('xdsoft_datetimepicker', datetimepicker)
  1764. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
  1765. if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
  1766. return;
  1767. }
  1768. clearTimeout(timer);
  1769. timer = setTimeout(function () {
  1770. if (input.is(':disabled')) {
  1771. return;
  1772. }
  1773. triggerAfterOpen = true;
  1774. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1775. datetimepicker.trigger('open.xdsoft');
  1776. }, 100);
  1777. })
  1778. .on('keydown.xdsoft', function (event) {
  1779. var val = this.value, elementSelector,
  1780. key = event.which;
  1781. if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
  1782. elementSelector = $("input:visible,textarea:visible");
  1783. datetimepicker.trigger('close.xdsoft');
  1784. elementSelector.eq(elementSelector.index(this) + 1).focus();
  1785. return false;
  1786. }
  1787. if ([TAB].indexOf(key) !== -1) {
  1788. datetimepicker.trigger('close.xdsoft');
  1789. return true;
  1790. }
  1791. });
  1792. };
  1793. destroyDateTimePicker = function (input) {
  1794. var datetimepicker = input.data('xdsoft_datetimepicker');
  1795. if (datetimepicker) {
  1796. datetimepicker.data('xdsoft_datetime', null);
  1797. datetimepicker.remove();
  1798. input
  1799. .data('xdsoft_datetimepicker', null)
  1800. .off('.xdsoft');
  1801. $(window).off('resize.xdsoft');
  1802. $([window, document.body]).off('mousedown.xdsoft');
  1803. if (input.unmousewheel) {
  1804. input.unmousewheel();
  1805. }
  1806. }
  1807. };
  1808. $(document)
  1809. .off('keydown.xdsoftctrl keyup.xdsoftctrl')
  1810. .on('keydown.xdsoftctrl', function (e) {
  1811. if (e.keyCode === CTRLKEY) {
  1812. ctrlDown = true;
  1813. }
  1814. })
  1815. .on('keyup.xdsoftctrl', function (e) {
  1816. if (e.keyCode === CTRLKEY) {
  1817. ctrlDown = false;
  1818. }
  1819. });
  1820. return this.each(function () {
  1821. var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
  1822. if (datetimepicker) {
  1823. if ($.type(opt) === 'string') {
  1824. switch (opt) {
  1825. case 'show':
  1826. $(this).select().focus();
  1827. datetimepicker.trigger('open.xdsoft');
  1828. break;
  1829. case 'hide':
  1830. datetimepicker.trigger('close.xdsoft');
  1831. break;
  1832. case 'toggle':
  1833. datetimepicker.trigger('toggle.xdsoft');
  1834. break;
  1835. case 'destroy':
  1836. destroyDateTimePicker($(this));
  1837. break;
  1838. case 'reset':
  1839. this.value = this.defaultValue;
  1840. if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(Date.parseDate(this.value, options.format))) {
  1841. datetimepicker.data('changed', false);
  1842. }
  1843. datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
  1844. break;
  1845. case 'validate':
  1846. $input = datetimepicker.data('input');
  1847. $input.trigger('blur.xdsoft');
  1848. break;
  1849. }
  1850. } else {
  1851. datetimepicker
  1852. .setOptions(opt);
  1853. }
  1854. return 0;
  1855. }
  1856. if ($.type(opt) !== 'string') {
  1857. if (!options.lazyInit || options.open || options.inline) {
  1858. createDateTimePicker($(this));
  1859. } else {
  1860. lazyInit($(this));
  1861. }
  1862. }
  1863. });
  1864. };
  1865. $.fn.datetimepicker.defaults = default_options;
  1866. }(jQuery));
  1867. function HighlightedDate(date, desc, style) {
  1868. "use strict";
  1869. this.date = date;
  1870. this.desc = desc;
  1871. this.style = style;
  1872. }
  1873. (function () {
  1874. /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
  1875. * Licensed under the MIT License (LICENSE.txt).
  1876. *
  1877. * Version: 3.1.12
  1878. *
  1879. * Requires: jQuery 1.2.2+
  1880. */
  1881. !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)}})});
  1882. // Parse and Format Library
  1883. //http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/
  1884. /*
  1885. * Copyright (C) 2004 Baron Schwartz <baron at sequent dot org>
  1886. *
  1887. * This program is free software; you can redistribute it and/or modify it
  1888. * under the terms of the GNU Lesser General Public License as published by the
  1889. * Free Software Foundation, version 2.1.
  1890. *
  1891. * This program is distributed in the hope that it will be useful, but WITHOUT
  1892. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  1893. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  1894. * details.
  1895. */
  1896. 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"};
  1897. }());