Skip to content

Commit a9ba30d

Browse files
Merge branch 'dev'
2 parents d9e9d7c + 8041ecb commit a9ba30d

6 files changed

+104
-48
lines changed

index.html

+10-11
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@
3535
.example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; }
3636
</style>
3737

38-
<link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css" />
38+
<link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.0/themes/smoothness/jquery-ui.css" />
3939
<link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
4040

41-
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
42-
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
41+
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
42+
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.min.js"></script>
4343
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
4444
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
4545
<script type="text/javascript">
@@ -122,11 +122,9 @@ <h3>Requirements</h3>
122122

123123

124124
<h3>Version</h3>
125-
<p>Version 1.1.1</p>
126-
127-
128-
<p>Last updated on 11/07/2012</p>
125+
<p>Version 1.1.2</p>
129126

127+
<p>Last updated on 01/19/2013</p>
130128
<p>jQuery Timepicker Addon is currently available for use in all personal or commercial projects under both MIT and GPL licenses. This means that you can choose the license that best suits your project, and use it accordingly. </p>
131129
<p><a href="http://trentrichardson.com/Impromptu/GPL-LICENSE.txt" title="GPL License">GPL License</a></p>
132130
<p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>
@@ -363,8 +361,8 @@ <h3>Other Options</h3>
363361
<dd><em>Default: 'strict'</em> - How to parse the time string. Two methods are provided: 'strict' which must match the timeFormat exactly, and 'loose' which uses javascript's new Date(timeString) to guess the time. You may also pass in a function(timeFormat, timeString, options) to handle the parsing yourself, returning a simple object:
364362
<pre>{
365363
hour: 19,
366-
minutes: 10,
367-
seconds: 23,
364+
minute: 10,
365+
second: 23,
368366
millisec: 45,
369367
timezone: '-0400'
370368
}</pre>
@@ -665,7 +663,9 @@ <h3 id="slider_examples">Slider Modifications</h3>
665663
max: max,
666664
step: step,
667665
change: function(e,ui){ // key events
668-
tp_inst._onTimeChange();
666+
// don't call if api was used and not key press
667+
if(e.originalEvent !== undefined)
668+
tp_inst._onTimeChange();
669669
tp_inst._onSelectHandler();
670670
},
671671
spin: function(e,ui){ // spin events
@@ -733,7 +733,6 @@ <h3 id="alt_examples">Alternate Fields</h3>
733733
</div>
734734
<pre>
735735
$('#alt_example_3').datetimepicker({
736-
ampm: true,
737736
altField: "#alt_example_3_alt",
738737
altFieldTimeOnly: false,
739738
altFormat: "yy-mm-dd",

jquery-ui-timepicker-addon.js

+53-33
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* jQuery timepicker addon
33
* By: Trent Richardson [http://trentrichardson.com]
4-
* Version 1.1.1
5-
* Last Modified: 11/07/2012
4+
* Version 1.1.2
5+
* Last Modified: 01/19/2013
66
*
77
* Copyright 2012 Trent Richardson
88
* You may use this project under MIT or GPL licenses.
@@ -27,7 +27,7 @@
2727
*/
2828
$.extend($.ui, {
2929
timepicker: {
30-
version: "1.1.1"
30+
version: "1.1.2"
3131
}
3232
});
3333

@@ -237,10 +237,14 @@
237237
}
238238

239239
tp_inst.timezone = tp_inst._defaults.timezone;
240-
tp_inst.hour = tp_inst._defaults.hour;
241-
tp_inst.minute = tp_inst._defaults.minute;
242-
tp_inst.second = tp_inst._defaults.second;
243-
tp_inst.millisec = tp_inst._defaults.millisec;
240+
tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
241+
tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
242+
tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
243+
tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
244+
tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
245+
tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
246+
tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
247+
tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
244248
tp_inst.ampm = '';
245249
tp_inst.$input = $input;
246250

@@ -396,7 +400,7 @@
396400
for(var i=0,l=tp_inst.units.length; i<l; i++){
397401
litem = tp_inst.units[i];
398402
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
399-
403+
400404
// add the slider
401405
tp_inst[litem+'_slider'] = tp_inst.control.create(tp_inst, $tp.find('.ui_tpicker_'+litem+'_slider'), litem, tp_inst[litem], o[litem+'Min'], max[litem], o['step'+uitem]);
402406

@@ -464,6 +468,7 @@
464468
this.timezone_select.change(function() {
465469
tp_inst._defaults.useLocalTimezone = false;
466470
tp_inst._onTimeChange();
471+
tp_inst._onSelectHandler();
467472
});
468473
// End timezone options
469474

@@ -591,13 +596,17 @@
591596
if (this.minute >= this._defaults.minuteMax) {
592597
this.minute = this._defaults.minuteMax;
593598
this._defaults.secondMax = maxDateTime.getSeconds();
594-
} else if (this.second >= this._defaults.secondMax) {
595-
this.second = this._defaults.secondMax;
596-
this._defaults.millisecMax = maxDateTime.getMilliseconds();
597-
} else {
598-
if (this.millisec > this._defaults.millisecMax) {
599-
this.millisec = this._defaults.millisecMax;
599+
if (this.second >= this._defaults.secondMax) {
600+
this.second = this._defaults.secondMax;
601+
this._defaults.millisecMax = maxDateTime.getMilliseconds();
602+
} else {
603+
if (this.millisec > this._defaults.millisecMax) {
604+
this.millisec = this._defaults.millisecMax;
605+
}
606+
this._defaults.millisecMax = this.millisecMaxOriginal;
600607
}
608+
} else {
609+
this._defaults.secondMax = this.secondMaxOriginal;
601610
this._defaults.millisecMax = this.millisecMaxOriginal;
602611
}
603612
} else {
@@ -621,19 +630,19 @@
621630

622631
if (this.hour_slider) {
623632
this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
624-
this.control.value(this, this.hour_slider, 'hour', this.hour);
633+
this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
625634
}
626635
if (this.minute_slider) {
627636
this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
628-
this.control.value(this, this.minute_slider, 'minute', this.minute);
637+
this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
629638
}
630639
if (this.second_slider) {
631640
this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
632-
this.control.value(this, this.second_slider, 'second', this.second);
641+
this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
633642
}
634643
if (this.millisec_slider) {
635644
this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
636-
this.control.value(this, this.millisec_slider, 'millisec', this.millisec);
645+
this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
637646
}
638647
}
639648

@@ -1028,10 +1037,11 @@
10281037

10291038
var regstr = '^' + f.toString()
10301039
.replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) {
1040+
var ml = match.length;
10311041
switch (match.charAt(0).toLowerCase()) {
1032-
case 'h': return '(\\d?\\d)';
1033-
case 'm': return '(\\d?\\d)';
1034-
case 's': return '(\\d?\\d)';
1042+
case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
1043+
case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
1044+
case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
10351045
case 'l': return '(\\d?\\d?\\d)';
10361046
case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
10371047
case 't': return getPatternAmpm(o.amNames, o.pmNames);
@@ -1123,10 +1133,20 @@
11231133
var looseParse = function(f,s,o){
11241134
try{
11251135
var d = new Date('2012-01-01 '+ s);
1136+
if(isNaN(d.getTime())){
1137+
d = new Date('2012-01-01T'+ s);
1138+
if(isNaN(d.getTime())){
1139+
d = new Date('01/01/2012 '+ s);
1140+
if(isNaN(d.getTime())){
1141+
throw "Unable to parse time with native Date: "+ s;
1142+
}
1143+
}
1144+
}
1145+
11261146
return {
11271147
hour: d.getHours(),
1128-
minutes: d.getMinutes(),
1129-
seconds: d.getSeconds(),
1148+
minute: d.getMinutes(),
1149+
second: d.getSeconds(),
11301150
millisec: d.getMilliseconds(),
11311151
timezone: $.timepicker.timeZoneOffsetString(d)
11321152
};
@@ -1259,11 +1279,11 @@
12591279
if (tp_inst) {
12601280
tp_inst._addTimePicker(inst);
12611281

1262-
if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
1263-
var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
1264-
selectLocalTimeZone(tp_inst, date);
1265-
tp_inst._onTimeChange();
1266-
}
1282+
// if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
1283+
// var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
1284+
// selectLocalTimeZone(tp_inst, date);
1285+
// tp_inst._onTimeChange();
1286+
// }
12671287
}
12681288
}
12691289
};
@@ -1320,9 +1340,9 @@
13201340
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;
13211341

13221342
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
1323-
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly){
1343+
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
13241344
if(tp_inst._defaults.altFormat)
1325-
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, (date === null ? new Date() : date), formatCfg) + altSeparator + altFormattedDateTime;
1345+
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
13261346
else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
13271347
}
13281348
$(altField).val(altFormattedDateTime);
@@ -1767,7 +1787,7 @@
17671787
var off = date.getTimezoneOffset() * -1,
17681788
minutes = off % 60,
17691789
hours = (off - minutes) / 60;
1770-
return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).substr(-2) + ('0' + (minutes * 101).toString()).substr(-2);
1790+
return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + ('0' + (minutes * 101).toString()).slice(-2);
17711791
};
17721792

