Skip to content

Commit

Permalink
Use 'one' function from jQuery to close the ngeo-popover
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Nov 14, 2017
1 parent e727fe4 commit e8b8bb1
Showing 1 changed file with 6 additions and 24 deletions.
30 changes: 6 additions & 24 deletions src/ol-ext/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@ ngeo.Popover = function(opt_options) {

const options = opt_options !== undefined ? opt_options : {};

/**
* The key for close button 'click' event
* @type {?goog.events.Key}
* @private
*/
this.clickKey_ = null;

let originalEl;
if (options.element) {
originalEl = options.element;
Expand Down Expand Up @@ -66,10 +59,6 @@ ngeo.Popover.prototype.setMap = function(map) {

const currentMap = this.getMap();
if (currentMap) {
if (this.clickKey_) {
goog.events.unlistenByKey(this.clickKey_);
this.clickKey_ = null;
}
$(element).popover('destroy');
}

Expand All @@ -95,18 +84,11 @@ ngeo.Popover.prototype.setMap = function(map) {
.popover('show');
}, 0);

this.clickKey_ = goog.events.listen(this.closeEl_[0],
'click', this.handleCloseElClick_, false, this);
}
};


/**
* @private
*/
ngeo.Popover.prototype.handleCloseElClick_ = function() {
const map = this.getMap();
if (map) {
map.removeOverlay(this);
this.closeEl_.one('click', () => {
const map = this.getMap();
if (map) {
map.removeOverlay(this);
}
});
}
};

0 comments on commit e8b8bb1

Please sign in to comment.