Skip to content

Patch for issue #471 #534

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
285650a
New dev version
trentrichardson Nov 7, 2012
63bd242
Raykov - date range and alternate fields
trentrichardson Nov 15, 2012
76285d2
Timezone change now fires onSelect
trentrichardson Nov 15, 2012
8ad3f66
Switch substr to slice as IE8 doesn't do negative substr properly
LawrenceOptify Nov 27, 2012
3d664da
Merge pull request #511 from LawrenceLeung/dev
trentrichardson Nov 27, 2012
7318a3d
Update jQuery and jQuery UI
trentrichardson Dec 4, 2012
b449d81
Fix spinner event in example
trentrichardson Dec 7, 2012
1ba5387
Fix spinner event in example
trentrichardson Dec 7, 2012
bdff862
Portuguese update by dufernandes
trentrichardson Dec 19, 2012
26765c3
Update Czech localization by bohumirslama
trentrichardson Dec 19, 2012
07e7f06
Thai localization by figgaro
trentrichardson Jan 1, 2013
2c8cf8f
Fix encoding of pt-BR
trentrichardson Jan 1, 2013
016efa6
scambra- fix setting time in cooperation with step settings
trentrichardson Jan 2, 2013
6741308
Fixes bug hourMin/Max defaults the input before setting a time
trentrichardson Jan 7, 2013
1b9f726
Fixes bug hourMin/Max defaults the input before setting a time
trentrichardson Jan 7, 2013
4beef27
Fix conditions for maxDate detection
trentrichardson Jan 9, 2013
6f22271
Fix parsing for single digits
trentrichardson Jan 11, 2013
3fd0508
Improve parsing flexibility
trentrichardson Jan 11, 2013
113812e
Update loose parse to use ISO
trentrichardson Jan 14, 2013
e3f8fc3
Update loose parse to try multiple formats
trentrichardson Jan 14, 2013
8f9a660
Rollback doc changes
trentrichardson Jan 14, 2013
c94e202
Basque localization by n3k0rA
trentrichardson Jan 15, 2013
13ab774
Fixes #471
magnetik Jan 17, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
.example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; }
</style>

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

<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
<script type="text/javascript">
Expand Down Expand Up @@ -122,7 +122,7 @@ <h3>Requirements</h3>


<h3>Version</h3>
<p>Version 1.1.1</p>
<p>Version 1.1.2</p>

<p>Last updated on 11/07/2012</p>
<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>
Expand Down Expand Up @@ -361,8 +361,8 @@ <h3>Other Options</h3>
<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:
<pre>{
hour: 19,
minutes: 10,
seconds: 23,
minute: 10,
second: 23,
millisec: 45,
timezone: '-0400'
}</pre>
Expand Down Expand Up @@ -663,7 +663,9 @@ <h3 id="slider_examples">Slider Modifications</h3>
max: max,
step: step,
change: function(e,ui){ // key events
tp_inst._onTimeChange();
// don't call if api was used and not key press
if(e.originalEvent !== undefined)
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
},
spin: function(e,ui){ // spin events
Expand Down
84 changes: 52 additions & 32 deletions jquery-ui-timepicker-addon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
* Version 1.1.1
* Version 1.1.2-dev
* Last Modified: 11/07/2012
*
* Copyright 2012 Trent Richardson
Expand All @@ -27,7 +27,7 @@
*/
$.extend($.ui, {
timepicker: {
version: "1.1.1"
version: "1.1.2"
}
});

Expand Down Expand Up @@ -237,10 +237,14 @@
}

tp_inst.timezone = tp_inst._defaults.timezone;
tp_inst.hour = tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second;
tp_inst.millisec = tp_inst._defaults.millisec;
tp_inst.hour = tp_inst._defaults.hour < tp_inst._defaults.hourMin? tp_inst._defaults.hourMin :
tp_inst._defaults.hour > tp_inst._defaults.hourMax? tp_inst._defaults.hourMax : tp_inst._defaults.hour;
tp_inst.minute = tp_inst._defaults.minute < tp_inst._defaults.minuteMin? tp_inst._defaults.minuteMin :
tp_inst._defaults.minute > tp_inst._defaults.minuteMax? tp_inst._defaults.minuteMax : tp_inst._defaults.minute;
tp_inst.second = tp_inst._defaults.second < tp_inst._defaults.secondMin? tp_inst._defaults.secondMin :
tp_inst._defaults.second > tp_inst._defaults.secondMax? tp_inst._defaults.secondMax : tp_inst._defaults.second;
tp_inst.millisec = tp_inst._defaults.millisec < tp_inst._defaults.millisecMin? tp_inst._defaults.millisecMin :
tp_inst._defaults.millisec > tp_inst._defaults.millisecMax? tp_inst._defaults.millisecMax : tp_inst._defaults.millisec;
tp_inst.ampm = '';
tp_inst.$input = $input;

