web_admin 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @preserve jQuery DateTimePicker plugin v2.4.1
2
+ * @preserve jQuery DateTimePicker plugin v2.4.5
3
3
  * @homepage http://xdsoft.net/jqplugins/datetimepicker/
4
4
  * (c) 2014, Chupurnov Valeriy.
5
5
  */
6
- /*global document,window,jQuery,setTimeout,clearTimeout*/
6
+ /*global document,window,jQuery,setTimeout,clearTimeout,HighlightedDate,getCurrentValue*/
7
7
  (function ($) {
8
8
  'use strict';
9
9
  var default_options = {
@@ -29,7 +29,15 @@
29
29
  "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
30
30
  ],
31
31
  dayOfWeek: [
32
- "Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Min"
32
+ "Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"
33
+ ]
34
+ },
35
+ is: { // Icelandic
36
+ months: [
37
+ "Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júní", "Júlí", "Ágúst", "September", "Október", "Nóvember", "Desember"
38
+ ],
39
+ dayOfWeek: [
40
+ "Sun", "Mán", "Þrið", "Mið", "Fim", "Fös", "Lau"
33
41
  ]
34
42
  },
35
43
  bg: { // Bulgarian
@@ -415,7 +423,23 @@
415
423
  dayOfWeek: [
416
424
  'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'
417
425
  ]
418
- }
426
+ },
427
+ hy: { // Armenian
428
+ months: [
429
+ "Հունվար", "Փետրվար", "Մարտ", "Ապրիլ", "Մայիս", "Հունիս", "Հուլիս", "Օգոստոս", "Սեպտեմբեր", "Հոկտեմբեր", "Նոյեմբեր", "Դեկտեմբեր"
430
+ ],
431
+ dayOfWeek: [
432
+ "Կի", "Երկ", "Երք", "Չոր", "Հնգ", "Ուրբ", "Շբթ"
433
+ ]
434
+ },
435
+ kg: { // Kyrgyz
436
+ months: [
437
+ 'Үчтүн айы', 'Бирдин айы', 'Жалган Куран', 'Чын Куран', 'Бугу', 'Кулжа', 'Теке', 'Баш Оона', 'Аяк Оона', 'Тогуздун айы', 'Жетинин айы', 'Бештин айы'
438
+ ],
439
+ dayOfWeek: [
440
+ "Жек", "Дүй", "Шей", "Шар", "Бей", "Жум", "Ише"
441
+ ]
442
+ }
419
443
  },
420
444
  value: '',
421
445
  lang: 'en',
@@ -429,6 +453,7 @@
429
453
  monthChangeSpinner: true,
430
454
 
431
455
  closeOnDateSelect: false,
456
+ closeOnTimeSelect: true,
432
457
  closeOnWithoutClick: true,
433
458
  closeOnInputClick: true,
434
459
 
@@ -443,6 +468,8 @@
443
468
  maxDate: false,
444
469
  minTime: false,
445
470
  maxTime: false,
471
+ disabledMinTime: false,
472
+ disabledMaxTime: false,
446
473
 
447
474
  allowTimes: [],
448
475
  opened: false,
@@ -462,13 +489,15 @@
462
489
  withoutCopyright: true,
463
490
  inverseButton: false,
464
491
  hours12: false,
465
- next: 'xdsoft_next',
492
+ next: 'xdsoft_next',
466
493
  prev : 'xdsoft_prev',
467
494
  dayOfWeekStart: 0,
468
495
  parentID: 'body',
469
496
  timeHeightInTimePicker: 25,
470
497
  timepickerScrollbar: true,
471
498
  todayButton: true,
499
+ prevButton: true,
500
+ nextButton: true,
472
501
  defaultSelect: true,
473
502
 
474
503
  scrollMonth: true,
@@ -481,19 +510,43 @@
481
510
  allowBlank: true,
482
511
  yearStart: 1950,
483
512
  yearEnd: 2050,
513
+ monthStart: 0,
514
+ monthEnd: 11,
484
515
  style: '',
485
516
  id: '',
486
517
  fixed: false,
487
518
  roundTime: 'round', // ceil, floor
488
519
  className: '',
489
520
  weekends: [],
521
+ highlightedDates: [],
522
+ highlightedPeriods: [],
490
523
  disabledDates : [],
524
+ disabledWeekDays: [],
491
525
  yearOffset: 0,
492
526
  beforeShowDay: null,
493
527
 
494
- enterLikeTab: true
528
+ enterLikeTab: true,
529
+ showApplyButton: false
495
530
  };
496
531
  // fix for ie8
