Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now support multiple pickers #69

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/wickedpicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@
showPicker: function (element) {
//If there is a beforeShow function, then call it with the input calling the timepicker and the
// timepicker itself
$(element).addClass('onPicker');
if (typeof this.options.beforeShow === 'function') {
this.options.beforeShow(element, this.timepicker);
}
var timepickerPos = $(element).offset();

$(element).attr({'aria-showingpicker': 'true', 'tabindex': -1});
this.setText(element);
this.showHideMeridiemControl();
if (this.getText(element) !== this.getTime()) {
if (this.getText(element) !== this.getTime() && this.getText(element).length > 0) {

// Check meridiem
var text = this.getText(element);
Expand All @@ -132,7 +132,8 @@
if (typeof this.options.show === 'function') {
this.options.show(element, this.timepicker);
}


this.setText(element);
this.handleTimeAdjustments(element);
},

Expand All @@ -144,6 +145,7 @@
* BeinnLora: added trigger function to call on closing/hiding timepicker.
*/
hideTimepicker: function (element) {
$('.onPicker').removeClass('onPicker');
this.timepicker.hide();
if (typeof this.options.afterShow === 'function') {
this.options.afterShow(element, this.timepicker);
Expand Down Expand Up @@ -234,9 +236,12 @@
//Clicking the X
if ($(event.target).is(self.close)) {
self.hideTimepicker(window.lastTimePickerControl);
} else if ($(event.target).closest(self.timepicker).length || $(event.target).closest($('.hasWickedpicker')).length) { //Clicking the Wickedpicker or one of it's inputs
} else if ($(event.target).closest(self.timepicker).length || $(event.target).closest($('.hasWickedpicker')).hasClass('onPicker')) { //Clicking the Wickedpicker or one of it's inputs
event.stopPropagation();
} else { //Everything else
}else if ($(event.target).closest($('.hasWickedpicker')).length) {
self.hideTimepicker(window.lastTimePickerControl);
self.showPicker($(event.target).closest($('.hasWickedpicker')));
}else { //Everything else
if (typeof self.options.onClickOutside === 'function') {
self.options.onClickOutside();
}
Expand Down