|
1 |
| -/*! jQuery Timepicker Addon - v1.4.3 - 2013-11-30 |
| 1 | +/*! jQuery Timepicker Addon - v1.4.4 - 2014-03-29 |
2 | 2 | * http://trentrichardson.com/examples/timepicker
|
3 |
| -* Copyright (c) 2013 Trent Richardson; Licensed MIT */ |
| 3 | +* Copyright (c) 2014 Trent Richardson; Licensed MIT */ |
4 | 4 | (function ($) {
|
5 | 5 |
|
6 | 6 | /*
|
|
16 | 16 | */
|
17 | 17 | $.extend($.ui, {
|
18 | 18 | timepicker: {
|
19 |
| - version: "1.4.3" |
| 19 | + version: "1.4.4" |
20 | 20 | }
|
21 | 21 | });
|
22 | 22 |
|
|
48 | 48 | this._defaults = { // Global defaults for all the datetime picker instances
|
49 | 49 | showButtonPanel: true,
|
50 | 50 | timeOnly: false,
|
| 51 | + timeOnlyShowDate: false, |
51 | 52 | showHour: null,
|
52 | 53 | showMinute: null,
|
53 | 54 | showSecond: null,
|
|
78 | 79 | microsecMax: 999,
|
79 | 80 | minDateTime: null,
|
80 | 81 | maxDateTime: null,
|
| 82 | + maxTime: null, |
| 83 | + minTime: null, |
81 | 84 | onSelect: null,
|
82 | 85 | hourGrid: 0,
|
83 | 86 | minuteGrid: 0,
|
|
114 | 117 | millisec_slider: null,
|
115 | 118 | microsec_slider: null,
|
116 | 119 | timezone_select: null,
|
| 120 | + maxTime: null, |
| 121 | + minTime: null, |
117 | 122 | hour: 0,
|
118 | 123 | minute: 0,
|
119 | 124 | second: 0,
|
|
660 | 665 | }
|
661 | 666 | }
|
662 | 667 |
|
| 668 | + if (dp_inst.settings.minTime!==null) { |
| 669 | + var tempMinTime=new Date("01/01/1970 " + dp_inst.settings.minTime); |
| 670 | + if (this.hour<tempMinTime.getHours()) { |
| 671 | + this.hour=this._defaults.hourMin=tempMinTime.getHours(); |
| 672 | + this.minute=this._defaults.minuteMin=tempMinTime.getMinutes(); |
| 673 | + } else if (this.hour===tempMinTime.getHours() && this.minute<tempMinTime.getMinutes()) { |
| 674 | + this.minute=this._defaults.minuteMin=tempMinTime.getMinutes(); |
| 675 | + } else { |
| 676 | + if (this._defaults.hourMin<tempMinTime.getHours()) { |
| 677 | + this._defaults.hourMin=tempMinTime.getHours(); |
| 678 | + this._defaults.minuteMin=tempMinTime.getMinutes(); |
| 679 | + } else if (this._defaults.hourMin===tempMinTime.getHours()===this.hour && this._defaults.minuteMin<tempMinTime.getMinutes()) { |
| 680 | + this._defaults.minuteMin=tempMinTime.getMinutes(); |
| 681 | + } else { |
| 682 | + this._defaults.minuteMin=0; |
| 683 | + } |
| 684 | + } |
| 685 | + } |
| 686 | + |
| 687 | + if (dp_inst.settings.maxTime!==null) { |
| 688 | + var tempMaxTime=new Date("01/01/1970 " + dp_inst.settings.maxTime); |
| 689 | + if (this.hour>tempMaxTime.getHours()) { |
| 690 | + this.hour=this._defaults.hourMax=tempMaxTime.getHours(); |
| 691 | + this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes(); |
| 692 | + } else if (this.hour===tempMaxTime.getHours() && this.minute>tempMaxTime.getMinutes()) { |
| 693 | + this.minute=this._defaults.minuteMax=tempMaxTime.getMinutes(); |
| 694 | + } else { |
| 695 | + if (this._defaults.hourMax>tempMaxTime.getHours()) { |
| 696 | + this._defaults.hourMax=tempMaxTime.getHours(); |
| 697 | + this._defaults.minuteMax=tempMaxTime.getMinutes(); |
| 698 | + } else if (this._defaults.hourMax===tempMaxTime.getHours()===this.hour && this._defaults.minuteMax>tempMaxTime.getMinutes()) { |
| 699 | + this._defaults.minuteMax=tempMaxTime.getMinutes(); |
| 700 | + } else { |
| 701 | + this._defaults.minuteMax=59; |
| 702 | + } |
| 703 | + } |
| 704 | + } |
| 705 | + |
663 | 706 | if (adjustSliders !== undefined && adjustSliders === true) {
|
664 | 707 | var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
|
665 | 708 | minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
|
668 | 711 | microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
|
669 | 712 |
|
670 | 713 | if (this.hour_slider) {
|
671 |
| - this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax }); |
| 714 | + this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax, step: this._defaults.stepHour }); |
672 | 715 | this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
|
673 | 716 | }
|
674 | 717 | if (this.minute_slider) {
|
675 |
| - this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax }); |
| 718 | + this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax, step: this._defaults.stepMinute }); |
676 | 719 | this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
|
677 | 720 | }
|
678 | 721 | if (this.second_slider) {
|
679 |
| - this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax }); |
| 722 | + this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax, step: this._defaults.stepSecond }); |
680 | 723 | this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
|
681 | 724 | }
|
682 | 725 | if (this.millisec_slider) {
|
683 |
| - this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax }); |
| 726 | + this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax, step: this._defaults.stepMillisec }); |
684 | 727 | this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
|
685 | 728 | }
|
686 | 729 | if (this.microsec_slider) {
|
687 |
| - this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax }); |
| 730 | + this.control.options(this, this.microsec_slider, 'microsec', { min: this._defaults.microsecMin, max: microsecMax, step: this._defaults.stepMicrosec }); |
688 | 731 | this.control.value(this, this.microsec_slider, 'microsec', this.microsec - (this.microsec % this._defaults.stepMicrosec));
|
689 | 732 | }
|
690 | 733 | }
|
|
806 | 849 | this.timeDefined = true;
|
807 | 850 | if (hasChanged) {
|
808 | 851 | this._updateDateTime();
|
809 |
| - this.$input.focus(); |
| 852 | + //this.$input.focus(); // may automatically open the picker on setDate |
810 | 853 | }
|
811 | 854 | },
|
812 | 855 |
|
|
855 | 898 | // return;
|
856 | 899 | //}
|
857 | 900 |
|
858 |
| - if (this._defaults.timeOnly === true) { |
| 901 | + if (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === false) { |
859 | 902 | formattedDateTime = this.formattedTime;
|
860 |
| - } else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) { |
| 903 | + } else if ((this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) || (this._defaults.timeOnly === true && this._defaults.timeOnlyShowDate === true)) { |
861 | 904 | formattedDateTime += this._defaults.separator + this.formattedTime + this._defaults.timeSuffix;
|
862 | 905 | }
|
863 | 906 |
|
|
1342 | 1385 | var inst = this._getInst($(id)[0]),
|
1343 | 1386 | tp_inst = this._get(inst, 'timepicker');
|
1344 | 1387 |
|
1345 |
| - if (tp_inst) { |
| 1388 | + if (tp_inst && inst.settings.showTimepicker) { |
1346 | 1389 | tp_inst._limitMinMaxDateTime(inst, true);
|
1347 | 1390 | inst.inline = inst.stay_open = true;
|
1348 | 1391 | //This way the onSelect handler called from calendarpicker get the full dateTime
|
|
2034 | 2077 | end: {} // options for end picker
|
2035 | 2078 | }, options);
|
2036 | 2079 |
|
| 2080 | + // for the mean time this fixes an issue with calling getDate with timepicker() |
| 2081 | + var timeOnly = false; |
| 2082 | + if(method === 'timepicker'){ |
| 2083 | + timeOnly = true; |
| 2084 | + method = 'datetimepicker'; |
| 2085 | + } |
| 2086 | + |
2037 | 2087 | function checkDates(changed, other) {
|
2038 | 2088 | var startdt = startTime[method]('getDate'),
|
2039 | 2089 | enddt = endTime[method]('getDate'),
|
|
2077 | 2127 | }
|
2078 | 2128 |
|
2079 | 2129 | $.fn[method].call(startTime, $.extend({
|
| 2130 | + timeOnly: timeOnly, |
2080 | 2131 | onClose: function (dateText, inst) {
|
2081 | 2132 | checkDates($(this), endTime);
|
2082 | 2133 | },
|
|
2085 | 2136 | }
|
2086 | 2137 | }, options, options.start));
|
2087 | 2138 | $.fn[method].call(endTime, $.extend({
|
| 2139 | + timeOnly: timeOnly, |
2088 | 2140 | onClose: function (dateText, inst) {
|
2089 | 2141 | checkDates($(this), startTime);
|
2090 | 2142 | },
|
|
2140 | 2192 | /*
|
2141 | 2193 | * Keep up with the version
|
2142 | 2194 | */
|
2143 |
| - $.timepicker.version = "1.4.3"; |
| 2195 | + $.timepicker.version = "1.4.4"; |
2144 | 2196 |
|
2145 | 2197 | })(jQuery);
|
0 commit comments