vendor: 4,605 bytes, lines 1-194
1/*L.Map.mergeOptions({ 2 editControl: true 3 });*/ 4/** 5 * @class L.EditToolbar 6 * @aka EditToolbar 7 */ 8L.EditToolbar = L.Toolbar.extend({ 9 statics: { 10 TYPE: 'edit' 11 }, 12 13 options: { 14 edit: { 15 selectedPathOptions: { 16 dashArray: '10, 10', 17 18 fill: true, 19 fillColor: '#fe57a1', 20 fillOpacity: 0.1, 21 22 // Whether to user the existing layers color 23 maintainColor: false 24 } 25 }, 26 remove: {}, 27 poly: null, 28 featureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */ 29 }, 30 31 // @method intialize(): void 32 initialize: function (options) { 33 // Need to set this manually since null is an acceptable value here 34 if (options.edit) { 35 if (typeof options.edit.selectedPathOptions === 'undefined') { 36 options.edit.selectedPathOptions = this.options.edit.selectedPathOptions; 37 } 38 options.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions); 39 } 40 41 if (options.remove) { 42 options.remove = L.extend({}, this.options.remove, options.remove); 43 } 44 45 if (options.poly) { 46 options.poly = L.extend({}, this.options.poly, options.poly); 47 } 48 49 this._toolbarClass = 'leaflet-draw-edit'; 50 L.Toolbar.prototype.initialize.call(this, options); 51 52 this._selectedFeatureCount = 0; 53 }, 54 55 // @method getModeHandlers(): object 56 // Get mode handlers information 57 getModeHandlers: function (map) { 58 var featureGroup = this.options.featureGroup; 59 return [ 60 { 61 enabled: this.options.edit, 62 handler: new L.EditToolbar.Edit(map, { 63 featureGroup: featureGroup, 64 selectedPathOptions: this.options.edit.selectedPathOptions, 65 poly: this.options.poly 66 }), 67 title: L.drawLocal.edit.toolbar.buttons.edit 68 }, 69 { 70 enabled: this.options.remove, 71 handler: new L.EditToolbar.Delete(map, { 72 featureGroup: featureGroup 73 }), 74 title: L.drawLocal.edit.toolbar.buttons.remove 75 } 76 ]; 77 }, 78 79 // @method getActions(): object 80 // Get actions information 81 getActions: function (handler) { 82 var actions = [ 83 { 84 title: L.drawLocal.edit.toolbar.actions.save.title, 85 text: L.drawLocal.edit.toolbar.actions.save.text, 86 callback: this._save, 87 context: this 88 }, 89 { 90 title: L.drawLocal.edit.toolbar.actions.cancel.title, 91 text: L.drawLocal.edit.toolbar.actions.cancel.text, 92 callback: this.disable, 93 context: this 94 } 95 ]; 96 97 if (handler.removeAllLayers) { 98 actions.push({ 99 title: L.drawLocal.edit.toolbar.actions.clearAll.title, 100 text: L.drawLocal.edit.toolbar.actions.clearAll.text, 101 callback: this._clearAllLayers, 102 context: this 103 }); 104 } 105 106 return actions; 107 }, 108 109 // @method addToolbar(map): L.DomUtil 110 // Adds the toolbar to the map 111 addToolbar: function (map) { 112 var container = L.Toolbar.prototype.addToolbar.call(this, map); 113 114 this._checkDisabled(); 115 116 this.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this); 117 118 return container; 119 }, 120 121 // @method removeToolbar(): void 122 // Removes the toolbar from the map 123 removeToolbar: function () { 124 this.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this); 125 126 L.Toolbar.prototype.removeToolbar.call(this); 127 }, 128 129 // @method disable(): void 130 // Disables the toolbar 131 disable: function () { 132 if (!this.enabled()) { 133 return; 134 } 135 136 this._activeMode.handler.revertLayers(); 137 138 L.Toolbar.prototype.disable.call(this); 139 }, 140 141 _save: function () { 142 this._activeMode.handler.save(); 143 if (this._activeMode) { 144 this._activeMode.handler.disable(); 145 } 146 }, 147 148 _clearAllLayers: function () { 149 this._activeMode.handler.removeAllLayers(); 150 if (this._activeMode) { 151 this._activeMode.handler.disable(); 152 } 153 }, 154 155 _checkDisabled: function () { 156 var featureGroup = this.options.featureGroup, 157 hasLayers = featureGroup.getLayers().length !== 0, 158 button; 159 160 if (this.options.edit) { 161 button = this._modes[L.EditToolbar.Edit.TYPE].button; 162 163 if (hasLayers) { 164 L.DomUtil.removeClass(button, 'leaflet-disabled'); 165 } else { 166 L.DomUtil.addClass(button, 'leaflet-disabled'); 167 } 168 169 button.setAttribute( 170 'title', 171 hasLayers ? 172 L.drawLocal.edit.toolbar.buttons.edit 173 : L.drawLocal.edit.toolbar.buttons.editDisabled 174 ); 175 } 176 177 if (this.options.remove) { 178 button = this._modes[L.EditToolbar.Delete.TYPE].button; 179 180 if (hasLayers) { 181 L.DomUtil.removeClass(button, 'leaflet-disabled'); 182 } else { 183 L.DomUtil.addClass(button, 'leaflet-disabled'); 184 } 185 186 button.setAttribute( 187 'title', 188 hasLayers ? 189 L.drawLocal.edit.toolbar.buttons.remove 190 : L.drawLocal.edit.toolbar.buttons.removeDisabled 191 ); 192 } 193 } 194});
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.