Let's not over-engineer things (see #164).
This commit is contained in:
@@ -64,20 +64,11 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
|
|||||||
* <OpenLayers.Events> instances.
|
* <OpenLayers.Events> instances.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* options - {<OpenLayers.Events>|Object} Target instance of
|
|
||||||
* <OpenLayers.Events> or configuration properties for this
|
|
||||||
* <OpenLayers.Events.buttonclick> instance.
|
|
||||||
*
|
|
||||||
* Required configuration properties:
|
|
||||||
* target - {<OpenLayers.Events>} The events instance that the buttonclick
|
* target - {<OpenLayers.Events>} The events instance that the buttonclick
|
||||||
* event will be triggered on.
|
* event will be triggered on.
|
||||||
*/
|
*/
|
||||||
initialize: function(options) {
|
initialize: function(target) {
|
||||||
if (options instanceof OpenLayers.Events) {
|
this.target = target;
|
||||||
options = {target: options};
|
|
||||||
}
|
|
||||||
OpenLayers.Util.extend(this, options);
|
|
||||||
|
|
||||||
for (var i=this.events.length-1; i>=0; --i) {
|
for (var i=this.events.length-1; i>=0; --i) {
|
||||||
this.target.register(this.events[i], this, this.buttonClick, {
|
this.target.register(this.events[i], this, this.buttonClick, {
|
||||||
extension: true
|
extension: true
|
||||||
@@ -118,12 +109,12 @@ OpenLayers.Events.buttonclick = OpenLayers.Class({
|
|||||||
if (this.cancelRegEx.test(evt.type)) {
|
if (this.cancelRegEx.test(evt.type)) {
|
||||||
delete this._buttonStarted;
|
delete this._buttonStarted;
|
||||||
}
|
}
|
||||||
OpenLayers.Event.stop(evt, false);
|
OpenLayers.Event.stop(evt);
|
||||||
propagate = false;
|
propagate = false;
|
||||||
}
|
}
|
||||||
if (this.startRegEx.test(evt.type)) {
|
if (this.startRegEx.test(evt.type)) {
|
||||||
this._buttonStarted = true;
|
this._buttonStarted = true;
|
||||||
OpenLayers.Event.stop(evt, false);
|
OpenLayers.Event.stop(evt);
|
||||||
propagate = false;
|
propagate = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -20,10 +20,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_ButtonClick(t) {
|
function test_ButtonClick(t) {
|
||||||
t.plan(2);
|
t.plan(1);
|
||||||
events = new OpenLayers.Events({}, element);
|
events = new OpenLayers.Events({}, element);
|
||||||
buttonClick = new OpenLayers.Events.buttonclick({target: events});
|
|
||||||
t.ok(buttonClick.target === events, "target set from options argument");
|
|
||||||
buttonClick = new OpenLayers.Events.buttonclick(events);
|
buttonClick = new OpenLayers.Events.buttonclick(events);
|
||||||
t.ok(buttonClick.target === events, "target set from constructor arg");
|
t.ok(buttonClick.target === events, "target set from constructor arg");
|
||||||
buttonClick.destroy();
|
buttonClick.destroy();
|
||||||
|
|||||||
Reference in New Issue
Block a user