You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2886 lines
106 KiB

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