leaflet-editable-textbox
Advanced tools
Comparing version 1.0.20 to 1.0.21
{ | ||
"name": "leaflet-editable-textbox", | ||
"version": "1.0.20", | ||
"version": "1.0.21", | ||
"description": "TextBox for Leaflet.Editable", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,3 +12,4 @@ /** | ||
textareaPadding: 1, | ||
placeholder: 'Please, add text here ...' | ||
placeholder: 'Please, add text here ...', | ||
updateDelay: 100 | ||
}, | ||
@@ -33,2 +34,6 @@ | ||
// Reduce amount of updateBounds | ||
this._updateTextAreaBounds = L.Util.throttle( | ||
this._updateTextAreaBounds, this.options.updateDelay, this); | ||
L.Editable.RectangleEditor.prototype.initialize | ||
@@ -51,8 +56,19 @@ .call(this, map, feature, options); | ||
onVertexMarkerDragEnd: function (evt) { | ||
L.Editable.RectangleEditor.prototype.onVertexMarkerDragEnd.call(this, evt); | ||
this._focus(); | ||
}, | ||
_createContainer: function() { | ||
if (null === this._container) { | ||
this._container = L.DomUtil.create('textarea', | ||
var textArea = this._container; | ||
if (!textArea) { | ||
textArea = this._container = L.DomUtil.create('textarea', | ||
'leaflet-zoom-animated leaflet-textbox'); | ||
var style = this._container.style; | ||
textArea.style.position = 'absolute'; | ||
textArea.setAttribute('spellcheck', false); | ||
var style = textArea.style; | ||
style.resize = 'none'; | ||
@@ -62,20 +78,21 @@ style.border = 'none'; | ||
style.backgroundColor = 'transparent'; | ||
style.overflow = 'hidden'; | ||
style.overflow = 'hidden'; | ||
if (this.options.placeholder) { | ||
this._container.setAttribute('placeholder', this.options.placeholder); | ||
textArea.setAttribute('placeholder', this.options.placeholder); | ||
} | ||
this.updateStyle(); | ||
this.map.getPane('markerPane').appendChild(this._container); | ||
this._text = this.feature.getText(); | ||
this._text = this.feature.getText(); | ||
if (this._text) { | ||
this._container.value = this._text; | ||
textArea.value = this._text; | ||
} | ||
L.DomEvent.addListener(this._container, 'keypress', | ||
L.DomEvent.stopPropagation); | ||
L.DomEvent.disableClickPropagation(this._container); | ||
L.DomEvent.addListener(textArea, 'keypress', L.DomEvent.stopPropagation); | ||
L.DomEvent.disableClickPropagation(textArea); | ||
this._updateTextAreaBounds(); | ||
this.map.getPane('markerPane').appendChild(textArea); | ||
this._focus(); | ||
} | ||
@@ -139,4 +156,7 @@ }, | ||
_updateBounds: L.Editable.RectangleEditor.prototype.updateBounds, | ||
updateBounds: function (bounds) { | ||
L.Editable.RectangleEditor.prototype.updateBounds.call(this, bounds); | ||
this._updateBounds(bounds); | ||
return this._updateTextAreaBounds(); | ||
@@ -178,3 +198,2 @@ }, | ||
var feature = this.feature; | ||
var bounds; | ||
var textArea = this._container; | ||
@@ -185,5 +204,5 @@ var map = this.map; | ||
if (null !== textArea) { | ||
if (null !== bounds) { | ||
bounds = feature.getBounds(); | ||
if (bounds) { | ||
scale = feature._getScale(map.getZoom()); | ||
bounds = feature.getBounds(); | ||
center = map.latLngToLayerPoint(bounds.getCenter()); | ||
@@ -200,5 +219,2 @@ pos = map.latLngToLayerPoint(bounds.getNorthWest()); | ||
textArea.style.display = ''; | ||
textArea.style.position = 'absolute'; | ||
textArea.setAttribute('spellcheck', false); | ||
this._focus(); | ||
} else { | ||
@@ -205,0 +221,0 @@ textArea.style.display = 'none'; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23
2750505
18159