Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 69ba916

Browse files
author
jboesch
committed
* fixing IE bugz
1 parent 4431ee7 commit 69ba916

File tree

4 files changed

+27
-15
lines changed

4 files changed

+27
-15
lines changed

example/index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,13 @@ <h3 class="grey-line"><span>Requirements</span></h3>
233233
<script src="lib/prism.js" type="text/javascript"></script>
234234

235235
<!-- Our TimeAutocomplete stuff -->
236-
<script src="../jquery.timeAutocomplete.min.js" type="text/javascript"></script>
236+
<!-- dev -->
237+
<script src="../src/jquery.timeAutocomplete.js" type="text/javascript"></script>
238+
<script src="../src/formatters/ampm.js" type="text/javascript"></script>
239+
<script src="../src/formatters/24hr.js" type="text/javascript"></script>
240+
<script src="../src/formatters/french.js" type="text/javascript"></script>
241+
242+
<!--<script src="../jquery.timeAutocomplete.min.js" type="text/javascript"></script>-->
237243

238244
<script type="text/javascript">
239245

@@ -256,7 +262,7 @@ <h3 class="grey-line"><span>Requirements</span></h3>
256262
});
257263

258264
// basic
259-
$('#basic-example').val('8:00 AM').timeAutocomplete();
265+
$('#basic-example').timeAutocomplete();
260266

261267
// ampm
262268
$('#from-ampm').timeAutocomplete({

src/formatters/24hr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@
9595
/*
9696
* Setup a filter when we type a key into this input.
9797
*
98-
* @param {Object} el The DOM element
98+
* @param {Object} el The jQuery element
9999
*/
100100
hook_filterSource: function(el){
101101

102102
var self = this;
103+
el = el[0];
103104

104105
return (function(times, self){
105106
return function(req, responseFn){

src/formatters/ampm.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,12 @@
6060
/*
6161
* Setup a filter when we type a key into this input.
6262
*
63-
* @param {Object} el The DOM element
63+
* @param {Object} el The jQuery element
6464
*/
6565
hook_filterSource: function(el){
6666

6767
var self = this;
68+
el = el[0];
6869

6970
return (function(times, self){
7071
return function(req, responseFn){
@@ -209,7 +210,7 @@
209210
var min = time[1];
210211
var ampm = (hour >= 12) ? 'PM' : 'AM';
211212

212-
if(("" + hour + "").length == 2 && hour < 10){
213+
if(hour.length == 2 && parseInt(hour, 10) < 10){
213214
hour = hour.substr(1);
214215
}
215216

@@ -357,16 +358,16 @@
357358
// Parse for hour and minute
358359
switch(num.length){
359360
case 4:
360-
hour = parseInt(num[0] + num[1], 10);
361-
minute = parseInt(num[2] + num[3], 10);
361+
hour = parseInt(num.charAt(0) + num.charAt(1), 10);
362+
minute = parseInt(num.charAt(2) + num.charAt(3), 10);
362363
break;
363364
case 3:
364-
hour = parseInt(num[0], 10);
365-
minute = parseInt(num[1] + num[2], 10);
365+
hour = parseInt(num.charAt(0), 10);
366+
minute = parseInt(num.charAt(1) + num.charAt(2), 10);
366367
break;
367368
case 2:
368369
case 1:
369-
hour = parseInt(num[0] + (num[1] || ''), 10);
370+
hour = parseInt(num.charAt(0) + (num.charAt(1) || ''), 10);
370371
minute = 0;
371372
break;
372373
default:

src/jquery.timeAutocomplete.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
_callAutocomplete: function(){
5353

54-
this.options.auto_complete.source = this._callFormatterMethod('filterSource', this.el, function(req, responseFn){
54+
this.options.auto_complete.source = this._callFormatterMethod('filterSource', [this.el], function(req, responseFn){
5555
throw new Error("You must set a hook_filterSource method in your formatter.");
5656
});
5757

@@ -251,7 +251,7 @@
251251
*/
252252
_createStringFromFormat: function(obj){
253253

254-
var combined = obj.h + obj.sep + obj.m;
254+
var combined = ("" + obj.h + "") + obj.sep + ("" + obj.m + "");
255255

256256
if(obj.postfix){
257257
combined += obj.postfix;
@@ -262,12 +262,16 @@
262262
},
263263

264264
/*
265-
* Pass an H:i:s time format in as the value: '' attribute on the element
265+
* Pass an H:i:s time format in as the value: '' attribute on the element or 'current'
266266
*/
267-
_setCurrentTimeAsValue: function(){
267+
_setValueAsTime: function(){
268268

269269
if($.trim(this.el.val()) == '' && this.options.value){
270270
this.setTime(this.options.value);
271+
} else {
272+
var time = this._getCurrentTimeAsValue();
273+
this.el.val(time);
274+
this._attacheUsableTimeData();
271275
}
272276

273277
},
@@ -346,7 +350,7 @@
346350
this._calling_from_init = true;
347351
this.setFormatter();
348352
this._callAutocomplete();
349-
this._setCurrentTimeAsValue();
353+
this._setValueAsTime();
350354
this._bindEvents();
351355
this._setupPlaceholder();
352356

0 commit comments

Comments
 (0)