summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--component.json2
-rw-r--r--index.html10
-rw-r--r--jquery-ui-timepicker-addon.js106
-rw-r--r--localization/jquery-ui-timepicker-hr.js20
-rw-r--r--localization/jquery-ui-timepicker-pt-BR.js2
5 files changed, 95 insertions, 45 deletions
diff --git a/component.json b/component.json
index 7e1fc6a..019712a 100644
--- a/component.json
+++ b/component.json
@@ -1,6 +1,6 @@
{
"name": "jquery-timepicker-addon",
- "version": "1.2",
+ "version": "1.2.1",
"repository": {
"type": "git",
"url": "git://github.com/trentrichardson/jQuery-Timepicker-Addon.git"
diff --git a/index.html b/index.html
index 2993db8..19a7423 100644
--- a/index.html
+++ b/index.html
@@ -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.10.0/themes/smoothness/jquery-ui.css" />
+ <link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.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.9.0.min.js"></script>
- <script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.min.js"></script>
+ <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
+ <script type="text/javascript" src="http://code.jquery.com/ui/1.10.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">
@@ -122,9 +122,9 @@
<h3>Version</h3>
- <p>Version 1.2</p>
+ <p>Version 1.2.1</p>
- <p>Last updated on 02/02/2013</p>
+ <p>Last updated on 04/06/2013</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>
<p><a href="http://trentrichardson.com/Impromptu/GPL-LICENSE.txt" title="GPL License">GPL License</a></p>
<p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index f9b5faa..863e375 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -1,8 +1,8 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
- * Version 1.2
- * Last Modified: 02/02/2013
+ * Version 1.2.1
+ * Last Modified: 04/06/2013
*
* Copyright 2013 Trent Richardson
* You may use this project under MIT or GPL licenses.
@@ -27,7 +27,7 @@
*/
$.extend($.ui, {
timepicker: {
- version: "1.2"
+ version: "1.2.1"
}
});
@@ -339,7 +339,9 @@
uitem = '',
max = {},
gridSize = {},
- size = null;
+ size = null,
+ i=0,
+ l=0;
// Prevent displaying twice
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
@@ -348,7 +350,7 @@
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
// Create the markup
- for(var i=0,l=this.units.length; i<l; i++){
+ for(i=0,l=this.units.length; i<l; i++){
litem = this.units[i];
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
// Added by Peter Medeiros:
@@ -397,7 +399,7 @@
}
// add sliders, adjust grids, add events
- for(var i=0,l=tp_inst.units.length; i<l; i++){
+ for(i=0,l=tp_inst.units.length; i<l; i++){
litem = tp_inst.units[i];
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
@@ -434,8 +436,7 @@
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
- })
- .css({
+ }).css({
cursor: 'pointer',
width: (100 / gridSize[litem]) + '%',
textAlign: 'center',
@@ -769,7 +770,7 @@
var formattedDateTime = this.formattedDate;
// if a slider was changed but datepicker doesn't have a value yet, set it
- if(dp_inst.lastVal==""){
+ if(dp_inst.lastVal===""){
dp_inst.currentYear=dp_inst.selectedYear;
dp_inst.currentMonth=dp_inst.selectedMonth;
dp_inst.currentDay=dp_inst.selectedDay;
@@ -803,11 +804,23 @@
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
- if (this._defaults.altFormat) altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
- else altFormattedDateTime = this.formattedDate;
- if (altFormattedDateTime) altFormattedDateTime += altSeparator;
- if (this._defaults.altTimeFormat) altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
- else altFormattedDateTime += this.formattedTime + altTimeSuffix;
+ if (this._defaults.altFormat){
+ altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
+ }
+ else{
+ altFormattedDateTime = this.formattedDate;
+ }
+
+ if (altFormattedDateTime){
+ altFormattedDateTime += altSeparator;
+ }
+
+ if(this._defaults.altTimeFormat){
+ altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
+ }
+ else{
+ altFormattedDateTime += this.formattedTime + altTimeSuffix;
+ }
this.$altInput.val(altFormattedDateTime);
} else {
this.$input.val(formattedDateTime);
@@ -861,8 +874,9 @@
if(tp_inst._defaults.isRTL){
if(typeof(opts) == 'string'){
if(opts == 'min' || opts == 'max'){
- if(val !== undefined)
+ if(val !== undefined){
return obj.slider(opts, val*-1);
+ }
return Math.abs(obj.slider(opts));
}
return obj.slider(opts);
@@ -870,24 +884,29 @@
var min = opts.min,
max = opts.max;
opts.min = opts.max = null;
- if(min !== undefined)
+ if(min !== undefined){
opts.max = min * -1;
- if(max !== undefined)
+ }
+ if(max !== undefined){
opts.min = max * -1;
+ }
return obj.slider(opts);
}
- if(typeof(opts) == 'string' && val !== undefined)
+ if(typeof(opts) == 'string' && val !== undefined){
return obj.slider(opts, val);
+ }
return obj.slider(opts);
},
value: function(tp_inst, obj, unit, val){
if(tp_inst._defaults.isRTL){
- if(val !== undefined)
+ if(val !== undefined){
return obj.slider('value', val*-1);
+ }
return Math.abs(obj.slider('value'));
}
- if(val !== undefined)
+ if(val !== undefined){
return obj.slider('value', val);
+ }
return obj.slider('value');
}
},
@@ -895,15 +914,15 @@
select: {
create: function(tp_inst, obj, unit, val, min, max, step){
var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
- ul = tp_inst._defaults.timeFormat.indexOf('t') !== -1? 'toLowerCase':'toUpperCase',
- m = 0;
+ format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
for(var i=min; i<=max; i+=step){
sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
- if(unit == 'hour' && useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat))
- sel += $.datepicker.formatTime("hh TT", {hour:i}, tp_inst._defaults);
- else if(unit == 'millisec' || i >= 10) sel += i;
- else sel += '0'+ i.toString();
+ if(unit == 'hour'){
+ sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
+ }
+ else if(unit == 'millisec' || i >= 10){ sel += i; }
+ else {sel += '0'+ i.toString(); }
sel += '</option>';
}
sel += '</select>';
@@ -921,17 +940,19 @@
var o = {},
$t = obj.children('select');
if(typeof(opts) == 'string'){
- if(val === undefined)
+ if(val === undefined){
return $t.data(opts);
+ }
o[opts] = val;
}
- else o = opts;
+ else{ o = opts; }
return tp_inst.control.create(tp_inst, obj, $t.data('unit'), $t.val(), o.min || $t.data('min'), o.max || $t.data('max'), o.step || $t.data('step'));
},
value: function(tp_inst, obj, unit, val){
var $t = obj.children('select');
- if(val !== undefined)
+ if(val !== undefined){
return $t.val(val);
+ }
return $t.val();
}
}
@@ -1170,7 +1191,7 @@
}; // end looseParse
if(typeof o.parse === "function"){
- return o.parse(timeFormat, timeString, o)
+ return o.parse(timeFormat, timeString, o);
}
if(o.parse === 'loose'){
return looseParse(timeFormat, timeString, o);
@@ -1348,9 +1369,12 @@
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
- if(tp_inst._defaults.altFormat)
+ if(tp_inst._defaults.altFormat){
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
- else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
+ }
+ else{
+ altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
+ }
}
$(altField).val(altFormattedDateTime);
}
@@ -1538,8 +1562,12 @@
// Hack! The error message ends with a colon, a space, and
// the "extra" characters. We rely on that instead of
// attempting to perfectly reproduce the parsing algorithm.
- date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
- $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
+ if (err.indexOf(":") >= 0) {
+ date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
+ $.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
+ } else {
+ throw err;
+ }
}
return date;
};
@@ -1639,6 +1667,7 @@
}
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
};
+
/*
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
* it will return false for all objects
@@ -1671,7 +1700,7 @@
* Returns true if should use ampm, false if not
*/
var useAmpm = function(timeFormat){
- return (timeFormat.indexOf('t') !== -1 && timeFormat.indexOf('h') !== -1);
+ return ((timeFormat.indexOf('t') !== -1 || timeFormat.indexOf('T') !== -1) && timeFormat.indexOf('h') !== -1);
};
/*
@@ -1683,7 +1712,7 @@
hour = hour - 12;
}
- if (hour == 0) {
+ if (hour === 0) {
hour = 12;
}
@@ -1907,13 +1936,14 @@
* @return void
*/
$.timepicker.log = function(err){
- if(window.console)
+ if(window.console){
console.log(err);
+ }
};
/*
* Keep up with the version
*/
- $.timepicker.version = "1.2";
+ $.timepicker.version = "1.2.1";
})(jQuery);
diff --git a/localization/jquery-ui-timepicker-hr.js b/localization/jquery-ui-timepicker-hr.js
new file mode 100644
index 0000000..b50c4df
--- /dev/null
+++ b/localization/jquery-ui-timepicker-hr.js
@@ -0,0 +1,20 @@
+/* Croatian translation for the jQuery Timepicker Addon */
+/* Written by Mladen */
+(function($) {
+ $.timepicker.regional['hr'] = {
+ timeOnlyTitle: 'Odaberi vrijeme',
+ timeText: 'Vrijeme',
+ hourText: 'Sati',
+ minuteText: 'Minute',
+ secondText: 'Sekunde',
+ millisecText: 'Milisekunde',
+ timezoneText: 'Vremenska zona',
+ currentText: 'Sada',
+ closeText: 'Gotovo',
+ timeFormat: 'HH:mm',
+ amNames: ['a.m.', 'AM', 'A'],
+ pmNames: ['p.m.', 'PM', 'P'],
+ isRTL: false
+ };
+ $.timepicker.setDefaults($.timepicker.regional['hr']);
+})(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 cd9ee12..7ba40a6 100644
--- a/localization/jquery-ui-timepicker-pt-BR.js
+++ b/localization/jquery-ui-timepicker-pt-BR.js
@@ -2,7 +2,7 @@
/* Written by Diogo Damiani (diogodamiani@gmail.com) */
(function ($) {
$.timepicker.regional['pt-BR'] = {
- timeOnlyTitle: 'Escolha a horário',
+ timeOnlyTitle: 'Escolha o horário',
timeText: 'Horário',
hourText: 'Hora',
minuteText: 'Minutos',