Skip to content

Commit

Permalink
0.9.3.beta.14 , close bootstrap-datepicker upon clicking on other filter
Browse files Browse the repository at this point in the history
  • Loading branch information
vedmack committed Mar 27, 2018
1 parent 792a9d6 commit e07db23
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
https://github.com/vedmack/yadcf/issues/425 - Filter fails when using data-*
https://github.com/vedmack/yadcf/issues/426 - Bug in column_inner_data_helper, related to
https://github.com/vedmack/yadcf/issues/441 - Continue stabilzing integration with 'bootstrap-datepicker'
https://github.com/vedmack/yadcf/issues/442 - Date picker is still shown on click of another input filed


## 0.9.2
Expand Down
31 changes: 30 additions & 1 deletion src/jquery.dataTables.yadcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Yet Another DataTables Column Filter - (yadcf)
*
* File: jquery.dataTables.yadcf.js
* Version: 0.9.3.beta.13 (grab latest stable from https://github.com/vedmack/yadcf/releases)
* Version: 0.9.3.beta.14 (grab latest stable from https://github.com/vedmack/yadcf/releases)
*
* Author: Daniel Reznick
* Info: https://github.com/vedmack/yadcf
Expand Down Expand Up @@ -555,6 +555,10 @@
return options[selector];
}

function getAllOptions() {
return options;
}

function eventTargetFixUp(pEvent) {
if (pEvent.target === undefined) {
pEvent.target = pEvent.srcElement;
Expand Down Expand Up @@ -4125,7 +4129,32 @@
initMultipleTables(tablesArray, filtersOptions);
}

function closeOpenDatePickersIfAny(evt) {
var closeBootstrapDatepicker = false,
closeBootstrapDatepickerRange = false;
Object.entries(getAllOptions()).some(function ([tableSelector, tableOptions]) {
Object.entries(tableOptions).some(function ([key, value]) {
if (value.datepicker_type === 'bootstrap-datepicker') {
if (value.filter_type === 'range_date') {
closeBootstrapDatepickerRange = true;
} else {
closeBootstrapDatepicker = true;
}
}
return closeBootstrapDatepicker && closeBootstrapDatepickerRange;
});
return closeBootstrapDatepicker && closeBootstrapDatepickerRange;
});
if (closeBootstrapDatepickerRange) {
$('.yadcf-filter-range-date').not($(evt.target)).datepicker('hide');
}
if (closeBootstrapDatepicker) {
$('.yadcf-filter-date').not($(evt.target)).datepicker('hide');
}
}

function stopPropagation(evt) {
closeOpenDatePickersIfAny(evt);
if (evt.stopPropagation !== undefined) {
evt.stopPropagation();
} else {
Expand Down

0 comments on commit e07db23

Please sign in to comment.