#2257 closed enhancement (fixed)
[PATCH] ui.datepicker: hideOnButton
Reported by: | bander | Owned by: | kbwood |
---|---|---|---|
Priority: | minor | Milestone: | 1.5 |
Component: | ui.core | Version: | 1.2.2 |
Keywords: | datepicker, toggle | Cc: | |
Blocked by: | Blocking: |
Description
This adds an option to change the date picker button to a toggle. (Not quite as simple as trigger.toggle, since you have to allow for outside clicks, but close.) I'd actually argue for making this the default behavior.
[www]jquery$ diff -u3 ui.datepicker.old.js ui.datepicker.js --- ui.datepicker.old.js Wed Jan 30 11:04:11 2008 +++ ui.datepicker.js Wed Jan 30 15:26:40 2008 @@ -60,6 +60,7 @@
buttonText: '...', Text for trigger button buttonImage: , URL for trigger button image buttonImageOnly: false, True if the image appears alone, false if it appears on a button
+ hideOnButton: false, True if clicking the button again closes the calendar
closeAtTop: true, True to have the clear/close at the top,
false to have them at the bottom
mandatory: false, True to hide the Clear link, false to include it
@@ -199,6 +200,7 @@
var buttonText = inst._get('buttonText'); var buttonImage = inst._get('buttonImage'); var buttonImageOnly = inst._get('buttonImageOnly');
+ var hideOnButton = inst._get('hideOnButton');
var trigger = $(buttonImageOnly ? '<img class="datepicker_trigger" src="' +
buttonImage + '" alt="' + buttonText + '" title="' + buttonText + '"/>' : '<button type="button" class="datepicker_trigger">' + (buttonImage != ?
@@ -211,7 +213,17 @@
else {
input.after(trigger);
}
- trigger.click(this.showFor);
+ if (hideOnButton) { + trigger.click(function() { + if ($.datepicker._datepickerShowing) { + $.datepicker.hideDatepicker(); + } else { + $.datepicker.showFor(input); + } + }); + } else { + trigger.click(this.showFor); + }
} input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress); input[0]._calId = inst._id;
Attachments (1)
Change History (6)
Changed 15 years ago by
Attachment: | ui.datepicker.js added |
---|
comment:1 Changed 15 years ago by
Owner: | changed from paul to iMarc |
---|
comment:2 Changed 15 years ago by
Owner: | changed from iMarc to kbwood |
---|---|
Status: | new → assigned |
comment:3 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Added as default behaviour in v3.4
comment:5 Changed 14 years ago by
Milestone: | → 1.5 |
---|
ugh, that formatting was horrible