Skip to content

Commit

Permalink
Add eventlistener to body to close dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ciar4n committed Jul 11, 2017
1 parent abdd678 commit 1e72e40
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion administrator/templates/atum/css/template-rtl.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion administrator/templates/atum/css/template-rtl.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion administrator/templates/atum/css/template.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion administrator/templates/atum/css/template.min.css

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions administrator/templates/atum/scss/blocks/_searchtools.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
.custom-select {
width: 100%;
}

&.js-filters-show {
display: flex;
}

}

.js-stools-field-filter {
Expand Down Expand Up @@ -80,10 +85,6 @@

}

.js-stools-container-filters-visible {
display: inline-block;
}

.js-stools-field-list,
.js-stools-field-filter {
display: block;
Expand Down
23 changes: 16 additions & 7 deletions media/system/js/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
self.filterButton.addEventListener('click', function(e) {
self.toggleFilters();
e.stopPropagation();
e.preventDefault();
e.preventDefault();
});
}

Expand Down Expand Up @@ -171,6 +171,16 @@
});

self.checkActiveStatus(self);

document.body.addEventListener('click', function(e) {
if (document.body.classList.contains('filters-shown')) {
self.hideFilters();
}
});
self.filterContainer.addEventListener('click',function(e) {
e.stopPropagation();
}, true);

},
checkFilter: function (element) {
var self = this;
Expand Down Expand Up @@ -220,7 +230,6 @@
var els = [].slice.call(el.querySelectorAll('.js-stools-field-filter select'));
els.forEach(function(item) {
if (item.classList.contains('active')) {
console.log('hello!!!!!');
cont.filterButton.classList.remove('btn-secondary');
cont.filterButton.classList.add('btn-primary');
return '';
Expand Down Expand Up @@ -255,16 +264,16 @@
// Common container functions
hideContainer: function (container) {
if (container) {
container.style.display = 'none';
container.classList.remove('shown');
container.classList.remove('js-filters-show');
document.body.classList.remove('filters-shown');
}
},
showContainer: function (container) {
container.style.display = 'flex';
container.classList.add('shown');
container.classList.add('js-filters-show');
document.body.classList.add('filters-shown');
},
toggleContainer: function (container) {
if (container.classList.contains('shown')) {
if (container.classList.contains('js-filters-show')) {
this.hideContainer(container);
} else {
this.showContainer(container);
Expand Down
2 changes: 1 addition & 1 deletion media/system/js/searchtools.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1e72e40

Please sign in to comment.