change Panel to avoid redrawing every control on every activate/deactivate, p=jorix, r=me (closes #2906)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11874 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -96,16 +96,16 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
*/
|
||||
destroy: function() {
|
||||
OpenLayers.Control.prototype.destroy.apply(this, arguments);
|
||||
for(var i = this.controls.length - 1 ; i >= 0; i--) {
|
||||
if(this.controls[i].events) {
|
||||
this.controls[i].events.un({
|
||||
"activate": this.redraw,
|
||||
"deactivate": this.redraw,
|
||||
scope: this
|
||||
for (var ctl, i = this.controls.length - 1; i >= 0; i--) {
|
||||
ctl = this.controls[i];
|
||||
if (ctl.events) {
|
||||
ctl.events.un({
|
||||
activate: this.iconOn,
|
||||
deactivate: this.iconOff
|
||||
});
|
||||
}
|
||||
OpenLayers.Event.stopObservingElement(this.controls[i].panel_div);
|
||||
this.controls[i].panel_div = null;
|
||||
OpenLayers.Event.stopObservingElement(ctl.panel_div);
|
||||
ctl.panel_div = null;
|
||||
}
|
||||
this.activeState = null;
|
||||
},
|
||||
@@ -172,13 +172,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
this.div.innerHTML = "";
|
||||
if (this.active) {
|
||||
for (var i=0, len=this.controls.length; i<len; i++) {
|
||||
var element = this.controls[i].panel_div;
|
||||
if (this.controls[i].active) {
|
||||
element.className = this.controls[i].displayClass + "ItemActive";
|
||||
} else {
|
||||
element.className = this.controls[i].displayClass + "ItemInactive";
|
||||
}
|
||||
this.div.appendChild(element);
|
||||
this.div.appendChild(this.controls[i].panel_div);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -195,7 +189,6 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
if (!this.active) { return false; }
|
||||
if (control.type == OpenLayers.Control.TYPE_BUTTON) {
|
||||
control.trigger();
|
||||
this.redraw();
|
||||
return;
|
||||
}
|
||||
if (control.type == OpenLayers.Control.TYPE_TOGGLE) {
|
||||
@@ -239,6 +232,7 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
// since they need to pass through.
|
||||
for (var i=0, len=controls.length; i<len; i++) {
|
||||
var element = document.createElement("div");
|
||||
element.className = controls[i].displayClass + "ItemInactive";
|
||||
controls[i].panel_div = element;
|
||||
if (controls[i].title != "") {
|
||||
controls[i].panel_div.title = controls[i].title;
|
||||
@@ -277,13 +271,30 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
control.deactivate();
|
||||
}
|
||||
control.events.on({
|
||||
"activate": this.redraw,
|
||||
"deactivate": this.redraw,
|
||||
scope: this
|
||||
activate: this.iconOn,
|
||||
deactivate: this.iconOff
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: iconOn
|
||||
* Internal use, for use only with "controls[i].events.on/un".
|
||||
*/
|
||||
iconOn: function() {
|
||||
var d = this.panel_div; // "this" refers to a control on panel!
|
||||
d.className = d.className.replace(/ItemInactive$/, "ItemActive");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: iconOff
|
||||
* Internal use, for use only with "controls[i].events.on/un".
|
||||
*/
|
||||
iconOff: function() {
|
||||
var d = this.panel_div; // "this" refers to a control on panel!
|
||||
d.className = d.className.replace(/ItemActive$/, "ItemInactive");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onClick
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user