diff --git a/lib/OpenLayers/Control.js b/lib/OpenLayers/Control.js index cd5672879c..bf401a888a 100644 --- a/lib/OpenLayers/Control.js +++ b/lib/OpenLayers/Control.js @@ -304,11 +304,6 @@ OpenLayers.Control = OpenLayers.Class({ this.handler.activate(); } this.active = true; - if(this.map) { - OpenLayers.Element.addClass( - this.map.div, this.displayClass + "Active" - ); - } this.events.triggerEvent("activate"); return true; }, @@ -328,11 +323,6 @@ OpenLayers.Control = OpenLayers.Class({ this.handler.deactivate(); } this.active = false; - if(this.map) { - OpenLayers.Element.removeClass( - this.map.div, this.displayClass + "Active" - ); - } this.events.triggerEvent("deactivate"); return true; } diff --git a/lib/OpenLayers/Control/DragFeature.js b/lib/OpenLayers/Control/DragFeature.js index 110ff741da..4c6ac9a767 100644 --- a/lib/OpenLayers/Control/DragFeature.js +++ b/lib/OpenLayers/Control/DragFeature.js @@ -162,9 +162,6 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, { this.feature = null; this.dragging = false; this.lastPixel = null; - OpenLayers.Element.removeClass( - this.map.div, this.displayClass + "Over" - ); return OpenLayers.Control.prototype.deactivate.apply(this, arguments); }, @@ -181,7 +178,8 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, { this.feature = feature; this.handlers.drag.activate(); this.over = true; - OpenLayers.Element.addClass(this.map.div, this.displayClass + "Over"); + // TBD replace with CSS classes + this.map.div.style.cursor = "move"; } else { if(this.feature.id == feature.id) { this.over = true; @@ -230,6 +228,12 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, { upFeature: function(pixel) { if(!this.over) { this.handlers.drag.deactivate(); + // TBD replace with CSS classes + this.map.div.style.cursor = "default"; + } else { + // the drag handler itself resetted the cursor, so + // set it back to "move" here + this.map.div.style.cursor = "move"; } }, @@ -256,9 +260,8 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, { if(!this.handlers.drag.dragging) { this.over = false; this.handlers.drag.deactivate(); - OpenLayers.Element.removeClass( - this.map.div, this.displayClass + "Over" - ); + // TBD replace with CSS classes + this.map.div.style.cursor = "default"; this.feature = null; } else { if(this.feature.id == feature.id) { diff --git a/lib/OpenLayers/Handler/Box.js b/lib/OpenLayers/Handler/Box.js index 8169027fc7..c9f7a3e82d 100644 --- a/lib/OpenLayers/Handler/Box.js +++ b/lib/OpenLayers/Handler/Box.js @@ -83,9 +83,8 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, { this.zoomBox.style.zIndex = this.map.Z_INDEX_BASE["Popup"] - 1; this.map.viewPortDiv.appendChild(this.zoomBox); - OpenLayers.Element.addClass( - this.map.div, "olDrawBox" - ); + // TBD: use CSS classes instead + this.map.div.style.cursor = "crosshair"; }, /** @@ -134,6 +133,9 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, { } this.removeBox(); + // TBD: use CSS classes instead + this.map.div.style.cursor = ""; + this.callback("done", [result]); }, @@ -145,10 +147,6 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, { this.map.viewPortDiv.removeChild(this.zoomBox); this.zoomBox = null; this.boxCharacteristics = null; - OpenLayers.Element.removeClass( - this.map.div, "olDrawBox" - ); - }, /** diff --git a/lib/OpenLayers/Handler/Drag.js b/lib/OpenLayers/Handler/Drag.js index 916aef4895..bd1643b375 100644 --- a/lib/OpenLayers/Handler/Drag.js +++ b/lib/OpenLayers/Handler/Drag.js @@ -177,9 +177,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { this.started = true; this.start = evt.xy; this.last = evt.xy; - OpenLayers.Element.addClass( - this.map.div, "olDragDown" - ); + // TBD replace with CSS classes + this.map.div.style.cursor = "move"; this.down(evt); this.callback("down", [evt.xy]); OpenLayers.Event.stop(evt); @@ -248,9 +247,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { var dragged = (this.start != this.last); this.started = false; this.dragging = false; - OpenLayers.Element.removeClass( - this.map.div, "olDragDown" - ); + // TBD replace with CSS classes + this.map.div.style.cursor = ""; this.up(evt); this.callback("up", [evt.xy]); if(dragged) { @@ -276,9 +274,8 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { var dragged = (this.start != this.last); this.started = false; this.dragging = false; - OpenLayers.Element.removeClass( - this.map.div, "olDragDown" - ); + // TBD replace with CSS classes + this.map.div.style.cursor = ""; this.out(evt); this.callback("out", []); if(dragged) { @@ -339,9 +336,6 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { this.start = null; this.last = null; deactivated = true; - OpenLayers.Element.removeClass( - this.map.div, "olDragDown" - ); } return deactivated; }, diff --git a/tests/Control/DragFeature.html b/tests/Control/DragFeature.html index 3d0be1def9..1768c6a61c 100644 --- a/tests/Control/DragFeature.html +++ b/tests/Control/DragFeature.html @@ -171,7 +171,7 @@ } function test_Control_DragFeature_up(t) { - t.plan(6); + t.plan(7); var map = new OpenLayers.Map("map"); var layer = new OpenLayers.Layer.Vector(); map.addLayer(layer); @@ -189,8 +189,8 @@ map.events.triggerEvent("mousemove", {type: "mousemove"}); t.eq(control.over, true, "mouseover on a feature sets the over property to true"); - t.ok(OpenLayers.Element.hasClass(control.map.div, "olControlDragFeatureOver"), - "mouseover on a feature adds class name to map container"); + t.eq(control.map.div.style.cursor, "move", + "mouseover on a feature sets the cursor to move"); t.eq(control.handlers.drag.active, true, "mouseover on a feature activates drag handler"); @@ -198,6 +198,8 @@ // over the dragged feature control.handlers.drag.started = true; map.events.triggerEvent("mouseup", {type: "mouseup"}); + t.eq(control.map.div.style.cursor, "move", + "mouseup while still over dragged feature does not reset cursor to default"); t.eq(control.handlers.drag.active, true, "mouseup while still over dragged feature does not deactivate drag handler"); @@ -206,12 +208,12 @@ control.handlers.drag.started = true; control.over = false; map.events.triggerEvent("mouseup", {type: "mouseup"}); + t.eq(control.map.div.style.cursor, "default", + "mouseup resets cursor to default"); t.eq(control.handlers.drag.active, false, "mouseup deactivates drag handler"); control.deactivate(); - t.ok(!OpenLayers.Element.hasClass(control.map.div, "olControlDragFeatureOver"), - "deactivate removes class name from map container"); } function test_Control_DragFeature_done(t) { diff --git a/theme/default/style.css b/theme/default/style.css index 02a434b49d..ca1d66602f 100644 --- a/theme/default/style.css +++ b/theme/default/style.css @@ -327,17 +327,4 @@ div.olControlMousePosition { .olCursorWait { cursor: wait; -} -.olDragDown { - cursor: move; -} -.olDrawBox { - cursor: crosshair; -} -.olControlDragFeatureOver { - cursor: move; -} -.olControlDragFeatureActive.olControlDragFeatureOver.olDragDown { - cursor: -moz-grabbing; -} - +} \ No newline at end of file