jquery.datetimepicker.js 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657
  1. /**
  2. * @preserve jQuery DateTimePicker
  3. * @homepage http://xdsoft.net/jqplugins/datetimepicker/
  4. * @author Chupurnov Valeriy (<chupurnov@gmail.com>)
  5. */
  6. /**
  7. * @param {jQuery} $
  8. */
  9. var datetimepickerFactory = function ($) {
  10. 'use strict';
  11. var default_options = {
  12. i18n: {
  13. ar: { // Arabic
  14. months: [
  15. "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول"
  16. ],
  17. dayOfWeekShort: [
  18. "ن", "ث", "ع", "خ", "ج", "س", "ح"
  19. ],
  20. dayOfWeek: ["الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت", "الأحد"]
  21. },
  22. ro: { // Romanian
  23. months: [
  24. "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"
  25. ],
  26. dayOfWeekShort: [
  27. "Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ"
  28. ],
  29. dayOfWeek: ["Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă"]
  30. },
  31. id: { // Indonesian
  32. months: [
  33. "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
  34. ],
  35. dayOfWeekShort: [
  36. "Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
  37. ],
  38. dayOfWeek: ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"]
  39. },
  40. is: { // Icelandic
  41. months: [
  42. "Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"
  43. ],
  44. dayOfWeekShort: [
  45. "Sun", "Mán", "Þrið", "Mið", "Fim", "Fös", "Lau"
  46. ],
  47. dayOfWeek: ["Sunnudagur", "Mánudagur", "Þriðjudagur", "Miðvikudagur", "Fimmtudagur", "Föstudagur", "Laugardagur"]
  48. },
  49. bg: { // Bulgarian
  50. months: [
  51. "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
  52. ],
  53. dayOfWeekShort: [
  54. "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  55. ],
  56. dayOfWeek: ["Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"]
  57. },
  58. fa: { // Persian/Farsi
  59. months: [
  60. 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند'
  61. ],
  62. dayOfWeekShort: [
  63. 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه'
  64. ],
  65. dayOfWeek: ["یک‌شنبه", "دوشنبه", "سه‌شنبه", "چهارشنبه", "پنج‌شنبه", "جمعه", "شنبه", "یک‌شنبه"]
  66. },
  67. ru: { // Russian
  68. months: [
  69. 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'
  70. ],
  71. dayOfWeekShort: [
  72. "Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"
  73. ],
  74. dayOfWeek: ["Воскресенье", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"]
  75. },
  76. uk: { // Ukrainian
  77. months: [
  78. 'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'
  79. ],
  80. dayOfWeekShort: [
  81. "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт"
  82. ],
  83. dayOfWeek: ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота"]
  84. },
  85. en: { // English
  86. months: [
  87. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  88. ],
  89. dayOfWeekShort: [
  90. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  91. ],
  92. dayOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  93. },
  94. el: { // Ελληνικά
  95. months: [
  96. "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
  97. ],
  98. dayOfWeekShort: [
  99. "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ"
  100. ],
  101. dayOfWeek: ["Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"]
  102. },
  103. de: { // German
  104. months: [
  105. 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'
  106. ],
  107. dayOfWeekShort: [
  108. "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"
  109. ],
  110. dayOfWeek: ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
  111. },
  112. nl: { // Dutch
  113. months: [
  114. "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"
  115. ],
  116. dayOfWeekShort: [
  117. "zo", "ma", "di", "wo", "do", "vr", "za"
  118. ],
  119. dayOfWeek: ["zondag", "maandag", "dinsdag", "woensdag", "donderdag", "vrijdag", "zaterdag"]
  120. },
  121. tr: { // Turkish
  122. months: [
  123. "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
  124. ],
  125. dayOfWeekShort: [
  126. "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"
  127. ],
  128. dayOfWeek: ["Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"]
  129. },
  130. fr: { //French
  131. months: [
  132. "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
  133. ],
  134. dayOfWeekShort: [
  135. "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"
  136. ],
  137. dayOfWeek: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"]
  138. },
  139. es: { // Spanish
  140. months: [
  141. "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
  142. ],
  143. dayOfWeekShort: [
  144. "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"
  145. ],
  146. dayOfWeek: ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"]
  147. },
  148. th: { // Thai
  149. months: [
  150. 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม'
  151. ],
  152. dayOfWeekShort: [
  153. 'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.'
  154. ],
  155. dayOfWeek: ["อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัส", "ศุกร์", "เสาร์", "อาทิตย์"]
  156. },
  157. pl: { // Polish
  158. months: [
  159. "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
  160. ],
  161. dayOfWeekShort: [
  162. "nd", "pn", "wt", "śr", "cz", "pt", "sb"
  163. ],
  164. dayOfWeek: ["niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"]
  165. },
  166. pt: { // Portuguese
  167. months: [
  168. "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  169. ],
  170. dayOfWeekShort: [
  171. "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab"
  172. ],
  173. dayOfWeek: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
  174. },
  175. ch: { // Simplified Chinese
  176. months: [
  177. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  178. ],
  179. dayOfWeekShort: [
  180. "日", "一", "二", "三", "四", "五", "六"
  181. ]
  182. },
  183. se: { // Swedish
  184. months: [
  185. "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  186. ],
  187. dayOfWeekShort: [
  188. "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  189. ]
  190. },
  191. km: { // Khmer (ភាសាខ្មែរ)
  192. months: [
  193. "មករា​", "កុម្ភៈ", "មិនា​", "មេសា​", "ឧសភា​", "មិថុនា​", "កក្កដា​", "សីហា​", "កញ្ញា​", "តុលា​", "វិច្ឆិកា", "ធ្នូ​"
  194. ],
  195. dayOfWeekShort: ["អាទិ​", "ច័ន្ទ​", "អង្គារ​", "ពុធ​", "ព្រហ​​", "សុក្រ​", "សៅរ៍"],
  196. dayOfWeek: ["អាទិត្យ​", "ច័ន្ទ​", "អង្គារ​", "ពុធ​", "ព្រហស្បតិ៍​", "សុក្រ​", "សៅរ៍"]
  197. },
  198. kr: { // Korean
  199. months: [
  200. "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  201. ],
  202. dayOfWeekShort: [
  203. "일", "월", "화", "수", "목", "금", "토"
  204. ],
  205. dayOfWeek: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"]
  206. },
  207. it: { // Italian
  208. months: [
  209. "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"
  210. ],
  211. dayOfWeekShort: [
  212. "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"
  213. ],
  214. dayOfWeek: ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"]
  215. },
  216. da: { // Dansk
  217. months: [
  218. "Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"
  219. ],
  220. dayOfWeekShort: [
  221. "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  222. ],
  223. dayOfWeek: ["søndag", "mandag", "tirsdag", "onsdag", "torsdag", "fredag", "lørdag"]
  224. },
  225. no: { // Norwegian
  226. months: [
  227. "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember"
  228. ],
  229. dayOfWeekShort: [
  230. "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør"
  231. ],
  232. dayOfWeek: ['Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag']
  233. },
  234. ja: { // Japanese
  235. months: [
  236. "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"
  237. ],
  238. dayOfWeekShort: [
  239. "日", "月", "火", "水", "木", "金", "土"
  240. ],
  241. dayOfWeek: ["日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜"]
  242. },
  243. vi: { // Vietnamese
  244. months: [
  245. "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"
  246. ],
  247. dayOfWeekShort: [
  248. "CN", "T2", "T3", "T4", "T5", "T6", "T7"
  249. ],
  250. dayOfWeek: ["Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"]
  251. },
  252. sl: { // Slovenščina
  253. months: [
  254. "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December"
  255. ],
  256. dayOfWeekShort: [
  257. "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob"
  258. ],
  259. dayOfWeek: ["Nedelja", "Ponedeljek", "Torek", "Sreda", "Četrtek", "Petek", "Sobota"]
  260. },
  261. cs: { // Čeština
  262. months: [
  263. "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
  264. ],
  265. dayOfWeekShort: [
  266. "Ne", "Po", "Út", "St", "Čt", "Pá", "So"
  267. ]
  268. },
  269. hu: { // Hungarian
  270. months: [
  271. "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
  272. ],
  273. dayOfWeekShort: [
  274. "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo"
  275. ],
  276. dayOfWeek: ["vasárnap", "hétfő", "kedd", "szerda", "csütörtök", "péntek", "szombat"]
  277. },
  278. az: { //Azerbaijanian (Azeri)
  279. months: [
  280. "Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr"
  281. ],
  282. dayOfWeekShort: [
  283. "B", "Be", "Ça", "Ç", "Ca", "C", "Ş"
  284. ],
  285. dayOfWeek: ["Bazar", "Bazar ertəsi", "Çərşənbə axşamı", "Çərşənbə", "Cümə axşamı", "Cümə", "Şənbə"]
  286. },
  287. bs: { //Bosanski
  288. months: [
  289. "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  290. ],
  291. dayOfWeekShort: [
  292. "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  293. ],
  294. dayOfWeek: ["Nedjelja","Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"]
  295. },
  296. ca: { //Català
  297. months: [
  298. "Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
  299. ],
  300. dayOfWeekShort: [
  301. "Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds"
  302. ],
  303. dayOfWeek: ["Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte"]
  304. },
  305. 'en-GB': { //English (British)
  306. months: [
  307. "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
  308. ],
  309. dayOfWeekShort: [
  310. "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  311. ],
  312. dayOfWeek: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
  313. },
  314. et: { //"Eesti"
  315. months: [
  316. "Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember"
  317. ],
  318. dayOfWeekShort: [
  319. "P", "E", "T", "K", "N", "R", "L"
  320. ],
  321. dayOfWeek: ["Pühapäev", "Esmaspäev", "Teisipäev", "Kolmapäev", "Neljapäev", "Reede", "Laupäev"]
  322. },
  323. eu: { //Euskara
  324. months: [
  325. "Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua"
  326. ],
  327. dayOfWeekShort: [
  328. "Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La."
  329. ],
  330. dayOfWeek: ['Igandea', 'Astelehena', 'Asteartea', 'Asteazkena', 'Osteguna', 'Ostirala', 'Larunbata']
  331. },
  332. fi: { //Finnish (Suomi)
  333. months: [
  334. "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
  335. ],
  336. dayOfWeekShort: [
  337. "Su", "Ma", "Ti", "Ke", "To", "Pe", "La"
  338. ],
  339. dayOfWeek: ["sunnuntai", "maanantai", "tiistai", "keskiviikko", "torstai", "perjantai", "lauantai"]
  340. },
  341. gl: { //Galego
  342. months: [
  343. "Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec"
  344. ],
  345. dayOfWeekShort: [
  346. "Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab"
  347. ],
  348. dayOfWeek: ["Domingo", "Luns", "Martes", "Mércores", "Xoves", "Venres", "Sábado"]
  349. },
  350. hr: { //Hrvatski
  351. months: [
  352. "Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
  353. ],
  354. dayOfWeekShort: [
  355. "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub"
  356. ],
  357. dayOfWeek: ["Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"]
  358. },
  359. ko: { //Korean (한국어)
  360. months: [
  361. "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
  362. ],
  363. dayOfWeekShort: [
  364. "일", "월", "화", "수", "목", "금", "토"
  365. ],
  366. dayOfWeek: ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"]
  367. },
  368. lt: { //Lithuanian (lietuvių)
  369. months: [
  370. "Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio"
  371. ],
  372. dayOfWeekShort: [
  373. "Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš"
  374. ],
  375. dayOfWeek: ["Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis"]
  376. },
  377. lv: { //Latvian (Latviešu)
  378. months: [
  379. "Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris"
  380. ],
  381. dayOfWeekShort: [
  382. "Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St"
  383. ],
  384. dayOfWeek: ["Svētdiena", "Pirmdiena", "Otrdiena", "Trešdiena", "Ceturtdiena", "Piektdiena", "Sestdiena"]
  385. },
  386. mk: { //Macedonian (Македонски)
  387. months: [
  388. "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември"
  389. ],
  390. dayOfWeekShort: [
  391. "нед", "пон", "вто", "сре", "чет", "пет", "саб"
  392. ],
  393. dayOfWeek: ["Недела", "Понеделник", "Вторник", "Среда", "Четврток", "Петок", "Сабота"]
  394. },
  395. mn: { //Mongolian (Монгол)
  396. months: [
  397. "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар"
  398. ],
  399. dayOfWeekShort: [
  400. "Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням"
  401. ],
  402. dayOfWeek: ["Даваа", "Мягмар", "Лхагва", "Пүрэв", "Баасан", "Бямба", "Ням"]
  403. },
  404. 'pt-BR': { //Português(Brasil)
  405. months: [
  406. "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
  407. ],
  408. dayOfWeekShort: [
  409. "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"
  410. ],
  411. dayOfWeek: ["Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"]
  412. },
  413. sk: { //Slovenčina
  414. months: [
  415. "Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
  416. ],
  417. dayOfWeekShort: [
  418. "Ne", "Po", "Ut", "St", "Št", "Pi", "So"
  419. ],
  420. dayOfWeek: ["Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota"]
  421. },
  422. sq: { //Albanian (Shqip)
  423. months: [
  424. "Janar", "Shkurt", "Mars", "Prill", "Maj", "Qershor", "Korrik", "Gusht", "Shtator", "Tetor", "Nëntor", "Dhjetor"
  425. ],
  426. dayOfWeekShort: [
  427. "Die", "Hën", "Mar", "Mër", "Enj", "Pre", "Shtu"
  428. ],
  429. dayOfWeek: ["E Diel", "E Hënë", "E Martē", "E Mërkurë", "E Enjte", "E Premte", "E Shtunë"]
  430. },
  431. 'sr-YU': { //Serbian (Srpski)
  432. months: [
  433. "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
  434. ],
  435. dayOfWeekShort: [
  436. "Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub"
  437. ],
  438. dayOfWeek: ["Nedelja","Ponedeljak", "Utorak", "Sreda", "Četvrtak", "Petak", "Subota"]
  439. },
  440. sr: { //Serbian Cyrillic (Српски)
  441. months: [
  442. "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар"
  443. ],
  444. dayOfWeekShort: [
  445. "нед", "пон", "уто", "сре", "чет", "пет", "суб"
  446. ],
  447. dayOfWeek: ["Недеља","Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота"]
  448. },
  449. sv: { //Svenska
  450. months: [
  451. "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
  452. ],
  453. dayOfWeekShort: [
  454. "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör"
  455. ],
  456. dayOfWeek: ["Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"]
  457. },
  458. 'zh-TW': { //Traditional Chinese (繁體中文)
  459. months: [
  460. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  461. ],
  462. dayOfWeekShort: [
  463. "日", "一", "二", "三", "四", "五", "六"
  464. ],
  465. dayOfWeek: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  466. },
  467. zh: { //Simplified Chinese (简体中文)
  468. months: [
  469. "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
  470. ],
  471. dayOfWeekShort: [
  472. "日", "一", "二", "三", "四", "五", "六"
  473. ],
  474. dayOfWeek: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
  475. },
  476. ug:{ // Uyghur(ئۇيغۇرچە)
  477. months: [
  478. "1-ئاي","2-ئاي","3-ئاي","4-ئاي","5-ئاي","6-ئاي","7-ئاي","8-ئاي","9-ئاي","10-ئاي","11-ئاي","12-ئاي"
  479. ],
  480. dayOfWeek: [
  481. "يەكشەنبە", "دۈشەنبە","سەيشەنبە","چارشەنبە","پەيشەنبە","جۈمە","شەنبە"
  482. ]
  483. },
  484. he: { //Hebrew (עברית)
  485. months: [
  486. 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'
  487. ],
  488. dayOfWeekShort: [
  489. 'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
  490. ],
  491. dayOfWeek: ["ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שבת", "ראשון"]
  492. },
  493. hy: { // Armenian
  494. months: [
  495. "Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
  496. ],
  497. dayOfWeekShort: [
  498. "Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
  499. ],
  500. dayOfWeek: ["Կիրակի", "Երկուշաբթի", "Երեքշաբթի", "Չորեքշաբթի", "Հինգշաբթի", "Ուրբաթ", "Շաբաթ"]
  501. },
  502. kg: { // Kyrgyz
  503. months: [
  504. 'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
  505. ],
  506. dayOfWeekShort: [
  507. "Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
  508. ],
  509. dayOfWeek: [
  510. "Жекшемб", "Дүйшөмб", "Шейшемб", "Шаршемб", "Бейшемби", "Жума", "Ишенб"
  511. ]
  512. },
  513. rm: { // Romansh
  514. months: [
  515. "Schaner", "Favrer", "Mars", "Avrigl", "Matg", "Zercladur", "Fanadur", "Avust", "Settember", "October", "November", "December"
  516. ],
  517. dayOfWeekShort: [
  518. "Du", "Gli", "Ma", "Me", "Gie", "Ve", "So"
  519. ],
  520. dayOfWeek: [
  521. "Dumengia", "Glindesdi", "Mardi", "Mesemna", "Gievgia", "Venderdi", "Sonda"
  522. ]
  523. },
  524. ka: { // Georgian
  525. months: [
  526. 'იანვარი', 'თებერვალი', 'მარტი', 'აპრილი', 'მაისი', 'ივნისი', 'ივლისი', 'აგვისტო', 'სექტემბერი', 'ოქტომბერი', 'ნოემბერი', 'დეკემბერი'
  527. ],
  528. dayOfWeekShort: [
  529. "კვ", "ორშ", "სამშ", "ოთხ", "ხუთ", "პარ", "შაბ"
  530. ],
  531. dayOfWeek: ["კვირა", "ორშაბათი", "სამშაბათი", "ოთხშაბათი", "ხუთშაბათი", "პარასკევი", "შაბათი"]
  532. }
  533. },
  534. ownerDocument: document,
  535. contentWindow: window,
  536. value: '',
  537. rtl: false,
  538. format: 'Y/m/d H:i',
  539. formatTime: 'H:i',
  540. formatDate: 'Y/m/d',
  541. startDate: false, // new Date(), '1986/12/08', '-1970/01/05','-1970/01/05',
  542. step: 60,
  543. monthChangeSpinner: true,
  544. closeOnDateSelect: false,
  545. closeOnTimeSelect: true,
  546. closeOnWithoutClick: true,
  547. closeOnInputClick: true,
  548. openOnFocus: true,
  549. timepicker: true,
  550. datepicker: true,
  551. weeks: false,
  552. defaultTime: false, // use formatTime format (ex. '10:00' for formatTime: 'H:i')
  553. defaultDate: false, // use formatDate format (ex new Date() or '1986/12/08' or '-1970/01/05' or '-1970/01/05')
  554. minDate: false,
  555. maxDate: false,
  556. minTime: false,
  557. maxTime: false,
  558. minDateTime: false,
  559. maxDateTime: false,
  560. allowTimes: [],
  561. opened: false,
  562. initTime: true,
  563. inline: false,
  564. theme: '',
  565. touchMovedThreshold: 5,
  566. onSelectDate: function () {},
  567. onSelectTime: function () {},
  568. onChangeMonth: function () {},
  569. onGetWeekOfYear: function () {},
  570. onChangeYear: function () {},
  571. onChangeDateTime: function () {},
  572. onShow: function () {},
  573. onClose: function () {},
  574. onGenerate: function () {},
  575. withoutCopyright: true,
  576. inverseButton: false,
  577. hours12: false,
  578. next: 'xdsoft_next',
  579. prev : 'xdsoft_prev',
  580. dayOfWeekStart: 0,
  581. parentID: 'body',
  582. timeHeightInTimePicker: 25,
  583. timepickerScrollbar: true,
  584. todayButton: true,
  585. prevButton: true,
  586. nextButton: true,
  587. defaultSelect: true,
  588. scrollMonth: true,
  589. scrollTime: true,
  590. scrollInput: true,
  591. lazyInit: false,
  592. mask: false,
  593. validateOnBlur: true,
  594. allowBlank: true,
  595. yearStart: 1950,
  596. yearEnd: 2050,
  597. monthStart: 0,
  598. monthEnd: 11,
  599. style: '',
  600. id: '',
  601. fixed: false,
  602. roundTime: 'round', // ceil, floor
  603. className: '',
  604. weekends: [],
  605. highlightedDates: [],
  606. highlightedPeriods: [],
  607. allowDates : [],
  608. allowDateRe : null,
  609. disabledDates : [],
  610. disabledWeekDays: [],
  611. yearOffset: 0,
  612. beforeShowDay: null,
  613. enterLikeTab: true,
  614. showApplyButton: false
  615. };
  616. var dateHelper = null,
  617. defaultDateHelper = null,
  618. globalLocaleDefault = 'en',
  619. globalLocale = 'en';
  620. var dateFormatterOptionsDefault = {
  621. meridiem: ['AM', 'PM']
  622. };
  623. var initDateFormatter = function(){
  624. var locale = default_options.i18n[globalLocale],
  625. opts = {
  626. days: locale.dayOfWeek,
  627. daysShort: locale.dayOfWeekShort,
  628. months: locale.months,
  629. monthsShort: $.map(locale.months, function(n){ return n.substring(0, 3) })
  630. };
  631. if (typeof DateFormatter === 'function') {
  632. dateHelper = defaultDateHelper = new DateFormatter({
  633. dateSettings: $.extend({}, dateFormatterOptionsDefault, opts)
  634. });
  635. }
  636. };
  637. var dateFormatters = {
  638. moment: {
  639. default_options:{
  640. format: 'YYYY/MM/DD HH:mm',
  641. formatDate: 'YYYY/MM/DD',
  642. formatTime: 'HH:mm',
  643. },
  644. formatter: {
  645. parseDate: function (date, format) {
  646. if(isFormatStandard(format)){
  647. return defaultDateHelper.parseDate(date, format);
  648. }
  649. var d = moment(date, format);
  650. return d.isValid() ? d.toDate() : false;
  651. },
  652. formatDate: function (date, format) {
  653. if(isFormatStandard(format)){
  654. return defaultDateHelper.formatDate(date, format);
  655. }
  656. return moment(date).format(format);
  657. },
  658. formatMask: function(format){
  659. return format
  660. .replace(/Y{4}/g, '9999')
  661. .replace(/Y{2}/g, '99')
  662. .replace(/M{2}/g, '19')
  663. .replace(/D{2}/g, '39')
  664. .replace(/H{2}/g, '29')
  665. .replace(/m{2}/g, '59')
  666. .replace(/s{2}/g, '59');
  667. },
  668. }
  669. }
  670. }
  671. // for locale settings
  672. $.datetimepicker = {
  673. setLocale: function(locale){
  674. var newLocale = default_options.i18n[locale] ? locale : globalLocaleDefault;
  675. if (globalLocale !== newLocale) {
  676. globalLocale = newLocale;
  677. // reinit date formatter
  678. initDateFormatter();
  679. }
  680. },
  681. setDateFormatter: function(dateFormatter) {
  682. if(typeof dateFormatter === 'string' && dateFormatters.hasOwnProperty(dateFormatter)){
  683. var df = dateFormatters[dateFormatter];
  684. $.extend(default_options, df.default_options);
  685. dateHelper = df.formatter;
  686. }
  687. else {
  688. dateHelper = dateFormatter;
  689. }
  690. },
  691. };
  692. var standardFormats = {
  693. RFC_2822: 'D, d M Y H:i:s O',
  694. ATOM: 'Y-m-d\TH:i:sP',
  695. ISO_8601: 'Y-m-d\TH:i:sO',
  696. RFC_822: 'D, d M y H:i:s O',
  697. RFC_850: 'l, d-M-y H:i:s T',
  698. RFC_1036: 'D, d M y H:i:s O',
  699. RFC_1123: 'D, d M Y H:i:s O',
  700. RSS: 'D, d M Y H:i:s O',
  701. W3C: 'Y-m-d\TH:i:sP'
  702. }
  703. var isFormatStandard = function(format){
  704. return Object.values(standardFormats).indexOf(format) === -1 ? false : true;
  705. }
  706. $.extend($.datetimepicker, standardFormats);
  707. // first init date formatter
  708. initDateFormatter();
  709. // fix for ie8
  710. if (!window.getComputedStyle) {
  711. window.getComputedStyle = function (el) {
  712. this.el = el;
  713. this.getPropertyValue = function (prop) {
  714. var re = /(-([a-z]))/g;
  715. if (prop === 'float') {
  716. prop = 'styleFloat';
  717. }
  718. if (re.test(prop)) {
  719. prop = prop.replace(re, function (a, b, c) {
  720. return c.toUpperCase();
  721. });
  722. }
  723. return el.currentStyle[prop] || null;
  724. };
  725. return this;
  726. };
  727. }
  728. if (!Array.prototype.indexOf) {
  729. Array.prototype.indexOf = function (obj, start) {
  730. var i, j;
  731. for (i = (start || 0), j = this.length; i < j; i += 1) {
  732. if (this[i] === obj) { return i; }
  733. }
  734. return -1;
  735. };
  736. }
  737. Date.prototype.countDaysInMonth = function () {
  738. return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate();
  739. };
  740. $.fn.xdsoftScroller = function (options, percent) {
  741. return this.each(function () {
  742. var timeboxparent = $(this),
  743. pointerEventToXY = function (e) {
  744. var out = {x: 0, y: 0},
  745. touch;
  746. if (e.type === 'touchstart' || e.type === 'touchmove' || e.type === 'touchend' || e.type === 'touchcancel') {
  747. touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
  748. out.x = touch.clientX;
  749. out.y = touch.clientY;
  750. } else if (e.type === 'mousedown' || e.type === 'mouseup' || e.type === 'mousemove' || e.type === 'mouseover' || e.type === 'mouseout' || e.type === 'mouseenter' || e.type === 'mouseleave') {
  751. out.x = e.clientX;
  752. out.y = e.clientY;
  753. }
  754. return out;
  755. },
  756. timebox,
  757. parentHeight,
  758. height,
  759. scrollbar,
  760. scroller,
  761. maximumOffset = 100,
  762. start = false,
  763. startY = 0,
  764. startTop = 0,
  765. h1 = 0,
  766. touchStart = false,
  767. startTopScroll = 0,
  768. calcOffset = function () {};
  769. if (percent === 'hide') {
  770. timeboxparent.find('.xdsoft_scrollbar').hide();
  771. return;
  772. }
  773. if (!$(this).hasClass('xdsoft_scroller_box')) {
  774. timebox = timeboxparent.children().eq(0);
  775. parentHeight = timeboxparent[0].clientHeight;
  776. height = timebox[0].offsetHeight;
  777. scrollbar = $('<div class="xdsoft_scrollbar"></div>');
  778. scroller = $('<div class="xdsoft_scroller"></div>');
  779. scrollbar.append(scroller);
  780. timeboxparent.addClass('xdsoft_scroller_box').append(scrollbar);
  781. calcOffset = function calcOffset(event) {
  782. var offset = pointerEventToXY(event).y - startY + startTopScroll;
  783. if (offset < 0) {
  784. offset = 0;
  785. }
  786. if (offset + scroller[0].offsetHeight > h1) {
  787. offset = h1 - scroller[0].offsetHeight;
  788. }
  789. timeboxparent.trigger('scroll_element.xdsoft_scroller', [maximumOffset ? offset / maximumOffset : 0]);
  790. };
  791. scroller
  792. .on('touchstart.xdsoft_scroller mousedown.xdsoft_scroller', function (event) {
  793. if (!parentHeight) {
  794. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  795. }
  796. startY = pointerEventToXY(event).y;
  797. startTopScroll = parseInt(scroller.css('margin-top'), 10);
  798. h1 = scrollbar[0].offsetHeight;
  799. if (event.type === 'mousedown' || event.type === 'touchstart') {
  800. if (options.ownerDocument) {
  801. $(options.ownerDocument.body).addClass('xdsoft_noselect');
  802. }
  803. $([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft_scroller', function arguments_callee() {
  804. $([options.ownerDocument.body, options.contentWindow]).off('touchend mouseup.xdsoft_scroller', arguments_callee)
  805. .off('mousemove.xdsoft_scroller', calcOffset)
  806. .removeClass('xdsoft_noselect');
  807. });
  808. $(options.ownerDocument.body).on('mousemove.xdsoft_scroller', calcOffset);
  809. } else {
  810. touchStart = true;
  811. event.stopPropagation();
  812. event.preventDefault();
  813. }
  814. })
  815. .on('touchmove', function (event) {
  816. if (touchStart) {
  817. event.preventDefault();
  818. calcOffset(event);
  819. }
  820. })
  821. .on('touchend touchcancel', function () {
  822. touchStart = false;
  823. startTopScroll = 0;
  824. });
  825. timeboxparent
  826. .on('scroll_element.xdsoft_scroller', function (event, percentage) {
  827. if (!parentHeight) {
  828. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percentage, true]);
  829. }
  830. percentage = percentage > 1 ? 1 : (percentage < 0 || isNaN(percentage)) ? 0 : percentage;
  831. scroller.css('margin-top', maximumOffset * percentage);
  832. setTimeout(function () {
  833. timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10));
  834. }, 10);
  835. })
  836. .on('resize_scroll.xdsoft_scroller', function (event, percentage, noTriggerScroll) {
  837. var percent, sh;
  838. parentHeight = timeboxparent[0].clientHeight;
  839. height = timebox[0].offsetHeight;
  840. percent = parentHeight / height;
  841. sh = percent * scrollbar[0].offsetHeight;
  842. if (percent > 1) {
  843. scroller.hide();
  844. } else {
  845. scroller.show();
  846. scroller.css('height', parseInt(sh > 10 ? sh : 10, 10));
  847. maximumOffset = scrollbar[0].offsetHeight - scroller[0].offsetHeight;
  848. if (noTriggerScroll !== true) {
  849. timeboxparent.trigger('scroll_element.xdsoft_scroller', [percentage || Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]);
  850. }
  851. }
  852. });
  853. timeboxparent.on('mousewheel', function (event) {
  854. var top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  855. top = top - (event.deltaY * 20);
  856. if (top < 0) {
  857. top = 0;
  858. }
  859. timeboxparent.trigger('scroll_element.xdsoft_scroller', [top / (height - parentHeight)]);
  860. event.stopPropagation();
  861. return false;
  862. });
  863. timeboxparent.on('touchstart', function (event) {
  864. start = pointerEventToXY(event);
  865. startTop = Math.abs(parseInt(timebox.css('marginTop'), 10));
  866. });
  867. timeboxparent.on('touchmove', function (event) {
  868. if (start) {
  869. event.preventDefault();
  870. var coord = pointerEventToXY(event);
  871. timeboxparent.trigger('scroll_element.xdsoft_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]);
  872. }
  873. });
  874. timeboxparent.on('touchend touchcancel', function () {
  875. start = false;
  876. startTop = 0;
  877. });
  878. }
  879. timeboxparent.trigger('resize_scroll.xdsoft_scroller', [percent]);
  880. });
  881. };
  882. $.fn.datetimepicker = function (opt, opt2) {
  883. var result = this,
  884. KEY0 = 48,
  885. KEY9 = 57,
  886. _KEY0 = 96,
  887. _KEY9 = 105,
  888. CTRLKEY = 17,
  889. DEL = 46,
  890. ENTER = 13,
  891. ESC = 27,
  892. BACKSPACE = 8,
  893. ARROWLEFT = 37,
  894. ARROWUP = 38,
  895. ARROWRIGHT = 39,
  896. ARROWDOWN = 40,
  897. TAB = 9,
  898. F5 = 116,
  899. AKEY = 65,
  900. CKEY = 67,
  901. VKEY = 86,
  902. ZKEY = 90,
  903. YKEY = 89,
  904. ctrlDown = false,
  905. options = ($.isPlainObject(opt) || !opt) ? $.extend(true, {}, default_options, opt) : $.extend(true, {}, default_options),
  906. lazyInitTimer = 0,
  907. createDateTimePicker,
  908. destroyDateTimePicker,
  909. lazyInit = function (input) {
  910. input
  911. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart', function initOnActionCallback() {
  912. if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
  913. return;
  914. }
  915. clearTimeout(lazyInitTimer);
  916. lazyInitTimer = setTimeout(function () {
  917. if (!input.data('xdsoft_datetimepicker')) {
  918. createDateTimePicker(input);
  919. }
  920. input
  921. .off('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart', initOnActionCallback)
  922. .trigger('open.xdsoft');
  923. }, 100);
  924. });
  925. };
  926. createDateTimePicker = function (input) {
  927. var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
  928. xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
  929. datepicker = $('<div class="xdsoft_datepicker active"></div>'),
  930. month_picker = $('<div class="xdsoft_monthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
  931. '<div class="xdsoft_label xdsoft_month"><span></span><i></i></div>' +
  932. '<div class="xdsoft_label xdsoft_year"><span></span><i></i></div>' +
  933. '<button type="button" class="xdsoft_next"></button></div>'),
  934. calendar = $('<div class="xdsoft_calendar"></div>'),
  935. 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>'),
  936. timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
  937. timebox = $('<div class="xdsoft_time_variant"></div>'),
  938. applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
  939. monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
  940. yearselect = $('<div class="xdsoft_select xdsoft_yearselect"><div></div></div>'),
  941. triggerAfterOpen = false,
  942. XDSoft_datetime,
  943. xchangeTimer,
  944. timerclick,
  945. current_time_index,
  946. setPos,
  947. timer = 0,
  948. _xdsoft_datetime,
  949. forEachAncestorOf;
  950. if (options.id) {
  951. datetimepicker.attr('id', options.id);
  952. }
  953. if (options.style) {
  954. datetimepicker.attr('style', options.style);
  955. }
  956. if (options.weeks) {
  957. datetimepicker.addClass('xdsoft_showweeks');
  958. }
  959. if (options.rtl) {
  960. datetimepicker.addClass('xdsoft_rtl');
  961. }
  962. datetimepicker.addClass('xdsoft_' + options.theme);
  963. datetimepicker.addClass(options.className);
  964. month_picker
  965. .find('.xdsoft_month span')
  966. .after(monthselect);
  967. month_picker
  968. .find('.xdsoft_year span')
  969. .after(yearselect);
  970. month_picker
  971. .find('.xdsoft_month,.xdsoft_year')
  972. .on('touchstart mousedown.xdsoft', function (event) {
  973. var select = $(this).find('.xdsoft_select').eq(0),
  974. val = 0,
  975. top = 0,
  976. visible = select.is(':visible'),
  977. items,
  978. i;
  979. month_picker
  980. .find('.xdsoft_select')
  981. .hide();
  982. if (_xdsoft_datetime.currentTime) {
  983. val = _xdsoft_datetime.currentTime[$(this).hasClass('xdsoft_month') ? 'getMonth' : 'getFullYear']();
  984. }
  985. select[visible ? 'hide' : 'show']();
  986. for (items = select.find('div.xdsoft_option'), i = 0; i < items.length; i += 1) {
  987. if (items.eq(i).data('value') === val) {
  988. break;
  989. } else {
  990. top += items[0].offsetHeight;
  991. }
  992. }
  993. select.xdsoftScroller(options, top / (select.children()[0].offsetHeight - (select[0].clientHeight)));
  994. event.stopPropagation();
  995. return false;
  996. });
  997. var handleTouchMoved = function (event) {
  998. var evt = event.originalEvent;
  999. var touchPosition = evt.touches ? evt.touches[0] : evt;
  1000. this.touchStartPosition = this.touchStartPosition || touchPosition;
  1001. var xMovement = Math.abs(this.touchStartPosition.clientX - touchPosition.clientX);
  1002. var yMovement = Math.abs(this.touchStartPosition.clientY - touchPosition.clientY);
  1003. var distance = Math.sqrt(xMovement * xMovement + yMovement * yMovement);
  1004. if(distance > options.touchMovedThreshold) {
  1005. this.touchMoved = true;
  1006. }
  1007. }
  1008. month_picker
  1009. .find('.xdsoft_select')
  1010. .xdsoftScroller(options)
  1011. .on('touchstart mousedown.xdsoft', function (event) {
  1012. var evt = event.originalEvent;
  1013. this.touchMoved = false;
  1014. this.touchStartPosition = evt.touches ? evt.touches[0] : evt;
  1015. event.stopPropagation();
  1016. event.preventDefault();
  1017. })
  1018. .on('touchmove', '.xdsoft_option', handleTouchMoved)
  1019. .on('touchend mousedown.xdsoft', '.xdsoft_option', function () {
  1020. if (!this.touchMoved) {
  1021. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1022. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1023. }
  1024. var year = _xdsoft_datetime.currentTime.getFullYear();
  1025. if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
  1026. _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
  1027. }
  1028. $(this).parent().parent().hide();
  1029. datetimepicker.trigger('xchange.xdsoft');
  1030. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1031. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1032. }
  1033. if (year !== _xdsoft_datetime.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1034. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1035. }
  1036. }
  1037. });
  1038. datetimepicker.getValue = function () {
  1039. return _xdsoft_datetime.getCurrentTime();
  1040. };
  1041. datetimepicker.setOptions = function (_options) {
  1042. var highlightedDates = {};
  1043. options = $.extend(true, {}, options, _options);
  1044. if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
  1045. options.allowTimes = $.extend(true, [], _options.allowTimes);
  1046. }
  1047. if (_options.weekends && $.isArray(_options.weekends) && _options.weekends.length) {
  1048. options.weekends = $.extend(true, [], _options.weekends);
  1049. }
  1050. if (_options.allowDates && $.isArray(_options.allowDates) && _options.allowDates.length) {
  1051. options.allowDates = $.extend(true, [], _options.allowDates);
  1052. }
  1053. if (_options.allowDateRe && Object.prototype.toString.call(_options.allowDateRe)==="[object String]") {
  1054. options.allowDateRe = new RegExp(_options.allowDateRe);
  1055. }
  1056. if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
  1057. $.each(_options.highlightedDates, function (index, value) {
  1058. var splitData = $.map(value.split(','), $.trim),
  1059. exDesc,
  1060. hDate = new HighlightedDate(dateHelper.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
  1061. keyDate = dateHelper.formatDate(hDate.date, options.formatDate);
  1062. if (highlightedDates[keyDate] !== undefined) {
  1063. exDesc = highlightedDates[keyDate].desc;
  1064. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  1065. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  1066. }
  1067. } else {
  1068. highlightedDates[keyDate] = hDate;
  1069. }
  1070. });
  1071. options.highlightedDates = $.extend(true, [], highlightedDates);
  1072. }
  1073. if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
  1074. highlightedDates = $.extend(true, [], options.highlightedDates);
  1075. $.each(_options.highlightedPeriods, function (index, value) {
  1076. var dateTest, // start date
  1077. dateEnd,
  1078. desc,
  1079. hDate,
  1080. keyDate,
  1081. exDesc,
  1082. style;
  1083. if ($.isArray(value)) {
  1084. dateTest = value[0];
  1085. dateEnd = value[1];
  1086. desc = value[2];
  1087. style = value[3];
  1088. }
  1089. else {
  1090. var splitData = $.map(value.split(','), $.trim);
  1091. dateTest = dateHelper.parseDate(splitData[0], options.formatDate);
  1092. dateEnd = dateHelper.parseDate(splitData[1], options.formatDate);
  1093. desc = splitData[2];
  1094. style = splitData[3];
  1095. }
  1096. while (dateTest <= dateEnd) {
  1097. hDate = new HighlightedDate(dateTest, desc, style);
  1098. keyDate = dateHelper.formatDate(dateTest, options.formatDate);
  1099. dateTest.setDate(dateTest.getDate() + 1);
  1100. if (highlightedDates[keyDate] !== undefined) {
  1101. exDesc = highlightedDates[keyDate].desc;
  1102. if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
  1103. highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
  1104. }
  1105. } else {
  1106. highlightedDates[keyDate] = hDate;
  1107. }
  1108. }
  1109. });
  1110. options.highlightedDates = $.extend(true, [], highlightedDates);
  1111. }
  1112. if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
  1113. options.disabledDates = $.extend(true, [], _options.disabledDates);
  1114. }
  1115. if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
  1116. options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
  1117. }
  1118. if ((options.open || options.opened) && (!options.inline)) {
  1119. input.trigger('open.xdsoft');
  1120. }
  1121. if (options.inline) {
  1122. triggerAfterOpen = true;
  1123. datetimepicker.addClass('xdsoft_inline');
  1124. input.after(datetimepicker).hide();
  1125. }
  1126. if (options.inverseButton) {
  1127. options.next = 'xdsoft_prev';
  1128. options.prev = 'xdsoft_next';
  1129. }
  1130. if (options.datepicker) {
  1131. datepicker.addClass('active');
  1132. } else {
  1133. datepicker.removeClass('active');
  1134. }
  1135. if (options.timepicker) {
  1136. timepicker.addClass('active');
  1137. } else {
  1138. timepicker.removeClass('active');
  1139. }
  1140. if (options.value) {
  1141. _xdsoft_datetime.setCurrentTime(options.value);
  1142. if (input && input.val) {
  1143. input.val(_xdsoft_datetime.str);
  1144. }
  1145. }
  1146. if (isNaN(options.dayOfWeekStart)) {
  1147. options.dayOfWeekStart = 0;
  1148. } else {
  1149. options.dayOfWeekStart = parseInt(options.dayOfWeekStart, 10) % 7;
  1150. }
  1151. if (!options.timepickerScrollbar) {
  1152. timeboxparent.xdsoftScroller(options, 'hide');
  1153. }
  1154. if (options.minDate && /^[\+\-](.*)$/.test(options.minDate)) {
  1155. options.minDate = dateHelper.formatDate(_xdsoft_datetime.strToDateTime(options.minDate), options.formatDate);
  1156. }
  1157. if (options.maxDate && /^[\+\-](.*)$/.test(options.maxDate)) {
  1158. options.maxDate = dateHelper.formatDate(_xdsoft_datetime.strToDateTime(options.maxDate), options.formatDate);
  1159. }
  1160. if (options.minDateTime && /^\+(.*)$/.test(options.minDateTime)) {
  1161. options.minDateTime = _xdsoft_datetime.strToDateTime(options.minDateTime).dateFormat(options.formatDate);
  1162. }
  1163. if (options.maxDateTime && /^\+(.*)$/.test(options.maxDateTime)) {
  1164. options.maxDateTime = _xdsoft_datetime.strToDateTime(options.maxDateTime).dateFormat(options.formatDate);
  1165. }
  1166. applyButton.toggle(options.showApplyButton);
  1167. month_picker
  1168. .find('.xdsoft_today_button')
  1169. .css('visibility', !options.todayButton ? 'hidden' : 'visible');
  1170. month_picker
  1171. .find('.' + options.prev)
  1172. .css('visibility', !options.prevButton ? 'hidden' : 'visible');
  1173. month_picker
  1174. .find('.' + options.next)
  1175. .css('visibility', !options.nextButton ? 'hidden' : 'visible');
  1176. setMask(options);
  1177. if (options.validateOnBlur) {
  1178. input
  1179. .off('blur.xdsoft')
  1180. .on('blur.xdsoft', function () {
  1181. if (options.allowBlank && (!$.trim($(this).val()).length ||
  1182. (typeof options.mask === "string" && $.trim($(this).val()) === options.mask.replace(/[0-9]/g, '_')))) {
  1183. $(this).val(null);
  1184. datetimepicker.data('xdsoft_datetime').empty();
  1185. } else {
  1186. var d = dateHelper.parseDate($(this).val(), options.format);
  1187. if (d) { // parseDate() may skip some invalid parts like date or time, so make it clear for user: show parsed date/time
  1188. $(this).val(dateHelper.formatDate(d, options.format));
  1189. } else {
  1190. var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
  1191. splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
  1192. // parse the numbers as 0312 => 03:12
  1193. if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
  1194. $(this).val([splittedHours, splittedMinutes].map(function (item) {
  1195. return item > 9 ? item : '0' + item;
  1196. }).join(':'));
  1197. } else {
  1198. $(this).val(dateHelper.formatDate(_xdsoft_datetime.now(), options.format));
  1199. }
  1200. }
  1201. datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
  1202. }
  1203. datetimepicker.trigger('changedatetime.xdsoft');
  1204. datetimepicker.trigger('close.xdsoft');
  1205. });
  1206. }
  1207. options.dayOfWeekStartPrev = (options.dayOfWeekStart === 0) ? 6 : options.dayOfWeekStart - 1;
  1208. datetimepicker
  1209. .trigger('xchange.xdsoft')
  1210. .trigger('afterOpen.xdsoft');
  1211. };
  1212. datetimepicker
  1213. .data('options', options)
  1214. .on('touchstart mousedown.xdsoft', function (event) {
  1215. event.stopPropagation();
  1216. event.preventDefault();
  1217. yearselect.hide();
  1218. monthselect.hide();
  1219. return false;
  1220. });
  1221. //scroll_element = timepicker.find('.xdsoft_time_box');
  1222. timeboxparent.append(timebox);
  1223. timeboxparent.xdsoftScroller(options);
  1224. datetimepicker.on('afterOpen.xdsoft', function () {
  1225. timeboxparent.xdsoftScroller(options);
  1226. });
  1227. datetimepicker
  1228. .append(datepicker)
  1229. .append(timepicker);
  1230. if (options.withoutCopyright !== true) {
  1231. datetimepicker
  1232. .append(xdsoft_copyright);
  1233. }
  1234. datepicker
  1235. .append(month_picker)
  1236. .append(calendar)
  1237. .append(applyButton);
  1238. $(options.parentID)
  1239. .append(datetimepicker);
  1240. XDSoft_datetime = function () {
  1241. var _this = this;
  1242. _this.now = function (norecursion) {
  1243. var d = new Date(),
  1244. date,
  1245. time;
  1246. if (!norecursion && options.defaultDate) {
  1247. date = _this.strToDateTime(options.defaultDate);
  1248. d.setFullYear(date.getFullYear());
  1249. d.setMonth(date.getMonth());
  1250. d.setDate(date.getDate());
  1251. }
  1252. d.setFullYear(d.getFullYear());
  1253. if (!norecursion && options.defaultTime) {
  1254. time = _this.strtotime(options.defaultTime);
  1255. d.setHours(time.getHours());
  1256. d.setMinutes(time.getMinutes());
  1257. d.setSeconds(time.getSeconds());
  1258. d.setMilliseconds(time.getMilliseconds());
  1259. }
  1260. return d;
  1261. };
  1262. _this.isValidDate = function (d) {
  1263. if (Object.prototype.toString.call(d) !== "[object Date]") {
  1264. return false;
  1265. }
  1266. return !isNaN(d.getTime());
  1267. };
  1268. _this.setCurrentTime = function (dTime, requireValidDate) {
  1269. if (typeof dTime === 'string') {
  1270. _this.currentTime = _this.strToDateTime(dTime);
  1271. }
  1272. else if (_this.isValidDate(dTime)) {
  1273. _this.currentTime = dTime;
  1274. }
  1275. else if (!dTime && !requireValidDate && options.allowBlank && !options.inline) {
  1276. _this.currentTime = null;
  1277. }
  1278. else {
  1279. _this.currentTime = _this.now();
  1280. }
  1281. datetimepicker.trigger('xchange.xdsoft');
  1282. };
  1283. _this.empty = function () {
  1284. _this.currentTime = null;
  1285. };
  1286. _this.getCurrentTime = function () {
  1287. return _this.currentTime;
  1288. };
  1289. _this.nextMonth = function () {
  1290. if (_this.currentTime === undefined || _this.currentTime === null) {
  1291. _this.currentTime = _this.now();
  1292. }
  1293. var month = _this.currentTime.getMonth() + 1,
  1294. year;
  1295. if (month === 12) {
  1296. _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1);
  1297. month = 0;
  1298. }
  1299. year = _this.currentTime.getFullYear();
  1300. _this.currentTime.setDate(
  1301. Math.min(
  1302. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1303. _this.currentTime.getDate()
  1304. )
  1305. );
  1306. _this.currentTime.setMonth(month);
  1307. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1308. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1309. }
  1310. if (year !== _this.currentTime.getFullYear() && $.isFunction(options.onChangeYear)) {
  1311. options.onChangeYear.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1312. }
  1313. datetimepicker.trigger('xchange.xdsoft');
  1314. return month;
  1315. };
  1316. _this.prevMonth = function () {
  1317. if (_this.currentTime === undefined || _this.currentTime === null) {
  1318. _this.currentTime = _this.now();
  1319. }
  1320. var month = _this.currentTime.getMonth() - 1;
  1321. if (month === -1) {
  1322. _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
  1323. month = 11;
  1324. }
  1325. _this.currentTime.setDate(
  1326. Math.min(
  1327. new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(),
  1328. _this.currentTime.getDate()
  1329. )
  1330. );
  1331. _this.currentTime.setMonth(month);
  1332. if (options.onChangeMonth && $.isFunction(options.onChangeMonth)) {
  1333. options.onChangeMonth.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1334. }
  1335. datetimepicker.trigger('xchange.xdsoft');
  1336. return month;
  1337. };
  1338. _this.getWeekOfYear = function (datetime) {
  1339. if (options.onGetWeekOfYear && $.isFunction(options.onGetWeekOfYear)) {
  1340. var week = options.onGetWeekOfYear.call(datetimepicker, datetime);
  1341. if (typeof week !== 'undefined') {
  1342. return week;
  1343. }
  1344. }
  1345. var onejan = new Date(datetime.getFullYear(), 0, 1);
  1346. //First week of the year is th one with the first Thursday according to ISO8601
  1347. if (onejan.getDay() !== 4) {
  1348. onejan.setMonth(0, 1 + ((4 - onejan.getDay()+ 7) % 7));
  1349. }
  1350. return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7);
  1351. };
  1352. _this.strToDateTime = function (sDateTime) {
  1353. var tmpDate = [], timeOffset, currentTime;
  1354. if (sDateTime && sDateTime instanceof Date && _this.isValidDate(sDateTime)) {
  1355. return sDateTime;
  1356. }
  1357. tmpDate = /^([+-]{1})(.*)$/.exec(sDateTime);
  1358. if (tmpDate) {
  1359. tmpDate[2] = dateHelper.parseDate(tmpDate[2], options.formatDate);
  1360. }
  1361. if (tmpDate && tmpDate[2]) {
  1362. timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
  1363. currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
  1364. } else {
  1365. currentTime = sDateTime ? dateHelper.parseDate(sDateTime, options.format) : _this.now();
  1366. }
  1367. if (!_this.isValidDate(currentTime)) {
  1368. currentTime = _this.now();
  1369. }
  1370. return currentTime;
  1371. };
  1372. _this.strToDate = function (sDate) {
  1373. if (sDate && sDate instanceof Date && _this.isValidDate(sDate)) {
  1374. return sDate;
  1375. }
  1376. var currentTime = sDate ? dateHelper.parseDate(sDate, options.formatDate) : _this.now(true);
  1377. if (!_this.isValidDate(currentTime)) {
  1378. currentTime = _this.now(true);
  1379. }
  1380. return currentTime;
  1381. };
  1382. _this.strtotime = function (sTime) {
  1383. if (sTime && sTime instanceof Date && _this.isValidDate(sTime)) {
  1384. return sTime;
  1385. }
  1386. var currentTime = sTime ? dateHelper.parseDate(sTime, options.formatTime) : _this.now(true);
  1387. if (!_this.isValidDate(currentTime)) {
  1388. currentTime = _this.now(true);
  1389. }
  1390. return currentTime;
  1391. };
  1392. _this.str = function () {
  1393. var format = options.format;
  1394. if (options.yearOffset) {
  1395. format = format.replace('Y', _this.currentTime.getFullYear() + options.yearOffset);
  1396. format = format.replace('y', String(_this.currentTime.getFullYear() + options.yearOffset).substring(2, 4));
  1397. }
  1398. return dateHelper.formatDate(_this.currentTime, format);
  1399. };
  1400. _this.currentTime = this.now();
  1401. };
  1402. _xdsoft_datetime = new XDSoft_datetime();
  1403. applyButton.on('touchend click', function (e) {//pathbrite
  1404. e.preventDefault();
  1405. datetimepicker.data('changed', true);
  1406. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  1407. input.val(_xdsoft_datetime.str());
  1408. datetimepicker.trigger('close.xdsoft');
  1409. });
  1410. month_picker
  1411. .find('.xdsoft_today_button')
  1412. .on('touchend mousedown.xdsoft', function () {
  1413. datetimepicker.data('changed', true);
  1414. _xdsoft_datetime.setCurrentTime(0, true);
  1415. datetimepicker.trigger('afterOpen.xdsoft');
  1416. }).on('dblclick.xdsoft', function () {
  1417. var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
  1418. currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
  1419. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1420. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1421. if (currentDate < minDate) {
  1422. return;
  1423. }
  1424. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1425. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
  1426. if (currentDate > maxDate) {
  1427. return;
  1428. }
  1429. input.val(_xdsoft_datetime.str());
  1430. input.trigger('change');
  1431. datetimepicker.trigger('close.xdsoft');
  1432. });
  1433. month_picker
  1434. .find('.xdsoft_prev,.xdsoft_next')
  1435. .on('touchend mousedown.xdsoft', function () {
  1436. var $this = $(this),
  1437. timer = 0,
  1438. stop = false;
  1439. (function arguments_callee1(v) {
  1440. if ($this.hasClass(options.next)) {
  1441. _xdsoft_datetime.nextMonth();
  1442. } else if ($this.hasClass(options.prev)) {
  1443. _xdsoft_datetime.prevMonth();
  1444. }
  1445. if (options.monthChangeSpinner) {
  1446. if (!stop) {
  1447. timer = setTimeout(arguments_callee1, v || 100);
  1448. }
  1449. }
  1450. }(500));
  1451. $([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft', function arguments_callee2() {
  1452. clearTimeout(timer);
  1453. stop = true;
  1454. $([options.ownerDocument.body, options.contentWindow]).off('touchend mouseup.xdsoft', arguments_callee2);
  1455. });
  1456. });
  1457. timepicker
  1458. .find('.xdsoft_prev,.xdsoft_next')
  1459. .on('touchend mousedown.xdsoft', function () {
  1460. var $this = $(this),
  1461. timer = 0,
  1462. stop = false,
  1463. period = 110;
  1464. (function arguments_callee4(v) {
  1465. var pheight = timeboxparent[0].clientHeight,
  1466. height = timebox[0].offsetHeight,
  1467. top = Math.abs(parseInt(timebox.css('marginTop'), 10));
  1468. if ($this.hasClass(options.next) && (height - pheight) - options.timeHeightInTimePicker >= top) {
  1469. timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px');
  1470. } else if ($this.hasClass(options.prev) && top - options.timeHeightInTimePicker >= 0) {
  1471. timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px');
  1472. }
  1473. /**
  1474. * Fixed bug:
  1475. * When using css3 transition, it will cause a bug that you cannot scroll the timepicker list.
  1476. * The reason is that the transition-duration time, if you set it to 0, all things fine, otherwise, this
  1477. * would cause a bug when you use jquery.css method.
  1478. * Let's say: * { transition: all .5s ease; }
  1479. * jquery timebox.css('marginTop') will return the original value which is before you clicking the next/prev button,
  1480. * meanwhile the timebox[0].style.marginTop will return the right value which is after you clicking the
  1481. * next/prev button.
  1482. *
  1483. * What we should do:
  1484. * Replace timebox.css('marginTop') with timebox[0].style.marginTop.
  1485. */
  1486. timeboxparent.trigger('scroll_element.xdsoft_scroller', [Math.abs(parseInt(timebox[0].style.marginTop, 10) / (height - pheight))]);
  1487. period = (period > 10) ? 10 : period - 10;
  1488. if (!stop) {
  1489. timer = setTimeout(arguments_callee4, v || period);
  1490. }
  1491. }(500));
  1492. $([options.ownerDocument.body, options.contentWindow]).on('touchend mouseup.xdsoft', function arguments_callee5() {
  1493. clearTimeout(timer);
  1494. stop = true;
  1495. $([options.ownerDocument.body, options.contentWindow])
  1496. .off('touchend mouseup.xdsoft', arguments_callee5);
  1497. });
  1498. });
  1499. xchangeTimer = 0;
  1500. // base handler - generating a calendar and timepicker
  1501. datetimepicker
  1502. .on('xchange.xdsoft', function (event) {
  1503. clearTimeout(xchangeTimer);
  1504. xchangeTimer = setTimeout(function () {
  1505. if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
  1506. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1507. }
  1508. var table = '',
  1509. start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
  1510. i = 0,
  1511. j,
  1512. today = _xdsoft_datetime.now(),
  1513. maxDate = false,
  1514. minDate = false,
  1515. minDateTime = false,
  1516. maxDateTime = false,
  1517. hDate,
  1518. day,
  1519. d,
  1520. y,
  1521. m,
  1522. w,
  1523. classes = [],
  1524. customDateSettings,
  1525. newRow = true,
  1526. time = '',
  1527. h,
  1528. line_time,
  1529. description;
  1530. while (start.getDay() !== options.dayOfWeekStart) {
  1531. start.setDate(start.getDate() - 1);
  1532. }
  1533. table += '<table><thead><tr>';
  1534. if (options.weeks) {
  1535. table += '<th></th>';
  1536. }
  1537. for (j = 0; j < 7; j += 1) {
  1538. table += '<th>' + options.i18n[globalLocale].dayOfWeekShort[(j + options.dayOfWeekStart) % 7] + '</th>';
  1539. }
  1540. table += '</tr></thead>';
  1541. table += '<tbody>';
  1542. if (options.maxDate !== false) {
  1543. maxDate = _xdsoft_datetime.strToDate(options.maxDate);
  1544. maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999);
  1545. }
  1546. if (options.minDate !== false) {
  1547. minDate = _xdsoft_datetime.strToDate(options.minDate);
  1548. minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
  1549. }
  1550. if (options.minDateTime !== false) {
  1551. minDateTime = _xdsoft_datetime.strToDate(options.minDateTime);
  1552. minDateTime = new Date(minDateTime.getFullYear(), minDateTime.getMonth(), minDateTime.getDate(), minDateTime.getHours(), minDateTime.getMinutes(), minDateTime.getSeconds());
  1553. }
  1554. if (options.maxDateTime !== false) {
  1555. maxDateTime = _xdsoft_datetime.strToDate(options.maxDateTime);
  1556. maxDateTime = new Date(maxDateTime.getFullYear(), maxDateTime.getMonth(), maxDateTime.getDate(), maxDateTime.getHours(), maxDateTime.getMinutes(), maxDateTime.getSeconds());
  1557. }
  1558. var maxDateTimeDay;
  1559. if (maxDateTime !== false) {
  1560. maxDateTimeDay = ((maxDateTime.getFullYear() * 12) + maxDateTime.getMonth()) * 31 + maxDateTime.getDate();
  1561. }
  1562. while (i < _xdsoft_datetime.currentTime.countDaysInMonth() || start.getDay() !== options.dayOfWeekStart || _xdsoft_datetime.currentTime.getMonth() === start.getMonth()) {
  1563. classes = [];
  1564. i += 1;
  1565. day = start.getDay();
  1566. d = start.getDate();
  1567. y = start.getFullYear();
  1568. m = start.getMonth();
  1569. w = _xdsoft_datetime.getWeekOfYear(start);
  1570. description = '';
  1571. classes.push('xdsoft_date');
  1572. if (options.beforeShowDay && $.isFunction(options.beforeShowDay.call)) {
  1573. customDateSettings = options.beforeShowDay.call(datetimepicker, start);
  1574. } else {
  1575. customDateSettings = null;
  1576. }
  1577. if(options.allowDateRe && Object.prototype.toString.call(options.allowDateRe) === "[object RegExp]"){
  1578. if(!options.allowDateRe.test(dateHelper.formatDate(start, options.formatDate))){
  1579. classes.push('xdsoft_disabled');
  1580. }
  1581. }
  1582. if(options.allowDates && options.allowDates.length>0){
  1583. if(options.allowDates.indexOf(dateHelper.formatDate(start, options.formatDate)) === -1){
  1584. classes.push('xdsoft_disabled');
  1585. }
  1586. }
  1587. var currentDay = ((start.getFullYear() * 12) + start.getMonth()) * 31 + start.getDate();
  1588. if ((maxDate !== false && start > maxDate) || (minDateTime !== false && start < minDateTime) || (minDate !== false && start < minDate) || (maxDateTime !== false && currentDay > maxDateTimeDay) || (customDateSettings && customDateSettings[0] === false)) {
  1589. classes.push('xdsoft_disabled');
  1590. }
  1591. if (options.disabledDates.indexOf(dateHelper.formatDate(start, options.formatDate)) !== -1) {
  1592. classes.push('xdsoft_disabled');
  1593. }
  1594. if (options.disabledWeekDays.indexOf(day) !== -1) {
  1595. classes.push('xdsoft_disabled');
  1596. }
  1597. if (input.is('[disabled]')) {
  1598. classes.push('xdsoft_disabled');
  1599. }
  1600. if (customDateSettings && customDateSettings[1] !== "") {
  1601. classes.push(customDateSettings[1]);
  1602. }
  1603. if (_xdsoft_datetime.currentTime.getMonth() !== m) {
  1604. classes.push('xdsoft_other_month');
  1605. }
  1606. if ((options.defaultSelect || datetimepicker.data('changed')) && dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(start, options.formatDate)) {
  1607. classes.push('xdsoft_current');
  1608. }
  1609. if (dateHelper.formatDate(today, options.formatDate) === dateHelper.formatDate(start, options.formatDate)) {
  1610. classes.push('xdsoft_today');
  1611. }
  1612. if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(dateHelper.formatDate(start, options.formatDate)) !== -1) {
  1613. classes.push('xdsoft_weekend');
  1614. }
  1615. if (options.highlightedDates[dateHelper.formatDate(start, options.formatDate)] !== undefined) {
  1616. hDate = options.highlightedDates[dateHelper.formatDate(start, options.formatDate)];
  1617. classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
  1618. description = hDate.desc === undefined ? '' : hDate.desc;
  1619. }
  1620. if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
  1621. classes.push(options.beforeShowDay(start));
  1622. }
  1623. if (newRow) {
  1624. table += '<tr>';
  1625. newRow = false;
  1626. if (options.weeks) {
  1627. table += '<th>' + w + '</th>';
  1628. }
  1629. }
  1630. table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
  1631. '<div>' + d + '</div>' +
  1632. '</td>';
  1633. if (start.getDay() === options.dayOfWeekStartPrev) {
  1634. table += '</tr>';
  1635. newRow = true;
  1636. }
  1637. start.setDate(d + 1);
  1638. }
  1639. table += '</tbody></table>';
  1640. calendar.html(table);
  1641. month_picker.find('.xdsoft_label span').eq(0).text(options.i18n[globalLocale].months[_xdsoft_datetime.currentTime.getMonth()]);
  1642. month_picker.find('.xdsoft_label span').eq(1).text(_xdsoft_datetime.currentTime.getFullYear() + options.yearOffset);
  1643. // generate timebox
  1644. time = '';
  1645. h = '';
  1646. m = '';
  1647. var minTimeMinutesOfDay = 0;
  1648. if (options.minTime !== false) {
  1649. var t = _xdsoft_datetime.strtotime(options.minTime);
  1650. minTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
  1651. }
  1652. var maxTimeMinutesOfDay = 24 * 60;
  1653. if (options.maxTime !== false) {
  1654. var t = _xdsoft_datetime.strtotime(options.maxTime);
  1655. maxTimeMinutesOfDay = 60 * t.getHours() + t.getMinutes();
  1656. }
  1657. if (options.minDateTime !== false) {
  1658. var t = _xdsoft_datetime.strToDateTime(options.minDateTime);
  1659. var currentDayIsMinDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
  1660. if (currentDayIsMinDateTimeDay) {
  1661. var m = 60 * t.getHours() + t.getMinutes();
  1662. if (m > minTimeMinutesOfDay) minTimeMinutesOfDay = m;
  1663. }
  1664. }
  1665. if (options.maxDateTime !== false) {
  1666. var t = _xdsoft_datetime.strToDateTime(options.maxDateTime);
  1667. var currentDayIsMaxDateTimeDay = dateHelper.formatDate(_xdsoft_datetime.currentTime, options.formatDate) === dateHelper.formatDate(t, options.formatDate);
  1668. if (currentDayIsMaxDateTimeDay) {
  1669. var m = 60 * t.getHours() + t.getMinutes();
  1670. if (m < maxTimeMinutesOfDay) maxTimeMinutesOfDay = m;
  1671. }
  1672. }
  1673. line_time = function line_time(h, m) {
  1674. var now = _xdsoft_datetime.now(), current_time,
  1675. isALlowTimesInit = options.allowTimes && $.isArray(options.allowTimes) && options.allowTimes.length;
  1676. now.setHours(h);
  1677. h = parseInt(now.getHours(), 10);
  1678. now.setMinutes(m);
  1679. m = parseInt(now.getMinutes(), 10);
  1680. classes = [];
  1681. var currentMinutesOfDay = 60 * h + m;
  1682. if (input.is('[disabled]') || (currentMinutesOfDay >= maxTimeMinutesOfDay) || (currentMinutesOfDay < minTimeMinutesOfDay)) {
  1683. classes.push('xdsoft_disabled');
  1684. }
  1685. current_time = new Date(_xdsoft_datetime.currentTime);
  1686. current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
  1687. if (!isALlowTimesInit) {
  1688. current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
  1689. }
  1690. if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && ((!isALlowTimesInit && options.step > 59) || current_time.getMinutes() === parseInt(m, 10))) {
  1691. if (options.defaultSelect || datetimepicker.data('changed')) {
  1692. classes.push('xdsoft_current');
  1693. } else if (options.initTime) {
  1694. classes.push('xdsoft_init_time');
  1695. }
  1696. }
  1697. if (parseInt(today.getHours(), 10) === parseInt(h, 10) && parseInt(today.getMinutes(), 10) === parseInt(m, 10)) {
  1698. classes.push('xdsoft_today');
  1699. }
  1700. time += '<div class="xdsoft_time ' + classes.join(' ') + '" data-hour="' + h + '" data-minute="' + m + '">' + dateHelper.formatDate(now, options.formatTime) + '</div>';
  1701. };
  1702. if (!options.allowTimes || !$.isArray(options.allowTimes) || !options.allowTimes.length) {
  1703. for (i = 0, j = 0; i < (options.hours12 ? 12 : 24); i += 1) {
  1704. for (j = 0; j < 60; j += options.step) {
  1705. var currentMinutesOfDay = i * 60 + j;
  1706. if (currentMinutesOfDay < minTimeMinutesOfDay) continue;
  1707. if (currentMinutesOfDay >= maxTimeMinutesOfDay) continue;
  1708. h = (i < 10 ? '0' : '') + i;
  1709. m = (j < 10 ? '0' : '') + j;
  1710. line_time(h, m);
  1711. }
  1712. }
  1713. } else {
  1714. for (i = 0; i < options.allowTimes.length; i += 1) {
  1715. h = _xdsoft_datetime.strtotime(options.allowTimes[i]).getHours();
  1716. m = _xdsoft_datetime.strtotime(options.allowTimes[i]).getMinutes();
  1717. line_time(h, m);
  1718. }
  1719. }
  1720. timebox.html(time);
  1721. opt = '';
  1722. for (i = parseInt(options.yearStart, 10); i <= parseInt(options.yearEnd, 10); i += 1) {
  1723. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getFullYear() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + (i + options.yearOffset) + '</div>';
  1724. }
  1725. yearselect.children().eq(0)
  1726. .html(opt);
  1727. for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
  1728. opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[globalLocale].months[i] + '</div>';
  1729. }
  1730. monthselect.children().eq(0).html(opt);
  1731. $(datetimepicker)
  1732. .trigger('generate.xdsoft');
  1733. }, 10);
  1734. event.stopPropagation();
  1735. })
  1736. .on('afterOpen.xdsoft', function () {
  1737. if (options.timepicker) {
  1738. var classType, pheight, height, top;
  1739. if (timebox.find('.xdsoft_current').length) {
  1740. classType = '.xdsoft_current';
  1741. } else if (timebox.find('.xdsoft_init_time').length) {
  1742. classType = '.xdsoft_init_time';
  1743. }
  1744. if (classType) {
  1745. pheight = timeboxparent[0].clientHeight;
  1746. height = timebox[0].offsetHeight;
  1747. top = timebox.find(classType).index() * options.timeHeightInTimePicker + 1;
  1748. if ((height - pheight) < top) {
  1749. top = height - pheight;
  1750. }
  1751. timeboxparent.trigger('scroll_element.xdsoft_scroller', [parseInt(top, 10) / (height - pheight)]);
  1752. } else {
  1753. timeboxparent.trigger('scroll_element.xdsoft_scroller', [0]);
  1754. }
  1755. }
  1756. });
  1757. timerclick = 0;
  1758. calendar
  1759. .on('touchend click.xdsoft', 'td', function (xdevent) {
  1760. xdevent.stopPropagation(); // Prevents closing of Pop-ups, Modals and Flyouts in Bootstrap
  1761. timerclick += 1;
  1762. var $this = $(this),
  1763. currentTime = _xdsoft_datetime.currentTime;
  1764. if (currentTime === undefined || currentTime === null) {
  1765. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1766. currentTime = _xdsoft_datetime.currentTime;
  1767. }
  1768. if ($this.hasClass('xdsoft_disabled')) {
  1769. return false;
  1770. }
  1771. currentTime.setDate(1);
  1772. currentTime.setFullYear($this.data('year'));
  1773. currentTime.setMonth($this.data('month'));
  1774. currentTime.setDate($this.data('date'));
  1775. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1776. input.val(_xdsoft_datetime.str());
  1777. if (options.onSelectDate && $.isFunction(options.onSelectDate)) {
  1778. options.onSelectDate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1779. }
  1780. datetimepicker.data('changed', true);
  1781. datetimepicker.trigger('xchange.xdsoft');
  1782. datetimepicker.trigger('changedatetime.xdsoft');
  1783. if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
  1784. datetimepicker.trigger('close.xdsoft');
  1785. }
  1786. setTimeout(function () {
  1787. timerclick = 0;
  1788. }, 200);
  1789. });
  1790. timebox
  1791. .on('touchstart', 'div', function (xdevent) {
  1792. this.touchMoved = false;
  1793. })
  1794. .on('touchmove', 'div', handleTouchMoved)
  1795. .on('touchend click.xdsoft', 'div', function (xdevent) {
  1796. if (!this.touchMoved) {
  1797. xdevent.stopPropagation();
  1798. var $this = $(this),
  1799. currentTime = _xdsoft_datetime.currentTime;
  1800. if (currentTime === undefined || currentTime === null) {
  1801. _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
  1802. currentTime = _xdsoft_datetime.currentTime;
  1803. }
  1804. if ($this.hasClass('xdsoft_disabled')) {
  1805. return false;
  1806. }
  1807. currentTime.setHours($this.data('hour'));
  1808. currentTime.setMinutes($this.data('minute'));
  1809. datetimepicker.trigger('select.xdsoft', [currentTime]);
  1810. datetimepicker.data('input').val(_xdsoft_datetime.str());
  1811. if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
  1812. options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
  1813. }
  1814. datetimepicker.data('changed', true);
  1815. datetimepicker.trigger('xchange.xdsoft');
  1816. datetimepicker.trigger('changedatetime.xdsoft');
  1817. if (options.inline !== true && options.closeOnTimeSelect === true) {
  1818. datetimepicker.trigger('close.xdsoft');
  1819. }
  1820. }
  1821. });
  1822. datepicker
  1823. .on('mousewheel.xdsoft', function (event) {
  1824. if (!options.scrollMonth) {
  1825. return true;
  1826. }
  1827. if (event.deltaY < 0) {
  1828. _xdsoft_datetime.nextMonth();
  1829. } else {
  1830. _xdsoft_datetime.prevMonth();
  1831. }
  1832. return false;
  1833. });
  1834. input
  1835. .on('mousewheel.xdsoft', function (event) {
  1836. if (!options.scrollInput) {
  1837. return true;
  1838. }
  1839. if (!options.datepicker && options.timepicker) {
  1840. current_time_index = timebox.find('.xdsoft_current').length ? timebox.find('.xdsoft_current').eq(0).index() : 0;
  1841. if (current_time_index + event.deltaY >= 0 && current_time_index + event.deltaY < timebox.children().length) {
  1842. current_time_index += event.deltaY;
  1843. }
  1844. if (timebox.children().eq(current_time_index).length) {
  1845. timebox.children().eq(current_time_index).trigger('mousedown');
  1846. }
  1847. return false;
  1848. }
  1849. if (options.datepicker && !options.timepicker) {
  1850. datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]);
  1851. if (input.val) {
  1852. input.val(_xdsoft_datetime.str());
  1853. }
  1854. datetimepicker.trigger('changedatetime.xdsoft');
  1855. return false;
  1856. }
  1857. });
  1858. datetimepicker
  1859. .on('changedatetime.xdsoft', function (event) {
  1860. if (options.onChangeDateTime && $.isFunction(options.onChangeDateTime)) {
  1861. var $input = datetimepicker.data('input');
  1862. options.onChangeDateTime.call(datetimepicker, _xdsoft_datetime.currentTime, $input, event);
  1863. delete options.value;
  1864. $input.trigger('change');
  1865. }
  1866. })
  1867. .on('generate.xdsoft', function () {
  1868. if (options.onGenerate && $.isFunction(options.onGenerate)) {
  1869. options.onGenerate.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'));
  1870. }
  1871. if (triggerAfterOpen) {
  1872. datetimepicker.trigger('afterOpen.xdsoft');
  1873. triggerAfterOpen = false;
  1874. }
  1875. })
  1876. .on('click.xdsoft', function (xdevent) {
  1877. xdevent.stopPropagation();
  1878. });
  1879. current_time_index = 0;
  1880. /**
  1881. * Runs the callback for each of the specified node's ancestors.
  1882. *
  1883. * Return FALSE from the callback to stop ascending.
  1884. *
  1885. * @param {DOMNode} node
  1886. * @param {Function} callback
  1887. * @returns {undefined}
  1888. */
  1889. forEachAncestorOf = function (node, callback) {
  1890. do {
  1891. node = node.parentNode;
  1892. if (!node || callback(node) === false) {
  1893. break;
  1894. }
  1895. } while (node.nodeName !== 'HTML');
  1896. };
  1897. /**
  1898. * Sets the position of the picker.
  1899. *
  1900. * @returns {undefined}
  1901. */
  1902. setPos = function () {
  1903. var dateInputOffset,
  1904. dateInputElem,
  1905. verticalPosition,
  1906. left,
  1907. position,
  1908. datetimepickerElem,
  1909. dateInputHasFixedAncestor,
  1910. $dateInput,
  1911. windowWidth,
  1912. verticalAnchorEdge,
  1913. datetimepickerCss,
  1914. windowHeight,
  1915. windowScrollTop;
  1916. $dateInput = datetimepicker.data('input');
  1917. dateInputOffset = $dateInput.offset();
  1918. dateInputElem = $dateInput[0];
  1919. verticalAnchorEdge = 'top';
  1920. verticalPosition = (dateInputOffset.top + dateInputElem.offsetHeight) - 1;
  1921. left = dateInputOffset.left;
  1922. position = "absolute";
  1923. windowWidth = $(options.contentWindow).width();
  1924. windowHeight = $(options.contentWindow).height();
  1925. windowScrollTop = $(options.contentWindow).scrollTop();
  1926. if ((options.ownerDocument.documentElement.clientWidth - dateInputOffset.left) < datepicker.parent().outerWidth(true)) {
  1927. var diff = datepicker.parent().outerWidth(true) - dateInputElem.offsetWidth;
  1928. left = left - diff;
  1929. }
  1930. if ($dateInput.parent().css('direction') === 'rtl') {
  1931. left -= (datetimepicker.outerWidth() - $dateInput.outerWidth());
  1932. }
  1933. if (options.fixed) {
  1934. verticalPosition -= windowScrollTop;
  1935. left -= $(options.contentWindow).scrollLeft();
  1936. position = "fixed";
  1937. } else {
  1938. dateInputHasFixedAncestor = false;
  1939. forEachAncestorOf(dateInputElem, function (ancestorNode) {
  1940. if (ancestorNode === null) {
  1941. return false;
  1942. }
  1943. if (options.contentWindow.getComputedStyle(ancestorNode).getPropertyValue('position') === 'fixed') {
  1944. dateInputHasFixedAncestor = true;
  1945. return false;
  1946. }
  1947. });
  1948. if (dateInputHasFixedAncestor) {
  1949. position = 'fixed';
  1950. //If the picker won't fit entirely within the viewport then display it above the date input.
  1951. if (verticalPosition + datetimepicker.outerHeight() > windowHeight + windowScrollTop) {
  1952. verticalAnchorEdge = 'bottom';
  1953. verticalPosition = (windowHeight + windowScrollTop) - dateInputOffset.top;
  1954. } else {
  1955. verticalPosition -= windowScrollTop;
  1956. }
  1957. } else {
  1958. if (verticalPosition + datetimepicker[0].offsetHeight > windowHeight + windowScrollTop) {
  1959. verticalPosition = dateInputOffset.top - datetimepicker[0].offsetHeight + 1;
  1960. }
  1961. }
  1962. if (verticalPosition < 0) {
  1963. verticalPosition = 0;
  1964. }
  1965. if (left + dateInputElem.offsetWidth > windowWidth) {
  1966. left = windowWidth - dateInputElem.offsetWidth;
  1967. }
  1968. }
  1969. datetimepickerElem = datetimepicker[0];
  1970. forEachAncestorOf(datetimepickerElem, function (ancestorNode) {
  1971. var ancestorNodePosition;
  1972. ancestorNodePosition = options.contentWindow.getComputedStyle(ancestorNode).getPropertyValue('position');
  1973. if (ancestorNodePosition === 'relative' && windowWidth >= ancestorNode.offsetWidth) {
  1974. left = left - ((windowWidth - ancestorNode.offsetWidth) / 2);
  1975. return false;
  1976. }
  1977. });
  1978. datetimepickerCss = {
  1979. position: position,
  1980. left: left,
  1981. top: '', //Initialize to prevent previous values interfering with new ones.
  1982. bottom: '' //Initialize to prevent previous values interfering with new ones.
  1983. };
  1984. datetimepickerCss[verticalAnchorEdge] = verticalPosition;
  1985. datetimepicker.css(datetimepickerCss);
  1986. };
  1987. datetimepicker
  1988. .on('open.xdsoft', function (event) {
  1989. var onShow = true;
  1990. if (options.onShow && $.isFunction(options.onShow)) {
  1991. onShow = options.onShow.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  1992. }
  1993. if (onShow !== false) {
  1994. datetimepicker.show();
  1995. setPos();
  1996. $(options.contentWindow)
  1997. .off('resize.xdsoft', setPos)
  1998. .on('resize.xdsoft', setPos);
  1999. if (options.closeOnWithoutClick) {
  2000. $([options.ownerDocument.body, options.contentWindow]).on('touchstart mousedown.xdsoft', function arguments_callee6() {
  2001. datetimepicker.trigger('close.xdsoft');
  2002. $([options.ownerDocument.body, options.contentWindow]).off('touchstart mousedown.xdsoft', arguments_callee6);
  2003. });
  2004. }
  2005. }
  2006. })
  2007. .on('close.xdsoft', function (event) {
  2008. var onClose = true;
  2009. month_picker
  2010. .find('.xdsoft_month,.xdsoft_year')
  2011. .find('.xdsoft_select')
  2012. .hide();
  2013. if (options.onClose && $.isFunction(options.onClose)) {
  2014. onClose = options.onClose.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), event);
  2015. }
  2016. if (onClose !== false && !options.opened && !options.inline) {
  2017. datetimepicker.hide();
  2018. }
  2019. event.stopPropagation();
  2020. })
  2021. .on('toggle.xdsoft', function () {
  2022. if (datetimepicker.is(':visible')) {
  2023. datetimepicker.trigger('close.xdsoft');
  2024. } else {
  2025. datetimepicker.trigger('open.xdsoft');
  2026. }
  2027. })
  2028. .data('input', input);
  2029. timer = 0;
  2030. datetimepicker.data('xdsoft_datetime', _xdsoft_datetime);
  2031. datetimepicker.setOptions(options);
  2032. function getCurrentValue() {
  2033. var ct = false, time;
  2034. if (options.startDate) {
  2035. ct = _xdsoft_datetime.strToDate(options.startDate);
  2036. } else {
  2037. ct = options.value || ((input && input.val && input.val()) ? input.val() : '');
  2038. if (ct) {
  2039. ct = _xdsoft_datetime.strToDateTime(ct);
  2040. if (options.yearOffset) {
  2041. ct = new Date(ct.getFullYear() - options.yearOffset, ct.getMonth(), ct.getDate(), ct.getHours(), ct.getMinutes(), ct.getSeconds(), ct.getMilliseconds());
  2042. }
  2043. } else if (options.defaultDate) {
  2044. ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
  2045. if (options.defaultTime) {
  2046. time = _xdsoft_datetime.strtotime(options.defaultTime);
  2047. ct.setHours(time.getHours());
  2048. ct.setMinutes(time.getMinutes());
  2049. }
  2050. }
  2051. }
  2052. if (ct && _xdsoft_datetime.isValidDate(ct)) {
  2053. datetimepicker.data('changed', true);
  2054. } else {
  2055. ct = '';
  2056. }
  2057. return ct || 0;
  2058. }
  2059. function setMask(options) {
  2060. var isValidValue = function (mask, value) {
  2061. var reg = mask
  2062. .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
  2063. .replace(/_/g, '{digit+}')
  2064. .replace(/([0-9]{1})/g, '{digit$1}')
  2065. .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
  2066. .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
  2067. return (new RegExp(reg)).test(value);
  2068. },
  2069. getCaretPos = function (input) {
  2070. try {
  2071. if (options.ownerDocument.selection && options.ownerDocument.selection.createRange) {
  2072. var range = options.ownerDocument.selection.createRange();
  2073. return range.getBookmark().charCodeAt(2) - 2;
  2074. }
  2075. if (input.setSelectionRange) {
  2076. return input.selectionStart;
  2077. }
  2078. } catch (e) {
  2079. return 0;
  2080. }
  2081. },
  2082. setCaretPos = function (node, pos) {
  2083. node = (typeof node === "string" || node instanceof String) ? options.ownerDocument.getElementById(node) : node;
  2084. if (!node) {
  2085. return false;
  2086. }
  2087. if (node.createTextRange) {
  2088. var textRange = node.createTextRange();
  2089. textRange.collapse(true);
  2090. textRange.moveEnd('character', pos);
  2091. textRange.moveStart('character', pos);
  2092. textRange.select();
  2093. return true;
  2094. }
  2095. if (node.setSelectionRange) {
  2096. node.setSelectionRange(pos, pos);
  2097. return true;
  2098. }
  2099. return false;
  2100. };
  2101. if(options.mask) {
  2102. input.off('keydown.xdsoft');
  2103. }
  2104. if (options.mask === true) {
  2105. if (dateHelper.formatMask) {
  2106. options.mask = dateHelper.formatMask(options.format)
  2107. } else {
  2108. options.mask = options.format
  2109. .replace(/Y/g, '9999')
  2110. .replace(/F/g, '9999')
  2111. .replace(/m/g, '19')
  2112. .replace(/d/g, '39')
  2113. .replace(/H/g, '29')
  2114. .replace(/i/g, '59')
  2115. .replace(/s/g, '59');
  2116. }
  2117. }
  2118. if ($.type(options.mask) === 'string') {
  2119. if (!isValidValue(options.mask, input.val())) {
  2120. input.val(options.mask.replace(/[0-9]/g, '_'));
  2121. setCaretPos(input[0], 0);
  2122. }
  2123. input.on('paste.xdsoft', function (event) {
  2124. // couple options here
  2125. // 1. return false - tell them they can't paste
  2126. // 2. insert over current characters - minimal validation
  2127. // 3. full fledged parsing and validation
  2128. // let's go option 2 for now
  2129. // fires multiple times for some reason
  2130. // https://stackoverflow.com/a/30496488/1366033
  2131. var clipboardData = event.clipboardData || event.originalEvent.clipboardData || window.clipboardData,
  2132. pastedData = clipboardData.getData('text'),
  2133. val = this.value,
  2134. pos = this.selectionStart
  2135. var valueBeforeCursor = val.substr(0, pos);
  2136. var valueAfterPaste = val.substr(pos + pastedData.length);
  2137. val = valueBeforeCursor + pastedData + valueAfterPaste;
  2138. pos += pastedData.length;
  2139. if (isValidValue(options.mask, val)) {
  2140. this.value = val;
  2141. setCaretPos(this, pos);
  2142. } else if ($.trim(val) === '') {
  2143. this.value = options.mask.replace(/[0-9]/g, '_');
  2144. } else {
  2145. input.trigger('error_input.xdsoft');
  2146. }
  2147. event.preventDefault();
  2148. return false;
  2149. });
  2150. input.on('keydown.xdsoft', function (event) {
  2151. var val = this.value,
  2152. key = event.which,
  2153. pos = this.selectionStart,
  2154. selEnd = this.selectionEnd,
  2155. hasSel = pos !== selEnd,
  2156. digit;
  2157. // only alow these characters
  2158. if (((key >= KEY0 && key <= KEY9) ||
  2159. (key >= _KEY0 && key <= _KEY9)) ||
  2160. (key === BACKSPACE || key === DEL)) {
  2161. // get char to insert which is new character or placeholder ('_')
  2162. digit = (key === BACKSPACE || key === DEL) ? '_' :
  2163. String.fromCharCode((_KEY0 <= key && key <= _KEY9) ? key - KEY0 : key);
  2164. // we're deleting something, we're not at the start, and have normal cursor, move back one
  2165. // if we have a selection length, cursor actually sits behind deletable char, not in front
  2166. if (key === BACKSPACE && pos && !hasSel) {
  2167. pos -= 1;
  2168. }
  2169. // don't stop on a separator, continue whatever direction you were going
  2170. // value char - keep incrementing position while on separator char and we still have room
  2171. // del char - keep decrementing position while on separator char and we still have room
  2172. while (true) {
  2173. var maskValueAtCurPos = options.mask.substr(pos, 1);
  2174. var posShorterThanMaskLength = pos < options.mask.length;
  2175. var posGreaterThanZero = pos > 0;
  2176. var notNumberOrPlaceholder = /[^0-9_]/;
  2177. var curPosOnSep = notNumberOrPlaceholder.test(maskValueAtCurPos);
  2178. var continueMovingPosition = curPosOnSep && posShorterThanMaskLength && posGreaterThanZero
  2179. // if we hit a real char, stay where we are
  2180. if (!continueMovingPosition) break;
  2181. // hitting backspace in a selection, you can possibly go back any further - go forward
  2182. pos += (key === BACKSPACE && !hasSel) ? -1 : 1;
  2183. }
  2184. if (hasSel) {
  2185. // pos might have moved so re-calc length
  2186. var selLength = selEnd - pos
  2187. // if we have a selection length we will wipe out entire selection and replace with default template for that range
  2188. var defaultBlank = options.mask.replace(/[0-9]/g, '_');
  2189. var defaultBlankSelectionReplacement = defaultBlank.substr(pos, selLength);
  2190. var selReplacementRemainder = defaultBlankSelectionReplacement.substr(1) // might be empty
  2191. var valueBeforeSel = val.substr(0, pos);
  2192. var insertChars = digit + selReplacementRemainder;
  2193. var charsAfterSelection = val.substr(pos + selLength);
  2194. val = valueBeforeSel + insertChars + charsAfterSelection
  2195. } else {
  2196. var valueBeforeCursor = val.substr(0, pos);
  2197. var insertChar = digit;
  2198. var valueAfterNextChar = val.substr(pos + 1);
  2199. val = valueBeforeCursor + insertChar + valueAfterNextChar
  2200. }
  2201. if ($.trim(val) === '') {
  2202. // if empty, set to default
  2203. val = defaultBlank
  2204. } else {
  2205. // if at the last character don't need to do anything
  2206. if (pos === options.mask.length) {
  2207. event.preventDefault();
  2208. return false;
  2209. }
  2210. }
  2211. // resume cursor location
  2212. pos += (key === BACKSPACE) ? 0 : 1;
  2213. // don't stop on a separator, continue whatever direction you were going
  2214. while (/[^0-9_]/.test(options.mask.substr(pos, 1)) && pos < options.mask.length && pos > 0) {
  2215. pos += (key === BACKSPACE) ? 0 : 1;
  2216. }
  2217. if (isValidValue(options.mask, val)) {
  2218. this.value = val;
  2219. setCaretPos(this, pos);
  2220. } else if ($.trim(val) === '') {
  2221. this.value = options.mask.replace(/[0-9]/g, '_');
  2222. } else {
  2223. input.trigger('error_input.xdsoft');
  2224. }
  2225. } else {
  2226. if (([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key) !== -1 && ctrlDown) || [ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key) !== -1) {
  2227. return true;
  2228. }
  2229. }
  2230. event.preventDefault();
  2231. return false;
  2232. });
  2233. }
  2234. }
  2235. _xdsoft_datetime.setCurrentTime(getCurrentValue());
  2236. input
  2237. .data('xdsoft_datetimepicker', datetimepicker)
  2238. .on('open.xdsoft focusin.xdsoft mousedown.xdsoft touchstart', function () {
  2239. if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
  2240. return;
  2241. }
  2242. if (!options.openOnFocus) {
  2243. return;
  2244. }
  2245. clearTimeout(timer);
  2246. timer = setTimeout(function () {
  2247. if (input.is(':disabled')) {
  2248. return;
  2249. }
  2250. triggerAfterOpen = true;
  2251. _xdsoft_datetime.setCurrentTime(getCurrentValue(), true);
  2252. if(options.mask) {
  2253. setMask(options);
  2254. }
  2255. datetimepicker.trigger('open.xdsoft');
  2256. }, 100);
  2257. })
  2258. .on('keydown.xdsoft', function (event) {
  2259. var elementSelector,
  2260. key = event.which;
  2261. if ([ENTER].indexOf(key) !== -1 && options.enterLikeTab) {
  2262. elementSelector = $("input:visible,textarea:visible,button:visible,a:visible");
  2263. datetimepicker.trigger('close.xdsoft');
  2264. elementSelector.eq(elementSelector.index(this) + 1).focus();
  2265. return false;
  2266. }
  2267. if ([TAB].indexOf(key) !== -1) {
  2268. datetimepicker.trigger('close.xdsoft');
  2269. return true;
  2270. }
  2271. })
  2272. .on('blur.xdsoft', function () {
  2273. datetimepicker.trigger('close.xdsoft');
  2274. });
  2275. };
  2276. destroyDateTimePicker = function (input) {
  2277. var datetimepicker = input.data('xdsoft_datetimepicker');
  2278. if (datetimepicker) {
  2279. datetimepicker.data('xdsoft_datetime', null);
  2280. datetimepicker.remove();
  2281. input
  2282. .data('xdsoft_datetimepicker', null)
  2283. .off('.xdsoft');
  2284. $(options.contentWindow).off('resize.xdsoft');
  2285. $([options.contentWindow, options.ownerDocument.body]).off('mousedown.xdsoft touchstart');
  2286. if (input.unmousewheel) {
  2287. input.unmousewheel();
  2288. }
  2289. }
  2290. };
  2291. $(options.ownerDocument)
  2292. .off('keydown.xdsoftctrl keyup.xdsoftctrl')
  2293. .on('keydown.xdsoftctrl', function (e) {
  2294. if (e.keyCode === CTRLKEY) {
  2295. ctrlDown = true;
  2296. }
  2297. })
  2298. .on('keyup.xdsoftctrl', function (e) {
  2299. if (e.keyCode === CTRLKEY) {
  2300. ctrlDown = false;
  2301. }
  2302. });
  2303. this.each(function () {
  2304. var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
  2305. if (datetimepicker) {
  2306. if ($.type(opt) === 'string') {
  2307. switch (opt) {
  2308. case 'show':
  2309. $(this).select().focus();
  2310. datetimepicker.trigger('open.xdsoft');
  2311. break;
  2312. case 'hide':
  2313. datetimepicker.trigger('close.xdsoft');
  2314. break;
  2315. case 'toggle':
  2316. datetimepicker.trigger('toggle.xdsoft');
  2317. break;
  2318. case 'destroy':
  2319. destroyDateTimePicker($(this));
  2320. break;
  2321. case 'reset':
  2322. this.value = this.defaultValue;
  2323. if (!this.value || !datetimepicker.data('xdsoft_datetime').isValidDate(dateHelper.parseDate(this.value, options.format))) {
  2324. datetimepicker.data('changed', false);
  2325. }
  2326. datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
  2327. break;
  2328. case 'validate':
  2329. $input = datetimepicker.data('input');
  2330. $input.trigger('blur.xdsoft');
  2331. break;
  2332. default:
  2333. if (datetimepicker[opt] && $.isFunction(datetimepicker[opt])) {
  2334. result = datetimepicker[opt](opt2);
  2335. }
  2336. }
  2337. } else {
  2338. datetimepicker
  2339. .setOptions(opt);
  2340. }
  2341. return 0;
  2342. }
  2343. if ($.type(opt) !== 'string') {
  2344. if (!options.lazyInit || options.open || options.inline) {
  2345. createDateTimePicker($(this));
  2346. } else {
  2347. lazyInit($(this));
  2348. }
  2349. }
  2350. });
  2351. return result;
  2352. };
  2353. $.fn.datetimepicker.defaults = default_options;
  2354. function HighlightedDate(date, desc, style) {
  2355. "use strict";
  2356. this.date = date;
  2357. this.desc = desc;
  2358. this.style = style;
  2359. }
  2360. };
  2361. ;(function (factory) {
  2362. if ( typeof define === 'function' && define.amd ) {
  2363. // AMD. Register as an anonymous module.
  2364. define(['jquery', 'jquery-mousewheel'], factory);
  2365. } else if (typeof exports === 'object') {
  2366. // Node/CommonJS style for Browserify
  2367. module.exports = factory(require('jquery'));;
  2368. } else {
  2369. // Browser globals
  2370. factory(jQuery);
  2371. }
  2372. }(datetimepickerFactory));