Expand Down Expand Up @@ -396,7 +400,7 @@
for(var i=0,l=tp_inst.units.length; i<l; i++){
litem = tp_inst.units[i];
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);

// add the slider
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]);

Expand Down Expand Up @@ -464,6 +468,7 @@
this.timezone_select.change(function() {
tp_inst._defaults.useLocalTimezone = false;
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
});
// End timezone options

Expand Down Expand Up @@ -591,13 +596,17 @@
if (this.minute >= this._defaults.minuteMax) {
this.minute = this._defaults.minuteMax;
this._defaults.secondMax = maxDateTime.getSeconds();
} else if (this.second >= this._defaults.secondMax) {
this.second = this._defaults.secondMax;
this._defaults.millisecMax = maxDateTime.getMilliseconds();
} else {
if (this.millisec > this._defaults.millisecMax) {
this.millisec = this._defaults.millisecMax;
if (this.second >= this._defaults.secondMax) {
this.second = this._defaults.secondMax;
this._defaults.millisecMax = maxDateTime.getMilliseconds();
} else {
if (this.millisec > this._defaults.millisecMax) {
this.millisec = this._defaults.millisecMax;
}
this._defaults.millisecMax = this.millisecMaxOriginal;
}
} else {
this._defaults.secondMax = this.secondMaxOriginal;
this._defaults.millisecMax = this.millisecMaxOriginal;
}
} else {
Expand All @@ -621,19 +630,19 @@

if (this.hour_slider) {
this.control.options(this, this.hour_slider, 'hour', { min: this._defaults.hourMin, max: hourMax });
this.control.value(this, this.hour_slider, 'hour', this.hour);
this.control.value(this, this.hour_slider, 'hour', this.hour - (this.hour % this._defaults.stepHour));
}
if (this.minute_slider) {
this.control.options(this, this.minute_slider, 'minute', { min: this._defaults.minuteMin, max: minMax });
this.control.value(this, this.minute_slider, 'minute', this.minute);
this.control.value(this, this.minute_slider, 'minute', this.minute - (this.minute % this._defaults.stepMinute));
}
if (this.second_slider) {
this.control.options(this, this.second_slider, 'second', { min: this._defaults.secondMin, max: secMax });
this.control.value(this, this.second_slider, 'second', this.second);
this.control.value(this, this.second_slider, 'second', this.second - (this.second % this._defaults.stepSecond));
}
if (this.millisec_slider) {
this.control.options(this, this.millisec_slider, 'millisec', { min: this._defaults.millisecMin, max: millisecMax });
this.control.value(this, this.millisec_slider, 'millisec', this.millisec);
this.control.value(this, this.millisec_slider, 'millisec', this.millisec - (this.millisec % this._defaults.stepMillisec));
}
}

Expand Down Expand Up @@ -1028,10 +1037,11 @@

