Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

EditToolbar now sets it's state correctly #203

Merged
merged 1 commit into from

2 participants

@joeybaker

Properly determines if it has layers, and then sets the button's disabled class.

fixes #202

@joeybaker joeybaker EditToolbar now sets it's state correctly
Properly determines if it has layers, and then sets the button's disabled class.

fixes #202
2923321
@jacobtoye jacobtoye merged commit 5ac5672 into from
@joeybaker joeybaker deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 12, 2013
  1. @joeybaker

    EditToolbar now sets it's state correctly

    joeybaker authored
    Properly determines if it has layers, and then sets the button's disabled class.
    
    fixes #202
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/edit/EditToolbar.js
View
10 src/edit/EditToolbar.js
@@ -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',
@@ -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',
@@ -164,4 +166,4 @@ if (!L.DomUtil.toggleClass) {
}
}
});
-}
+}
Something went wrong with that request. Please try again.