Skip to content

Commit af2f050

Browse files
Fix conflict
2 parents 3b76e37 + 34e2ee2 commit af2f050

File tree

9 files changed

+4348
-44
lines changed

9 files changed

+4348
-44
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.iml
2+
.idea

SpecRunner.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>jquery-ui-timepicker-addon Spec Runner</title>
5+
6+
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
7+
8+
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.3.1/jasmine_favicon.png">
9+
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css">
10+
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script>
11+
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script>
12+
<script type="text/javascript" src="http://github.com/searls/jasmine-fixture/releases/1.0.5/1737/jasmine-fixture.js"></script>
13+
14+
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
15+
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
16+
17+
<script type="text/javascript" src="test/jquery-ui-timepicker-addon_spec.js"></script>
18+
19+
<script type="text/javascript">
20+
(function() {
21+
var jasmineEnv = jasmine.getEnv();
22+
jasmineEnv.updateInterval = 1000;
23+
24+
var htmlReporter = new jasmine.HtmlReporter();
25+
26+
jasmineEnv.addReporter(htmlReporter);
27+
28+
jasmineEnv.specFilter = function(spec) {
29+
return htmlReporter.specFilter(spec);
30+
};
31+
32+
var currentWindowOnload = window.onload;
33+
34+
window.onload = function() {
35+
if (currentWindowOnload) {
36+
currentWindowOnload();
37+
}
38+
execJasmine();
39+
};
40+
41+
function execJasmine() {
42+
jasmineEnv.execute();
43+
}
44+
45+
})();
46+
</script>
47+
48+
</head>
49+
<body>
50+
51+
</body>
52+
</html>

jquery-ui-timepicker-addon.js

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@
675675
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)), 10),
676676
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)), 10),
677677
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.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)), 10),
679679
microsecMax = parseInt((this._defaults.microsecMax - ((this._defaults.microsecMax - this._defaults.microsecMin) % this._defaults.stepMicrosec)), 10);
680680

