vendor: 3,005 bytes, lines 1-118
1L.Draw = L.Draw || {}; 2/** 3 * @class L.Draw.Tooltip 4 * @aka Tooltip 5 * 6 * The tooltip class â it is used to display the tooltip while drawing 7 * This will be depreciated 8 * 9 * @example 10 * 11 * ```js 12 * var tooltip = L.Draw.Tooltip(); 13 * ``` 14 * 15 */ 16L.Draw.Tooltip = L.Class.extend({ 17 18 // @section Methods for modifying draw state 19 20 // @method initialize(map): void 21 // Tooltip constructor 22 initialize: function (map) { 23 this._map = map; 24 this._popupPane = map._panes.popupPane; 25 this._visible = false; 26 27 this._container = map.options.drawControlTooltips ? 28 L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null; 29 this._singleLineLabel = false; 30 31 this._map.on('mouseout', this._onMouseOut, this); 32 }, 33 34 // @method dispose(): void 35 // Remove Tooltip DOM and unbind events 36 dispose: function () { 37 this._map.off('mouseout', this._onMouseOut, this); 38 39 if (this._container) { 40 this._popupPane.removeChild(this._container); 41 this._container = null; 42 } 43 }, 44 45 // @method updateContent(labelText): this 46 // Changes the tooltip text to string in function call 47 updateContent: function (labelText) { 48 if (!this._container) { 49 return this; 50 } 51 labelText.subtext = labelText.subtext || ''; 52 53 // update the vertical position (only if changed) 54 if (labelText.subtext.length === 0 && !this._singleLineLabel) { 55 L.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single'); 56 this._singleLineLabel = true; 57 } 58 else if (labelText.subtext.length > 0 && this._singleLineLabel) { 59 L.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single'); 60 this._singleLineLabel = false; 61 } 62 63 this._container.innerHTML = 64 (labelText.subtext.length > 0 ? 65 '<span class="leaflet-draw-tooltip-subtext">' + labelText.subtext + '</span>' + '<br />' : '') + 66 '<span>' + labelText.text + '</span>'; 67 68 if (!labelText.text && !labelText.subtext) { 69 this._visible = false; 70 this._container.style.visibility = 'hidden'; 71 } else { 72 this._visible = true; 73 this._container.style.visibility = 'inherit'; 74 } 75 76 return this; 77 }, 78 79 // @method updatePosition(latlng): this 80 // Changes the location of the tooltip 81 updatePosition: function (latlng) { 82 var pos = this._map.latLngToLayerPoint(latlng), 83 tooltipContainer = this._container; 84 85 if (this._container) { 86 if (this._visible) { 87 tooltipContainer.style.visibility = 'inherit'; 88 } 89 L.DomUtil.setPosition(tooltipContainer, pos); 90 } 91 92 return this; 93 }, 94 95 // @method showAsError(): this 96 // Applies error class to tooltip 97 showAsError: function () { 98 if (this._container) { 99 L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip'); 100 } 101 return this; 102 }, 103 104 // @method removeError(): this 105 // Removes the error class from the tooltip 106 removeError: function () { 107 if (this._container) { 108 L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip'); 109 } 110 return this; 111 }, 112 113 _onMouseOut: function () { 114 if (this._container) { 115 this._container.style.visibility = 'hidden'; 116 } 117 } 118});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.