diff --git a/index.html b/index.html index f151fd5..99a19fe 100644 --- a/index.html +++ b/index.html @@ -35,11 +35,11 @@ .example-container input{ border: solid 1px #aaa; padding: 4px; width: 175px; } - + - - + + @@ -122,7 +122,7 @@

Requirements

Version

-

Version 1.1.1

+

Version 1.1.2

Last updated on 11/07/2012

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.

@@ -361,8 +361,8 @@

Other Options

Default: 'strict' - 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:
{
 	hour: 19,
-	minutes: 10,
-	seconds: 23,
+	minute: 10,
+	second: 23,
 	millisec: 45,
 	timezone: '-0400'
 }
@@ -663,7 +663,9 @@

Slider Modifications

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 diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index b8616da..eb0cb21 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -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 @@ -27,7 +27,7 @@ */ $.extend($.ui, { timepicker: { - version: "1.1.1" + version: "1.1.2" } }); @@ -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; @@ -396,7 +400,7 @@ for(var i=0,l=tp_inst.units.length; i= 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 { @@ -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)); } } @@ -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); @@ -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) }; @@ -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(); +// } } } }; @@ -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); @@ -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); }; /** @@ -1877,6 +1897,6 @@ /* * Keep up with the version */ - $.timepicker.version = "1.1.1"; + $.timepicker.version = "1.1.2"; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/localization/jquery-ui-timepicker-cs.js b/localization/jquery-ui-timepicker-cs.js index 8b31e6b..814dd94 100644 --- a/localization/jquery-ui-timepicker-cs.js +++ b/localization/jquery-ui-timepicker-cs.js @@ -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 diff --git a/localization/jquery-ui-timepicker-eu.js b/localization/jquery-ui-timepicker-eu.js new file mode 100644 index 0000000..7b1c510 --- /dev/null +++ b/localization/jquery-ui-timepicker-eu.js @@ -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); \ No newline at end of file diff --git a/localization/jquery-ui-timepicker-pt-BR.js b/localization/jquery-ui-timepicker-pt-BR.js index 104b353..cd9ee12 100644 --- a/localization/jquery-ui-timepicker-pt-BR.js +++ b/localization/jquery-ui-timepicker-pt-BR.js @@ -2,13 +2,13 @@ /* Written by Diogo Damiani (diogodamiani@gmail.com) */ (function ($) { $.timepicker.regional['pt-BR'] = { - timeOnlyTitle: 'Escolha a horrio', - timeText: 'Horrio', + timeOnlyTitle: 'Escolha a horário', + timeText: 'Horário', hourText: 'Hora', minuteText: 'Minutos', secondText: 'Segundos', millisecText: 'Milissegundos', - timezoneText: 'Fuso horrio', + timezoneText: 'Fuso horário', currentText: 'Agora', closeText: 'Fechar', timeFormat: 'HH:mm', diff --git a/localization/jquery-ui-timepicker-th.js b/localization/jquery-ui-timepicker-th.js new file mode 100644 index 0000000..5d2d561 --- /dev/null +++ b/localization/jquery-ui-timepicker-th.js @@ -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); \ No newline at end of file