Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#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)

ui.datepicker.js (59.8 KB) - added by bander 15 years ago.
ugh, that formatting was horrible

Download all attachments as: .zip

Change History (6)

Changed 15 years ago by bander

Attachment: ui.datepicker.js added

ugh, that formatting was horrible

comment:1 Changed 15 years ago by paul

Owner: changed from paul to iMarc

comment:2 Changed 15 years ago by kbwood

Owner: changed from iMarc to kbwood
Status: newassigned

comment:3 Changed 15 years ago by kbwood

Resolution: fixed
Status: assignedclosed

Added as default behaviour in v3.4

comment:4 Changed 15 years ago by (none)

Milestone: 1.2.3

Milestone 1.2.3 deleted

comment:5 Changed 14 years ago by paul

Milestone: 1.5
Note: See TracTickets for help on using tickets.