|
1 | | -(function (L, setTimeout) { |
2 | | - |
| 1 | +(function (factory) { |
| 2 | + var L; |
| 3 | + if (typeof define === 'function' && define.amd) { |
| 4 | + // AMD |
| 5 | + define(['leaflet'], function(L) { |
| 6 | + factory(L, setTimeout); |
| 7 | + }); |
| 8 | + } else if (typeof module !== 'undefined') { |
| 9 | + // Node/CommonJS |
| 10 | + L = require('leaflet'); |
| 11 | + module.exports = factory(L, setTimeout); |
| 12 | + } else { |
| 13 | + // Browser globals |
| 14 | + if (typeof window.L === 'undefined') |
| 15 | + throw 'Leaflet must be loaded first'; |
| 16 | + factory(window.L, setTimeout); |
| 17 | + } |
| 18 | +}(function (L, setTimeout) { |
3 | 19 | var _controlContainer, |
4 | 20 | _map, |
5 | 21 | _zoomThreshold, |
6 | 22 | _hideClass = 'leaflet-control-edit-hidden', |
7 | 23 | _anchorClass = 'leaflet-control-edit-in-osm-toggle', |
8 | 24 |
|
9 | 25 | _Widgets = { |
| 26 | + SimpleButton: function (config) { |
| 27 | + var className = (config && config.className) || 'leaflet-control-edit-in-osm-simple', |
| 28 | + helpText = config && config.helpText, |
| 29 | + addEditors = (config && config.addEditors) || function (container, editors) { |
| 30 | + addEditorToWidget(container, editors[0], helpText); |
| 31 | + }; |
| 32 | + |
| 33 | + return { |
| 34 | + className: className, |
| 35 | + helpText: helpText, |
| 36 | + addEditors: addEditors |
| 37 | + }; |
| 38 | + }, |
10 | 39 | MultiButton: function (config) { |
11 | 40 | var className = 'leaflet-control-edit-in-osm', |
12 | 41 | helpText = "Open this map extent in a map editor to provide more accurate data to OpenStreetMap", |
|
44 | 73 | buildUrl = function (map) { |
45 | 74 | return this.url + [ |
46 | 75 | map.getZoom(), |
47 | | - map.getCenter().wrap().lng, |
48 | | - map.getCenter().wrap().lat |
| 76 | + map.getCenter().wrap().lat, |
| 77 | + map.getCenter().wrap().lng |
49 | 78 | ].join('/'); |
50 | 79 | }; |
51 | 80 | return { |
|
151 | 180 | widgetSmallName = typeof(widget) === 'string' ? widget.toLowerCase() : ''; |
152 | 181 |
|
153 | 182 | // setup widget from string or object |
154 | | - if (widgetSmallName === "multibutton") { |
| 183 | + if (widgetSmallName === "simplebutton") { |
| 184 | + this.options.widget = new _Widgets.SimpleButton(this.options.widgetOptions); |
| 185 | + } else if (widgetSmallName === "multibutton") { |
155 | 186 | this.options.widget = new _Widgets.MultiButton(this.options.widgetOptions); |
156 | 187 | } else if (widgetSmallName === "attributionbox") { |
157 | 188 | this.options.widget = new _Widgets.AttributionBox(this.options.widgetOptions); |
|
206 | 237 | } |
207 | 238 | }); |
208 | 239 |
|
209 | | -})(L, setTimeout); |
| 240 | +})); |
0 commit comments