|
1 | 1 | /*
|
2 | 2 | * jQuery timepicker addon
|
3 | 3 | * By: Trent Richardson [http://trentrichardson.com]
|
4 |
| - * Version 1.1.2 |
5 |
| - * Last Modified: 01/19/2013 |
| 4 | + * Version 1.2 |
| 5 | + * Last Modified: 02/02/2013 |
6 | 6 | *
|
7 |
| - * Copyright 2012 Trent Richardson |
| 7 | + * Copyright 2013 Trent Richardson |
8 | 8 | * You may use this project under MIT or GPL licenses.
|
9 | 9 | * http://trentrichardson.com/Impromptu/GPL-LICENSE.txt
|
10 | 10 | * http://trentrichardson.com/Impromptu/MIT-LICENSE.txt
|
|
27 | 27 | */
|
28 | 28 | $.extend($.ui, {
|
29 | 29 | timepicker: {
|
30 |
| - version: "1.1.2" |
| 30 | + version: "1.2" |
31 | 31 | }
|
32 | 32 | });
|
33 | 33 |
|
|
37 | 37 | * Settings for (groups of) time pickers are maintained in an instance object,
|
38 | 38 | * allowing multiple different settings on the same page.
|
39 | 39 | */
|
40 |
| - function Timepicker() { |
| 40 | + var Timepicker = function() { |
41 | 41 | this.regional = []; // Available regional settings, indexed by language code
|
42 | 42 | this.regional[''] = { // Default regional settings
|
43 | 43 | currentText: 'Now',
|
|
108 | 108 | parse: 'strict'
|
109 | 109 | };
|
110 | 110 | $.extend(this._defaults, this.regional['']);
|
111 |
| - } |
| 111 | + }; |
112 | 112 |
|
113 | 113 | $.extend(Timepicker.prototype, {
|
114 | 114 | $input: null,
|
|
311 | 311 | }
|
312 | 312 | $.extend(this, parseRes.timeObj);
|
313 | 313 | } catch (err) {
|
314 |
| - $.datepicker.log("Error parsing the date/time string: " + err + |
| 314 | + $.timepicker.log("Error parsing the date/time string: " + err + |
315 | 315 | "\ndate/time string = " + timeString +
|
316 | 316 | "\ntimeFormat = " + this._defaults.timeFormat +
|
317 | 317 | "\ndateFormat = " + dp_dateFormat);
|
|
767 | 767 | timeAvailable = dt !== null && this.timeDefined;
|
768 | 768 | this.formattedDate = $.datepicker.formatDate(dateFmt, (dt === null ? new Date() : dt), formatCfg);
|
769 | 769 | var formattedDateTime = this.formattedDate;
|
| 770 | + |
| 771 | + // if a slider was changed but datepicker doesn't have a value yet, set it |
| 772 | + if(dp_inst.lastVal==""){ |
| 773 | + dp_inst.currentYear=dp_inst.selectedYear; |
| 774 | + dp_inst.currentMonth=dp_inst.selectedMonth; |
| 775 | + dp_inst.currentDay=dp_inst.selectedDay; |
| 776 | + } |
770 | 777 |
|
771 | 778 | /*
|
772 | 779 | * remove following lines to force every changes in date picker to change the input value
|
|
819 | 826 | try {
|
820 | 827 | $.datepicker._updateDatepicker(inst);
|
821 | 828 | } catch (err) {
|
822 |
| - $.datepicker.log(err); |
| 829 | + $.timepicker.log(err); |
823 | 830 | }
|
824 | 831 | }
|
825 | 832 | }
|
|
1156 | 1163 | return strictParse(f,s,o);
|
1157 | 1164 | }
|
1158 | 1165 | catch(err2){
|
1159 |
| - $.datepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f); |
| 1166 | + $.timepicker.log("Unable to parse \ntimeString: "+ s +"\ntimeFormat: "+ f); |
1160 | 1167 | }
|
1161 | 1168 | }
|
1162 | 1169 | return false;
|
|
1366 | 1373 | try {
|
1367 | 1374 | $.datepicker._updateDatepicker(inst);
|
1368 | 1375 | } catch (err) {
|
1369 |
| - $.datepicker.log(err); |
| 1376 | + $.timepicker.log(err); |
1370 | 1377 | }
|
1371 | 1378 | }
|
1372 | 1379 | }
|
|
1532 | 1539 | // the "extra" characters. We rely on that instead of
|
1533 | 1540 | // attempting to perfectly reproduce the parsing algorithm.
|
1534 | 1541 | date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
|
1535 |
| - $.datepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format); |
| 1542 | + $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format); |
1536 | 1543 | }
|
1537 | 1544 | return date;
|
1538 | 1545 | };
|
|
1707 | 1714 | }
|
1708 | 1715 |
|
1709 | 1716 | } catch (err) {
|
1710 |
| - $.datepicker.log('Could not split the date from the time. Please check the following datetimepicker options' + |
| 1717 | + $.timepicker.log('Could not split the date from the time. Please check the following datetimepicker options' + |
1711 | 1718 | "\nthrown error: " + err +
|
1712 | 1719 | "\ndateTimeString" + dateTimeString +
|
1713 | 1720 | "\ndateFormat = " + dateFormat +
|
|
1894 | 1901 | return $([startTime.get(0), endTime.get(0)]);
|
1895 | 1902 | };
|
1896 | 1903 |
|
| 1904 | + /** |
| 1905 | + * Log error or data to the console during error or debugging |
| 1906 | + * @param Object err pass any type object to log to the console during error or debugging |
| 1907 | + * @return void |
| 1908 | + */ |
| 1909 | + $.timepicker.log = function(err){ |
| 1910 | + if(window.console) |
| 1911 | + console.log(err); |
| 1912 | + }; |
| 1913 | + |
1897 | 1914 | /*
|
1898 | 1915 | * Keep up with the version
|
1899 | 1916 | */
|
1900 |
| - $.timepicker.version = "1.1.2"; |
| 1917 | + $.timepicker.version = "1.2"; |
1901 | 1918 |
|
1902 | 1919 | })(jQuery);
|
0 commit comments