532
+ if (!window.getComputedStyle) {
533
+ window.getComputedStyle = function (el, pseudo) {
534
+ this.el = el;
535
+ this.getPropertyValue = function (prop) {
536
+ var re = /(\-([a-z]){1})/g;
537
+ if (prop === 'float') {
538
+ prop = 'styleFloat';
539
+ }
540
+ if (re.test(prop)) {
541
+ prop = prop.replace(re, function (a, b, c) {
542
+ return c.toUpperCase();
543
+ });
544
+ }
545
+ return el.currentStyle[prop] || null;
546
+ };
547
+ return this;
548
+ };
549
+ }
497
550
  if (!Array.prototype.indexOf) {
498
551
  Array.prototype.indexOf = function (obj, start) {
499
552
  var i, j;
@@ -694,7 +747,7 @@
694
747
  lazyInit = function (input) {
695
748
  input
696
749
  .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function initOnActionCallback(event) {
697
- if (input.is(':disabled') || input.is(':hidden') || !input.is(':visible') || input.data('xdsoft_datetimepicker')) {
750
+ if (input.is(':disabled') || input.data('xdsoft_datetimepicker')) {
698
751
  return;
699
752
  }
700
753
  clearTimeout(lazyInitTimer);
@@ -711,7 +764,7 @@
711
764
  };
712
765
 
713
766
  createDateTimePicker = function (input) {
714
- 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>'),
767
+ var datetimepicker = $('<div class="xdsoft_datetimepicker xdsoft_noselect"></div>'),
715
768
  xdsoft_copyright = $('<div class="xdsoft_copyright"><a target="_blank" href="http://xdsoft.net/jqplugins/datetimepicker/">xdsoft.net</a></div>'),
716
769
  datepicker = $('<div class="xdsoft_datepicker active"></div>'),
717
770
  mounth_picker = $('<div class="xdsoft_mounthpicker"><button type="button" class="xdsoft_prev"></button><button type="button" class="xdsoft_today_button"></button>' +
@@ -722,6 +775,7 @@
722
775
  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>'),
723
776
  timeboxparent = timepicker.find('.xdsoft_time_box').eq(0),
724
777
  timebox = $('<div class="xdsoft_time_variant"></div>'),
778
+ applyButton = $('<button type="button" class="xdsoft_save_selected blue-gradient-button">Save Selected</button>'),
725
779
  /*scrollbar = $('<div class="xdsoft_scrollbar"></div>'),
726
780
  scroller = $('<div class="xdsoft_scroller"></div>'),*/
727
781
  monthselect = $('<div class="xdsoft_select xdsoft_monthselect"><div></div></div>'),
@@ -737,6 +791,19 @@
737
791
  timer1 = 0,
738
792
  _xdsoft_datetime;
739
793
 
794
+ if (options.id) {
795
+ datetimepicker.attr('id', options.id);
796
+ }
797
+ if (options.style) {
798
+ datetimepicker.attr('style', options.style);
799
+ }
800
+ if (options.weeks) {
801
+ datetimepicker.addClass('xdsoft_showweeks');
802
+ }
803
+
804
+ datetimepicker.addClass('xdsoft_' + options.theme);
805
+ datetimepicker.addClass(options.className);
806
+
740
807
  mounth_picker
741
808
  .find('.xdsoft_month span')
742
809
  .after(monthselect);
@@ -783,6 +850,11 @@
783
850
  event.preventDefault();
784
851
  })
785
852
  .on('mousedown.xdsoft', '.xdsoft_option', function (event) {
853
+
854
+ if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
855
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
856
+ }
857
+
786
858
  var year = _xdsoft_datetime.currentTime.getFullYear();
787
859
  if (_xdsoft_datetime && _xdsoft_datetime.currentTime) {
788
860
  _xdsoft_datetime.currentTime[$(this).parent().parent().hasClass('xdsoft_monthselect') ? 'setMonth' : 'setFullYear']($(this).data('value'));
@@ -801,6 +873,48 @@
801
873
  });
802
874
 
803
875
  datetimepicker.setOptions = function (_options) {
876
+ var highlightedDates = {},
877
+ getCaretPos = function (input) {
878
+ try {
879
+ if (document.selection && document.selection.createRange) {
880
+ var range = document.selection.createRange();
881
+ return range.getBookmark().charCodeAt(2) - 2;
882
+ }
883
+ if (input.setSelectionRange) {
884
+ return input.selectionStart;
885
+ }
886
+ } catch (e) {
887
+ return 0;
888
+ }
889
+ },
890
+ setCaretPos = function (node, pos) {
891
+ node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
892
+ if (!node) {
893
+ return false;
894
+ }
895
+ if (node.createTextRange) {
896
+ var textRange = node.createTextRange();
897
+ textRange.collapse(true);
898
+ textRange.moveEnd('character', pos);
899
+ textRange.moveStart('character', pos);
900
+ textRange.select();
901
+ return true;
902
+ }
903
+ if (node.setSelectionRange) {
904
+ node.setSelectionRange(pos, pos);
905
+ return true;
906
+ }
907
+ return false;
908
+ },
909
+ isValidValue = function (mask, value) {
910
+ var reg = mask
911
+ .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
912
+ .replace(/_/g, '{digit+}')
913
+ .replace(/([0-9]{1})/g, '{digit$1}')
914
+ .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
915
+ .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
916
+ return (new RegExp(reg)).test(value);
917
+ };
804
918
  options = $.extend(true, {}, options, _options);
805
919
 
806
920
  if (_options.allowTimes && $.isArray(_options.allowTimes) && _options.allowTimes.length) {
@@ -811,9 +925,62 @@
811
925
  options.weekends = $.extend(true, [], _options.weekends);
812
926
  }
813
927
 
928
+ if (_options.highlightedDates && $.isArray(_options.highlightedDates) && _options.highlightedDates.length) {
929
+ $.each(_options.highlightedDates, function (index, value) {
930
+ var splitData = $.map(value.split(','), $.trim),
931
+ exDesc,
932
+ hDate = new HighlightedDate(Date.parseDate(splitData[0], options.formatDate), splitData[1], splitData[2]), // date, desc, style
933
+ keyDate = hDate.date.dateFormat(options.formatDate);
934
+ if (highlightedDates[keyDate] !== undefined) {
935
+ exDesc = highlightedDates[keyDate].desc;
936
+ if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
937
+ highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
938
+ }
939
+ } else {
940
+ highlightedDates[keyDate] = hDate;
941
+ }
942
+ });
943
+
944
+ options.highlightedDates = $.extend(true, [], highlightedDates);
945
+ }
946
+
947
+ if (_options.highlightedPeriods && $.isArray(_options.highlightedPeriods) && _options.highlightedPeriods.length) {
948
+ highlightedDates = $.extend(true, [], options.highlightedDates);
949
+ $.each(_options.highlightedPeriods, function (index, value) {
950
+ var splitData = $.map(value.split(','), $.trim),
951
+ dateTest = Date.parseDate(splitData[0], options.formatDate), // start date
952
+ dateEnd = Date.parseDate(splitData[1], options.formatDate),
953
+ desc = splitData[2],
954
+ hDate,
955
+ keyDate,
956
+ exDesc,
957
+ style = splitData[3];
958
+
959
+ while (dateTest <= dateEnd) {
960
+ hDate = new HighlightedDate(dateTest, desc, style);
961
+ keyDate = dateTest.dateFormat(options.formatDate);
962
+ dateTest.setDate(dateTest.getDate() + 1);
963
+ if (highlightedDates[keyDate] !== undefined) {
964
+ exDesc = highlightedDates[keyDate].desc;
965
+ if (exDesc && exDesc.length && hDate.desc && hDate.desc.length) {
966
+ highlightedDates[keyDate].desc = exDesc + "\n" + hDate.desc;
967
+ }
968
+ } else {
969
+ highlightedDates[keyDate] = hDate;
970
+ }
971
+ }
972
+ });
973
+
974
+ options.highlightedDates = $.extend(true, [], highlightedDates);
975
+ }
976
+
814
977
  if (_options.disabledDates && $.isArray(_options.disabledDates) && _options.disabledDates.length) {
815
- options.disabledDates = $.extend(true, [], _options.disabledDates);
816
- }
978
+ options.disabledDates = $.extend(true, [], _options.disabledDates);
979
+ }
980
+
981
+ if (_options.disabledWeekDays && $.isArray(_options.disabledWeekDays) && _options.disabledWeekDays.length) {
982
+ options.disabledWeekDays = $.extend(true, [], _options.disabledWeekDays);
983
+ }
817
984
 
818
985
  if ((options.open || options.opened) && (!options.inline)) {
819
986
  input.trigger('open.xdsoft');
@@ -843,10 +1010,10 @@
843
1010
  }
844
1011
 
845
1012
  if (options.value) {
1013
+ _xdsoft_datetime.setCurrentTime(options.value);
846
1014
  if (input && input.val) {
847
- input.val(options.value);
1015
+ input.val(_xdsoft_datetime.str);
848
1016
  }
849
- _xdsoft_datetime.setCurrentTime(options.value);
850
1017
  }
851
1018
 
852
1019
  if (isNaN(options.dayOfWeekStart)) {
@@ -867,53 +1034,21 @@
867
1034
  options.maxDate = _xdsoft_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate);
868
1035
  }
869
1036
 
1037
+ applyButton.toggle(options.showApplyButton);
1038
+
870
1039
  mounth_picker
871
1040
  .find('.xdsoft_today_button')
872
1041
  .css('visibility', !options.todayButton ? 'hidden' : 'visible');
873
1042
 
1043
+ mounth_picker
1044
+ .find('.' + options.prev)
1045
+ .css('visibility', !options.prevButton ? 'hidden' : 'visible');
1046
+
1047
+ mounth_picker
1048
+ .find('.' + options.next)
1049
+ .css('visibility', !options.nextButton ? 'hidden' : 'visible');
1050
+
874
1051
  if (options.mask) {
875
- var e,
876
- getCaretPos = function (input) {
877
- try {
878
- if (document.selection && document.selection.createRange) {
879
- var range = document.selection.createRange();
880
- return range.getBookmark().charCodeAt(2) - 2;
881
- }
882
- if (input.setSelectionRange) {
883
- return input.selectionStart;
884
- }
885
- } catch (e) {
886
- return 0;
887
- }
888
- },
889
- setCaretPos = function (node, pos) {
890
- node = (typeof node === "string" || node instanceof String) ? document.getElementById(node) : node;
891
- if (!node) {
892
- return false;
893
- }
894
- if (node.createTextRange) {
895
- var textRange = node.createTextRange();
896
- textRange.collapse(true);
897
- textRange.moveEnd('character', pos);
898
- textRange.moveStart('character', pos);
899
- textRange.select();
900
- return true;
901
- }
902
- if (node.setSelectionRange) {
903
- node.setSelectionRange(pos, pos);
904
- return true;
905
- }
906
- return false;
907
- },
908
- isValidValue = function (mask, value) {
909
- var reg = mask
910
- .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1')
911
- .replace(/_/g, '{digit+}')
912
- .replace(/([0-9]{1})/g, '{digit$1}')
913
- .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}')
914
- .replace(/\{digit[\+]\}/g, '[0-9_]{1}');
915
- return (new RegExp(reg)).test(value);
916
- };
917
1052
  input.off('keydown.xdsoft');
918
1053
 
919
1054
  if (options.mask === true) {
@@ -993,11 +1128,23 @@
993
1128
  $(this).val(null);
994
1129
  datetimepicker.data('xdsoft_datetime').empty();
995
1130
  } else if (!Date.parseDate($(this).val(), options.format)) {
996
- $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
1131
+ var splittedHours = +([$(this).val()[0], $(this).val()[1]].join('')),
1132
+ splittedMinutes = +([$(this).val()[2], $(this).val()[3]].join(''));
1133
+
1134
+ // parse the numbers as 0312 => 03:12
1135
+ if (!options.datepicker && options.timepicker && splittedHours >= 0 && splittedHours < 24 && splittedMinutes >= 0 && splittedMinutes < 60) {
1136
+ $(this).val([splittedHours, splittedMinutes].map(function (item) {
1137
+ return item > 9 ? item : '0' + item;
1138
+ }).join(':'));
1139
+ } else {
1140
+ $(this).val((_xdsoft_datetime.now()).dateFormat(options.format));
1141
+ }
1142
+
997
1143
  datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
998
1144
  } else {
999
1145
  datetimepicker.data('xdsoft_datetime').setCurrentTime($(this).val());
1000
1146
  }
1147
+
1001
1148
  datetimepicker.trigger('changedatetime.xdsoft');
1002
1149
  });