17731793
/**
@@ -1877,6 +1897,6 @@
18771897
/*
18781898
* Keep up with the version
18791899
*/
1880-
$.timepicker.version = "1.1.1";
1900+
$.timepicker.version = "1.1.2";
18811901

1882-
})(jQuery);
1902+
})(jQuery);

localization/jquery-ui-timepicker-cs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
timezoneText: 'Časové pásmo',
1212
currentText: 'Nyní',
1313
closeText: 'Zavřít',
14-
timeFormat: 'H:m',
14+
timeFormat: 'HH:mm',
1515
amNames: ['dop.', 'AM', 'A'],
1616
pmNames: ['odp.', 'PM', 'P'],
1717
isRTL: false
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* Basque trannslation for JQuery Timepicker Addon
2+
/* Translated by Xabi Fer */
3+
(function($) {
4+
$.timepicker.regional['eu'] = {
5+
timeOnlyTitle: 'Aukeratu ordua',
6+
timeText: 'Ordua',
7+
hourText: 'Orduak',
8+
minuteText: 'Minutuak',
9+
secondText: 'Segunduak',
10+
millisecText: 'Milisegunduak',
11+
timezoneText: 'Ordu-eremua',
12+
currentText: 'Orain',
13+
closeText: 'Itxi',
14+
timeFormat: 'HH:mm',
15+
amNames: ['a.m.', 'AM', 'A'],
16+
pmNames: ['p.m.', 'PM', 'P'],
17+
isRTL: false
18+
};
19+
$.timepicker.setDefaults($.timepicker.regional['eu']);
20+
})(jQuery);

