Skip to content

Commit 84e39e8

Browse files
Merge branch 'dev'
2 parents e752ef7 + dd4ec60 commit 84e39e8

5 files changed

+95
-45
lines changed

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery-timepicker-addon",
3-
"version": "1.2",
3+
"version": "1.2.1",
44
"repository": {
55
"type": "git",
66
"url": "git://github.com/trentrichardson/jQuery-Timepicker-Addon.git"

index.html

Lines changed: 5 additions & 5 deletions
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.10.0/themes/smoothness/jquery-ui.css" />
38+
<link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.2/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.9.0.min.js"></script>
42-
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.min.js"></script>
41+
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
42+
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.2/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,9 +122,9 @@ <h3>Requirements</h3>
122122

123123

124124
<h3>Version</h3>
125-
<p>Version 1.2</p>
125+
<p>Version 1.2.1</p>
126126

127-
<p>Last updated on 02/02/2013</p>
127+
<p>Last updated on 04/06/2013</p>
128128
<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>
129129
<p><a href="http://trentrichardson.com/Impromptu/GPL-LICENSE.txt" title="GPL License">GPL License</a></p>
130130
<p><a href="http://trentrichardson.com/Impromptu/MIT-LICENSE.txt" title="MIT License">MIT License</a></p>

jquery-ui-timepicker-addon.js

Lines changed: 68 additions & 38 deletions
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.2
5-
* Last Modified: 02/02/2013
4+
* Version 1.2.1
5+
* Last Modified: 04/06/2013
66
*
77
* Copyright 2013 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.2"
30+
version: "1.2.1"
3131
}
3232
});
3333

@@ -339,7 +339,9 @@
339339
uitem = '',
340340
max = {},
341341
gridSize = {},
342-
size = null;
342+
size = null,
343+
i=0,
344+
l=0;
343345