var regstr = '^' + f.toString()
.replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) {
var ml = match.length;
switch (match.charAt(0).toLowerCase()) {
case 'h': return '(\\d?\\d)';
case 'm': return '(\\d?\\d)';
case 's': return '(\\d?\\d)';
case 'h': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
case 'm': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
case 's': return ml === 1? '(\\d?\\d)':'(\\d{'+ml+'})';
case 'l': return '(\\d?\\d?\\d)';
case 'z': return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
case 't': return getPatternAmpm(o.amNames, o.pmNames);
Expand Down Expand Up @@ -1123,10 +1133,20 @@
var looseParse = function(f,s,o){
try{
var d = new Date('2012-01-01 '+ s);
if(isNaN(d.getTime())){
d = new Date('2012-01-01T'+ s);
if(isNaN(d.getTime())){
d = new Date('01/01/2012 '+ s);
if(isNaN(d.getTime())){
throw "Unable to parse time with native Date: "+ s;
}
}
}

return {
hour: d.getHours(),
minutes: d.getMinutes(),
seconds: d.getSeconds(),
minute: d.getMinutes(),
second: d.getSeconds(),
millisec: d.getMilliseconds(),
timezone: $.timepicker.timeZoneOffsetString(d)
};
Expand Down Expand Up @@ -1259,11 +1279,11 @@
if (tp_inst) {
tp_inst._addTimePicker(inst);

if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
selectLocalTimeZone(tp_inst, date);
tp_inst._onTimeChange();
}
// if (tp_inst._defaults.useLocalTimezone) { //checks daylight saving with the new date.
// var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
// selectLocalTimeZone(tp_inst, date);
// tp_inst._onTimeChange();
// }
}
}
};
Expand Down Expand Up @@ -1320,9 +1340,9 @@
altTimeFormat = tp_inst._defaults.altTimeFormat !== null ? tp_inst._defaults.altTimeFormat : tp_inst._defaults.timeFormat;

altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly){
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
if(tp_inst._defaults.altFormat)
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, (date === null ? new Date() : date), formatCfg) + altSeparator + altFormattedDateTime;
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
}
$(altField).val(altFormattedDateTime);
Expand Down Expand Up @@ -1767,7 +1787,7 @@
var off = date.getTimezoneOffset() * -1,
minutes = off % 60,
hours = (off - minutes) / 60;
return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).substr(-2) + ('0' + (minutes * 101).toString()).substr(-2);
return (off >= 0 ? '+' : '-') + ('0' + (hours * 101).toString()).slice(-2) + ('0' + (minutes * 101).toString()).slice(-2);
};

/**
Expand Down Expand Up @@ -1877,6 +1897,6 @@
/*
* Keep up with the version
*/
$.timepicker.version = "1.1.1";
$.timepicker.version = "1.1.2";

})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion localization/jquery-ui-timepicker-cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
timezoneText: 'Časové pásmo',
currentText: 'Nyní',
closeText: 'Zavřít',
timeFormat: 'H:m',
timeFormat: 'HH:mm',
amNames: ['dop.', 'AM', 'A'],
pmNames: ['odp.', 'PM', 'P'],
isRTL: false
Expand Down
20 changes: 20 additions & 0 deletions localization/jquery-ui-timepicker-eu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Basque trannslation for JQuery Timepicker Addon
/* Translated by Xabi Fer */
(function($) {
$.timepicker.regional['eu'] = {
timeOnlyTitle: 'Aukeratu ordua',
timeText: 'Ordua',
hourText: 'Orduak',
minuteText: 'Minutuak',
secondText: 'Segunduak',
millisecText: 'Milisegunduak',
timezoneText: 'Ordu-eremua',
currentText: 'Orain',
closeText: 'Itxi',
timeFormat: 'HH:mm',
amNames: ['a.m.', 'AM', 'A'],
pmNames: ['p.m.', 'PM', 'P'],
isRTL: false
};
$.timepicker.setDefaults($.timepicker.regional['eu']);
})(jQuery);
6 changes: 3 additions & 3 deletions localization/jquery-ui-timepicker-pt-BR.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
/* Written by Diogo Damiani (diogodamiani@gmail.com) */
(function ($) {
$.timepicker.regional['pt-BR'] = {
timeOnlyTitle: 'Escolha a horário',
timeText: 'Horário',
timeOnlyTitle: 'Escolha a horário',
timeText: 'Horário',
hourText: 'Hora',
minuteText: 'Minutos',
secondText: 'Segundos',
millisecText: 'Milissegundos',
timezoneText: 'Fuso horário',
timezoneText: 'Fuso horário',
currentText: 'Agora',
closeText: 'Fechar',
timeFormat: 'HH:mm',
Expand Down
17 changes: 17 additions & 0 deletions localization/jquery-ui-timepicker-th.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Thai translation for the jQuery Timepicker Addon */
/* Written by Yote Wachirapornpongsa */
(function($) {
$.timepicker.regional['th'] = {
timeOnlyTitle: 'เลือกเวลา',
timeText: 'เวลา ',
hourText: 'ชั่วโมง ',
minuteText: 'นาที',
secondText: 'วินาที',
millisecText: 'มิลลิวินาที',
timezoneText: 'เขตเวลา',
currentText: 'เวลาปัจจุบัน',
closeText: 'ปิด',
timeFormat: 'hh:mm tt'
};
$.timepicker.setDefaults($.timepicker.regional['th']);
})(jQuery);