| Line 1... |
Line 1... |
| 1 |
/*! jQuery Timepicker Addon - v1.6.1 - 2015-11-14
|
1 |
/*! jQuery Timepicker Addon - v1.6.3 - 2016-04-20
|
| 2 |
* http://trentrichardson.com/examples/timepicker
|
2 |
* http://trentrichardson.com/examples/timepicker
|
| 3 |
* Copyright (c) 2015 Trent Richardson; Licensed MIT */
|
3 |
* Copyright (c) 2016 Trent Richardson; Licensed MIT */
|
| 4 |
(function (factory) {
|
4 |
(function (factory) {
|
| 5 |
if (typeof define === 'function' && define.amd) {
|
5 |
if (typeof define === 'function' && define.amd) {
|
| 6 |
define(['jquery', 'jquery-ui'], factory);
|
6 |
define(['jquery', 'jquery-ui'], factory);
|
| 7 |
} else {
|
7 |
} else {
|
| 8 |
factory(jQuery);
|
8 |
factory(jQuery);
|
| Line 20... |
Line 20... |
| 20 |
/*
|
20 |
/*
|
| 21 |
* Extend jQueryUI, get it started with our version number
|
21 |
* Extend jQueryUI, get it started with our version number
|
| 22 |
*/
|
22 |
*/
|
| 23 |
$.extend($.ui, {
|
23 |
$.extend($.ui, {
|
| 24 |
timepicker: {
|
24 |
timepicker: {
|
| 25 |
version: "1.6.1"
|
25 |
version: "1.6.3"
|
| 26 |
}
|
26 |
}
|
| 27 |
});
|
27 |
});
|
| 28 |
|
28 |
|
| 29 |
/*
|
29 |
/*
|
| 30 |
* Timepicker manager.
|
30 |
* Timepicker manager.
|
| 31 |
* Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
31 |
* Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
| 32 |
* Settings for (groups of) time pickers are maintained in an instance object,
|
32 |
* Settings for (groups of) time pickers are maintained in an instance object,
|
| 33 |
* allowing multiple different settings on the same page.
|
33 |
* allowing multiple different settings on the same page.
|
| 34 |
*/
|
34 |
*/
|
| Line 151... |
Line 151... |
| 151 |
timezoneList: null,
|
151 |
timezoneList: null,
|
| 152 |
units: ['hour', 'minute', 'second', 'millisec', 'microsec'],
|
152 |
units: ['hour', 'minute', 'second', 'millisec', 'microsec'],
|
| 153 |
support: {},
|
153 |
support: {},
|
| 154 |
control: null,
|
154 |
control: null,
|
| 155 |
|
155 |
|
| 156 |
/*
|
156 |
/*
|
| 157 |
* Override the default settings for all instances of the time picker.
|
157 |
* Override the default settings for all instances of the time picker.
|
| 158 |
* @param {Object} settings object - the new settings to use as defaults (anonymous object)
|
158 |
* @param {Object} settings object - the new settings to use as defaults (anonymous object)
|
| 159 |
* @return {Object} the manager object
|
159 |
* @return {Object} the manager object
|
| 160 |
*/
|
160 |
*/
|
| 161 |
setDefaults: function (settings) {
|
161 |
setDefaults: function (settings) {
|
| Line 224... |
Line 224... |
| 224 |
return val.toUpperCase();
|
224 |
return val.toUpperCase();
|
| 225 |
});
|
225 |
});
|
| 226 |
|
226 |
|
| 227 |
// detect which units are supported
|
227 |
// detect which units are supported
|
| 228 |
tp_inst.support = detectSupport(
|
228 |
tp_inst.support = detectSupport(
|
| 229 |
tp_inst._defaults.timeFormat +
|
229 |
tp_inst._defaults.timeFormat +
|
| 230 |
(tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
|
230 |
(tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
|
| 231 |
(tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
|
231 |
(tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
|
| 232 |
|
232 |
|
| 233 |
// controlType is string - key to our this._controls
|
233 |
// controlType is string - key to our this._controls
|
| 234 |
if (typeof(tp_inst._defaults.controlType) === 'string') {
|
234 |
if (typeof(tp_inst._defaults.controlType) === 'string') {
|
| Line 423... |
Line 423... |
| 423 |
|
423 |
|
| 424 |
html += '</tr></table></div>';
|
424 |
html += '</tr></table></div>';
|
| 425 |
}
|
425 |
}
|
| 426 |
html += '</dd>';
|
426 |
html += '</dd>';
|
| 427 |
}
|
427 |
}
|
| 428 |
|
428 |
|
| 429 |
// Timezone
|
429 |
// Timezone
|
| 430 |
var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
|
430 |
var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
|
| 431 |
html += '<dt class="ui_tpicker_timezone_label' + (showTz ? '' : noDisplay) + '">' + o.timezoneText + '</dt>';
|
431 |
html += '<dt class="ui_tpicker_timezone_label' + (showTz ? '' : noDisplay) + '">' + o.timezoneText + '</dt>';
|
| 432 |
html += '<dd class="ui_tpicker_timezone' + (showTz ? '' : noDisplay) + '"></dd>';
|
432 |
html += '<dd class="ui_tpicker_timezone' + (showTz ? '' : noDisplay) + '"></dd>';
|
| 433 |
|
433 |
|
| Line 438... |
Line 438... |
| 438 |
// if we only want time picker...
|
438 |
// if we only want time picker...
|
| 439 |
if (o.timeOnly === true) {
|
439 |
if (o.timeOnly === true) {
|
| 440 |
$tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
|
440 |
$tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
|
| 441 |
$dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
|
441 |
$dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
|
| 442 |
}
|
442 |
}
|
| 443 |
|
443 |
|
| 444 |
// add sliders, adjust grids, add events
|
444 |
// add sliders, adjust grids, add events
|
| 445 |
for (i = 0, l = tp_inst.units.length; i < l; i++) {
|
445 |
for (i = 0, l = tp_inst.units.length; i < l; i++) {
|
| 446 |
litem = tp_inst.units[i];
|
446 |
litem = tp_inst.units[i];
|
| 447 |
uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
|
447 |
uitem = litem.substr(0, 1).toUpperCase() + litem.substr(1);
|
| 448 |
show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
|
448 |
show = o['show' + uitem] !== null ? o['show' + uitem] : this.support[litem];
|
| Line 473... |
Line 473... |
| 473 |
if (ap.indexOf('a') !== -1 && n === 12) {
|
473 |
if (ap.indexOf('a') !== -1 && n === 12) {
|
| 474 |
n = 0;
|
474 |
n = 0;
|
| 475 |
}
|
475 |
}
|
| 476 |
}
|
476 |
}
|
| 477 |
}
|
477 |
}
|
| 478 |
|
478 |
|
| 479 |
tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
|
479 |
tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
|
| 480 |
|
480 |
|
| 481 |
tp_inst._onTimeChange();
|
481 |
tp_inst._onTimeChange();
|
| 482 |
tp_inst._onSelectHandler();
|
482 |
tp_inst._onSelectHandler();
|
| 483 |
}).css({
|
483 |
}).css({
|
| Line 513... |
Line 513... |
| 513 |
tp_inst._onTimeChange();
|
513 |
tp_inst._onTimeChange();
|
| 514 |
tp_inst._onSelectHandler();
|
514 |
tp_inst._onSelectHandler();
|
| 515 |
tp_inst._afterInject();
|
515 |
tp_inst._afterInject();
|
| 516 |
});
|
516 |
});
|
| 517 |
// End timezone options
|
517 |
// End timezone options
|
| 518 |
|
518 |
|
| 519 |
// inject timepicker into datepicker
|
519 |
// inject timepicker into datepicker
|
| 520 |
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
|
520 |
var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
|
| 521 |
if ($buttonPanel.length) {
|
521 |
if ($buttonPanel.length) {
|
| 522 |
$buttonPanel.before($tp);
|
522 |
$buttonPanel.before($tp);
|
| 523 |
} else {
|
523 |
} else {
|
| Line 549... |
Line 549... |
| 549 |
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
|
549 |
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
|
| 550 |
if (this._defaults.addSliderAccess) {
|
550 |
if (this._defaults.addSliderAccess) {
|
| 551 |
var sliderAccessArgs = this._defaults.sliderAccessArgs,
|
551 |
var sliderAccessArgs = this._defaults.sliderAccessArgs,
|
| 552 |
rtl = this._defaults.isRTL;
|
552 |
rtl = this._defaults.isRTL;
|
| 553 |
sliderAccessArgs.isRTL = rtl;
|
553 |
sliderAccessArgs.isRTL = rtl;
|
| 554 |
|
554 |
|
| 555 |
setTimeout(function () { // fix for inline mode
|
555 |
setTimeout(function () { // fix for inline mode
|
| 556 |
if ($tp.find('.ui-slider-access').length === 0) {
|
556 |
if ($tp.find('.ui-slider-access').length === 0) {
|
| 557 |
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
|
557 |
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
|
| 558 |
|
558 |
|
| 559 |
// fix any grids since sliders are shorter
|
559 |
// fix any grids since sliders are shorter
|
| Line 701... |
Line 701... |
| 701 |
this._defaults.millisecMax = this.millisecMaxOriginal;
|
701 |
this._defaults.millisecMax = this.millisecMaxOriginal;
|
| 702 |
this._defaults.microsecMax = this.microsecMaxOriginal;
|
702 |
this._defaults.microsecMax = this.microsecMaxOriginal;
|
| 703 |
}
|
703 |
}
|
| 704 |
}
|
704 |
}
|
| 705 |
|
705 |
|
| 706 |
if (dp_inst.settings.minTime!==null) {
|
706 |
if (dp_inst.settings.minTime!==null) {
|
| 707 |
var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime);
|
707 |
var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime);
|
| 708 |
if (this.hour<tempMinTime.getHours()) {
|
708 |
if (this.hour<tempMinTime.getHours()) {
|
| 709 |
this.hour=this._defaults.hourMin=tempMinTime.getHours();
|
709 |
this.hour=this._defaults.hourMin=tempMinTime.getHours();
|
| 710 |
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
710 |
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
| 711 |
} else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) {
|
711 |
} else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) {
|
| 712 |
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
712 |
this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
| 713 |
} else {
|
713 |
} else {
|
| 714 |
if (this._defaults.hourMin<tempMinTime.getHours()) {
|
714 |
if (this._defaults.hourMin<tempMinTime.getHours()) {
|
| 715 |
this._defaults.hourMin=tempMinTime.getHours();
|
715 |
this._defaults.hourMin=tempMinTime.getHours();
|
| 716 |
this._defaults.minuteMin=tempMinTime.getMinutes();
|
716 |
this._defaults.minuteMin=tempMinTime.getMinutes();
|
| 717 |
} else if (this._defaults.hourMin===tempMinTime.getHours()===this.hour && this._defaults.minuteMin<tempMinTime.getMinutes()) {
|
717 |
} else if (this._defaults.hourMin===tempMinTime.getHours()===this.hour && this._defaults.minuteMin<tempMinTime.getMinutes()) {
|
| 718 |
this._defaults.minuteMin=tempMinTime.getMinutes();
|
718 |
this._defaults.minuteMin=tempMinTime.getMinutes();
|
| 719 |
} else {
|
719 |
} else {
|
| 720 |
this._defaults.minuteMin=0;
|
720 |
this._defaults.minuteMin=0;
|
| 721 |
}
|
721 |
}
|
| 722 |
}
|
722 |
}
|
| 723 |
}
|
723 |
}
|
| 724 |
|
724 |
|
| 725 |
if (dp_inst.settings.maxTime!==null) {
|
725 |
if (dp_inst.settings.maxTime!==null) {
|
| 726 |
var tempMaxTime=new Date("01/01/1970 " + dp_inst.settings.maxTime);
|
726 |
var tempMaxTime=new Date("01/01/1970 " + dp_inst.settings.maxTime);
|
| 727 |
if (this.hour>tempMaxTime.getHours()) {
|
727 |
if (this.hour>tempMaxTime.getHours()) {
|
| 728 |
this.hour=this._defaults.hourMax=tempMaxTime.getHours();
|
728 |
this.hour=this._defaults.hourMax=tempMaxTime.getHours();
|
| - |
|
729 |
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
|
| - |
|
730 |
} else if (this.hour===tempMaxTime.getHours() && this.minute>tempMaxTime.getMinutes()) {
|
| 729 |
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
|
731 |
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
|
| 730 |
} else if (this.hour===tempMaxTime.getHours() && this.minute>tempMaxTime.getMinutes()) {
|
- |
|
| 731 |
this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes();
|
- |
|
| 732 |
} else {
|
732 |
} else {
|
| 733 |
if (this._defaults.hourMax>tempMaxTime.getHours()) {
|
733 |
if (this._defaults.hourMax>tempMaxTime.getHours()) {
|
| 734 |
this._defaults.hourMax=tempMaxTime.getHours();
|
734 |
this._defaults.hourMax=tempMaxTime.getHours();
|
| 735 |
this._defaults.minuteMax=tempMaxTime.getMinutes();
|
735 |
this._defaults.minuteMax=tempMaxTime.getMinutes();
|
| 736 |
} else if (this._defaults.hourMax===tempMaxTime.getHours()===this.hour && this._defaults.minuteMax>tempMaxTime.getMinutes()) {
|
736 |
} else if (this._defaults.hourMax===tempMaxTime.getHours()===this.hour && this._defaults.minuteMax>tempMaxTime.getMinutes()) {
|
| 737 |
this._defaults.minuteMax=tempMaxTime.getMinutes();
|
737 |
this._defaults.minuteMax=tempMaxTime.getMinutes();
|
| 738 |
} else {
|
738 |
} else {
|
| 739 |
this._defaults.minuteMax=59;
|
739 |
this._defaults.minuteMax=59;
|
| 740 |
}
|
740 |
}
|
| 741 |
}
|
741 |
}
|
| 742 |
}
|
742 |
}
|
| 743 |
|
743 |
|
| 744 |
if (adjustSliders !== undefined && adjustSliders === true) {
|
744 |
if (adjustSliders !== undefined && adjustSliders === true) {
|
| 745 |
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
|
745 |
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
|
| 746 |
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
746 |
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
| 747 |
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
|
747 |
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
|
| 748 |
millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
|
748 |
millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
|
| Line 832... |
Line 832... |
| 832 |
|
832 |
|
| 833 |
// If the update was done in the input field, the input field should not be updated.
|
833 |
// If the update was done in the input field, the input field should not be updated.
|
| 834 |
// If the update was done using the sliders, update the input field.
|
834 |
// If the update was done using the sliders, update the input field.
|
| 835 |
var hasChanged = (
|
835 |
var hasChanged = (
|
| 836 |
hour !== parseInt(this.hour,10) || // sliders should all be numeric
|
836 |
hour !== parseInt(this.hour,10) || // sliders should all be numeric
|
| 837 |
minute !== parseInt(this.minute,10) ||
|
837 |
minute !== parseInt(this.minute,10) ||
|
| 838 |
second !== parseInt(this.second,10) ||
|
838 |
second !== parseInt(this.second,10) ||
|
| 839 |
millisec !== parseInt(this.millisec,10) ||
|
839 |
millisec !== parseInt(this.millisec,10) ||
|
| 840 |
microsec !== parseInt(this.microsec,10) ||
|
840 |
microsec !== parseInt(this.microsec,10) ||
|
| 841 |
(this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) ||
|
841 |
(this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) ||
|
| 842 |
(this.timezone !== null && timezone !== this.timezone.toString()) // could be numeric or "EST" format, so use toString()
|
842 |
(this.timezone !== null && timezone !== this.timezone.toString()) // could be numeric or "EST" format, so use toString()
|
| 843 |
);
|
843 |
);
|
| 844 |
|
844 |
|
| 845 |
if (hasChanged) {
|
845 |
if (hasChanged) {
|
| 846 |
|
846 |
|
| Line 874... |
Line 874... |
| 874 |
}
|
874 |
}
|
| 875 |
|
875 |
|
| 876 |
// Updates the time within the timepicker
|
876 |
// Updates the time within the timepicker
|
| 877 |
this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
|
877 |
this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
|
| 878 |
if (this.$timeObj) {
|
878 |
if (this.$timeObj) {
|
| 879 |
var sPos = this.$timeObj[0].selectionStart;
|
- |
|
| 880 |
var ePos = this.$timeObj[0].selectionEnd;
|
- |
|
| 881 |
if (pickerTimeFormat === o.timeFormat) {
|
879 |
if (pickerTimeFormat === o.timeFormat) {
|
| 882 |
this.$timeObj.val(this.formattedTime + pickerTimeSuffix);
|
880 |
this.$timeObj.val(this.formattedTime + pickerTimeSuffix);
|
| 883 |
}
|
881 |
}
|
| 884 |
else {
|
882 |
else {
|
| 885 |
this.$timeObj.val($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
|
883 |
this.$timeObj.val($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
|
| 886 |
}
|
884 |
}
|
| - |
|
885 |
if (this.$timeObj[0].setSelectionRange) {
|
| - |
|
886 |
var sPos = this.$timeObj[0].selectionStart;
|
| - |
|
887 |
var ePos = this.$timeObj[0].selectionEnd;
|
| 887 |
this.$timeObj[0].setSelectionRange(sPos, ePos);
|
888 |
this.$timeObj[0].setSelectionRange(sPos, ePos);
|
| - |
|
889 |
}
|
| 888 |
}
|
890 |
}
|
| 889 |
|
891 |
|
| 890 |
this.timeDefined = true;
|
892 |
this.timeDefined = true;
|
| 891 |
if (hasChanged) {
|
893 |
if (hasChanged) {
|
| 892 |
this._updateDateTime();
|
894 |
this._updateDateTime();
|
| Line 909... |
Line 911... |
| 909 |
/*
|
911 |
/*
|
| 910 |
* update our input with the new date time..
|
912 |
* update our input with the new date time..
|
| 911 |
*/
|
913 |
*/
|
| 912 |
_updateDateTime: function (dp_inst) {
|
914 |
_updateDateTime: function (dp_inst) {
|
| 913 |
dp_inst = this.inst || dp_inst;
|
915 |
dp_inst = this.inst || dp_inst;
|
| 914 |
var dtTmp = (dp_inst.currentYear > 0?
|
916 |
var dtTmp = (dp_inst.currentYear > 0?
|
| 915 |
new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
|
917 |
new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) :
|
| 916 |
new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
918 |
new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
| 917 |
dt = $.datepicker._daylightSavingAdjust(dtTmp),
|
919 |
dt = $.datepicker._daylightSavingAdjust(dtTmp),
|
| 918 |
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
920 |
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
| 919 |
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
|
921 |
//dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay)),
|
| 920 |
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
|
922 |
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
|
| 921 |
formatCfg = $.datepicker._getFormatConfig(dp_inst),
|
923 |
formatCfg = $.datepicker._getFormatConfig(dp_inst),
|
| 922 |
timeAvailable = dt !== null && this.timeDefined;
|
924 |
timeAvailable = dt !== null && this.timeDefined;
|
| 923 |
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
925 |
this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
| 924 |
var formattedDateTime = this.formattedDate;
|
926 |
var formattedDateTime = this.formattedDate;
|
| 925 |
|
927 |
|
| 926 |
// if a slider was changed but datepicker doesn't have a value yet, set it
|
928 |
// if a slider was changed but datepicker doesn't have a value yet, set it
|
| 927 |
if (dp_inst.lastVal === "") {
|
929 |
if (dp_inst.lastVal === "") {
|
| 928 |
dp_inst.currentYear = dp_inst.selectedYear;
|
930 |
dp_inst.currentYear = dp_inst.selectedYear;
|
| 929 |
dp_inst.currentMonth = dp_inst.selectedMonth;
|
931 |
dp_inst.currentMonth = dp_inst.selectedMonth;
|
| 930 |
dp_inst.currentDay = dp_inst.selectedDay;
|
932 |
dp_inst.currentDay = dp_inst.selectedDay;
|
| 931 |
}
|
933 |
}
|
| 932 |
|
934 |
|
| 933 |
/*
|
935 |
/*
|
| 934 |
* remove following lines to force every changes in date picker to change the input value
|
936 |
* remove following lines to force every changes in date picker to change the input value
|
| 935 |
* Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
|
937 |
* Bug descriptions: when an input field has a default value, and click on the field to pop up the date picker.
|
| 936 |
* If the user manually empty the value in the input field, the date picker will never change selected value.
|
938 |
* If the user manually empty the value in the input field, the date picker will never change selected value.
|
| 937 |
*/
|
939 |
*/
|
| 938 |
//if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
|
940 |
//if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
|
| 939 |
// return;
|
941 |
// return;
|
| 940 |
//}
|
942 |
//}
|
| Line 955... |
Line 957... |
| 955 |
} else if (this.$altInput) {
|
957 |
} else if (this.$altInput) {
|
| 956 |
this.$input.val(formattedDateTime);
|
958 |
this.$input.val(formattedDateTime);
|
| 957 |
var altFormattedDateTime = '',
|
959 |
var altFormattedDateTime = '',
|
| 958 |
altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
|
960 |
altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
|
| 959 |
altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
|
961 |
altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
|
| 960 |
|
962 |
|
| 961 |
if (!this._defaults.timeOnly) {
|
963 |
if (!this._defaults.timeOnly) {
|
| 962 |
if (this._defaults.altFormat) {
|
964 |
if (this._defaults.altFormat) {
|
| 963 |
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
|
965 |
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
|
| 964 |
}
|
966 |
}
|
| 965 |
else {
|
967 |
else {
|
| Line 1022... |
Line 1024... |
| 1022 |
tp_inst._onTimeChange();
|
1024 |
tp_inst._onTimeChange();
|
| 1023 |
},
|
1025 |
},
|
| 1024 |
stop: function (event, ui) {
|
1026 |
stop: function (event, ui) {
|
| 1025 |
tp_inst._onSelectHandler();
|
1027 |
tp_inst._onSelectHandler();
|
| 1026 |
}
|
1028 |
}
|
| 1027 |
});
|
1029 |
});
|
| 1028 |
},
|
1030 |
},
|
| 1029 |
options: function (tp_inst, obj, unit, opts, val) {
|
1031 |
options: function (tp_inst, obj, unit, opts, val) {
|
| 1030 |
if (tp_inst._defaults.isRTL) {
|
1032 |
if (tp_inst._defaults.isRTL) {
|
| 1031 |
if (typeof(opts) === 'string') {
|
1033 |
if (typeof(opts) === 'string') {
|
| 1032 |
if (opts === 'min' || opts === 'max') {
|
1034 |
if (opts === 'min' || opts === 'max') {
|
| Line 1035... |
Line 1037... |
| 1035 |
}
|
1037 |
}
|
| 1036 |
return Math.abs(obj.slider(opts));
|
1038 |
return Math.abs(obj.slider(opts));
|
| 1037 |
}
|
1039 |
}
|
| 1038 |
return obj.slider(opts);
|
1040 |
return obj.slider(opts);
|
| 1039 |
}
|
1041 |
}
|
| 1040 |
var min = opts.min,
|
1042 |
var min = opts.min,
|
| 1041 |
max = opts.max;
|
1043 |
max = opts.max;
|
| 1042 |
opts.min = opts.max = null;
|
1044 |
opts.min = opts.max = null;
|
| 1043 |
if (min !== undefined) {
|
1045 |
if (min !== undefined) {
|
| 1044 |
opts.max = min * -1;
|
1046 |
opts.max = min * -1;
|
| 1045 |
}
|
1047 |
}
|
| Line 1098... |
Line 1100... |
| 1098 |
$t = obj.children('select');
|
1100 |
$t = obj.children('select');
|
| 1099 |
if (typeof(opts) === 'string') {
|
1101 |
if (typeof(opts) === 'string') {
|
| 1100 |
if (val === undefined) {
|
1102 |
if (val === undefined) {
|
| 1101 |
return $t.data(opts);
|
1103 |
return $t.data(opts);
|
| 1102 |
}
|
1104 |
}
|
| 1103 |
o[opts] = val;
|
1105 |
o[opts] = val;
|
| 1104 |
}
|
1106 |
}
|
| 1105 |
else { o = opts; }
|
1107 |
else { o = opts; }
|
| 1106 |
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min>=0 ? o.min : $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
|
1108 |
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min>=0 ? o.min : $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
|
| 1107 |
},
|
1109 |
},
|
| 1108 |
value: function (tp_inst, obj, unit, val) {
|
1110 |
value: function (tp_inst, obj, unit, val) {
|
| Line 1333... |
Line 1335... |
| 1333 |
try {
|
1335 |
try {
|
| 1334 |
return strictParse(f, s, o);
|
1336 |
return strictParse(f, s, o);
|
| 1335 |
}
|
1337 |
}
|
| 1336 |
catch (err2) {
|
1338 |
catch (err2) {
|
| 1337 |
$.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
|
1339 |
$.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
|
| 1338 |
}
|
1340 |
}
|
| 1339 |
}
|
1341 |
}
|
| 1340 |
return false;
|
1342 |
return false;
|
| 1341 |
}; // end looseParse
|
1343 |
}; // end looseParse
|
| 1342 |
|
1344 |
|
| 1343 |
if (typeof o.parse === "function") {
|
1345 |
if (typeof o.parse === "function") {
|
| 1344 |
return o.parse(timeFormat, timeString, o);
|
1346 |
return o.parse(timeFormat, timeString, o);
|
| 1345 |
}
|
1347 |
}
|
| 1346 |
if (o.parse === 'loose') {
|
1348 |
if (o.parse === 'loose') {
|
| 1347 |
return looseParse(timeFormat, timeString, o);
|
1349 |
return looseParse(timeFormat, timeString, o);
|
| Line 1486... |
Line 1488... |
| 1486 |
.replace(/TT/g, ampm ? 'APM' : '')
|
1488 |
.replace(/TT/g, ampm ? 'APM' : '')
|
| 1487 |
.replace(/Tt/g, ampm ? 'AaPpMm' : '')
|
1489 |
.replace(/Tt/g, ampm ? 'AaPpMm' : '')
|
| 1488 |
.replace(/tT/g, ampm ? 'AaPpMm' : '')
|
1490 |
.replace(/tT/g, ampm ? 'AaPpMm' : '')
|
| 1489 |
.replace(/T/g, ampm ? 'AP' : '')
|
1491 |
.replace(/T/g, ampm ? 'AP' : '')
|
| 1490 |
.replace(/tt/g, ampm ? 'apm' : '')
|
1492 |
.replace(/tt/g, ampm ? 'apm' : '')
|
| 1491 |
.replace(/t/g, ampm ? 'ap' : '') +
|
1493 |
.replace(/t/g, ampm ? 'ap' : '') +
|
| 1492 |
" " + tp_inst._defaults.separator +
|
1494 |
" " + tp_inst._defaults.separator +
|
| 1493 |
tp_inst._defaults.timeSuffix +
|
1495 |
tp_inst._defaults.timeSuffix +
|
| 1494 |
(tz ? tp_inst._defaults.timezoneList.join('') : '') +
|
1496 |
(tz ? tp_inst._defaults.timezoneList.join('') : '') +
|
| 1495 |
(tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
|
1497 |
(tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) +
|
| 1496 |
dateChars,
|
1498 |
dateChars,
|
| 1497 |
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
1499 |
chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
| 1498 |
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
|
1500 |
return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
|
| 1499 |
}
|
1501 |
}
|
| 1500 |
}
|
1502 |
}
|
| Line 1513... |
Line 1515... |
| 1513 |
var altField = tp_inst._defaults.altField;
|
1515 |
var altField = tp_inst._defaults.altField;
|
| 1514 |
if (altField) { // update alternate field too
|
1516 |
if (altField) { // update alternate field too
|
| 1515 |
var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
|
1517 |
var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
|
| 1516 |
date = this._getDate(inst),
|
1518 |
date = this._getDate(inst),
|
| 1517 |
formatCfg = $.datepicker._getFormatConfig(inst),
|
1519 |
formatCfg = $.datepicker._getFormatConfig(inst),
|
| 1518 |
altFormattedDateTime = '',
|
1520 |
altFormattedDateTime = '',
|
| 1519 |
altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
|
1521 |
altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator,
|
| 1520 |
altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
|
1522 |
altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
|
| 1521 |
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
|
1523 |
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
|
| 1522 |
|
1524 |
|
| 1523 |
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
|
1525 |
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
|
| 1524 |
if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
|
1526 |
if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
|
| 1525 |
if (tp_inst._defaults.altFormat) {
|
1527 |
if (tp_inst._defaults.altFormat) {
|
| 1526 |
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
|
1528 |
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
|
| 1527 |
}
|
1529 |
}
|
| Line 1531... |
Line 1533... |
| 1531 |
}
|
1533 |
}
|
| 1532 |
$(altField).val( inst.input.val() ? altFormattedDateTime : "");
|
1534 |
$(altField).val( inst.input.val() ? altFormattedDateTime : "");
|
| 1533 |
}
|
1535 |
}
|
| 1534 |
}
|
1536 |
}
|
| 1535 |
else {
|
1537 |
else {
|
| 1536 |
$.datepicker._base_updateAlternate(inst);
|
1538 |
$.datepicker._base_updateAlternate(inst);
|
| 1537 |
}
|
1539 |
}
|
| 1538 |
};
|
1540 |
};
|
| 1539 |
|
1541 |
|
| 1540 |
/*
|
1542 |
/*
|
| 1541 |
* Override key up event to sync manual input changes.
|
1543 |
* Override key up event to sync manual input changes.
|
| Line 1564... |
Line 1566... |
| 1564 |
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
|
1566 |
$.datepicker._base_gotoToday = $.datepicker._gotoToday;
|
| 1565 |
$.datepicker._gotoToday = function (id) {
|
1567 |
$.datepicker._gotoToday = function (id) {
|
| 1566 |
var inst = this._getInst($(id)[0]);
|
1568 |
var inst = this._getInst($(id)[0]);
|
| 1567 |
this._base_gotoToday(id);
|
1569 |
this._base_gotoToday(id);
|
| 1568 |
var tp_inst = this._get(inst, 'timepicker');
|
1570 |
var tp_inst = this._get(inst, 'timepicker');
|
| - |
|
1571 |
if (!tp_inst) {
|
| - |
|
1572 |
return;
|
| - |
|
1573 |
}
|
| - |
|
1574 |
|
| 1569 |
var tzoffset = $.timepicker.timezoneOffsetNumber(tp_inst.timezone);
|
1575 |
var tzoffset = $.timepicker.timezoneOffsetNumber(tp_inst.timezone);
|
| 1570 |
var now = new Date();
|
1576 |
var now = new Date();
|
| 1571 |
now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + tzoffset);
|
1577 |
now.setMinutes(now.getMinutes() + now.getTimezoneOffset() + parseInt(tzoffset, 10));
|
| 1572 |
this._setTime(inst, now);
|
1578 |
this._setTime(inst, now);
|
| 1573 |
this._setDate(inst, now);
|
1579 |
this._setDate(inst, now);
|
| 1574 |
tp_inst._onSelectHandler();
|
1580 |
tp_inst._onSelectHandler();
|
| 1575 |
};
|
1581 |
};
|
| 1576 |
|
1582 |
|
| Line 1621... |
Line 1627... |
| 1621 |
tp_inst.minute = date ? date.getMinutes() : defaults.minute;
|
1627 |
tp_inst.minute = date ? date.getMinutes() : defaults.minute;
|
| 1622 |
tp_inst.second = date ? date.getSeconds() : defaults.second;
|
1628 |
tp_inst.second = date ? date.getSeconds() : defaults.second;
|
| 1623 |
tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
|
1629 |
tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
|
| 1624 |
tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
|
1630 |
tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
|
| 1625 |
|
1631 |
|
| 1626 |
//check if within min/max times..
|
1632 |
//check if within min/max times..
|
| 1627 |
tp_inst._limitMinMaxDateTime(inst, true);
|
1633 |
tp_inst._limitMinMaxDateTime(inst, true);
|
| 1628 |
|
1634 |
|
| 1629 |
tp_inst._onTimeChange();
|
1635 |
tp_inst._onTimeChange();
|
| 1630 |
tp_inst._updateDateTime(inst);
|
1636 |
tp_inst._updateDateTime(inst);
|
| 1631 |
}
|
1637 |
}
|
| Line 1689... |
Line 1695... |
| 1689 |
tp_date = new Date(date.getTime());
|
1695 |
tp_date = new Date(date.getTime());
|
| 1690 |
tp_date.setMicroseconds(date.getMicroseconds());
|
1696 |
tp_date.setMicroseconds(date.getMicroseconds());
|
| 1691 |
} else {
|
1697 |
} else {
|
| 1692 |
tp_date = date;
|
1698 |
tp_date = date;
|
| 1693 |
}
|
1699 |
}
|
| 1694 |
|
1700 |
|
| 1695 |
// This is important if you are using the timezone option, javascript's Date
|
1701 |
// This is important if you are using the timezone option, javascript's Date
|
| 1696 |
// object will only return the timezone offset for the current locale, so we
|
1702 |
// object will only return the timezone offset for the current locale, so we
|
| 1697 |
// adjust it accordingly. If not using timezone option this won't matter..
|
1703 |
// adjust it accordingly. If not using timezone option this won't matter..
|
| 1698 |
// If a timezone is different in tp, keep the timezone as is
|
1704 |
// If a timezone is different in tp, keep the timezone as is
|
| 1699 |
if (tp_inst && tp_date) {
|
1705 |
if (tp_inst && tp_date) {
|
| 1700 |
// look out for DST if tz wasn't specified
|
1706 |
// look out for DST if tz wasn't specified
|
| 1701 |
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
|
1707 |
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
|
| 1702 |
tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
|
1708 |
tp_inst.timezone = tp_date.getTimezoneOffset() * -1;
|
| 1703 |
}
|
1709 |
}
|
| 1704 |
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
|
1710 |
date = $.timepicker.timezoneAdjust(date, $.timepicker.timezoneOffsetString(-date.getTimezoneOffset()), tp_inst.timezone);
|
| 1705 |
tp_date = $.timepicker.timezoneAdjust(tp_date, tp_inst.timezone);
|
1711 |
tp_date = $.timepicker.timezoneAdjust(tp_date, $.timepicker.timezoneOffsetString(-tp_date.getTimezoneOffset()), tp_inst.timezone);
|
| 1706 |
}
|
1712 |
}
|
| 1707 |
|
1713 |
|
| 1708 |
this._updateDatepicker(inst);
|
1714 |
this._updateDatepicker(inst);
|
| 1709 |
this._base_setDateDatepicker.apply(this, arguments);
|
1715 |
this._base_setDateDatepicker.apply(this, arguments);
|
| 1710 |
this._setTimeDatepicker(target, tp_date, true);
|
1716 |
this._setTimeDatepicker(target, tp_date, true);
|
| Line 1727... |
Line 1733... |
| 1727 |
if (inst.lastVal === undefined) {
|
1733 |
if (inst.lastVal === undefined) {
|
| 1728 |
this._setDateFromField(inst, noDefault);
|
1734 |
this._setDateFromField(inst, noDefault);
|
| 1729 |
}
|
1735 |
}
|
| 1730 |
|
1736 |
|
| 1731 |
var date = this._getDate(inst);
|
1737 |
var date = this._getDate(inst);
|
| - |
|
1738 |
|
| - |
|
1739 |
var currDT = null;
|
| - |
|
1740 |
|
| - |
|
1741 |
if (tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) {
|
| 1732 |
var currDT = $.trim((tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) ? tp_inst.$input.val() + ' ' + tp_inst.$altInput.val() : tp_inst.$input.val());
|
1742 |
currDT = tp_inst.$input.val() + ' ' + tp_inst.$altInput.val();
|
| - |
|
1743 |
}
|
| - |
|
1744 |
else if (tp_inst.$input.get(0).tagName !== 'INPUT' && tp_inst.$altInput) {
|
| - |
|
1745 |
/**
|
| - |
|
1746 |
* in case the datetimepicker has been applied to a non-input tag for inline UI,
|
| - |
|
1747 |
* and the user has not configured the plugin to display only time in altInput,
|
| - |
|
1748 |
* pick current date time from the altInput (and hope for the best, for now, until "ER1" is applied)
|
| - |
|
1749 |
*
|
| - |
|
1750 |
* @todo ER1. Since altInput can have a totally difference format, convert it to standard format by reading input format from "altFormat" and "altTimeFormat" option values
|
| - |
|
1751 |
*/
|
| - |
|
1752 |
currDT = tp_inst.$altInput.val();
|
| - |
|
1753 |
}
|
| - |
|
1754 |
else {
|
| - |
|
1755 |
currDT = tp_inst.$input.val();
|
| - |
|
1756 |
}
|
| - |
|
1757 |
|
| 1733 |
if (date && tp_inst._parseTime(currDT, !inst.settings.timeOnly)) {
|
1758 |
if (date && tp_inst._parseTime(currDT, !inst.settings.timeOnly)) {
|
| 1734 |
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
1759 |
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
| 1735 |
date.setMicroseconds(tp_inst.microsec);
|
1760 |
date.setMicroseconds(tp_inst.microsec);
|
| 1736 |
|
1761 |
|
| 1737 |
// This is important if you are using the timezone option, javascript's Date
|
1762 |
// This is important if you are using the timezone option, javascript's Date
|
| 1738 |
// object will only return the timezone offset for the current locale, so we
|
1763 |
// object will only return the timezone offset for the current locale, so we
|
| 1739 |
// adjust it accordingly. If not using timezone option this won't matter..
|
1764 |
// adjust it accordingly. If not using timezone option this won't matter..
|
| 1740 |
if (tp_inst.timezone != null) {
|
1765 |
if (tp_inst.timezone != null) {
|
| 1741 |
// look out for DST if tz wasn't specified
|
1766 |
// look out for DST if tz wasn't specified
|
| 1742 |
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
|
1767 |
if (!tp_inst.support.timezone && tp_inst._defaults.timezone === null) {
|
| 1743 |
tp_inst.timezone = date.getTimezoneOffset() * -1;
|
1768 |
tp_inst.timezone = date.getTimezoneOffset() * -1;
|
| 1744 |
}
|
1769 |
}
|
| 1745 |
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone);
|
1770 |
date = $.timepicker.timezoneAdjust(date, tp_inst.timezone, $.timepicker.timezoneOffsetString(-date.getTimezoneOffset()));
|
| 1746 |
}
|
1771 |
}
|
| 1747 |
}
|
1772 |
}
|
| 1748 |
return date;
|
1773 |
return date;
|
| 1749 |
}
|
1774 |
}
|
| 1750 |
return this._base_getDateDatepicker(target, noDefault);
|
1775 |
return this._base_getDateDatepicker(target, noDefault);
|
| Line 1864... |
Line 1889... |
| 1864 |
tp_inst._defaults.maxDateTime = max;
|
1889 |
tp_inst._defaults.maxDateTime = max;
|
| 1865 |
} else if (onselect) {
|
1890 |
} else if (onselect) {
|
| 1866 |
tp_inst._defaults.onSelect = onselect;
|
1891 |
tp_inst._defaults.onSelect = onselect;
|
| 1867 |
}
|
1892 |
}
|
| 1868 |
|
1893 |
|
| 1869 |
// Datepicker will override our date when we call _base_optionDatepicker when
|
1894 |
// Datepicker will override our date when we call _base_optionDatepicker when
|
| 1870 |
// calling minDate/maxDate, so we will first grab the value, call
|
1895 |
// calling minDate/maxDate, so we will first grab the value, call
|
| 1871 |
// _base_optionDatepicker, then set our value back.
|
1896 |
// _base_optionDatepicker, then set our value back.
|
| 1872 |
if(min || max){
|
1897 |
if(min || max){
|
| 1873 |
$target = $(target);
|
1898 |
$target = $(target);
|
| 1874 |
oldVal = $target.datetimepicker('getDate');
|
1899 |
oldVal = $target.datetimepicker('getDate');
|
| 1875 |
ret = this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
1900 |
ret = this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
| Line 1880... |
Line 1905... |
| 1880 |
if (value === undefined) {
|
1905 |
if (value === undefined) {
|
| 1881 |
return this._base_optionDatepicker.call($.datepicker, target, name);
|
1906 |
return this._base_optionDatepicker.call($.datepicker, target, name);
|
| 1882 |
}
|
1907 |
}
|
| 1883 |
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
1908 |
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
| 1884 |
};
|
1909 |
};
|
| 1885 |
|
1910 |
|
| 1886 |
/*
|
1911 |
/*
|
| 1887 |
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
|
1912 |
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
|
| 1888 |
* it will return false for all objects
|
1913 |
* it will return false for all objects
|
| 1889 |
*/
|
1914 |
*/
|
| 1890 |
var isEmptyObject = function (obj) {
|
1915 |
var isEmptyObject = function (obj) {
|
| Line 2038... |
Line 2063... |
| 2038 |
var off = tzMinutes,
|
2063 |
var off = tzMinutes,
|
| 2039 |
minutes = off % 60,
|
2064 |
minutes = off % 60,
|
| 2040 |
hours = (off - minutes) / 60,
|
2065 |
hours = (off - minutes) / 60,
|
| 2041 |
iso = iso8601 ? ':' : '',
|
2066 |
iso = iso8601 ? ':' : '',
|
| 2042 |
tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
|
2067 |
tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
|
| 2043 |
|
2068 |
|
| 2044 |
if (tz === '+00:00') {
|
2069 |
if (tz === '+00:00') {
|
| 2045 |
return 'Z';
|
2070 |
return 'Z';
|
| 2046 |
}
|
2071 |
}
|
| 2047 |
return tz;
|
2072 |
return tz;
|
| 2048 |
};
|
2073 |
};
|
| Line 2058... |
Line 2083... |
| 2058 |
if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
|
2083 |
if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
|
| 2059 |
return 0;
|
2084 |
return 0;
|
| 2060 |
}
|
2085 |
}
|
| 2061 |
|
2086 |
|
| 2062 |
if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
|
2087 |
if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
|
| 2063 |
return tzString;
|
2088 |
return parseInt(tzString, 10);
|
| 2064 |
}
|
2089 |
}
|
| 2065 |
|
2090 |
|
| 2066 |
return ((normalized.substr(0, 1) === '-' ? -1 : 1) * // plus or minus
|
2091 |
return ((normalized.substr(0, 1) === '-' ? -1 : 1) * // plus or minus
|
| 2067 |
((parseInt(normalized.substr(1, 2), 10) * 60) + // hours (converted to minutes)
|
2092 |
((parseInt(normalized.substr(1, 2), 10) * 60) + // hours (converted to minutes)
|
| 2068 |
parseInt(normalized.substr(3, 2), 10))); // minutes
|
2093 |
parseInt(normalized.substr(3, 2), 10))); // minutes
|
| 2069 |
};
|
2094 |
};
|
| 2070 |
|
2095 |
|
| 2071 |
/**
|
2096 |
/**
|
| 2072 |
* No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
|
2097 |
* No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
|
| 2073 |
* @param {Date} date
|
2098 |
* @param {Date} date
|
| - |
|
2099 |
* @param {string} fromTimezone formatted like "+0500", "-1245"
|
| 2074 |
* @param {string} toTimezone formatted like "+0500", "-1245"
|
2100 |
* @param {string} toTimezone formatted like "+0500", "-1245"
|
| 2075 |
* @return {Date}
|
2101 |
* @return {Date}
|
| 2076 |
*/
|
2102 |
*/
|
| 2077 |
$.timepicker.timezoneAdjust = function (date, toTimezone) {
|
2103 |
$.timepicker.timezoneAdjust = function (date, fromTimezone, toTimezone) {
|
| - |
|
2104 |
var fromTz = $.timepicker.timezoneOffsetNumber(fromTimezone);
|
| 2078 |
var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
|
2105 |
var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
|
| 2079 |
if (!isNaN(toTz)) {
|
2106 |
if (!isNaN(toTz)) {
|
| 2080 |
date.setMinutes(date.getMinutes() + -date.getTimezoneOffset() - toTz);
|
2107 |
date.setMinutes(date.getMinutes() + (-fromTz) - (-toTz));
|
| 2081 |
}
|
2108 |
}
|
| 2082 |
return date;
|
2109 |
return date;
|
| 2083 |
};
|
2110 |
};
|
| 2084 |
|
2111 |
|
| 2085 |
/**
|
2112 |
/**
|
| Line 2182... |
Line 2209... |
| 2182 |
}
|
2209 |
}
|
| 2183 |
if (option === 'maxDate') {
|
2210 |
if (option === 'maxDate') {
|
| 2184 |
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
|
2211 |
date.setMilliseconds(date.getMilliseconds() - options.minInterval);
|
| 2185 |
}
|
2212 |
}
|
| 2186 |
}
|
2213 |
}
|
| 2187 |
|
2214 |
|
| 2188 |
if (date.getTime) {
|
2215 |
if (date.getTime) {
|
| 2189 |
other[method].call(other, 'option', option, date);
|
2216 |
other[method].call(other, 'option', option, date);
|
| 2190 |
}
|
2217 |
}
|
| 2191 |
}
|
2218 |
}
|
| 2192 |
|
2219 |
|
| Line 2208... |
Line 2235... |
| 2208 |
selected($(this), startTime, 'maxDate');
|
2235 |
selected($(this), startTime, 'maxDate');
|
| 2209 |
}
|
2236 |
}
|
| 2210 |
}, options, options.end));
|
2237 |
}, options, options.end));
|
| 2211 |
|
2238 |
|
| 2212 |
checkDates(startTime, endTime);
|
2239 |
checkDates(startTime, endTime);
|
| 2213 |
|
2240 |
|
| 2214 |
selected(startTime, endTime, 'minDate');
|
2241 |
selected(startTime, endTime, 'minDate');
|
| 2215 |
selected(endTime, startTime, 'maxDate');
|
2242 |
selected(endTime, startTime, 'maxDate');
|
| 2216 |
|
2243 |
|
| 2217 |
return $([startTime.get(0), endTime.get(0)]);
|
2244 |
return $([startTime.get(0), endTime.get(0)]);
|
| 2218 |
};
|
2245 |
};
|
| Line 2221... |
Line 2248... |
| 2221 |
* Log error or data to the console during error or debugging
|
2248 |
* Log error or data to the console during error or debugging
|
| 2222 |
* @param {Object} err pass any type object to log to the console during error or debugging
|
2249 |
* @param {Object} err pass any type object to log to the console during error or debugging
|
| 2223 |
* @return {void}
|
2250 |
* @return {void}
|
| 2224 |
*/
|
2251 |
*/
|
| 2225 |
$.timepicker.log = function () {
|
2252 |
$.timepicker.log = function () {
|
| - |
|
2253 |
// Older IE (9, maybe 10) throw error on accessing `window.console.log.apply`, so check first.
|
| 2226 |
if (window.console) {
|
2254 |
if (window.console && window.console.log && window.console.log.apply) {
|
| 2227 |
window.console.log.apply(window.console, Array.prototype.slice.call(arguments));
|
2255 |
window.console.log.apply(window.console, Array.prototype.slice.call(arguments));
|
| 2228 |
}
|
2256 |
}
|
| 2229 |
};
|
2257 |
};
|
| 2230 |
|
2258 |
|
| 2231 |
/*
|
2259 |
/*
|
| Line 2256... |
Line 2284... |
| 2256 |
}
|
2284 |
}
|
| 2257 |
|
2285 |
|
| 2258 |
/*
|
2286 |
/*
|
| 2259 |
* Keep up with the version
|
2287 |
* Keep up with the version
|
| 2260 |
*/
|
2288 |
*/
|
| 2261 |
$.timepicker.version = "1.6.1";
|
2289 |
$.timepicker.version = "1.6.3";
|
| 2262 |
|
2290 |
|
| 2263 |
}));
|
2291 |
}));
|