344346
// Prevent displaying twice
345347
if ($dp.find("div.ui-timepicker-div").length === 0 && o.showTimepicker) {
@@ -348,7 +350,7 @@
348350
'<dd class="ui_tpicker_time"' + ((o.showTime) ? '' : noDisplay) + '></dd>';
349351

350352
// Create the markup
351-
for(var i=0,l=this.units.length; i<l; i++){
353+
for(i=0,l=this.units.length; i<l; i++){
352354
litem = this.units[i];
353355
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
354356
// Added by Peter Medeiros:
@@ -397,7 +399,7 @@
397399
}
398400

399401
// add sliders, adjust grids, add events
400-
for(var i=0,l=tp_inst.units.length; i<l; i++){
402+
for(i=0,l=tp_inst.units.length; i<l; i++){
401403
litem = tp_inst.units[i];
402404
uitem = litem.substr(0,1).toUpperCase() + litem.substr(1);
403405

@@ -434,8 +436,7 @@
434436

435437
tp_inst._onTimeChange();
436438
tp_inst._onSelectHandler();
437-
})
438-
.css({
439+
}).css({
439440
cursor: 'pointer',
440441
width: (100 / gridSize[litem]) + '%',
441442
textAlign: 'center',
@@ -769,7 +770,7 @@
769770
var formattedDateTime = this.formattedDate;
770771

771772
// if a slider was changed but datepicker doesn't have a value yet, set it
772-
if(dp_inst.lastVal==""){
773+
if(dp_inst.lastVal===""){
773774
dp_inst.currentYear=dp_inst.selectedYear;
774775
dp_inst.currentMonth=dp_inst.selectedMonth;
775776
dp_inst.currentDay=dp_inst.selectedDay;
@@ -803,11 +804,23 @@
803804
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
804805
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
805806

806-
if (this._defaults.altFormat) altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
807-
else altFormattedDateTime = this.formattedDate;
808-
if (altFormattedDateTime) altFormattedDateTime += altSeparator;
809-
if (this._defaults.altTimeFormat) altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
810-
else altFormattedDateTime += this.formattedTime + altTimeSuffix;
807+
if (this._defaults.altFormat){
808+
altFormattedDateTime = $.datepicker.formatDate(this._defaults.altFormat, (dt === null ? new Date() : dt), formatCfg);
809+
}
810+
else{
811+
altFormattedDateTime = this.formattedDate;
812+
}
813+
814+
if (altFormattedDateTime){
815+
altFormattedDateTime += altSeparator;
816+
}
817+
818+
if(this._defaults.altTimeFormat){
819+
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
820+
}
821+
else{
822+
altFormattedDateTime += this.formattedTime + altTimeSuffix;
823+
}
811824
this.$altInput.val(altFormattedDateTime);
812825
} else {
813826
this.$input.val(formattedDateTime);
@@ -861,49 +874,55 @@
861874
if(tp_inst._defaults.isRTL){
862875
if(typeof(opts) == 'string'){
863876
if(opts == 'min' || opts == 'max'){
864-
if(val !== undefined)
877+
if(val !== undefined){
865878
return obj.slider(opts, val*-1);
879+
}
866880
return Math.abs(obj.slider(opts));
867881
}
868882
return obj.slider(opts);
869883
}
870884
var min = opts.min,
871885
max = opts.max;
872886
opts.min = opts.max = null;
873-
if(min !== undefined)
887+
if(min !== undefined){
874888
opts.max = min * -1;
875-
if(max !== undefined)
889+
}
890+
if(max !== undefined){
876891
opts.min = max * -1;
892+
}
877893
return obj.slider(opts);
878894
}
879-
if(typeof(opts) == 'string' && val !== undefined)
895+
if(typeof(opts) == 'string' && val !== undefined){
880896
return obj.slider(opts, val);
897+
}
881898
return obj.slider(opts);
882899
},
883900
value: function(tp_inst, obj, unit, val){
884901
if(tp_inst._defaults.isRTL){
885-
if(val !== undefined)
902+
if(val !== undefined){
886903
return obj.slider('value', val*-1);
904+
}
887905
return Math.abs(obj.slider('value'));
888906
}
889-
if(val !== undefined)
907+
if(val !== undefined){
890908
return obj.slider('value', val);
909+
}
891910
return obj.slider('value');
892911
}
893912
},
894913
// select methods
895914
select: {
896915
create: function(tp_inst, obj, unit, val, min, max, step){
897916
var sel = '<select class="ui-timepicker-select" data-unit="'+ unit +'" data-min="'+ min +'" data-max="'+ max +'" data-step="'+ step +'">',
898-
ul = tp_inst._defaults.timeFormat.indexOf('t') !== -1? 'toLowerCase':'toUpperCase',
899-
m = 0;
917+
format = tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat;
900918

901919
for(var i=min; i<=max; i+=step){
902920
sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
903-
if(unit == 'hour' && useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat))
904-
sel += $.datepicker.formatTime("hh TT", {hour:i}, tp_inst._defaults);
905-
else if(unit == 'millisec' || i >= 10) sel += i;
906-
else sel += '0'+ i.toString();
921+
if(unit == 'hour'){
922+
sel += $.datepicker.formatTime($.trim(format.replace(/[^ht ]/ig,'')), {hour:i}, tp_inst._defaults);
923+
}
924+
else if(unit == 'millisec' || i >= 10){ sel += i; }
925+
else {sel += '0'+ i.toString(); }
907926
sel += '</option>';
908927
}
909928
sel += '</select>';
@@ -921,17 +940,19 @@
921940
var o = {},
922941
$t = obj.children('select');
923942
if(typeof(opts) == 'string'){
924-
if(val === undefined)
943+
if(val === undefined){
925944
return $t.data(opts);
945+
}
926946
o[opts] = val;
927947
}
928-
else o = opts;
948+
else{ o = opts; }
929949
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'));
930950
},
931951
value: function(tp_inst, obj, unit, val){
932952
var $t = obj.children('select');
933-
if(val !== undefined)
953+
if(val !== undefined){
934954
return $t.val(val);
955+
}
935956
return $t.val();
936957
}
937958
}
@@ -1170,7 +1191,7 @@
11701191
}; // end looseParse
11711192

11721193
if(typeof o.parse === "function"){
1173-
return o.parse(timeFormat, timeString, o)
1194+
return o.parse(timeFormat, timeString, o);
11741195
}
11751196
if(o.parse === 'loose'){
11761197
return looseParse(timeFormat, timeString, o);
@@ -1348,9 +1369,12 @@
13481369

13491370
altFormattedDateTime += $.datepicker.formatTime(altTimeFormat, tp_inst, tp_inst._defaults) + altTimeSuffix;
13501371
if(!tp_inst._defaults.timeOnly && !tp_inst._defaults.altFieldTimeOnly && date !== null){
1351-
if(tp_inst._defaults.altFormat)
1372+
if(tp_inst._defaults.altFormat){
13521373
altFormattedDateTime = $.datepicker.formatDate(tp_inst._defaults.altFormat, date, formatCfg) + altSeparator + altFormattedDateTime;
1353-
else altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
1374+
}
1375+
else{
1376+
altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
1377+
}
13541378
}
13551379
$(altField).val(altFormattedDateTime);
13561380
}
@@ -1538,8 +1562,12 @@
15381562
// Hack! The error message ends with a colon, a space, and
15391563
// the "extra" characters. We rely on that instead of
15401564
// attempting to perfectly reproduce the parsing algorithm.
1541-
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1542-
$.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
1565+
if (err.indexOf(":") >= 0) {
1566+
date = this._base_parseDate(format, value.substring(0,value.length-(err.length-err.indexOf(':')-2)), settings);
1567+
$.timepicker.log("Error parsing the date string: " + err + "\ndate string = " + value + "\ndate format = " + format);
1568+
} else {
1569+
throw err;
1570+
}
15431571
}
15441572
return date;
15451573
};
@@ -1639,6 +1667,7 @@
16391667
}
16401668
return this._base_optionDatepicker.call($.datepicker, target, name_clone || name, value);
16411669
};
1670+
16421671
/*
16431672
* jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
16441673
* it will return false for all objects
@@ -1671,7 +1700,7 @@
16711700
* Returns true if should use ampm, false if not
16721701
*/
16731702
var useAmpm = function(timeFormat){
1674-
return (timeFormat.indexOf('t') !== -1 && timeFormat.indexOf('h') !== -1);
1703+
return ((timeFormat.indexOf('t') !== -1 || timeFormat.indexOf('T') !== -1) && timeFormat.indexOf('h') !== -1);
16751704
};
16761705