681681
if (this.hour_slider) {
@@ -1028,7 +1028,7 @@
10281028

10291029
$.fn.extend({
10301030
/*
1031-
* shorthand just to use timepicker..
1031+
* shorthand just to use timepicker.
10321032
*/
10331033
timepicker: function(o) {
10341034
o = o || {};
@@ -1320,7 +1320,7 @@
13201320
};
13211321

13221322
/*
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
13241324
// inspired: http://stackoverflow.com/questions/1252512/jquery-datepicker-prevent-closing-picker-when-clicking-a-date/1762378#1762378
13251325
*/
13261326
$.datepicker._base_selectDate = $.datepicker._selectDate;
@@ -1768,7 +1768,7 @@
17681768
var isEmptyObject = function(obj) {
17691769
var prop;
17701770
for (prop in obj) {
1771-
if (obj.hasOwnProperty(obj)) {
1771+
if (obj.hasOwnProperty(prop)) {
17721772
return false;
17731773
}
17741774
}
@@ -1793,9 +1793,9 @@
17931793
* Returns an object of booleans for each unit
17941794
*/
17951795
var detectSupport = function(timeFormat){
1796-
var tf = timeFormat.replace(/\'.*?\'/g,'').toLowerCase(), // removes literals
1796+
var tf = timeFormat.replace(/'.*?'/g,'').toLowerCase(), // removes literals
17971797
isIn = function(f, t){ // does the format contain the token?
1798-
return f.indexOf(t) !== -1? true:false;
1798+
return !!(f.indexOf(t) !== -1);
17991799
};
18001800
return {
18011801
hour: isIn(tf,'h'),
@@ -1804,7 +1804,7 @@
18041804
millisec: isIn(tf,'l'),
18051805
microsec: isIn(tf,'c'),
18061806
timezone: isIn(tf,'z'),
1807-
ampm: isIn(tf,'t') && isIn(timeFormat,'h'),
1807+
ampm: isIn(tf, 't') && isIn(timeFormat,'h'),
18081808
iso8601: isIn(timeFormat, 'Z')
18091809
};
18101810
};
@@ -1814,9 +1814,7 @@
18141814
* Returns 12 hour without leading 0
18151815
*/
18161816
var convert24to12 = function(hour) {
1817-
if (hour > 12) {
1818-
hour = hour - 12;
1819-
}
1817+
hour %= 12;
18201818

18211819
if (hour === 0) {
18221820
hour = 12;
@@ -1826,17 +1824,17 @@
18261824
};
18271825

18281826
/*
1829-
* Splits datetime string into date ans time substrings.
1827+
* Splits datetime string into date and time substrings.
18301828
* Throws exception when date can't be parsed
18311829
* Returns [dateString, timeString]
18321830
*/
18331831
var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) {
18341832
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
18361834
// fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
18371835
var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
18381836
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?
18401838
timePartsLen = timeParts.length,
18411839
allParts = dateTimeString.split(separator),
18421840
allPartsLen = allParts.length;
@@ -1905,21 +1903,21 @@
19051903
*/
19061904
var selectLocalTimezone = function(tp_inst, date) {
19071905
if (tp_inst && tp_inst.timezone_select) {
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());
19101908
}
19111909
};
19121910

19131911
/*
1914-
* Create a Singleton Insance
1912+
* Create a Singleton Instance
19151913
*/
19161914
$.timepicker = new Timepicker();
19171915

19181916
/**
19191917
* 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}
19231921
*/
19241922
$.timepicker.timezoneOffsetString = function(tzMinutes, iso8601) {
19251923
if(isNaN(tzMinutes) || tzMinutes > 840){
@@ -1940,8 +1938,8 @@
19401938

19411939
/**
19421940
* 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}
19451943
*/
19461944
$.timepicker.timezoneOffsetNumber = function(tzString) {
19471945
tzString = tzString.toString().replace(':',''); // excuse any iso8601, end up with "+1245"
@@ -1961,9 +1959,9 @@
19611959

19621960
/**
19631961
* 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}
19671965
*/
19681966
$.timepicker.timezoneAdjust = function(date, toTimezone) {
19691967
var toTz = $.timepicker.timezoneOffsetNumber(toTimezone);
@@ -1977,10 +1975,10 @@
19771975
* Calls `timepicker()` on the `startTime` and `endTime` elements, and configures them to
19781976
* enforce date range limits.
19791977
* 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}
19841982
*/
19851983
$.timepicker.timeRange = function(startTime, endTime, options) {
19861984
return $.timepicker.handleRange('timepicker', startTime, endTime, options);
@@ -1989,12 +1987,12 @@
19891987
/**
19901988
* Calls `datetimepicker` on the `startTime` and `endTime` elements, and configures them to
19911989
* enforce date range limits.
1992-
* @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`,
19951993
* 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}
19981996
*/
19991997
$.timepicker.datetimeRange = function(startTime, endTime, options) {
20001998
$.timepicker.handleRange('datetimepicker', startTime, endTime, options);
@@ -2003,11 +2001,11 @@
20032001
/**
20042002
* Calls `method` on the `startTime` and `endTime` elements, and configures them to
20052003
* 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`,
20092007
* a boolean value that can be used to reformat the input values to the `dateFormat`.
2010-
* @return jQuery
2008+
* @return {jQuery}
20112009
*/
20122010
$.timepicker.dateRange = function(startTime, endTime, options) {
20132011
$.timepicker.handleRange('datepicker', startTime, endTime, options);
@@ -2016,12 +2014,12 @@
20162014
/**
20172015
* Calls `method` on the `startTime` and `endTime` elements, and configures them to
20182016
* 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`,
20232021
* a boolean value that can be used to reformat the input values to the `dateFormat`.
2024-
* @return jQuery
2022+
* @return {jQuery}
20252023
*/
20262024
$.timepicker.handleRange = function(method, startTime, endTime, options) {
20272025
options = $.extend({}, {
@@ -2098,15 +2096,26 @@
20982096

20992097
/**
21002098
* 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}
21032101
*/
21042102
$.timepicker.log = function(err){
21052103
if(window.console){
21062104
console.log(err);
21072105
}
21082106
};
21092107

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+
21102119
/*
21112120
* Microsecond support
21122121
*/

lib/jasmine-1.3.1/MIT.LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2008-2011 Pivotal Labs
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)