Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EditToolbar now sets it's state correctly #203

Merged
merged 1 commit into from Oct 13, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/edit/EditToolbar.js
Expand Up @@ -123,13 +123,14 @@ L.EditToolbar = L.Toolbar.extend({


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


if (this.options.edit) { if (this.options.edit) {
button = this._modes[L.EditToolbar.Edit.TYPE].button; 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( button.setAttribute(
'title', 'title',
Expand All @@ -142,7 +143,8 @@ L.EditToolbar = L.Toolbar.extend({
if (this.options.remove) { if (this.options.remove) {
button = this._modes[L.EditToolbar.Delete.TYPE].button; 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( button.setAttribute(
'title', 'title',
Expand All @@ -164,4 +166,4 @@ if (!L.DomUtil.toggleClass) {
} }
} }
}); });
} }