Skip to content

Commit

Permalink
Add altRedirectFocus option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
emlun committed May 11, 2014
1 parent a792358 commit 66ba807
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/docs/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ <h3>Alt Field Options</h3>

<dt>altTimeFormat</dt>
<dd><em>Default: (timeFormat option)</em> - The time format to use with the altField.</dd>

<dt>altRedirectFocus</dt>
<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>
</dl>

<h3>Timezone Options</h3>
Expand Down
14 changes: 9 additions & 5 deletions src/jquery-ui-timepicker-addon.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
altTimeFormat: null,
altSeparator: null,
altTimeSuffix: null,
altRedirectFocus: true,
pickerTimeFormat: null,
pickerTimeSuffix: null,
showTimepicker: true,
Expand Down Expand Up @@ -271,11 +272,14 @@
tp_inst.$input = $input;

if (tp_inst._defaults.altField) {
tp_inst.$altInput = $(tp_inst._defaults.altField).css({
cursor: 'pointer'
}).focus(function () {
$input.trigger("focus");
});
tp_inst.$altInput = $(tp_inst._defaults.altField);
if (tp_inst._defaults.altRedirectFocus === true) {
tp_inst.$altInput.css({
cursor: 'pointer'
}).focus(function () {
$input.trigger("focus");
});
}
}

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

0 comments on commit 66ba807

Please sign in to comment.