|
26 | 26 | }
|
27 | 27 | });
|
28 | 28 |
|
29 |
| - /* |
| 29 | + /* |
30 | 30 | * Timepicker manager.
|
31 | 31 | * Use the singleton instance of this class, $.timepicker, to interact with the time picker.
|
32 | 32 | * Settings for (groups of) time pickers are maintained in an instance object,
|
|
153 | 153 | support: {},
|
154 | 154 | control: null,
|
155 | 155 |
|
156 |
| - /* |
| 156 | + /* |
157 | 157 | * Override the default settings for all instances of the time picker.
|
158 | 158 | * @param {Object} settings object - the new settings to use as defaults (anonymous object)
|
159 | 159 | * @return {Object} the manager object
|
|
226 | 226 |
|
227 | 227 | // detect which units are supported
|
228 | 228 | tp_inst.support = detectSupport(
|
229 |
| - tp_inst._defaults.timeFormat + |
| 229 | + tp_inst._defaults.timeFormat + |
230 | 230 | (tp_inst._defaults.pickerTimeFormat ? tp_inst._defaults.pickerTimeFormat : '') +
|
231 | 231 | (tp_inst._defaults.altTimeFormat ? tp_inst._defaults.altTimeFormat : ''));
|
232 | 232 |
|
|
425 | 425 | }
|
426 | 426 | html += '</dd>';
|
427 | 427 | }
|
428 |
| - |
| 428 | + |
429 | 429 | // Timezone
|
430 | 430 | var showTz = o.showTimezone !== null ? o.showTimezone : this.support.timezone;
|
431 | 431 | html += '<dt class="ui_tpicker_timezone_label' + (showTz ? '' : noDisplay) + '">' + o.timezoneText + '</dt>';
|
|
440 | 440 | $tp.prepend('<div class="ui-widget-header ui-helper-clearfix ui-corner-all">' + '<div class="ui-datepicker-title">' + o.timeOnlyTitle + '</div>' + '</div>');
|
441 | 441 | $dp.find('.ui-datepicker-header, .ui-datepicker-calendar').hide();
|
442 | 442 | }
|
443 |
| - |
| 443 | + |
444 | 444 | // add sliders, adjust grids, add events
|
445 | 445 | for (i = 0, l = tp_inst.units.length; i < l; i++) {
|
446 | 446 | litem = tp_inst.units[i];
|
|
475 | 475 | }
|
476 | 476 | }
|
477 | 477 | }
|
478 |
| - |
| 478 | + |
479 | 479 | tp_inst.control.value(tp_inst, tp_inst[f + '_slider'], litem, n);
|
480 | 480 |
|
481 | 481 | tp_inst._onTimeChange();
|
|
515 | 515 | tp_inst._afterInject();
|
516 | 516 | });
|
517 | 517 | // End timezone options
|
518 |
| - |
| 518 | + |
519 | 519 | // inject timepicker into datepicker
|
520 | 520 | var $buttonPanel = $dp.find('.ui-datepicker-buttonpane');
|
521 | 521 | if ($buttonPanel.length) {
|
|
551 | 551 | var sliderAccessArgs = this._defaults.sliderAccessArgs,
|
552 | 552 | rtl = this._defaults.isRTL;
|
553 | 553 | sliderAccessArgs.isRTL = rtl;
|
554 |
| - |
| 554 | + |
555 | 555 | setTimeout(function () { // fix for inline mode
|
556 | 556 | if ($tp.find('.ui-slider-access').length === 0) {
|
557 | 557 | $tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
|
|
703 | 703 | }
|
704 | 704 | }
|
705 | 705 |
|
706 |
| - if (dp_inst.settings.minTime!==null) { |
707 |
| - var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime); |
| 706 | + if (dp_inst.settings.minTime!==null) { |
| 707 | + var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime); |
708 | 708 | if (this.hour<tempMinTime.getHours()) {
|
709 | 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 | 711 | } else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) {
|
712 | 712 | this.minute=this._defaults.minuteMin=tempMinTime.getMinutes();
|
713 |
| - } else { |
| 713 | + } else { |
714 | 714 | if (this._defaults.hourMin<tempMinTime.getHours()) {
|
715 | 715 | this._defaults.hourMin=tempMinTime.getHours();
|
716 |
| - this._defaults.minuteMin=tempMinTime.getMinutes(); |
| 716 | + this._defaults.minuteMin=tempMinTime.getMinutes(); |
717 | 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 | 719 | } else {
|
720 | 720 | this._defaults.minuteMin=0;
|
721 | 721 | }
|
722 |
| - } |
| 722 | + } |
723 | 723 | }
|
724 |
| - |
725 |
| - if (dp_inst.settings.maxTime!==null) { |
| 724 | + |
| 725 | + if (dp_inst.settings.maxTime!==null) { |
726 | 726 | var tempMaxTime=new Date("01/01/1970 " + dp_inst.settings.maxTime);
|
727 | 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 | 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 | 732 | } else {
|
733 | 733 | if (this._defaults.hourMax>tempMaxTime.getHours()) {
|
734 | 734 | this._defaults.hourMax=tempMaxTime.getHours();
|
735 |
| - this._defaults.minuteMax=tempMaxTime.getMinutes(); |
| 735 | + this._defaults.minuteMax=tempMaxTime.getMinutes(); |
736 | 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 | 738 | } else {
|
739 | 739 | this._defaults.minuteMax=59;
|
740 | 740 | }
|
741 |
| - } |
| 741 | + } |
742 | 742 | }
|
743 |
| - |
| 743 | + |
744 | 744 | if (adjustSliders !== undefined && adjustSliders === true) {
|
745 | 745 | var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
|
746 | 746 | minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
|
834 | 834 | // If the update was done using the sliders, update the input field.
|
835 | 835 | var hasChanged = (
|
836 | 836 | hour !== parseInt(this.hour,10) || // sliders should all be numeric
|
837 |
| - minute !== parseInt(this.minute,10) || |
838 |
| - second !== parseInt(this.second,10) || |
839 |
| - millisec !== parseInt(this.millisec,10) || |
840 |
| - microsec !== parseInt(this.microsec,10) || |
841 |
| - (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) || |
| 837 | + minute !== parseInt(this.minute,10) || |
| 838 | + second !== parseInt(this.second,10) || |
| 839 | + millisec !== parseInt(this.millisec,10) || |
| 840 | + microsec !== parseInt(this.microsec,10) || |
| 841 | + (this.ampm.length > 0 && (hour < 12) !== ($.inArray(this.ampm.toUpperCase(), this.amNames) !== -1)) || |
842 | 842 | (this.timezone !== null && timezone !== this.timezone.toString()) // could be numeric or "EST" format, so use toString()
|
843 | 843 | );
|
844 | 844 |
|
|
876 | 876 | // Updates the time within the timepicker
|
877 | 877 | this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o);
|
878 | 878 | if (this.$timeObj) {
|
879 |
| - var sPos = this.$timeObj[0].selectionStart; |
880 |
| - var ePos = this.$timeObj[0].selectionEnd; |
881 | 879 | if (pickerTimeFormat === o.timeFormat) {
|
882 | 880 | this.$timeObj.val(this.formattedTime + pickerTimeSuffix);
|
883 | 881 | }
|
884 | 882 | else {
|
885 | 883 | this.$timeObj.val($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix);
|
886 | 884 | }
|
887 |
| - this.$timeObj[0].setSelectionRange(sPos, ePos); |
| 885 | + if (this.$timeObj[0].setSelectionRange) { |
| 886 | + var sPos = this.$timeObj[0].selectionStart; |
| 887 | + var ePos = this.$timeObj[0].selectionEnd; |
| 888 | + this.$timeObj[0].setSelectionRange(sPos, ePos); |
| 889 | + } |
888 | 890 | }
|
889 | 891 |
|
890 | 892 | this.timeDefined = true;
|
|
911 | 913 | */
|
912 | 914 | _updateDateTime: function (dp_inst) {
|
913 | 915 | dp_inst = this.inst || dp_inst;
|
914 |
| - var dtTmp = (dp_inst.currentYear > 0? |
915 |
| - new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) : |
| 916 | + var dtTmp = (dp_inst.currentYear > 0? |
| 917 | + new Date(dp_inst.currentYear, dp_inst.currentMonth, dp_inst.currentDay) : |
916 | 918 | new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
917 | 919 | dt = $.datepicker._daylightSavingAdjust(dtTmp),
|
918 | 920 | //dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
|
|
922 | 924 | timeAvailable = dt !== null && this.timeDefined;
|
923 | 925 | this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
924 | 926 | var formattedDateTime = this.formattedDate;
|
925 |
| - |
| 927 | + |
926 | 928 | // if a slider was changed but datepicker doesn't have a value yet, set it
|
927 | 929 | if (dp_inst.lastVal === "") {
|
928 | 930 | dp_inst.currentYear = dp_inst.selectedYear;
|
|
932 | 934 |
|
933 | 935 | /*
|
934 | 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 | 938 | * If the user manually empty the value in the input field, the date picker will never change selected value.
|
937 | 939 | */
|
938 | 940 | //if (dp_inst.lastVal !== undefined && (dp_inst.lastVal.length > 0 && this.$input.val().length === 0)) {
|
|
957 | 959 | var altFormattedDateTime = '',
|
958 | 960 | altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
|
959 | 961 | altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
|
960 |
| - |
| 962 | + |
961 | 963 | if (!this._defaults.timeOnly) {
|
962 | 964 | if (this._defaults.altFormat) {
|
963 | 965 | altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
|
|
1024 | 1026 | stop: function (event, ui) {
|
1025 | 1027 | tp_inst._onSelectHandler();
|
1026 | 1028 | }
|
1027 |
| - }); |
| 1029 | + }); |
1028 | 1030 | },
|
1029 | 1031 | options: function (tp_inst, obj, unit, opts, val) {
|
1030 | 1032 | if (tp_inst._defaults.isRTL) {
|
|
1037 | 1039 | }
|
1038 | 1040 | return obj.slider(opts);
|
1039 | 1041 | }
|
1040 |
| - var min = opts.min, |
| 1042 | + var min = opts.min, |
1041 | 1043 | max = opts.max;
|
1042 | 1044 | opts.min = opts.max = null;
|
1043 | 1045 | if (min !== undefined) {
|
|
1100 | 1102 | if (val === undefined) {
|
1101 | 1103 | return $t.data(opts);
|
1102 | 1104 | }
|
1103 |
| - o[opts] = val; |
| 1105 | + o[opts] = val; |
1104 | 1106 | }
|
1105 | 1107 | else { o = opts; }
|
1106 | 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'));
|
|
1335 | 1337 | }
|
1336 | 1338 | catch (err2) {
|
1337 | 1339 | $.timepicker.log("Unable to parse \ntimeString: " + s + "\ntimeFormat: " + f);
|
1338 |
| - } |
| 1340 | + } |
1339 | 1341 | }
|
1340 | 1342 | return false;
|
1341 | 1343 | }; // end looseParse
|
1342 |
| - |
| 1344 | + |
1343 | 1345 | if (typeof o.parse === "function") {
|
1344 | 1346 | return o.parse(timeFormat, timeString, o);
|
1345 | 1347 | }
|
|
1488 | 1490 | .replace(/tT/g, ampm ? 'AaPpMm' : '')
|
1489 | 1491 | .replace(/T/g, ampm ? 'AP' : '')
|
1490 | 1492 | .replace(/tt/g, ampm ? 'apm' : '')
|
1491 |
| - .replace(/t/g, ampm ? 'ap' : '') + |
1492 |
| - " " + tp_inst._defaults.separator + |
1493 |
| - tp_inst._defaults.timeSuffix + |
1494 |
| - (tz ? tp_inst._defaults.timezoneList.join('') : '') + |
1495 |
| - (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) + |
| 1493 | + .replace(/t/g, ampm ? 'ap' : '') + |
| 1494 | + " " + tp_inst._defaults.separator + |
| 1495 | + tp_inst._defaults.timeSuffix + |
| 1496 | + (tz ? tp_inst._defaults.timezoneList.join('') : '') + |
| 1497 | + (tp_inst._defaults.amNames.join('')) + (tp_inst._defaults.pmNames.join('')) + |
1496 | 1498 | dateChars,
|
1497 | 1499 | chr = String.fromCharCode(event.charCode === undefined ? event.keyCode : event.charCode);
|
1498 | 1500 | return event.ctrlKey || (chr < ' ' || !dateChars || datetimeChars.indexOf(chr) > -1);
|
|
1515 | 1517 | var altFormat = tp_inst._defaults.altFormat || tp_inst._defaults.dateFormat,
|
1516 | 1518 | date = this._getDate(inst),
|
1517 | 1519 | formatCfg = $.datepicker._getFormatConfig(inst),
|
1518 |
| - altFormattedDateTime = '', |
1519 |
| - altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator, |
| 1520 | + altFormattedDateTime = '', |
| 1521 | + altSeparator = tp_inst._defaults.altSeparator ? tp_inst._defaults.altSeparator : tp_inst._defaults.separator, |
1520 | 1522 | altTimeSuffix = tp_inst._defaults.altTimeSuffix ? tp_inst._defaults.altTimeSuffix : tp_inst._defaults.timeSuffix,
|
1521 | 1523 | altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
|
1522 |
| - |
| 1524 | + |
1523 | 1525 | altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
|
1524 | 1526 | if (!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null) {
|
1525 | 1527 | if (tp_inst._defaults.altFormat) {
|
|
1533 | 1535 | }
|
1534 | 1536 | }
|
1535 | 1537 | else {
|
1536 |
| - $.datepicker._base_updateAlternate(inst); |
| 1538 | + $.datepicker._base_updateAlternate(inst); |
1537 | 1539 | }
|
1538 | 1540 | };
|
1539 | 1541 |
|
|
1623 | 1625 | tp_inst.millisec = date ? date.getMilliseconds() : defaults.millisec;
|
1624 | 1626 | tp_inst.microsec = date ? date.getMicroseconds() : defaults.microsec;
|
1625 | 1627 |
|
1626 |
| - //check if within min/max times.. |
| 1628 | + //check if within min/max times.. |
1627 | 1629 | tp_inst._limitMinMaxDateTime(inst, true);
|
1628 | 1630 |
|
1629 | 1631 | tp_inst._onTimeChange();
|
|
1691 | 1693 | } else {
|
1692 | 1694 | tp_date = date;
|
1693 | 1695 | }
|
1694 |
| - |
1695 |
| - // 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 |
| 1696 | + |
| 1697 | + // This is important if you are using the timezone option, javascript's Date |
| 1698 | + // object will only return the timezone offset for the current locale, so we |
1697 | 1699 | // adjust it accordingly. If not using timezone option this won't matter..
|
1698 | 1700 | // If a timezone is different in tp, keep the timezone as is
|
1699 | 1701 | if (tp_inst && tp_date) {
|
|
1729 | 1731 | }
|
1730 | 1732 |
|
1731 | 1733 | var date = this._getDate(inst);
|
1732 |
| - var currDT = $.trim((tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) ? tp_inst.$input.val() + ' ' + tp_inst.$altInput.val() : tp_inst.$input.val()); |
| 1734 | + |
| 1735 | + var currDT = null; |
| 1736 | + |
| 1737 | + if (tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) { |
| 1738 | + currDT = tp_inst.$input.val() + ' ' + tp_inst.$altInput.val(); |
| 1739 | + } |
| 1740 | + else if (tp_inst.$input.get(0).tagName !== 'INPUT' && tp_inst.$altInput) { |
| 1741 | + /** |
| 1742 | + * in case the datetimepicker has been applied to a non-input tag for inline UI, |
| 1743 | + * and the user has not configured the plugin to display only time in altInput, |
| 1744 | + * pick current date time from the altInput (and hope for the best, for now, until "ER1" is applied) |
| 1745 | + * |
| 1746 | + * @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 |
| 1747 | + */ |
| 1748 | + currDT = tp_inst.$altInput.val(); |
| 1749 | + } |
| 1750 | + else { |
| 1751 | + currDT = tp_inst.$input.val(); |
| 1752 | + } |
| 1753 | + |
1733 | 1754 | if (date && tp_inst._parseTime(currDT, !inst.settings.timeOnly)) {
|
1734 | 1755 | date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
|
1735 | 1756 | date.setMicroseconds(tp_inst.microsec);
|
1736 | 1757 |
|
1737 |
| - // 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 |
| 1758 | + // This is important if you are using the timezone option, javascript's Date |
| 1759 | + // object will only return the timezone offset for the current locale, so we |
1739 | 1760 | // adjust it accordingly. If not using timezone option this won't matter..
|
1740 | 1761 | if (tp_inst.timezone != null) {
|
1741 | 1762 | // look out for DST if tz wasn't specified
|
|
1866 | 1887 | tp_inst._defaults.onSelect = onselect;
|
1867 | 1888 | }
|
1868 | 1889 |
|
1869 |
| - // Datepicker will override our date when we call _base_optionDatepicker when |
1870 |
| - // calling minDate/maxDate, so we will first grab the value, call |
| 1890 | + // Datepicker will override our date when we call _base_optionDatepicker when |
| 1891 | + // calling minDate/maxDate, so we will first grab the value, call |
1871 | 1892 | // _base_optionDatepicker, then set our value back.
|
1872 | 1893 | if(min || max){
|
1873 | 1894 | $target = $(target);
|
|
1882 | 1903 | }
|
1883 | 1904 | return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
|
1884 | 1905 | };
|
1885 |
| - |
| 1906 | + |
1886 | 1907 | /*
|
1887 | 1908 | * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
|
1888 | 1909 | * it will return false for all objects
|
|
2040 | 2061 | hours = (off - minutes) / 60,
|
2041 | 2062 | iso = iso8601 ? ':' : '',
|
2042 | 2063 | tz = (off >= 0 ? '+' : '-') + ('0' + Math.abs(hours)).slice(-2) + iso + ('0' + Math.abs(minutes)).slice(-2);
|
2043 |
| - |
| 2064 | + |
2044 | 2065 | if (tz === '+00:00') {
|
2045 | 2066 | return 'Z';
|
2046 | 2067 | }
|
|
2184 | 2205 | date.setMilliseconds(date.getMilliseconds() - options.minInterval);
|
2185 | 2206 | }
|
2186 | 2207 | }
|
2187 |
| - |
| 2208 | + |
2188 | 2209 | if (date.getTime) {
|
2189 | 2210 | other[method].call(other, 'option', option, date);
|
2190 | 2211 | }
|
|
2210 | 2231 | }, options, options.end));
|
2211 | 2232 |
|
2212 | 2233 | checkDates(startTime, endTime);
|
2213 |
| - |
| 2234 | + |
2214 | 2235 | selected(startTime, endTime, 'minDate');
|
2215 | 2236 | selected(endTime, startTime, 'maxDate');
|
2216 | 2237 |
|
|
0 commit comments