Skip to content

Commit

Permalink
Merge pull request #247 from manubb/master
Browse files Browse the repository at this point in the history
Edit/delete handler bug.
  • Loading branch information
jacobtoye committed Dec 19, 2013
2 parents 76e1bea + cb6e48b commit 8ff11e9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/draw/handler/Draw.Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,21 @@ L.Draw.Feature = L.Handler.extend({
enable: function () {
if (this._enabled) { return; }

L.Handler.prototype.enable.call(this);

this.fire('enabled', { handler: this.type });

this._map.fire('draw:drawstart', { layerType: this.type });

L.Handler.prototype.enable.call(this);
},

disable: function () {
if (!this._enabled) { return; }

L.Handler.prototype.disable.call(this);

this.fire('disabled', { handler: this.type });

this._map.fire('draw:drawstop', { layerType: this.type });

this.fire('disabled', { handler: this.type });
},

addHooks: function () {
Expand Down
7 changes: 6 additions & 1 deletion src/edit/EditToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ L.EditToolbar = L.Toolbar.extend({

L.Toolbar.prototype.removeToolbar.call(this);
},

_handlerActivated: function (e) {
if (this._activeMode && this._activeMode.handler.enabled()) {
this._activeMode.handler.revertLayers();
}
L.Toolbar.prototype._handlerActivated.call(this, e);
},
disable: function () {
if (!this.enabled()) { return; }

Expand Down
16 changes: 7 additions & 9 deletions src/edit/handler/EditToolbar.Delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,26 @@ L.EditToolbar.Delete = L.Handler.extend({
if (this._enabled || !this._hasAvailableLayers()) {
return;
}
this.fire('enabled', { handler: this.type});
//this disable other handlers

L.Handler.prototype.enable.call(this);
this._map.fire('draw:deletestart', { handler: this.type });
//allow drawLayer to be updated before beginning deletion.

L.Handler.prototype.enable.call(this);
this._deletableLayers
.on('layeradd', this._enableLayerDelete, this)
.on('layerremove', this._disableLayerDelete, this);

this.fire('enabled', { handler: this.type});
this._map.fire('draw:editstart', { handler: this.type });
},

disable: function () {
if (!this._enabled) { return; }

L.Handler.prototype.disable.call(this);

this._deletableLayers
.off('layeradd', this._enableLayerDelete, this)
.off('layerremove', this._disableLayerDelete, this);

L.Handler.prototype.disable.call(this);
this._map.fire('draw:deletestop', { handler: this.type });
this.fire('disabled', { handler: this.type});
this._map.fire('draw:editstop', { handler: this.type });
},

addHooks: function () {
Expand Down
16 changes: 7 additions & 9 deletions src/edit/handler/EditToolbar.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,26 @@ L.EditToolbar.Edit = L.Handler.extend({
if (this._enabled || !this._hasAvailableLayers()) {
return;
}
this.fire('enabled', {handler: this.type});
//this disable other handlers

L.Handler.prototype.enable.call(this);
this._map.fire('draw:editstart', { handler: this.type });
//allow drawLayer to be updated before beginning edition.

L.Handler.prototype.enable.call(this);
this._featureGroup
.on('layeradd', this._enableLayerEdit, this)
.on('layerremove', this._disableLayerEdit, this);

this.fire('enabled', {handler: this.type});
this._map.fire('draw:editstart', { handler: this.type });
},

disable: function () {
if (!this._enabled) { return; }

this.fire('disabled', {handler: this.type});
this._map.fire('draw:editstop', { handler: this.type });

this._featureGroup
.off('layeradd', this._enableLayerEdit, this)
.off('layerremove', this._disableLayerEdit, this);

L.Handler.prototype.disable.call(this);
this._map.fire('draw:editstop', { handler: this.type });
this.fire('disabled', {handler: this.type});
},

addHooks: function () {
Expand Down

0 comments on commit 8ff11e9

Please sign in to comment.