1003
1150
  }
@@ -1037,7 +1184,8 @@
1037
1184
 
1038
1185
  datepicker
1039
1186
  .append(mounth_picker)
1040
- .append(calendar);
1187
+ .append(calendar)
1188
+ .append(applyButton);
1041
1189
 
1042
1190
  $(options.parentID)
1043
1191
  .append(datetimepicker);
@@ -1050,7 +1198,7 @@
1050
1198
  time;
1051
1199
 
1052
1200
  if (!norecursion && options.defaultDate) {
1053
- date = _this.strToDate(options.defaultDate);
1201
+ date = _this.strToDateTime(options.defaultDate);
1054
1202
  d.setFullYear(date.getFullYear());
1055
1203
  d.setMonth(date.getMonth());
1056
1204
  d.setDate(date.getDate());
@@ -1065,7 +1213,6 @@
1065
1213
  d.setHours(time.getHours());
1066
1214
  d.setMinutes(time.getMinutes());
1067
1215
  }
1068
-
1069
1216
  return d;
1070
1217
  };
1071
1218
 
@@ -1090,6 +1237,11 @@
1090
1237
  };
1091
1238
 
1092
1239
  _this.nextMonth = function () {
1240
+
1241
+ if (_this.currentTime === undefined || _this.currentTime === null) {
1242
+ _this.currentTime = _this.now();
1243
+ }
1244
+
1093
1245
  var month = _this.currentTime.getMonth() + 1,
1094
1246
  year;
1095
1247
  if (month === 12) {
@@ -1120,6 +1272,11 @@
1120
1272
  };
1121
1273
 
1122
1274
  _this.prevMonth = function () {
1275
+
1276
+ if (_this.currentTime === undefined || _this.currentTime === null) {
1277
+ _this.currentTime = _this.now();
1278
+ }
1279
+
1123
1280
  var month = _this.currentTime.getMonth() - 1;
1124
1281
  if (month === -1) {
1125
1282
  _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1);
@@ -1157,7 +1314,7 @@
1157
1314
  }
1158
1315
  if (tmpDate && tmpDate[2]) {
1159
1316
  timeOffset = tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000;
1160
- currentTime = new Date((_xdsoft_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
1317
+ currentTime = new Date((_this.now(true)).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset);
1161
1318
  } else {
1162
1319
  currentTime = sDateTime ? Date.parseDate(sDateTime, options.format) : _this.now();
1163
1320
  }
@@ -1200,6 +1357,13 @@
1200
1357
 
1201
1358
  _xdsoft_datetime = new XDSoft_datetime();
1202
1359
 
1360
+ applyButton.on('click', function (e) {//pathbrite
1361
+ e.preventDefault();
1362
+ datetimepicker.data('changed', true);
1363
+ _xdsoft_datetime.setCurrentTime(getCurrentValue());
1364
+ input.val(_xdsoft_datetime.str());
1365
+ datetimepicker.trigger('close.xdsoft');
1366
+ });
1203
1367
  mounth_picker
1204
1368
  .find('.xdsoft_today_button')
1205
1369
  .on('mousedown.xdsoft', function () {
@@ -1207,6 +1371,18 @@
1207
1371
  _xdsoft_datetime.setCurrentTime(0);
1208
1372
  datetimepicker.trigger('afterOpen.xdsoft');
1209
1373
  }).on('dblclick.xdsoft', function () {
1374
+ var currentDate = _xdsoft_datetime.getCurrentTime(), minDate, maxDate;
1375
+ currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate());
1376
+ minDate = _xdsoft_datetime.strToDate(options.minDate);
1377
+ minDate = new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate());
1378
+ if (currentDate < minDate) {
1379
+ return;
1380
+ }
1381
+ maxDate = _xdsoft_datetime.strToDate(options.maxDate);
1382
+ maxDate = new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate());
1383
+ if (currentDate > maxDate) {
1384
+ return;
1385
+ }
1210
1386
  input.val(_xdsoft_datetime.str());
1211
1387
  datetimepicker.trigger('close.xdsoft');
1212
1388
  });
