Skip to content

Commit 66ba807

Browse files
committed
Add altRedirectFocus option
If set to true (default), the altField will redirect focus to the main field (this is how it always worked before this change). Otherwise, the altField will not redirect its focus, and the altField will behave as a normal text field that can be edited by the user.
1 parent a792358 commit 66ba807

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/docs/options.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ <h3>Alt Field Options</h3>
6868

6969
<dt>altTimeFormat</dt>
7070
<dd><em>Default: (timeFormat option)</em> - The time format to use with the altField.</dd>
71+
72+
<dt>altRedirectFocus</dt>
73+
<dd><em>Default: true</em> - Whether to immediately focus the main field whenever the altField receives focus. Effective at construction time only, changing it later has no effect.</dd>
7174
</dl>
7275

7376
<h3>Timezone Options</h3>

src/jquery-ui-timepicker-addon.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@
9999
altTimeFormat: null,
100100
altSeparator: null,
101101
altTimeSuffix: null,
102+
altRedirectFocus: true,
102103
pickerTimeFormat: null,
103104
pickerTimeSuffix: null,
104105
showTimepicker: true,
@@ -271,11 +272,14 @@
271272
tp_inst.$input = $input;
272273

273274
if (tp_inst._defaults.altField) {
274-
tp_inst.$altInput = $(tp_inst._defaults.altField).css({
275-
cursor: 'pointer'
276-
}).focus(function () {
277-
$input.trigger("focus");
278-
});
275+
tp_inst.$altInput = $(tp_inst._defaults.altField);
276+
if (tp_inst._defaults.altRedirectFocus === true) {
277+
tp_inst.$altInput.css({
278+
cursor: 'pointer'
279+
}).focus(function () {
280+
$input.trigger("focus");
281+
});
282+
}
279283
}
280284

281285
if (tp_inst._defaults.minDate === 0 || tp_inst._defaults.minDateTime === 0) {

0 commit comments

Comments
 (0)