ol.control.Attribution no longer require ol.event

This commit is contained in:
Éric Lemoine
2012-07-09 21:31:56 +02:00
parent a3387bc673
commit 77b809bead
+11 -7
View File
@@ -1,6 +1,5 @@
goog.provide('ol.control.Attribution'); goog.provide('ol.control.Attribution');
goog.require('ol.event');
goog.require('ol.control.Control'); goog.require('ol.control.Control');
goog.require('goog.dom'); goog.require('goog.dom');
@@ -43,7 +42,7 @@ ol.control.Attribution.prototype.setMap = function(map) {
var staticOverlay = map.getStaticOverlay(); var staticOverlay = map.getStaticOverlay();
if (goog.isNull(this.container_)) { if (goog.isNull(this.container_)) {
this.container_ = goog.dom.createDom('div', this.CLS); this.container_ = goog.dom.createDom('div', this.CLS);
goog.events.listen(this.container_, 'click', ol.event.stopPropagation); goog.events.listen(this.container_, 'click', this.stopEventPropagation);
} }
if (!goog.isNull(staticOverlay)) { if (!goog.isNull(staticOverlay)) {
goog.dom.append(staticOverlay, this.container_); goog.dom.append(staticOverlay, this.container_);
@@ -55,8 +54,7 @@ ol.control.Attribution.prototype.setMap = function(map) {
ol.control.Attribution.prototype.activate = function() { ol.control.Attribution.prototype.activate = function() {
var active = goog.base(this, 'activate'); var active = goog.base(this, 'activate');
if (active) { if (active) {
goog.events.listen(this.map_, 'layeradd', this.update, goog.events.listen(this.map_, 'layeradd', this.update, undefined, this);
undefined, this);
this.update(); this.update();
} }
return active; return active;
@@ -66,8 +64,7 @@ ol.control.Attribution.prototype.activate = function() {
ol.control.Attribution.prototype.deactivate = function() { ol.control.Attribution.prototype.deactivate = function() {
var inactive = goog.base(this, 'deactivate'); var inactive = goog.base(this, 'deactivate');
if (inactive) { if (inactive) {
goog.events.unlisten(this.map_, 'layeradd', this.update, goog.events.unlisten(this.map_, 'layeradd', this.update, undefined, this);
undefined, this);
} }
return inactive; return inactive;
}; };
@@ -86,9 +83,16 @@ ol.control.Attribution.prototype.update = function() {
}; };
ol.control.Attribution.prototype.destroy = function() { ol.control.Attribution.prototype.destroy = function() {
goog.events.unlisten(this.container_, 'click', ol.event.stopPropagation); goog.events.unlisten(this.container_, 'click', this.stopEventPropagation);
goog.dom.removeNode(this.container_); goog.dom.removeNode(this.container_);
goog.base(this, 'destroy'); goog.base(this, 'destroy');
}; };
/**
* @param {goog.events.BrowserEvent} e
*/
ol.control.Attribution.prototype.stopEventPropagation = function(e) {
e.stopPropagation();
};
ol.control.addControl('attribution', ol.control.Attribution); ol.control.addControl('attribution', ol.control.Attribution);