@@ -1218,7 +1394,6 @@
1218
1394
  stop = false;
1219
1395
 
1220
1396
  (function arguments_callee1(v) {
1221
- var month = _xdsoft_datetime.currentTime.getMonth();
1222
1397
  if ($this.hasClass(options.next)) {
1223
1398
  _xdsoft_datetime.nextMonth();
1224
1399
  } else if ($this.hasClass(options.prev)) {
@@ -1274,6 +1449,11 @@
1274
1449
  .on('xchange.xdsoft', function (event) {
1275
1450
  clearTimeout(xchangeTimer);
1276
1451
  xchangeTimer = setTimeout(function () {
1452
+
1453
+ if (_xdsoft_datetime.currentTime === undefined || _xdsoft_datetime.currentTime === null) {
1454
+ _xdsoft_datetime.currentTime = _xdsoft_datetime.now();
1455
+ }
1456
+
1277
1457
  var table = '',
1278
1458
  start = new Date(_xdsoft_datetime.currentTime.getFullYear(), _xdsoft_datetime.currentTime.getMonth(), 1, 12, 0, 0),
1279
1459
  i = 0,
@@ -1281,6 +1461,8 @@
1281
1461
  today = _xdsoft_datetime.now(),
1282
1462
  maxDate = false,
1283
1463
  minDate = false,
1464
+ hDate,
1465
+ day,
1284
1466
  d,
1285
1467
  y,
1286
1468
  m,
@@ -1290,7 +1472,8 @@
1290
1472
  newRow = true,
1291
1473
  time = '',
1292
1474
  h = '',
1293
- line_time;
1475
+ line_time,
1476
+ description;
1294
1477
 
1295
1478
  while (start.getDay() !== options.dayOfWeekStart) {
1296
1479
  start.setDate(start.getDate() - 1);
@@ -1323,10 +1506,12 @@
1323
1506
  classes = [];
1324
1507
  i += 1;
1325
1508
 
1509
+ day = start.getDay();
1326
1510
  d = start.getDate();
1327
1511
  y = start.getFullYear();
1328
1512
  m = start.getMonth();
1329
1513
  w = _xdsoft_datetime.getWeekOfYear(start);
1514
+ description = '';
1330
1515
 
1331
1516
  classes.push('xdsoft_date');
1332
1517
 
@@ -1340,6 +1525,8 @@
1340
1525
  classes.push('xdsoft_disabled');
1341
1526
  } else if (options.disabledDates.indexOf(start.dateFormat(options.formatDate)) !== -1) {
1342
1527
  classes.push('xdsoft_disabled');
1528
+ } else if (options.disabledWeekDays.indexOf(day) !== -1) {
1529
+ classes.push('xdsoft_disabled');
1343
1530
  }
1344
1531
 
1345
1532
  if (customDateSettings && customDateSettings[1] !== "") {
@@ -1358,10 +1545,16 @@
1358
1545
  classes.push('xdsoft_today');
1359
1546
  }
1360
1547
 
1361
- if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) === -1) {
1548
+ if (start.getDay() === 0 || start.getDay() === 6 || options.weekends.indexOf(start.dateFormat(options.formatDate)) !== -1) {
1362
1549
  classes.push('xdsoft_weekend');
1363
1550
  }
1364
1551
 
1552
+ if (options.highlightedDates[start.dateFormat(options.formatDate)] !== undefined) {
1553
+ hDate = options.highlightedDates[start.dateFormat(options.formatDate)];
1554
+ classes.push(hDate.style === undefined ? 'xdsoft_highlighted_default' : hDate.style);
1555
+ description = hDate.desc === undefined ? '' : hDate.desc;
1556
+ }
1557
+
1365
1558
  if (options.beforeShowDay && $.isFunction(options.beforeShowDay)) {
1366
1559
  classes.push(options.beforeShowDay(start));
1367
1560
  }
@@ -1374,7 +1567,7 @@
1374
1567
  }
1375
1568
  }
1376
1569
 
1377
- table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '">' +
1570
+ table += '<td data-date="' + d + '" data-month="' + m + '" data-year="' + y + '"' + ' class="xdsoft_date xdsoft_day_of_week' + start.getDay() + ' ' + classes.join(' ') + '" title="' + description + '">' +
1378
1571
  '<div>' + d + '</div>' +
1379
1572
  '</td>';
1380
1573
 
@@ -1397,19 +1590,27 @@
1397
1590
  h = '';
1398
1591
  m = '';
1399
1592
  line_time = function line_time(h, m) {
1400
- var now = _xdsoft_datetime.now();
1593
+ var now = _xdsoft_datetime.now(), optionDateTime, current_time;
1401
1594
  now.setHours(h);
1402
1595
  h = parseInt(now.getHours(), 10);
1403
1596
  now.setMinutes(m);
1404
1597
  m = parseInt(now.getMinutes(), 10);
1405
- var optionDateTime = new Date(_xdsoft_datetime.currentTime)
1598
+ optionDateTime = new Date(_xdsoft_datetime.currentTime);
1406
1599
  optionDateTime.setHours(h);
1407
1600
  optionDateTime.setMinutes(m);
1408
1601
  classes = [];
1409
- 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())) {
1602
+ 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())) {
1603
+ classes.push('xdsoft_disabled');
1604
+ }
1605
+ if ((options.minDateTime !== false && options.minDateTime > optionDateTime) || ((options.disabledMinTime !== false && now.getTime() > _xdsoft_datetime.strtotime(options.disabledMinTime).getTime()) && (options.disabledMaxTime !== false && now.getTime() < _xdsoft_datetime.strtotime(options.disabledMaxTime).getTime()))) {
1410
1606
  classes.push('xdsoft_disabled');
1411
1607
  }
1412
- if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && parseInt(_xdsoft_datetime.currentTime.getHours(), 10) === parseInt(h, 10) && (options.step > 59 || Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step === parseInt(m, 10))) {
1608
+
1609
+ current_time = new Date(_xdsoft_datetime.currentTime);
1610
+ current_time.setHours(parseInt(_xdsoft_datetime.currentTime.getHours(), 10));
1611
+ current_time.setMinutes(Math[options.roundTime](_xdsoft_datetime.currentTime.getMinutes() / options.step) * options.step);
1612
+
1613
+ if ((options.initTime || options.defaultSelect || datetimepicker.data('changed')) && current_time.getHours() === parseInt(h, 10) && (options.step > 59 || current_time.getMinutes() === parseInt(m, 10))) {
1413
1614
  if (options.defaultSelect || datetimepicker.data('changed')) {
1414
1615
  classes.push('xdsoft_current');
1415
1616
  } else if (options.initTime) {
@@ -1449,7 +1650,7 @@
1449
1650
  yearselect.children().eq(0)
1450
1651
  .html(opt);
1451
1652
 
1452
- for (i = 0, opt = ''; i <= 11; i += 1) {
1653
+ for (i = parseInt(options.monthStart, 10), opt = ''; i <= parseInt(options.monthEnd, 10); i += 1) {
1453
1654
  opt += '<div class="xdsoft_option ' + (_xdsoft_datetime.currentTime.getMonth() === i ? 'xdsoft_current' : '') + '" data-value="' + i + '">' + options.i18n[options.lang].months[i] + '</div>';
1454
1655
  }
1455
1656
  monthselect.children().eq(0).html(opt);
@@ -1505,7 +1706,7 @@
1505
1706
  datetimepicker.trigger('select.xdsoft', [currentTime]);
1506
1707
 
1507
1708
  input.val(_xdsoft_datetime.str());
1508
- if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === 0 && !options.timepicker))) && !options.inline) {
1709
+ if ((timerclick > 1 || (options.closeOnDateSelect === true || (options.closeOnDateSelect === false && !options.timepicker))) && !options.inline) {
1509
1710
  datetimepicker.trigger('close.xdsoft');
1510
1711
  }
1511
1712
 
@@ -1540,9 +1741,10 @@
1540
1741
  datetimepicker.trigger('select.xdsoft', [currentTime]);
1541
1742
 
1542
1743
  datetimepicker.data('input').val(_xdsoft_datetime.str());
1543
- if (!options.inline) {
1544
- datetimepicker.trigger('close.xdsoft');
1545
- }
1744
+
1745
+ if (options.inline !== true && options.closeOnTimeSelect === true) {
1746
+ datetimepicker.trigger('close.xdsoft');
1747
+ }
1546
1748
 
1547
1749
  if (options.onSelectTime && $.isFunction(options.onSelectTime)) {
1548
1750
  options.onSelectTime.call(datetimepicker, _xdsoft_datetime.currentTime, datetimepicker.data('input'), xdevent);
@@ -1616,7 +1818,7 @@
1616
1818
  current_time_index = 0;
1617
1819
 
1618
1820
  setPos = function () {
1619
- var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute";
1821
+ var offset = datetimepicker.data('input').offset(), top = offset.top + datetimepicker.data('input')[0].offsetHeight - 1, left = offset.left, position = "absolute", node;
1620
1822
  if (options.fixed) {
1621
1823
  top -= $(window).scrollTop();
1622
1824
  left -= $(window).scrollLeft();
@@ -1632,6 +1834,15 @@
1632
1834
  left = $(window).width() - datetimepicker[0].offsetWidth;
1633
1835
  }
1634
1836
  }
1837
+
1838
+ node = datetimepicker[0];
1839
+ do {
1840
+ node = node.parentNode;
1841
+ if (window.getComputedStyle(node).getPropertyValue('position') === 'relative' && $(window).width() >= node.offsetWidth) {
1842
+ left = left - (($(window).width() - node.offsetWidth) / 2);
1843
+ break;
1844
+ }
1845
+ } while (node.nodeName !== 'HTML');
1635
1846
  datetimepicker.css({
1636
1847
  left: left,
1637
1848
  top: top,
@@ -1689,7 +1900,6 @@
1689
1900
  datetimepicker.setOptions(options);
1690
1901
 
1691
1902
  function getCurrentValue() {
1692
-
1693
1903
  var ct = false, time;
1694
1904
 
1695
1905
  if (options.startDate) {
@@ -1699,7 +1909,7 @@
1699
1909
  if (ct) {
1700
1910
  ct = _xdsoft_datetime.strToDateTime(ct);
1701
1911
  } else if (options.defaultDate) {
1702
- ct = _xdsoft_datetime.strToDate(options.defaultDate);
1912
+ ct = _xdsoft_datetime.strToDateTime(options.defaultDate);
1703
1913
  if (options.defaultTime) {
1704
1914
  time = _xdsoft_datetime.strtotime(options.defaultTime);
1705
1915
  ct.setHours(time.getHours());
@@ -1722,12 +1932,12 @@
1722
1932
  input
1723
1933
  .data('xdsoft_datetimepicker', datetimepicker)
1724
1934
  .on('open.xdsoft focusin.xdsoft mousedown.xdsoft', function (event) {
1725
- if (input.is(':disabled') || input.is(':hidden') || !input.is(':visible') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
1935
+ if (input.is(':disabled') || (input.data('xdsoft_datetimepicker').is(':visible') && options.closeOnInputClick)) {
1726
1936
  return;
1727
1937
  }
1728
1938
  clearTimeout(timer);
1729
1939
  timer = setTimeout(function () {
1730
- if (input.is(':disabled') || input.is(':hidden') || !input.is(':visible')) {
1940
+ if (input.is(':disabled')) {
1731
1941
  return;
1732
1942
  }
1733
1943
 
@@ -1780,7 +1990,7 @@
1780
1990
  }
1781
1991
  });
1782
1992
  return this.each(function () {
1783
- var datetimepicker = $(this).data('xdsoft_datetimepicker');
1993
+ var datetimepicker = $(this).data('xdsoft_datetimepicker'), $input;
1784
1994
  if (datetimepicker) {
1785
1995
  if ($.type(opt) === 'string') {
1786
1996
  switch (opt) {
@@ -1804,6 +2014,10 @@
1804
2014
  }
1805
2015
  datetimepicker.data('xdsoft_datetime').setCurrentTime(this.value);
1806
2016
  break;
2017
+ case 'validate':
2018
+ $input = datetimepicker.data('input');
2019
+ $input.trigger('blur.xdsoft');
2020
+ break;
1807
2021
  }
1808
2022
  } else {
1809
2023
  datetimepicker
@@ -1822,6 +2036,14 @@
1822
2036
  };
1823
2037
  $.fn.datetimepicker.defaults = default_options;
1824
2038
  }(jQuery));
2039
+
2040
+ function HighlightedDate(date, desc, style) {
2041
+ "use strict";
2042
+ this.date = date;
2043
+ this.desc = desc;
2044
+ this.style = style;
2045
+ }
2046
+
1825
2047
  (function () {
1826
2048
 
1827
2049
  /*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
@@ -1847,5 +2069,5 @@
1847
2069
  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
1848
2070
  * details.
1849
2071
  */
1850
- 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 code="Date.prototype."+funcName+" = function() {return ";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);}}}eval(code.substring(0,code.length-3)+";}");};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"};
2072
+ Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var codePrefix="Date.prototype."+funcName+" = function() {return ";var code="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;code+="'"+String.escape(ch)+"' + ";}else{code+=Date.getFormatCode(ch);}}}if(code.length==0){code="\"\"";}else{code=code.substring(0,code.length-3);}eval(codePrefix+code+";}");};Date.getFormatCode=function(a){switch(a){case"d":return"String.leftPad(this.getDate(), 2, '0') + ";case"D":return"Date.dayNames[this.getDay()].substring(0, 3) + ";case"j":return"this.getDate() + ";case"l":return"Date.dayNames[this.getDay()] + ";case"S":return"this.getSuffix() + ";case"w":return"this.getDay() + ";case"z":return"this.getDayOfYear() + ";case"W":return"this.getWeekOfYear() + ";case"F":return"Date.monthNames[this.getMonth()] + ";case"m":return"String.leftPad(this.getMonth() + 1, 2, '0') + ";case"M":return"Date.monthNames[this.getMonth()].substring(0, 3) + ";case"n":return"(this.getMonth() + 1) + ";case"t":return"this.getDaysInMonth() + ";case"L":return"(this.isLeapYear() ? 1 : 0) + ";case"Y":return"this.getFullYear() + ";case"y":return"('' + this.getFullYear()).substring(2, 4) + ";case"a":return"(this.getHours() < 12 ? 'am' : 'pm') + ";case"A":return"(this.getHours() < 12 ? 'AM' : 'PM') + ";case"g":return"((this.getHours() %12) ? this.getHours() % 12 : 12) + ";case"G":return"this.getHours() + ";case"h":return"String.leftPad((this.getHours() %12) ? this.getHours() % 12 : 12, 2, '0') + ";case"H":return"String.leftPad(this.getHours(), 2, '0') + ";case"i":return"String.leftPad(this.getMinutes(), 2, '0') + ";case"s":return"String.leftPad(this.getSeconds(), 2, '0') + ";case"O":return"this.getGMTOffset() + ";case"T":return"this.getTimezone() + ";case"Z":return"(this.getTimezoneOffset() * -60) + ";default:return"'"+String.escape(a)+"' + ";}};Date.parseDate=function(a,c){if(c=="unixtime"){return new Date(!isNaN(parseInt(a))?parseInt(a)*1000:0);}if(Date.parseFunctions[c]==null){Date.createParser(c);}var b=Date.parseFunctions[c];return Date[b](a);};Date.createParser=function(format){var funcName="parse"+Date.parseFunctions.count++;var regexNum=Date.parseRegexes.length;var currentGroup=1;Date.parseFunctions[format]=funcName;var code="Date."+funcName+" = function(input) {\nvar y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, z = -1;\nvar d = new Date();\ny = d.getFullYear();\nm = d.getMonth();\nd = d.getDate();\nvar results = input.match(Date.parseRegexes["+regexNum+"]);\nif (results && results.length > 0) {";var regex="";var special=false;var ch="";for(var i=0;i<format.length;++i){ch=format.charAt(i);if(!special&&ch=="\\"){special=true;}else{if(special){special=false;regex+=String.escape(ch);}else{obj=Date.formatCodeToRegex(ch,currentGroup);currentGroup+=obj.g;regex+=obj.s;if(obj.g&&obj.c){code+=obj.c;}}}}code+="if (y > 0 && z > 0){\nvar doyDate = new Date(y,0);\ndoyDate.setDate(z);\nm = doyDate.getMonth();\nd = doyDate.getDate();\n}";code+="if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n{return new Date(y, m, d, h, i, s);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n{return new Date(y, m, d, h, i);}\nelse if (y > 0 && m >= 0 && d > 0 && h >= 0)\n{return new Date(y, m, d, h);}\nelse if (y > 0 && m >= 0 && d > 0)\n{return new Date(y, m, d);}\nelse if (y > 0 && m >= 0)\n{return new Date(y, m);}\nelse if (y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$",'i');eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z = parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m = parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m = parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y = parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty = parseInt(results["+a+"], 10);\ny = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if (results["+a+"] == 'am') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if (results["+a+"] == 'AM') {\nif (h == 12) { h = 0; }\n} else { if (h < 12) { h += 12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h = parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s = parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b<this.getMonth();++b){a+=Date.daysInMonth[b];}return a+this.getDate();};Date.prototype.getWeekOfYear=function(){var b=this.getDayOfYear()+(4-this.getDay());var a=new Date(this.getFullYear(),0,1);var c=(7-a.getDay()+4);return String.leftPad(Math.ceil((b-c)/7)+1,2,"0");};Date.prototype.isLeapYear=function(){var a=this.getFullYear();return((a&3)==0&&(a%100||(a%400==0&&a)));};Date.prototype.getFirstDayOfMonth=function(){var a=(this.getDay()-(this.getDate()-1))%7;return(a<0)?(a+7):a;};Date.prototype.getLastDayOfMonth=function(){var a=(this.getDay()+(Date.daysInMonth[this.getMonth()]-this.getDate()))%7;return(a<0)?(a+7):a;};Date.prototype.getDaysInMonth=function(){Date.daysInMonth[1]=this.isLeapYear()?29:28;return Date.daysInMonth[this.getMonth()];};Date.prototype.getSuffix=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};String.escape=function(a){return a.replace(/('|\\)/g,"\\$1");};String.leftPad=function(d,b,c){var a=new String(d);if(c==null){c=" ";}while(a.length<b){a=c+a;}return a;};Date.daysInMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Date.monthNames=["January","February","March","April","May","June","July","August","September","October","November","December"];Date.dayNames=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Date.y2kYear=50;Date.monthNumbers={Jan:0,Feb:1,Mar:2,Apr:3,May:4,Jun:5,Jul:6,Aug:7,Sep:8,Oct:9,Nov:10,Dec:11};Date.patterns={ISO8601LongPattern:"Y-m-d H:i:s",ISO8601ShortPattern:"Y-m-d",ShortDatePattern:"n/j/Y",LongDatePattern:"l, F d, Y",FullDateTimePattern:"l, F d, Y g:i:s A",MonthDayPattern:"F d",ShortTimePattern:"g:i A",LongTimePattern:"g:i:s A",SortableDateTimePattern:"Y-m-d\\TH:i:s",UniversalSortableDateTimePattern:"Y-m-d H:i:sO",YearMonthPattern:"F, Y"};
1851
2073
  }());