Skip to content

Commit

Permalink
Merge pull request #203 from joeybaker/patch-1
Browse files Browse the repository at this point in the history
EditToolbar now sets it's state correctly
  • Loading branch information
jacobtoye committed Oct 13, 2013
2 parents d7c4103 + 2923321 commit 5ac5672
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/edit/EditToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@ L.EditToolbar = L.Toolbar.extend({

_checkDisabled: function () {
var featureGroup = this.options.featureGroup,
hasLayers = featureGroup.getLayers().length === 0,
hasLayers = featureGroup.getLayers().length !== 0,
button;

if (this.options.edit) {
button = this._modes[L.EditToolbar.Edit.TYPE].button;

L.DomUtil.toggleClass(button, 'leaflet-disabled');
if (hasLayers) { L.DomUtil.removeClass(button, 'leaflet-disabled'); }
else { L.DomUtil.addClass(button, 'leaflet-disabled'); }

button.setAttribute(
'title',
Expand All @@ -142,7 +143,8 @@ L.EditToolbar = L.Toolbar.extend({
if (this.options.remove) {
button = this._modes[L.EditToolbar.Delete.TYPE].button;

L.DomUtil.toggleClass(button, 'leaflet-disabled');
if (hasLayers) { L.DomUtil.removeClass(button, 'leaflet-disabled'); }
else { L.DomUtil.addClass(button, 'leaflet-disabled'); }

button.setAttribute(
'title',
Expand All @@ -164,4 +166,4 @@ if (!L.DomUtil.toggleClass) {
}
}
});
}
}

0 comments on commit 5ac5672

Please sign in to comment.