1 L.OSM.Zoom = L.Control.extend({
6 onAdd: function (map) {
8 container = L.DomUtil.create("div", zoomName);
12 this._zoomInButton = this._createButton(
13 "", I18n.t("javascripts.map.zoom.in"), zoomName + "in", container, this._zoomIn, this);
14 this._zoomOutButton = this._createButton(
15 "", I18n.t("javascripts.map.zoom.out"), zoomName + "out", container, this._zoomOut, this);
17 map.on("zoomend zoomlevelschange", this._updateDisabled, this);
22 onRemove: function (map) {
23 map.off("zoomend zoomlevelschange", this._updateDisabled, this);
26 _zoomIn: function (e) {
27 this._map.zoomIn(e.shiftKey ? 3 : 1);
30 _zoomOut: function (e) {
31 this._map.zoomOut(e.shiftKey ? 3 : 1);
34 _createButton: function (html, title, className, container, fn, context) {
35 var link = L.DomUtil.create("a", "control-button " + className, container);
36 link.innerHTML = html;
40 L.DomUtil.create("span", "icon " + className, link);
42 var stop = L.DomEvent.stopPropagation;
45 .on(link, "click", stop)
46 .on(link, "mousedown", stop)
47 .on(link, "dblclick", stop)
48 .on(link, "click", L.DomEvent.preventDefault)
49 .on(link, "click", fn, context);
54 _updateDisabled: function () {
56 className = "disabled";
58 L.DomUtil.removeClass(this._zoomInButton, className);
59 L.DomUtil.removeClass(this._zoomOutButton, className);
61 if (map._zoom === map.getMinZoom()) {
62 L.DomUtil.addClass(this._zoomOutButton, className);
64 if (map._zoom === map.getMaxZoom()) {
65 L.DomUtil.addClass(this._zoomInButton, className);
70 L.OSM.zoom = function (options) {
71 return new L.OSM.Zoom(options);