16771706
/*
@@ -1683,7 +1712,7 @@
16831712
hour = hour - 12;
16841713
}
16851714

1686-
if (hour == 0) {
1715+
if (hour === 0) {
16871716
hour = 12;
16881717
}
16891718

@@ -1907,13 +1936,14 @@
19071936
* @return void
19081937
*/
19091938
$.timepicker.log = function(err){
1910-
if(window.console)
1939+
if(window.console){
19111940
console.log(err);
1941+
}
19121942
};
19131943

19141944
/*
19151945
* Keep up with the version
19161946
*/
1917-
$.timepicker.version = "1.2";
1947+
$.timepicker.version = "1.2.1";
19181948

19191949
})(jQuery);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* Croatian translation for the jQuery Timepicker Addon */
2+
/* Written by Mladen */
3+
(function($) {
4+
$.timepicker.regional['hr'] = {
5+
timeOnlyTitle: 'Odaberi vrijeme',
6+
timeText: 'Vrijeme',
7+
hourText: 'Sati',
8+
minuteText: 'Minute',
9+
secondText: 'Sekunde',
10+
millisecText: 'Milisekunde',
11+
timezoneText: 'Vremenska zona',
12+
currentText: 'Sada',
13+
closeText: 'Gotovo',
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['hr']);
20+
})(jQuery);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* Written by Diogo Damiani (diogodamiani@gmail.com) */
33
(function ($) {
44
$.timepicker.regional['pt-BR'] = {
5-
timeOnlyTitle: 'Escolha a horário',
5+
timeOnlyTitle: 'Escolha o horário',
66
timeText: 'Horário',
77
hourText: 'Hora',
88
minuteText: 'Minutos',

0 commit comments

Comments
 (0)