[Control.Panel] place code creating the control markup in a separate function
This commit is contained in:
@@ -245,26 +245,56 @@ OpenLayers.Control.Panel = OpenLayers.Class(OpenLayers.Control, {
|
||||
controls = [controls];
|
||||
}
|
||||
this.controls = this.controls.concat(controls);
|
||||
|
||||
// Give each control a panel_div which will be used later.
|
||||
// Access to this div is via the panel_div attribute of the
|
||||
// control added to the panel.
|
||||
// Also, stop mousedowns and clicks, but don't stop mouseup,
|
||||
// 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 olButton";
|
||||
controls[i].panel_div = element;
|
||||
if (controls[i].title != "") {
|
||||
controls[i].panel_div.title = controls[i].title;
|
||||
var control = controls[i],
|
||||
element = this.createControlMarkup(control);
|
||||
element.className = control.displayClass + "ItemInactive olButton";
|
||||
if (control.title != "") {
|
||||
element.title = control.title;
|
||||
}
|
||||
}
|
||||
controls[i].panel_div = element;
|
||||
}
|
||||
|
||||
if (this.map) { // map.addControl() has already been called on the panel
|
||||
this.addControlsToMap(controls);
|
||||
this.redraw();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* APIMethod: createControlMarkup
|
||||
* This function just creates a div for the control. If specific HTML
|
||||
* markup is needed this function can be overridden in specific classes,
|
||||
* or at panel instantiation time:
|
||||
*
|
||||
* Example:
|
||||
* (code)
|
||||
* var panel = new OpenLayers.Control.Panel({
|
||||
* defaultControl: control,
|
||||
* // ovverride createControlMarkup to create actual buttons
|
||||
* // including texts wrapped into span elements.
|
||||
* createControlMarkup: function(control) {
|
||||
* var button = document.createElement('button'),
|
||||
* span = document.createElement('span');
|
||||
* if (control.text) {
|
||||
* span.innerHTML = control.text;
|
||||
* }
|
||||
* return button;
|
||||
* }
|
||||
* });
|
||||
* (end)
|
||||
*
|
||||
* Parameters:
|
||||
* control - {<OpenLayers.Control>} The control to create the HTML
|
||||
* markup for.
|
||||
*
|
||||
* Returns:
|
||||
* {DOMElement} The markup.
|
||||
*/
|
||||
createControlMarkup: function(control) {
|
||||
return document.createElement("div");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: addControlsToMap
|
||||
|
||||
Reference in New Issue
Block a user