Skip to content

Commit

Permalink
reset and re-add deleteKeyBinding (#130)
Browse files Browse the repository at this point in the history
  • Loading branch information
sashadev-sky authored and jywarren committed Feb 18, 2019
1 parent 05a8c7d commit 90c9777
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/edit/DistortableImage.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ L.DistortableImage.Edit = L.Handler.extend({
76: '_toggleLock', // l
79: '_toggleOutline', // o
82: '_toggleRotateDistort', // r
84: '_toggleTransparency', // t
84: '_toggleTransparency', // t
46: "_removeOverlay", // delete windows / delete + fn mac
8: "_removeOverlay" // backspace windows / delete mac
}
},

Expand Down Expand Up @@ -92,7 +94,12 @@ L.DistortableImage.Edit = L.Handler.extend({
L.DomEvent.off(window, 'keydown', this._onKeyDown, this);

overlay.fire('deselect');
},
},

confirmDelete: function () {
return window.confirm("Are you sure you want to delete?");
},


_rotateBy: function(angle) {
var overlay = this._overlay,
Expand Down Expand Up @@ -250,7 +257,19 @@ L.DistortableImage.Edit = L.Handler.extend({
}

L.DomEvent.stopPropagation(event);
},
},

_removeOverlay: function () {
var overlay = this._overlay;
if (this._mode !== "lock") {
var choice = this.confirmDelete();
if (choice) {
overlay._map.removeLayer(overlay);
overlay.fire('delete');
this.disable();
}
}
},


// Based on https://github.com/publiclab/mapknitter/blob/8d94132c81b3040ae0d0b4627e685ff75275b416/app/assets/javascripts/mapknitter/Map.js#L47-L82
Expand Down

0 comments on commit 90c9777

Please sign in to comment.