Close all flyovers on click outside a flyover

This commit is contained in:
Alexander A. Klimov 2017-11-21 16:37:52 +01:00
parent 5042fdab54
commit e9c189fa38
1 changed files with 13 additions and 1 deletions

View File

@ -15,7 +15,8 @@
Icinga.EventListener.call(this, icinga);
this.on('rendered', this.onRendered, this);
this.on('click', '.flyover-toggle', this.onClick, this);
this.on('click', this.onClick, this);
this.on('click', '.flyover-toggle', this.onClickFlyoverToggle, this);
}
Flyover.prototype = new Icinga.EventListener();
@ -33,6 +34,17 @@
};
Flyover.prototype.onClick = function(event) {
var $target = $(event.target);
if (! $target.closest('.flyover').length) {
var _this = event.data.self;
$target.closest('.container').find('.flyover.flyover-expanded .flyover-toggle').each(function() {
_this.onClickFlyoverToggle({target: this});
});
}
};
Flyover.prototype.onClickFlyoverToggle = function(event) {
var $flyover = $(event.target).closest('.flyover');
$flyover.toggleClass('flyover-expanded');