Skip to content

Commit

Permalink
3180: treat UI and non-UI controls differently, on non-UI controls `d…
Browse files Browse the repository at this point in the history
…raw` method should be empty.
  • Loading branch information
jorix committed Feb 29, 2012
1 parent d7a3eca commit 890cf80
Show file tree
Hide file tree
Showing 31 changed files with 333 additions and 50 deletions.
10 changes: 10 additions & 0 deletions lib/OpenLayers/Control.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ OpenLayers.Control = OpenLayers.Class({
*/
type: null,

/**
* Property: outsideViewport
* {Boolean} This property is set to true when the control is added to the
* map if the control was created with a <div> property (to take value the
* control must have a draw method)
*/
outsideViewport: false,

/**
* Property: allowSelection
* {Boolean} By default, controls do not allow selection, because
Expand Down Expand Up @@ -248,6 +256,8 @@ OpenLayers.Control = OpenLayers.Class({
* on the page. If a div has not been created one is created. Controls
* with a visual component will almost always want to override this method
* to customize the look of control.
* Controls without a visual HTML component should override this method
* with a empty function.
*
* Parameters:
* px - {<OpenLayers.Pixel>} The top-left pixel position of the control
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/ArgParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ OpenLayers.Control.ArgParser = OpenLayers.Class(OpenLayers.Control, {
}
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: setCenter
* As soon as a baseLayer has been loaded, we center and zoom
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ OpenLayers.Control.Button = OpenLayers.Class(OpenLayers.Control, {
*/
type: OpenLayers.Control.TYPE_BUTTON,

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: trigger
* Called by a control panel when the button is clicked.
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/DragFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
return OpenLayers.Control.prototype.deactivate.apply(this, arguments);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: overFeature
* Called when the feature handler detects a mouse-over on a feature.
Expand Down
17 changes: 13 additions & 4 deletions lib/OpenLayers/Control/DragPan.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {


/**
* Method: draw
* Creates a Drag handler, using <panMap> and
* <panMapDone> as callbacks.
* Constructor: OpenLayers.Control.DragPan
* Create a DragPan control.
*
* Parameters:
* options - {Object} The options object.
*/
draw: function() {
initialize: function(options) {
OpenLayers.Control.prototype.initialize.call(this, options);
if(this.enableKinetic) {
var config = {interval: this.kineticInterval};
if(typeof this.enableKinetic === "object") {
Expand All @@ -95,6 +98,12 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: panMapStart
*/
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/DrawFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ OpenLayers.Control.DrawFeature = OpenLayers.Class(OpenLayers.Control, {
this.handler = new handler(this, this.callbacks, this.handlerOptions);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: drawFeature
*/
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/Geolocate.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ OpenLayers.Control.Geolocate = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: activate
* Activates the control.
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/GetFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,12 @@ OpenLayers.Control.GetFeature = OpenLayers.Class(OpenLayers.Control, {
);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: selectClick
* Called on click
Expand Down
46 changes: 20 additions & 26 deletions lib/OpenLayers/Control/Graticule.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,9 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
this.labelSymbolizer.labelAlign = "${labelAlign}";
this.labelSymbolizer.labelXOffset = "${xOffset}";
this.labelSymbolizer.labelYOffset = "${yOffset}";
},

/**
* APIMethod: destroy
*/
destroy: function() {
this.deactivate();
OpenLayers.Control.prototype.destroy.apply(this, arguments);
if (this.gratLayer) {
this.gratLayer.destroy();
this.gratLayer = null;
}
},

/**
* Method: draw
*
* initializes the graticule layer and does the initial update
*
* Returns:
* {DOMElement}
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
if (!this.gratLayer) {
var gratStyle = new OpenLayers.Style({},{
var gratStyle = new OpenLayers.Style({}, {
rules: [new OpenLayers.Rule({'symbolizer':
{"Point":this.labelSymbolizer,
"Line":this.lineSymbolizer}
Expand All @@ -159,10 +136,27 @@ OpenLayers.Control.Graticule = OpenLayers.Class(OpenLayers.Control, {
displayInLayerSwitcher: this.displayInLayerSwitcher
});
}
return this.div;
},

/**
/**
* APIMethod: destroy
*/
destroy: function() {
this.deactivate();
OpenLayers.Control.prototype.destroy.apply(this, arguments);
if (this.gratLayer) {
this.gratLayer.destroy();
this.gratLayer = null;
}
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* APIMethod: activate
*/
activate: function() {
Expand Down
10 changes: 7 additions & 3 deletions lib/OpenLayers/Control/KeyboardDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ OpenLayers.Control.KeyboardDefaults = OpenLayers.Class(OpenLayers.Control, {
*/

/**
* Method: draw
* Create handler.
* Method: initialize
* Create a KeyboardDefaults handler.
*
* Parameters:
* options - {Object} The options object.
*/
draw: function() {
initialize: function(options) {
OpenLayers.Control.prototype.initialize.call(this, options);
var observeElement = this.observeElement || document;
this.handler = new OpenLayers.Handler.Keyboard( this,
{"keydown": this.defaultKeyPress},
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/Measure.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ OpenLayers.Control.Measure = OpenLayers.Class(OpenLayers.Control, {
this.handler = new handler(this, this.callbacks, this.handlerOptions);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* APIMethod: deactivate
*/
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/ModifyFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ OpenLayers.Control.ModifyFeature = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Control.prototype.destroy.apply(this, []);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* APIMethod: activate
* Activate the control.
Expand Down
19 changes: 15 additions & 4 deletions lib/OpenLayers/Control/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,14 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
},

/**
* Method: draw
* Method: setMap
*
* Parameters:
* map - {<OpenLayers.Map>} The map.
*/
draw: function() {
setMap: function(map) {
OpenLayers.Control.prototype.setMap.call(this, map);

// disable right mouse context menu for support of right click events
if (this.handleRightClicks) {
this.map.viewPortDiv.oncontextmenu = OpenLayers.Function.False;
Expand All @@ -206,8 +211,8 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
);
this.zoomBox = new OpenLayers.Control.ZoomBox(
{map: this.map, keyMask: this.zoomBoxKeyMask});
this.dragPan.draw();
this.zoomBox.draw();
this.dragPan.setMap(map);
this.zoomBox.setMap(map);
this.handlers.wheel = new OpenLayers.Handler.MouseWheel(
this, {"up" : this.wheelUp,
"down": this.wheelDown},
Expand All @@ -219,6 +224,12 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
}
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: defaultClick
*
Expand Down
8 changes: 2 additions & 6 deletions lib/OpenLayers/Control/NavigationHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,9 @@ OpenLayers.Control.NavigationHistory = OpenLayers.Class(OpenLayers.Control, {

/**
* Method: draw
* Called when the control is added to the map.
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
this.next.draw();
this.previous.draw();
},
draw: function() {},

/**
* Method: previousTrigger
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/Pan.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ OpenLayers.Control.Pan = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Control.prototype.initialize.apply(this, [options]);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: trigger
*/
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/PinchZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, {
}, this.handlerOptions);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* APIMethod: activate
* Activate this control. Must be called after the control is added to a
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/SLDSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ OpenLayers.Control.SLDSelect = OpenLayers.Class(OpenLayers.Control, {
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: coupleLayerVisiblity
* Couple the selection layer and the source layer with respect to
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/SelectFeature.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ OpenLayers.Control.SelectFeature = OpenLayers.Class(OpenLayers.Control, {
}
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* Method: activate
* Activates the control.
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/Snapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ OpenLayers.Control.Snapping = OpenLayers.Class(OpenLayers.Control, {
this.geoToleranceCache = {};
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* APIMethod: setLayer
* Set the editable layer. Call the setLayer method if the editable layer
Expand Down
6 changes: 6 additions & 0 deletions lib/OpenLayers/Control/Split.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ OpenLayers.Control.Split = OpenLayers.Class(OpenLayers.Control, {
}
},

/**
* Method: draw
* This control does not have HTML component, so this method should be empty.
*/
draw: function() {},

/**
* APIMethod: setSource
* Set the source layer for edits layer.
Expand Down
Loading

0 comments on commit 890cf80

Please sign in to comment.