localization/jquery-ui-timepicker-pt-BR.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
/* Written by Diogo Damiani (diogodamiani@gmail.com) */
33
(function ($) {
44
$.timepicker.regional['pt-BR'] = {
5-
timeOnlyTitle: 'Escolha a horário',
6-
timeText: 'Horário',
5+
timeOnlyTitle: 'Escolha a horário',
6+
timeText: 'Horário',
77
hourText: 'Hora',
88
minuteText: 'Minutos',
99
secondText: 'Segundos',
1010
millisecText: 'Milissegundos',
11-
timezoneText: 'Fuso horário',
11+
timezoneText: 'Fuso horário',
1212
currentText: 'Agora',
1313
closeText: 'Fechar',
1414
timeFormat: 'HH:mm',
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* Thai translation for the jQuery Timepicker Addon */
2+
/* Written by Yote Wachirapornpongsa */
3+
(function($) {
4+
$.timepicker.regional['th'] = {
5+
timeOnlyTitle: 'เลือกเวลา',
6+
timeText: 'เวลา ',
7+
hourText: 'ชั่วโมง ',
8+
minuteText: 'นาที',
9+
secondText: 'วินาที',
10+
millisecText: 'มิลลิวินาที',
11+
timezoneText: 'เขตเวลา',
12+
currentText: 'เวลาปัจจุบัน',
13+
closeText: 'ปิด',
14+
timeFormat: 'hh:mm tt'
15+
};
16+
$.timepicker.setDefaults($.timepicker.regional['th']);
17+
})(jQuery);

0 commit comments

Comments
 (0)