Box Handler missing start callback, r=pgiraud (closes #3324)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12051 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -43,12 +43,16 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* control - {<OpenLayers.Control>}
|
* control - {<OpenLayers.Control>}
|
||||||
* callbacks - {Object} An object with a "done" property whose value is a
|
* callbacks - {Object} An object with a properties whose values are
|
||||||
* callback to be called when the box drag operation is finished.
|
* functions. Various callbacks described below.
|
||||||
* The callback should expect to recieve a single argument, the box
|
* options - {Object}
|
||||||
|
*
|
||||||
|
* Named callbacks:
|
||||||
|
* start - Called when the box drag operation starts.
|
||||||
|
* done - Called when the box drag operation is finished.
|
||||||
|
* The callback should expect to receive a single argument, the box
|
||||||
* bounds or a pixel. If the box dragging didn't span more than a 5
|
* bounds or a pixel. If the box dragging didn't span more than a 5
|
||||||
* pixel distance, a pixel will be returned instead of a bounds object.
|
* pixel distance, a pixel will be returned instead of a bounds object.
|
||||||
* options - {Object}
|
|
||||||
*/
|
*/
|
||||||
initialize: function(control, callbacks, options) {
|
initialize: function(control, callbacks, options) {
|
||||||
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
OpenLayers.Handler.prototype.initialize.apply(this, arguments);
|
||||||
@@ -89,9 +93,10 @@ OpenLayers.Handler.Box = OpenLayers.Class(OpenLayers.Handler, {
|
|||||||
* Method: startBox
|
* Method: startBox
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* evt - {Event}
|
* xy - {<OpenLayers.Pixel>}
|
||||||
*/
|
*/
|
||||||
startBox: function (xy) {
|
startBox: function (xy) {
|
||||||
|
this.callback("start", []);
|
||||||
this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
|
this.zoomBox = OpenLayers.Util.createDiv('zoomBox',
|
||||||
new OpenLayers.Pixel(-9999, -9999));
|
new OpenLayers.Pixel(-9999, -9999));
|
||||||
this.zoomBox.className = this.boxDivClassName;
|
this.zoomBox.className = this.boxDivClassName;
|
||||||
|
|||||||
+13
-7
@@ -3,16 +3,17 @@
|
|||||||
<script src="../OLLoader.js"></script>
|
<script src="../OLLoader.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function test_Handler_Box_constructor(t) {
|
function test_Handler_Box_constructor(t) {
|
||||||
t.plan(4);
|
t.plan(5);
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
control.id = Math.random();
|
control.id = Math.random();
|
||||||
var callbacks = {done: "bar"};
|
var callbacks = {start: "foo", done: "bar"};
|
||||||
var options = {bar: "foo"};
|
var options = {bar: "foo"};
|
||||||
|
|
||||||
var handler = new OpenLayers.Handler.Box(control, callbacks, options);
|
var handler = new OpenLayers.Handler.Box(control, callbacks, options);
|
||||||
|
|
||||||
t.eq(handler.control.id, control.id, "handler created with the correct control");
|
t.eq(handler.control.id, control.id, "handler created with the correct control");
|
||||||
t.eq(handler.callbacks.done, "bar", "handler created with the correct callback");
|
t.eq(handler.callbacks.start, "foo", "handler created with the correct start callback");
|
||||||
|
t.eq(handler.callbacks.done, "bar", "handler created with the correct done callback");
|
||||||
t.eq(handler.bar, "foo", "handler created with the correct options");
|
t.eq(handler.bar, "foo", "handler created with the correct options");
|
||||||
t.ok(handler.dragHandler instanceof OpenLayers.Handler.Drag, "drag handler created");
|
t.ok(handler.dragHandler instanceof OpenLayers.Handler.Drag, "drag handler created");
|
||||||
}
|
}
|
||||||
@@ -22,9 +23,14 @@
|
|||||||
var map = new OpenLayers.Map('map');
|
var map = new OpenLayers.Map('map');
|
||||||
var control = new OpenLayers.Control();
|
var control = new OpenLayers.Control();
|
||||||
map.addControl(control);
|
map.addControl(control);
|
||||||
var handler = new OpenLayers.Handler.Box(control, {done: function(e) {
|
var handler = new OpenLayers.Handler.Box(control, {
|
||||||
t.ok(e.equals(new OpenLayers.Bounds(5, 11, 11, 5)), "box result correct");
|
start: function(e) {
|
||||||
}});
|
t.ok(true, "start callback called");
|
||||||
|
},
|
||||||
|
done: function(e) {
|
||||||
|
t.ok(e.equals(new OpenLayers.Bounds(5, 11, 11, 5)), "box result correct");
|
||||||
|
}
|
||||||
|
});
|
||||||
handler.activate();
|
handler.activate();
|
||||||
|
|
||||||
// determine whether we can test the box position, the hidden frame
|
// determine whether we can test the box position, the hidden frame
|
||||||
@@ -39,7 +45,7 @@
|
|||||||
map.div.removeChild(testdiv);
|
map.div.removeChild(testdiv);
|
||||||
var testAll = !isNaN(left);
|
var testAll = !isNaN(left);
|
||||||
|
|
||||||
t.plan(testAll ? 10 : 2);
|
t.plan(testAll ? 11 : 3);
|
||||||
|
|
||||||
// we change NaN values to 0 values in the handler's
|
// we change NaN values to 0 values in the handler's
|
||||||
// boxOffsets object, this is to prevent "invalid
|
// boxOffsets object, this is to prevent "invalid
|
||||||
|
|||||||
Reference in New Issue
Block a user