|
675 | 675 | var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
|
676 | 676 | minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
|
677 | 677 | secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)), 10),
|
678 |
| - millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10); |
| 678 | + millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.m
8458
illisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10), |
679 | 679 | microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
|
680 | 680 |
|
681 | 681 | if (this.hour_slider) {
|
|
1028 | 1028 |
|
1029 | 1029 | $.fn.extend({
|
1030 | 1030 | /*
|
1031 |
| - * shorthand just to use timepicker.. |
| 1031 | + * shorthand just to use timepicker. |
1032 | 1032 | */
|
1033 | 1033 | timepicker: function(o) {
|
1034 | 1034 | o = o || {};
|
|
1320 | 1320 | };
|
1321 | 1321 |
|
1322 | 1322 | /*
|
1323 |
| - * the bad hack :/ override datepicker so it doesnt close on select |
| 1323 | + * the bad hack :/ override datepicker so it doesn't close on select |
1324 | 1324 | // inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
|
1325 | 1325 | */
|
1326 | 1326 | $.datepicker._base_selectDate = $.datepicker._selectDate;
|
|
1768 | 1768 | var isEmptyObject = function(obj) {
|
1769 | 1769 | var prop;
|
1770 | 1770 | for (prop in obj) {
|
1771 |
| - if (obj.hasOwnProperty(obj)) { |
| 1771 | + if (obj.hasOwnProperty(prop)) { |
1772 | 1772 | return false;
|
1773 | 1773 | }
|
1774 | 1774 | }
|
|
1793 | 1793 | * Returns an object of booleans for each unit
|
1794 | 1794 | */
|
1795 | 1795 | var detectSupport = function(timeFormat){
|
1796 |
| - var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals |
| 1796 | + var tf = timeFormat.replace(/'.*?'/g,'').toLowerCase(), // removes literals |
1797 | 1797 | isIn = function(f, t){ // does the format contain the token?
|
1798 |
| - return f.indexOf(t) !== -1? true:false; |
| 1798 | + return !!(f.indexOf(t) !== -1); |
1799 | 1799 | };
|
1800 | 1800 | return {
|
1801 | 1801 | hour: isIn(tf,'h'),
|
|
1804 | 1804 | millisec: isIn(tf,'l'),
|
1805 | 1805 | microsec: isIn(tf,'c'),
|
1806 | 1806 | timezone: isIn(tf,'z'),
|
1807 |
| - ampm: isIn(tf,'t') && isIn(timeFormat,'h'), |
| 1807 | + ampm: isIn(tf, 't') && isIn(timeFormat,'h'), |
1808 | 1808 | iso8601: isIn(timeFormat, 'Z')
|
1809 | 1809 | };
|
1810 | 1810 | };
|
|
1814 | 1814 | * Returns 12 hour without leading 0
|
1815 | 1815 | */
|
1816 | 1816 | var convert24to12 = function(hour) {
|
1817 |
| - if (hour > 12) { |
1818 |
| - hour = hour - 12; |
1819 |
| - } |
| 1817 | + hour %= 12; |
1820 | 1818 |
|
1821 | 1819 | if (hour === 0) {
|
1822 | 1820 | hour = 12;
|
|
1826 | 1824 | };
|
1827 | 1825 |
|
1828 | 1826 | /*
|
1829 |
| - * Splits datetime string into date ans time substrings. |
| 1827 | + * Splits datetime string into date and time substrings. |
1830 | 1828 | * Throws exception when date can't be parsed
|
1831 | 1829 | * Returns [dateString, timeString]
|
1832 | 1830 | */
|
1833 | 1831 | var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
|
1834 | 1832 | try {
|
1835 |
| - // The idea is to get the number separator occurances in datetime and the time format requested (since time has |
| 1833 | + // The idea is to get the number separator occurrences in datetime and the time format requested (since time has |
1836 | 1834 | // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
|
1837 | 1835 | var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
|
1838 | 1836 | format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
|
1839 |
| - timeParts = format.split(separator), // how many occurances of separator may be in our format? |
| 1837 | + timeParts = format.split(separator), // how many occurrences of separator may be in our format? |
1840 | 1838 | timePartsLen = timeParts.length,
|
1841 | 1839 | allParts = dateTimeString.split(separator),
|
1842 | 1840 | allPartsLen = allParts.length;
|
|
1905 | 1903 | */
|
1906 | 1904 | var selectLocalTimezone = function(tp_inst, date) {
|
1907 | 1905 | if (tp_inst && tp_inst.timezone_select<
FB8A
/span>) {
|
1908 |
| - var now = typeof date !== 'undefined' ? date : new Date(); |
1909 |
| - tp_inst.timezone_select.val(now.getTimezoneOffset()*-1); |
| 1906 | + var now = date || new Date(); |
| 1907 | + tp_inst.timezone_select.val(-now.getTimezoneOffset()); |
1910 | 1908 | }
|
1911 | 1909 | };
|
1912 | 1910 |
|
1913 | 1911 | /*
|
1914 |
| - * Create a Singleton Insance |
| 1912 | + * Create a Singleton Instance |
1915 | 1913 | */
|
1916 | 1914 | $.timepicker = new Timepicker();
|
1917 | 1915 |
|
1918 | 1916 | /**
|
1919 | 1917 | * Get the timezone offset as string from a date object (eg '+0530' for UTC+5.5)
|
1920 |
| - * @param number if not a number this value is returned |
1921 |
| - * @param boolean if true formats in accordance to iso8601 "+12:45" |
1922 |
| - * @return string |
| 1918 | + * @param {number} tzMinutes if not a number this value is returned |
| 1919 | + * @param {boolean} iso8601 if true formats in accordance to iso8601 "+12:45" |
| 1920 | + * @return {string} |
1923 | 1921 | */
|
1924 | 1922 | $.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) {
|
1925 | 1923 | if(isNaN(tzMinutes) || tzMinutes > 840){
|
|
1940 | 1938 |
|
1941 | 1939 | /**
|
1942 | 1940 | * Get the number in minutes that represents a timezone string
|
1943 |
| - * @param string formated like "+0500", "-1245" |
1944 |
| - * @return number |
| 1941 | + * @param {string} tzString formatted like "+0500", "-1245" |
| 1942 | + * @return {number} |
1945 | 1943 | */
|
1946 | 1944 | $.timepicker.timezoneOffsetNumber = function(tzString) {
|
1947 | 1945 | tzString = tzString.toString().replace(':',''); // excuse any iso8601, end up with "+1245"
|
|
1961 | 1959 |
|
1962 | 1960 | /**
|
1963 | 1961 | * No way to set timezone in js Date, so we must adjust the minutes to compensate. (think setDate, getDate)
|
1964 |
| - * @param date |
1965 |
| - * @param string formated like "+0500", "-1245" |
1966 |
| - * @return date |
| 1962 | + * @param {Date} date |
| 1963 | + * @param {string} toTimezone formatted like "+0500", "-1245" |
| 1964 | + * @return {Date} |
1967 | 1965 | */
|
1968 | 1966 | $.timepicker.timezoneAdjust = function(date, toTimezone) {
|
1969 | 1967 | var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
|
|
1977 | 1975 | * Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
|
1978 | 1976 | * enforce date range limits.
|
1979 | 1977 | * n.b. The input value must be correctly formatted (reformatting is not supported)
|
1980 |
| - * @param Element startTime |
1981 |
| - * @param Element endTime |
1982 |
| - * @param obj options Options for the timepicker() call |
1983 |
| - * @return jQuery |
| 1978 | + * @param {Element} startTime |
| 1979 | + * @param {Element} endTime |
| 1980 | + * @param {Object} options Options for the timepicker() call |
| 1981 | + * @return {jQuery} |
1984 | 1982 | */
|
1985 | 1983 | $.timepicker.timeRange = function(startTime, endTime, options) {
|
1986 | 1984 | return $.timepicker.handleRange('timepicker', startTime, endTime, options);
|
|
1989 | 1987 | /**
|
1990 | 1988 | * Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
|
1991 | 1989 | * enforce date range limits.
|
1992 |
| <
7B64
code class="diff-text syntax-highlighted-line deletion">- * @param Element startTime |
1993 |
| - * @param Element endTime |
1994 |
| - * @param obj options Options for the `timepicker()` call. Also supports `reformat`, |
| 1990 | + * @param {Element} startTime |
| 1991 | + * @param {Element} endTime |
| 1992 | + * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`, |
1995 | 1993 | * a boolean value that can be used to reformat the input values to the `dateFormat`.
|
1996 |
| - * @param string method Can be used to specify the type of picker to be added |
1997 |
| - * @return jQuery |
| 1994 | + * @param {string} method Can be used to specify the type of picker to be added |
| 1995 | + * @return {jQuery} |
1998 | 1996 | */
|
1999 | 1997 | $.timepicker.datetimeRange = function(startTime, endTime, options) {
|
2000 | 1998 | $.timepicker.handleRange('datetimepicker', startTime, endTime, options);
|
|
2003 | 2001 | /**
|
2004 | 2002 | * Calls `method` on the `startTime` and `endTime` elements, and configures them to
|
2005 | 2003 | * enforce date range limits.
|
2006 |
| - * @param Element startTime |
2007 |
| - * @param Element endTime |
2008 |
| - * @param obj options Options for the `timepicker()` call. Also supports `reformat`, |
| 2004 | + * @param {Element} startTime |
| 2005 | + * @param {Element} endTime |
| 2006 | + * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`, |
2009 | 2007 | * a boolean value that can be used to reformat the input values to the `dateFormat`.
|
2010 |
| - * @return jQuery |
| 2008 | + * @return {jQuery} |
2011 | 2009 | */
|
2012 | 2010 | $.timepicker.dateRange = function(startTime, endTime, options) {
|
2013 | 2011 | $.timepicker.handleRange('datepicker', startTime, endTime, options);
|
|
2016 | 2014 | /**
|
2017 | 2015 | * Calls `method` on the `startTime` and `endTime` elements, and configures them to
|
2018 | 2016 | * enforce date range limits.
|
2019 |
| - * @param string method Can be used to specify the type of picker to be added |
2020 |
| - * @param Element startTime |
2021 |
| - * @param Element endTime |
2022 |
| - * @param obj options Options for the `timepicker()` call. Also supports `reformat`, |
| 2017 | + * @param {string} method Can be used to specify the type of picker to be added |
| 2018 | + * @param {Element} startTime |
| 2019 | + * @param {Element} endTime |
| 2020 | + * @param {Object} options Options for the `timepicker()` call. Also supports `reformat`, |
2023 | 2021 | * a boolean value that can be used to reformat the input values to the `dateFormat`.
|
2024 |
| - * @return jQuery |
| 2022 | + * @return {jQuery} |
2025 | 2023 | */
|
2026 | 2024 | $.timepicker.handleRange = function(method, startTime, endTime, options) {
|
2027 | 2025 | options = $.extend({}, {
|
|
2098 | 2096 |
|
2099 | 2097 | /**
|
2100 | 2098 | * Log error or data to the console during error or debugging
|
2101 |
| - * @param Object err pass any type object to log to the console during error or debugging |
2102 |
| - * @return void |
| 2099 | + * @param {Object} err pass any type object to log to the console during error or debugging |
| 2100 | + * @return {void} |
2103 | 2101 | */
|
2104 | 2102 | $.timepicker.log = function(err){
|
2105 | 2103 | if(window.console){
|
2106 | 2104 | console.log(err);
|
2107 | 2105 | }
|
2108 | 2106 | };
|
2109 | 2107 |
|
| 2108 | + /* |
| 2109 | + * Add util object to allow access to private methods for testability. |
| 2110 | + */ |
| 2111 | + $.timepicker._util = { |
| 2112 | + _extendRemove: extendRemove, |
| 2113 | + _isEmptyObject: isEmptyObject, |
| 2114 | + _convert24to12: convert24to12, |
| 2115 | + _detectSupport: detectSupport, |
| 2116 | + _selectLocalTimezone: selectLocalTimezone |
| 2117 | + }; |
| 2118 | + |
2110 | 2119 | /*
|
2111 | 2120 | * Microsecond support
|
2112 | 2121 | */
|
|
0 commit comments