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