leaflet-js 0.6.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/CHANGELOG.rdoc +32 -0
- data/LICENSE +21 -0
- data/README.rdoc +54 -0
- data/Rakefile +15 -0
- data/leaflet-js.gemspec +28 -0
- data/lib/leaflet-js.rb +10 -0
- data/lib/leaflet.draw/BREAKINGCHANGES.md +54 -0
- data/lib/leaflet.draw/CHANGELOG.md +73 -0
- data/lib/leaflet.draw/Jakefile.js +26 -0
- data/lib/leaflet.draw/MIT-LICENCE.txt +20 -0
- data/lib/leaflet.draw/README.md +364 -0
- data/lib/leaflet.draw/TODO.md +62 -0
- data/lib/leaflet.draw/build/build.html +243 -0
- data/lib/leaflet.draw/build/build.js +189 -0
- data/lib/leaflet.draw/build/deps.js +75 -0
- data/lib/leaflet.draw/build/hintrc.js +47 -0
- data/lib/leaflet.draw/build/leaflet.draw-include.js +42 -0
- data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
- data/lib/leaflet.draw/dist/leaflet.draw-src.js +2429 -0
- data/lib/leaflet.draw/dist/leaflet.draw.css +212 -0
- data/lib/leaflet.draw/dist/leaflet.draw.ie.css +44 -0
- data/lib/leaflet.draw/dist/leaflet.draw.js +10 -0
- data/lib/leaflet.draw/examples/basic.html +106 -0
- data/lib/leaflet.draw/examples/edithandlers.html +67 -0
- data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-icon@2x.png +0 -0
- data/lib/leaflet.draw/examples/libs/images/marker-shadow.png +0 -0
- data/lib/leaflet.draw/examples/libs/leaflet-src.js +8587 -0
- data/lib/leaflet.draw/examples/libs/leaflet.css +459 -0
- data/lib/leaflet.draw/examples/libs/leaflet.ie.css +51 -0
- data/lib/leaflet.draw/package.json +37 -0
- data/lib/leaflet.draw/spec/after.js +2 -0
- data/lib/leaflet.draw/spec/before.js +3 -0
- data/lib/leaflet.draw/spec/expect.js +1253 -0
- data/lib/leaflet.draw/spec/happen.js +93 -0
- data/lib/leaflet.draw/spec/index.html +36 -0
- data/lib/leaflet.draw/spec/karma.conf.js +69 -0
- data/lib/leaflet.draw/spec/sinon.js +4223 -0
- data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +15 -0
- data/lib/leaflet.draw/spec/suites/SpecHelper.js +26 -0
- data/lib/leaflet.draw/src/Control.Draw.js +101 -0
- data/lib/leaflet.draw/src/Leaflet.draw.js +5 -0
- data/lib/leaflet.draw/src/Toolbar.js +187 -0
- data/lib/leaflet.draw/src/Tooltip.js +52 -0
- data/lib/leaflet.draw/src/copyright.js +8 -0
- data/lib/leaflet.draw/src/draw/DrawToolbar.js +107 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +59 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +74 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +97 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +79 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +360 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +41 -0
- data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +67 -0
- data/lib/leaflet.draw/src/edit/EditToolbar.js +93 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Circle.js +63 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +267 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.Rectangle.js +117 -0
- data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +138 -0
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +109 -0
- data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +233 -0
- data/lib/leaflet.draw/src/ext/LatLngUtil.js +18 -0
- data/lib/leaflet.draw/src/ext/LineUtil.Intersect.js +15 -0
- data/lib/leaflet.draw/src/ext/Polygon.Intersect.js +27 -0
- data/lib/leaflet.draw/src/ext/Polyline.Intersect.js +85 -0
- data/lib/leaflet.label/CHANGELOG.md +35 -0
- data/lib/leaflet.label/Jakefile.js +21 -0
- data/lib/leaflet.label/MIT-LICENCE.txt +20 -0
- data/lib/leaflet.label/README.md +86 -0
- data/lib/leaflet.label/build/build.js +155 -0
- data/lib/leaflet.label/build/deps.js +24 -0
- data/lib/leaflet.label/build/hint.js +30 -0
- data/lib/leaflet.label/build/hintrc.js +47 -0
- data/lib/leaflet.label/dist/images/death.png +0 -0
- data/lib/leaflet.label/dist/leaflet.label-src.js +359 -0
- data/lib/leaflet.label/dist/leaflet.label.css +33 -0
- data/lib/leaflet.label/dist/leaflet.label.js +9 -0
- data/lib/leaflet.label/example/label.html +82 -0
- data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-icon@2x.png +0 -0
- data/lib/leaflet.label/libs/leaflet/images/marker-shadow.png +0 -0
- data/lib/leaflet.label/libs/leaflet/leaflet-src.js +8587 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.css +459 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +51 -0
- data/lib/leaflet.label/libs/leaflet/leaflet.js +8 -0
- data/lib/leaflet.label/src/FeatureGroup.Label.js +20 -0
- data/lib/leaflet.label/src/Label.js +123 -0
- data/lib/leaflet.label/src/Leaflet.label.js +5 -0
- data/lib/leaflet.label/src/Map.Label.js +7 -0
- data/lib/leaflet.label/src/Marker.Label.js +160 -0
- data/lib/leaflet.label/src/Path.Label.js +55 -0
- data/lib/leaflet.label/src/copyright.js +8 -0
- data/lib/leaflet/CHANGELOG.md +637 -0
- data/lib/leaflet/CONTRIBUTING.md +155 -0
- data/lib/leaflet/Jakefile.js +26 -0
- data/lib/leaflet/LICENSE +23 -0
- data/lib/leaflet/README.md +30 -0
- data/lib/leaflet/build/build.html +243 -0
- data/lib/leaflet/build/build.js +193 -0
- data/lib/leaflet/build/deps.js +256 -0
- data/lib/leaflet/build/hintrc.js +37 -0
- data/lib/leaflet/debug/css/mobile.css +6 -0
- data/lib/leaflet/debug/css/screen.css +5 -0
- data/lib/leaflet/debug/hacks/jitter.html +43 -0
- data/lib/leaflet/debug/leaflet-include.js +59 -0
- data/lib/leaflet/debug/map/canvas.html +47 -0
- data/lib/leaflet/debug/map/controls.html +50 -0
- data/lib/leaflet/debug/map/geolocation.html +35 -0
- data/lib/leaflet/debug/map/image-overlay.html +44 -0
- data/lib/leaflet/debug/map/map-mobile.html +35 -0
- data/lib/leaflet/debug/map/map.html +60 -0
- data/lib/leaflet/debug/map/max-bounds.html +37 -0
- data/lib/leaflet/debug/map/scroll.html +36 -0
- data/lib/leaflet/debug/map/simple-proj.html +45 -0
- data/lib/leaflet/debug/map/wms-marble.html +31 -0
- data/lib/leaflet/debug/map/wms.html +41 -0
- data/lib/leaflet/debug/map/zoomlevels.html +46 -0
- data/lib/leaflet/debug/tests/add_remove_layers.html +88 -0
- data/lib/leaflet/debug/tests/bringtoback.html +38 -0
- data/lib/leaflet/debug/tests/click_on_canvas.html +59 -0
- data/lib/leaflet/debug/tests/click_on_canvas_broken.html +49 -0
- data/lib/leaflet/debug/tests/opacity.html +57 -0
- data/lib/leaflet/debug/tests/remove_while_dragging.html +29 -0
- data/lib/leaflet/debug/tests/removetilewhilepan.html +42 -0
- data/lib/leaflet/debug/tests/reuse_popups.html +41 -0
- data/lib/leaflet/debug/tests/svg_clicks.html +55 -0
- data/lib/leaflet/debug/vector/bounds-extend.html +89 -0
- data/lib/leaflet/debug/vector/feature-group-bounds.html +91 -0
- data/lib/leaflet/debug/vector/geojson-sample.js +53 -0
- data/lib/leaflet/debug/vector/geojson.html +174 -0
- data/lib/leaflet/debug/vector/rectangle.html +54 -0
- data/lib/leaflet/debug/vector/route.js +1 -0
- data/lib/leaflet/debug/vector/touchzoomemu.html +195 -0
- data/lib/leaflet/debug/vector/us-states.js +54 -0
- data/lib/leaflet/debug/vector/vector-bounds.html +70 -0
- data/lib/leaflet/debug/vector/vector-canvas.html +93 -0
- data/lib/leaflet/debug/vector/vector-mobile.html +39 -0
- data/lib/leaflet/debug/vector/vector-simple.html +49 -0
- data/lib/leaflet/debug/vector/vector.html +38 -0
- data/lib/leaflet/dist/images/layers.png +0 -0
- data/lib/leaflet/dist/images/marker-icon-2x.png +0 -0
- data/lib/leaflet/dist/images/marker-icon.png +0 -0
- data/lib/leaflet/dist/images/marker-shadow.png +0 -0
- data/lib/leaflet/dist/leaflet-src.js +8579 -0
- data/lib/leaflet/dist/leaflet.css +459 -0
- data/lib/leaflet/dist/leaflet.ie.css +51 -0
- data/lib/leaflet/dist/leaflet.js +8 -0
- data/lib/leaflet/package.json +22 -0
- data/lib/leaflet/spec/after.js +2 -0
- data/lib/leaflet/spec/before.js +3 -0
- data/lib/leaflet/spec/expect.js +1253 -0
- data/lib/leaflet/spec/happen.js +93 -0
- data/lib/leaflet/spec/index.html +78 -0
- data/lib/leaflet/spec/karma.conf.js +64 -0
- data/lib/leaflet/spec/sinon.js +4223 -0
- data/lib/leaflet/spec/suites/LeafletSpec.js +13 -0
- data/lib/leaflet/spec/suites/SpecHelper.js +26 -0
- data/lib/leaflet/spec/suites/control/Control.AttributionSpec.js +68 -0
- data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +67 -0
- data/lib/leaflet/spec/suites/control/Control.ScaleSpec.js +6 -0
- data/lib/leaflet/spec/suites/core/ClassSpec.js +156 -0
- data/lib/leaflet/spec/suites/core/EventsSpec.js +336 -0
- data/lib/leaflet/spec/suites/core/UtilSpec.js +212 -0
- data/lib/leaflet/spec/suites/dom/DomEventSpec.js +102 -0
- data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +89 -0
- data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +136 -0
- data/lib/leaflet/spec/suites/geo/LatLngSpec.js +118 -0
- data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +47 -0
- data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +87 -0
- data/lib/leaflet/spec/suites/geometry/LineUtilSpec.js +75 -0
- data/lib/leaflet/spec/suites/geometry/PointSpec.js +104 -0
- data/lib/leaflet/spec/suites/geometry/PolyUtilSpec.js +27 -0
- data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +31 -0
- data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +36 -0
- data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +86 -0
- data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +58 -0
- data/lib/leaflet/spec/suites/layer/PopupSpec.js +59 -0
- data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +87 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +53 -0
- data/lib/leaflet/spec/suites/layer/vector/CircleSpec.js +17 -0
- data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +55 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +35 -0
- data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +55 -0
- data/lib/leaflet/spec/suites/map/MapSpec.js +244 -0
- data/lib/leaflet/src/Leaflet.js +23 -0
- data/lib/leaflet/src/control/Control.Attribution.js +115 -0
- data/lib/leaflet/src/control/Control.Layers.js +243 -0
- data/lib/leaflet/src/control/Control.Scale.js +112 -0
- data/lib/leaflet/src/control/Control.Zoom.js +86 -0
- data/lib/leaflet/src/control/Control.js +107 -0
- data/lib/leaflet/src/copyright.js +4 -0
- data/lib/leaflet/src/core/Browser.js +96 -0
- data/lib/leaflet/src/core/Class.js +106 -0
- data/lib/leaflet/src/core/Events.js +174 -0
- data/lib/leaflet/src/core/Handler.js +28 -0
- data/lib/leaflet/src/core/Util.js +182 -0
- data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +103 -0
- data/lib/leaflet/src/dom/DomEvent.MsTouch.js +146 -0
- data/lib/leaflet/src/dom/DomEvent.js +211 -0
- data/lib/leaflet/src/dom/DomUtil.js +239 -0
- data/lib/leaflet/src/dom/Draggable.js +198 -0
- data/lib/leaflet/src/dom/PosAnimation.Timer.js +67 -0
- data/lib/leaflet/src/dom/PosAnimation.js +83 -0
- data/lib/leaflet/src/geo/LatLng.js +88 -0
- data/lib/leaflet/src/geo/LatLngBounds.js +153 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +14 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG3857.js +21 -0
- data/lib/leaflet/src/geo/crs/CRS.EPSG4326.js +10 -0
- data/lib/leaflet/src/geo/crs/CRS.Simple.js +12 -0
- data/lib/leaflet/src/geo/crs/CRS.js +27 -0
- data/lib/leaflet/src/geo/projection/Projection.LonLat.js +13 -0
- data/lib/leaflet/src/geo/projection/Projection.Mercator.js +56 -0
- data/lib/leaflet/src/geo/projection/Projection.SphericalMercator.js +27 -0
- data/lib/leaflet/src/geo/projection/Projection.js +5 -0
- data/lib/leaflet/src/geometry/Bounds.js +95 -0
- data/lib/leaflet/src/geometry/LineUtil.js +202 -0
- data/lib/leaflet/src/geometry/Point.js +119 -0
- data/lib/leaflet/src/geometry/PolyUtil.js +55 -0
- data/lib/leaflet/src/geometry/Transformation.js +31 -0
- data/lib/leaflet/src/images/marker.svg +1 -0
- data/lib/leaflet/src/layer/FeatureGroup.js +81 -0
- data/lib/leaflet/src/layer/GeoJSON.js +245 -0
- data/lib/leaflet/src/layer/ImageOverlay.js +132 -0
- data/lib/leaflet/src/layer/LayerGroup.js +110 -0
- data/lib/leaflet/src/layer/Popup.js +316 -0
- data/lib/leaflet/src/layer/marker/DivIcon.js +43 -0
- data/lib/leaflet/src/layer/marker/Icon.Default.js +51 -0
- data/lib/leaflet/src/layer/marker/Icon.js +101 -0
- data/lib/leaflet/src/layer/marker/Marker.Drag.js +66 -0
- data/lib/leaflet/src/layer/marker/Marker.Popup.js +72 -0
- data/lib/leaflet/src/layer/marker/Marker.js +275 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +117 -0
- data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +60 -0
- data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +83 -0
- data/lib/leaflet/src/layer/tile/TileLayer.js +578 -0
- data/lib/leaflet/src/layer/vector/Circle.js +98 -0
- data/lib/leaflet/src/layer/vector/CircleMarker.js +33 -0
- data/lib/leaflet/src/layer/vector/MultiPoly.js +47 -0
- data/lib/leaflet/src/layer/vector/Path.Popup.js +65 -0
- data/lib/leaflet/src/layer/vector/Path.SVG.js +219 -0
- data/lib/leaflet/src/layer/vector/Path.VML.js +125 -0
- data/lib/leaflet/src/layer/vector/Path.js +115 -0
- data/lib/leaflet/src/layer/vector/Polygon.js +81 -0
- data/lib/leaflet/src/layer/vector/Polyline.js +164 -0
- data/lib/leaflet/src/layer/vector/Rectangle.js +27 -0
- data/lib/leaflet/src/layer/vector/canvas/Circle.Canvas.js +18 -0
- data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +196 -0
- data/lib/leaflet/src/layer/vector/canvas/Polygon.Canvas.js +37 -0
- data/lib/leaflet/src/layer/vector/canvas/Polyline.Canvas.js +30 -0
- data/lib/leaflet/src/map/Map.js +743 -0
- data/lib/leaflet/src/map/anim/Map.PanAnimation.js +88 -0
- data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +90 -0
- data/lib/leaflet/src/map/ext/Map.Geolocation.js +91 -0
- data/lib/leaflet/src/map/handler/Map.BoxZoom.js +104 -0
- data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +23 -0
- data/lib/leaflet/src/map/handler/Map.Drag.js +146 -0
- data/lib/leaflet/src/map/handler/Map.Keyboard.js +147 -0
- data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +56 -0
- data/lib/leaflet/src/map/handler/Map.TouchZoom.js +121 -0
- data/vendor/assets/images/layers.png +0 -0
- data/vendor/assets/images/marker-icon-2x.png +0 -0
- data/vendor/assets/images/marker-icon.png +0 -0
- data/vendor/assets/images/marker-shadow.png +0 -0
- data/vendor/assets/images/spritesheet.png +0 -0
- data/vendor/assets/javascripts/leaflet.draw.js +39 -0
- data/vendor/assets/javascripts/leaflet.js +145 -0
- data/vendor/assets/javascripts/leaflet.label.js +9 -0
- data/vendor/assets/stylesheets/leaflet.css.erb +459 -0
- data/vendor/assets/stylesheets/leaflet.draw.css.erb +212 -0
- data/vendor/assets/stylesheets/leaflet.draw.ie.css +44 -0
- data/vendor/assets/stylesheets/leaflet.ie.css +51 -0
- data/vendor/assets/stylesheets/leaflet.label.css +33 -0
- metadata +317 -0
@@ -0,0 +1,239 @@
|
|
1
|
+
/*
|
2
|
+
* L.DomUtil contains various utility functions for working with DOM.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.DomUtil = {
|
6
|
+
get: function (id) {
|
7
|
+
return (typeof id === 'string' ? document.getElementById(id) : id);
|
8
|
+
},
|
9
|
+
|
10
|
+
getStyle: function (el, style) {
|
11
|
+
|
12
|
+
var value = el.style[style];
|
13
|
+
|
14
|
+
if (!value && el.currentStyle) {
|
15
|
+
value = el.currentStyle[style];
|
16
|
+
}
|
17
|
+
|
18
|
+
if ((!value || value === 'auto') && document.defaultView) {
|
19
|
+
var css = document.defaultView.getComputedStyle(el, null);
|
20
|
+
value = css ? css[style] : null;
|
21
|
+
}
|
22
|
+
|
23
|
+
return value === 'auto' ? null : value;
|
24
|
+
},
|
25
|
+
|
26
|
+
getViewportOffset: function (element) {
|
27
|
+
|
28
|
+
var top = 0,
|
29
|
+
left = 0,
|
30
|
+
el = element,
|
31
|
+
docBody = document.body,
|
32
|
+
docEl = document.documentElement,
|
33
|
+
pos,
|
34
|
+
ie7 = L.Browser.ie7;
|
35
|
+
|
36
|
+
do {
|
37
|
+
top += el.offsetTop || 0;
|
38
|
+
left += el.offsetLeft || 0;
|
39
|
+
|
40
|
+
//add borders
|
41
|
+
top += parseInt(L.DomUtil.getStyle(el, 'borderTopWidth'), 10) || 0;
|
42
|
+
left += parseInt(L.DomUtil.getStyle(el, 'borderLeftWidth'), 10) || 0;
|
43
|
+
|
44
|
+
pos = L.DomUtil.getStyle(el, 'position');
|
45
|
+
|
46
|
+
if (el.offsetParent === docBody && pos === 'absolute') { break; }
|
47
|
+
|
48
|
+
if (pos === 'fixed') {
|
49
|
+
top += docBody.scrollTop || docEl.scrollTop || 0;
|
50
|
+
left += docBody.scrollLeft || docEl.scrollLeft || 0;
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
el = el.offsetParent;
|
54
|
+
|
55
|
+
} while (el);
|
56
|
+
|
57
|
+
el = element;
|
58
|
+
|
59
|
+
do {
|
60
|
+
if (el === docBody) { break; }
|
61
|
+
|
62
|
+
top -= el.scrollTop || 0;
|
63
|
+
left -= el.scrollLeft || 0;
|
64
|
+
|
65
|
+
// webkit (and ie <= 7) handles RTL scrollLeft different to everyone else
|
66
|
+
// https://code.google.com/p/closure-library/source/browse/trunk/closure/goog/style/bidi.js
|
67
|
+
if (!L.DomUtil.documentIsLtr() && (L.Browser.webkit || ie7)) {
|
68
|
+
left += el.scrollWidth - el.clientWidth;
|
69
|
+
|
70
|
+
// ie7 shows the scrollbar by default and provides clientWidth counting it, so we
|
71
|
+
// need to add it back in if it is visible; scrollbar is on the left as we are RTL
|
72
|
+
if (ie7 && L.DomUtil.getStyle(el, 'overflow-y') !== 'hidden' &&
|
73
|
+
L.DomUtil.getStyle(el, 'overflow') !== 'hidden') {
|
74
|
+
left += 17;
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
78
|
+
el = el.parentNode;
|
79
|
+
} while (el);
|
80
|
+
|
81
|
+
return new L.Point(left, top);
|
82
|
+
},
|
83
|
+
|
84
|
+
documentIsLtr: function () {
|
85
|
+
if (!L.DomUtil._docIsLtrCached) {
|
86
|
+
L.DomUtil._docIsLtrCached = true;
|
87
|
+
L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === 'ltr';
|
88
|
+
}
|
89
|
+
return L.DomUtil._docIsLtr;
|
90
|
+
},
|
91
|
+
|
92
|
+
create: function (tagName, className, container) {
|
93
|
+
|
94
|
+
var el = document.createElement(tagName);
|
95
|
+
el.className = className;
|
96
|
+
|
97
|
+
if (container) {
|
98
|
+
container.appendChild(el);
|
99
|
+
}
|
100
|
+
|
101
|
+
return el;
|
102
|
+
},
|
103
|
+
|
104
|
+
disableTextSelection: function () {
|
105
|
+
if (document.selection && document.selection.empty) {
|
106
|
+
document.selection.empty();
|
107
|
+
}
|
108
|
+
if (!this._onselectstart) {
|
109
|
+
this._onselectstart = document.onselectstart || null;
|
110
|
+
document.onselectstart = L.Util.falseFn;
|
111
|
+
}
|
112
|
+
},
|
113
|
+
|
114
|
+
enableTextSelection: function () {
|
115
|
+
if (document.onselectstart === L.Util.falseFn) {
|
116
|
+
document.onselectstart = this._onselectstart;
|
117
|
+
this._onselectstart = null;
|
118
|
+
}
|
119
|
+
},
|
120
|
+
|
121
|
+
hasClass: function (el, name) {
|
122
|
+
return (el.className.length > 0) &&
|
123
|
+
new RegExp('(^|\\s)' + name + '(\\s|$)').test(el.className);
|
124
|
+
},
|
125
|
+
|
126
|
+
addClass: function (el, name) {
|
127
|
+
if (!L.DomUtil.hasClass(el, name)) {
|
128
|
+
el.className += (el.className ? ' ' : '') + name;
|
129
|
+
}
|
130
|
+
},
|
131
|
+
|
132
|
+
removeClass: function (el, name) {
|
133
|
+
el.className = L.Util.trim((' ' + el.className + ' ').replace(' ' + name + ' ', ' '));
|
134
|
+
},
|
135
|
+
|
136
|
+
setOpacity: function (el, value) {
|
137
|
+
|
138
|
+
if ('opacity' in el.style) {
|
139
|
+
el.style.opacity = value;
|
140
|
+
|
141
|
+
} else if ('filter' in el.style) {
|
142
|
+
|
143
|
+
var filter = false,
|
144
|
+
filterName = 'DXImageTransform.Microsoft.Alpha';
|
145
|
+
|
146
|
+
// filters collection throws an error if we try to retrieve a filter that doesn't exist
|
147
|
+
try {
|
148
|
+
filter = el.filters.item(filterName);
|
149
|
+
} catch (e) {
|
150
|
+
// don't set opacity to 1 if we haven't already set an opacity,
|
151
|
+
// it isn't needed and breaks transparent pngs.
|
152
|
+
if (value === 1) { return; }
|
153
|
+
}
|
154
|
+
|
155
|
+
value = Math.round(value * 100);
|
156
|
+
|
157
|
+
if (filter) {
|
158
|
+
filter.Enabled = (value !== 100);
|
159
|
+
filter.Opacity = value;
|
160
|
+
} else {
|
161
|
+
el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';
|
162
|
+
}
|
163
|
+
}
|
164
|
+
},
|
165
|
+
|
166
|
+
testProp: function (props) {
|
167
|
+
|
168
|
+
var style = document.documentElement.style;
|
169
|
+
|
170
|
+
for (var i = 0; i < props.length; i++) {
|
171
|
+
if (props[i] in style) {
|
172
|
+
return props[i];
|
173
|
+
}
|
174
|
+
}
|
175
|
+
return false;
|
176
|
+
},
|
177
|
+
|
178
|
+
getTranslateString: function (point) {
|
179
|
+
// on WebKit browsers (Chrome/Safari/iOS Safari/Android) using translate3d instead of translate
|
180
|
+
// makes animation smoother as it ensures HW accel is used. Firefox 13 doesn't care
|
181
|
+
// (same speed either way), Opera 12 doesn't support translate3d
|
182
|
+
|
183
|
+
var is3d = L.Browser.webkit3d,
|
184
|
+
open = 'translate' + (is3d ? '3d' : '') + '(',
|
185
|
+
close = (is3d ? ',0' : '') + ')';
|
186
|
+
|
187
|
+
return open + point.x + 'px,' + point.y + 'px' + close;
|
188
|
+
},
|
189
|
+
|
190
|
+
getScaleString: function (scale, origin) {
|
191
|
+
|
192
|
+
var preTranslateStr = L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1 * scale))),
|
193
|
+
scaleStr = ' scale(' + scale + ') ';
|
194
|
+
|
195
|
+
return preTranslateStr + scaleStr;
|
196
|
+
},
|
197
|
+
|
198
|
+
setPosition: function (el, point, disable3D) { // (HTMLElement, Point[, Boolean])
|
199
|
+
|
200
|
+
// jshint camelcase: false
|
201
|
+
el._leaflet_pos = point;
|
202
|
+
|
203
|
+
if (!disable3D && L.Browser.any3d) {
|
204
|
+
el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point);
|
205
|
+
|
206
|
+
// workaround for Android 2/3 stability (https://github.com/CloudMade/Leaflet/issues/69)
|
207
|
+
if (L.Browser.mobileWebkit3d) {
|
208
|
+
el.style.WebkitBackfaceVisibility = 'hidden';
|
209
|
+
}
|
210
|
+
} else {
|
211
|
+
el.style.left = point.x + 'px';
|
212
|
+
el.style.top = point.y + 'px';
|
213
|
+
}
|
214
|
+
},
|
215
|
+
|
216
|
+
getPosition: function (el) {
|
217
|
+
// this method is only used for elements previously positioned using setPosition,
|
218
|
+
// so it's safe to cache the position for performance
|
219
|
+
|
220
|
+
// jshint camelcase: false
|
221
|
+
return el._leaflet_pos;
|
222
|
+
}
|
223
|
+
};
|
224
|
+
|
225
|
+
|
226
|
+
// prefix style property names
|
227
|
+
|
228
|
+
L.DomUtil.TRANSFORM = L.DomUtil.testProp(
|
229
|
+
['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
|
230
|
+
|
231
|
+
// webkitTransition comes first because some browser versions that drop vendor prefix don't do
|
232
|
+
// the same for the transitionend event, in particular the Android 4.1 stock browser
|
233
|
+
|
234
|
+
L.DomUtil.TRANSITION = L.DomUtil.testProp(
|
235
|
+
['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);
|
236
|
+
|
237
|
+
L.DomUtil.TRANSITION_END =
|
238
|
+
L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?
|
239
|
+
L.DomUtil.TRANSITION + 'End' : 'transitionend';
|
@@ -0,0 +1,198 @@
|
|
1
|
+
/*
|
2
|
+
* L.Draggable allows you to add dragging capabilities to any element. Supports mobile devices too.
|
3
|
+
*/
|
4
|
+
|
5
|
+
L.Draggable = L.Class.extend({
|
6
|
+
includes: L.Mixin.Events,
|
7
|
+
|
8
|
+
statics: {
|
9
|
+
START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],
|
10
|
+
END: {
|
11
|
+
mousedown: 'mouseup',
|
12
|
+
touchstart: 'touchend',
|
13
|
+
MSPointerDown: 'touchend'
|
14
|
+
},
|
15
|
+
MOVE: {
|
16
|
+
mousedown: 'mousemove',
|
17
|
+
touchstart: 'touchmove',
|
18
|
+
MSPointerDown: 'touchmove'
|
19
|
+
},
|
20
|
+
TAP_TOLERANCE: 15
|
21
|
+
},
|
22
|
+
|
23
|
+
initialize: function (element, dragStartTarget, longPress) {
|
24
|
+
this._element = element;
|
25
|
+
this._dragStartTarget = dragStartTarget || element;
|
26
|
+
this._longPress = longPress && !L.Browser.msTouch;
|
27
|
+
},
|
28
|
+
|
29
|
+
enable: function () {
|
30
|
+
if (this._enabled) { return; }
|
31
|
+
|
32
|
+
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
|
33
|
+
L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
|
34
|
+
}
|
35
|
+
|
36
|
+
this._enabled = true;
|
37
|
+
},
|
38
|
+
|
39
|
+
disable: function () {
|
40
|
+
if (!this._enabled) { return; }
|
41
|
+
|
42
|
+
for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
|
43
|
+
L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
|
44
|
+
}
|
45
|
+
|
46
|
+
this._enabled = false;
|
47
|
+
this._moved = false;
|
48
|
+
},
|
49
|
+
|
50
|
+
_onDown: function (e) {
|
51
|
+
if (e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }
|
52
|
+
|
53
|
+
L.DomEvent
|
54
|
+
.preventDefault(e)
|
55
|
+
.stopPropagation(e);
|
56
|
+
|
57
|
+
if (L.Draggable._disabled) { return; }
|
58
|
+
|
59
|
+
this._simulateClick = true;
|
60
|
+
|
61
|
+
var touchesNum = (e.touches && e.touches.length) || 0;
|
62
|
+
|
63
|
+
// don't simulate click or track longpress if more than 1 touch
|
64
|
+
if (touchesNum > 1) {
|
65
|
+
this._simulateClick = false;
|
66
|
+
clearTimeout(this._longPressTimeout);
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
|
70
|
+
var first = touchesNum === 1 ? e.touches[0] : e,
|
71
|
+
el = first.target;
|
72
|
+
|
73
|
+
// if touching a link, highlight it
|
74
|
+
if (L.Browser.touch && el.tagName.toLowerCase() === 'a') {
|
75
|
+
L.DomUtil.addClass(el, 'leaflet-active');
|
76
|
+
}
|
77
|
+
|
78
|
+
this._moved = false;
|
79
|
+
|
80
|
+
if (this._moving) { return; }
|
81
|
+
|
82
|
+
this._startPoint = new L.Point(first.clientX, first.clientY);
|
83
|
+
this._startPos = this._newPos = L.DomUtil.getPosition(this._element);
|
84
|
+
|
85
|
+
// touch contextmenu event emulation
|
86
|
+
if (touchesNum === 1 && L.Browser.touch && this._longPress) {
|
87
|
+
|
88
|
+
this._longPressTimeout = setTimeout(L.bind(function () {
|
89
|
+
var dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
90
|
+
|
91
|
+
if (dist < L.Draggable.TAP_TOLERANCE) {
|
92
|
+
this._simulateClick = false;
|
93
|
+
this._onUp();
|
94
|
+
this._simulateEvent('contextmenu', first);
|
95
|
+
}
|
96
|
+
}, this), 1000);
|
97
|
+
}
|
98
|
+
|
99
|
+
L.DomEvent
|
100
|
+
.on(document, L.Draggable.MOVE[e.type], this._onMove, this)
|
101
|
+
.on(document, L.Draggable.END[e.type], this._onUp, this);
|
102
|
+
},
|
103
|
+
|
104
|
+
_onMove: function (e) {
|
105
|
+
if (e.touches && e.touches.length > 1) { return; }
|
106
|
+
|
107
|
+
var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),
|
108
|
+
newPoint = new L.Point(first.clientX, first.clientY),
|
109
|
+
offset = newPoint.subtract(this._startPoint);
|
110
|
+
|
111
|
+
if (!offset.x && !offset.y) { return; }
|
112
|
+
|
113
|
+
L.DomEvent.preventDefault(e);
|
114
|
+
|
115
|
+
if (!this._moved) {
|
116
|
+
this.fire('dragstart');
|
117
|
+
|
118
|
+
this._moved = true;
|
119
|
+
this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);
|
120
|
+
|
121
|
+
if (!L.Browser.touch) {
|
122
|
+
L.DomUtil.disableTextSelection();
|
123
|
+
L.DomUtil.addClass(document.body, 'leaflet-dragging');
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
this._newPos = this._startPos.add(offset);
|
128
|
+
this._moving = true;
|
129
|
+
|
130
|
+
L.Util.cancelAnimFrame(this._animRequest);
|
131
|
+
this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget);
|
132
|
+
},
|
133
|
+
|
134
|
+
_updatePosition: function () {
|
135
|
+
this.fire('predrag');
|
136
|
+
L.DomUtil.setPosition(this._element, this._newPos);
|
137
|
+
this.fire('drag');
|
138
|
+
},
|
139
|
+
|
140
|
+
_onUp: function (e) {
|
141
|
+
var first, el, dist, simulateClickTouch, i;
|
142
|
+
|
143
|
+
clearTimeout(this._longPressTimeout);
|
144
|
+
|
145
|
+
if (this._simulateClick && e.changedTouches) {
|
146
|
+
|
147
|
+
dist = (this._newPos && this._newPos.distanceTo(this._startPos)) || 0;
|
148
|
+
first = e.changedTouches[0];
|
149
|
+
el = first.target;
|
150
|
+
|
151
|
+
if (el.tagName.toLowerCase() === 'a') {
|
152
|
+
L.DomUtil.removeClass(el, 'leaflet-active');
|
153
|
+
}
|
154
|
+
|
155
|
+
// simulate click if the touch didn't move too much
|
156
|
+
if (dist < L.Draggable.TAP_TOLERANCE) {
|
157
|
+
simulateClickTouch = true;
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
if (!L.Browser.touch) {
|
162
|
+
L.DomUtil.enableTextSelection();
|
163
|
+
L.DomUtil.removeClass(document.body, 'leaflet-dragging');
|
164
|
+
}
|
165
|
+
|
166
|
+
for (i in L.Draggable.MOVE) {
|
167
|
+
L.DomEvent
|
168
|
+
.off(document, L.Draggable.MOVE[i], this._onMove)
|
169
|
+
.off(document, L.Draggable.END[i], this._onUp);
|
170
|
+
}
|
171
|
+
|
172
|
+
if (this._moved) {
|
173
|
+
// ensure drag is not fired after dragend
|
174
|
+
L.Util.cancelAnimFrame(this._animRequest);
|
175
|
+
|
176
|
+
this.fire('dragend');
|
177
|
+
}
|
178
|
+
|
179
|
+
this._moving = false;
|
180
|
+
|
181
|
+
if (simulateClickTouch) {
|
182
|
+
this._moved = false;
|
183
|
+
this._simulateEvent('click', first);
|
184
|
+
}
|
185
|
+
},
|
186
|
+
|
187
|
+
_simulateEvent: function (type, e) {
|
188
|
+
var simulatedEvent = document.createEvent('MouseEvents');
|
189
|
+
|
190
|
+
simulatedEvent.initMouseEvent(
|
191
|
+
type, true, true, window, 1,
|
192
|
+
e.screenX, e.screenY,
|
193
|
+
e.clientX, e.clientY,
|
194
|
+
false, false, false, false, 0, null);
|
195
|
+
|
196
|
+
e.target.dispatchEvent(simulatedEvent);
|
197
|
+
}
|
198
|
+
});
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/*
|
2
|
+
* L.PosAnimation fallback implementation that powers Leaflet pan animations
|
3
|
+
* in browsers that don't support CSS3 Transitions.
|
4
|
+
*/
|
5
|
+
|
6
|
+
L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({
|
7
|
+
|
8
|
+
run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
|
9
|
+
this.stop();
|
10
|
+
|
11
|
+
this._el = el;
|
12
|
+
this._inProgress = true;
|
13
|
+
this._duration = duration || 0.25;
|
14
|
+
this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
|
15
|
+
|
16
|
+
this._startPos = L.DomUtil.getPosition(el);
|
17
|
+
this._offset = newPos.subtract(this._startPos);
|
18
|
+
this._startTime = +new Date();
|
19
|
+
|
20
|
+
this.fire('start');
|
21
|
+
|
22
|
+
this._animate();
|
23
|
+
},
|
24
|
+
|
25
|
+
stop: function () {
|
26
|
+
if (!this._inProgress) { return; }
|
27
|
+
|
28
|
+
this._step();
|
29
|
+
this._complete();
|
30
|
+
},
|
31
|
+
|
32
|
+
_animate: function () {
|
33
|
+
// animation loop
|
34
|
+
this._animId = L.Util.requestAnimFrame(this._animate, this);
|
35
|
+
this._step();
|
36
|
+
},
|
37
|
+
|
38
|
+
_step: function () {
|
39
|
+
var elapsed = (+new Date()) - this._startTime,
|
40
|
+
duration = this._duration * 1000;
|
41
|
+
|
42
|
+
if (elapsed < duration) {
|
43
|
+
this._runFrame(this._easeOut(elapsed / duration));
|
44
|
+
} else {
|
45
|
+
this._runFrame(1);
|
46
|
+
this._complete();
|
47
|
+
}
|
48
|
+
},
|
49
|
+
|
50
|
+
_runFrame: function (progress) {
|
51
|
+
var pos = this._startPos.add(this._offset.multiplyBy(progress));
|
52
|
+
L.DomUtil.setPosition(this._el, pos);
|
53
|
+
|
54
|
+
this.fire('step');
|
55
|
+
},
|
56
|
+
|
57
|
+
_complete: function () {
|
58
|
+
L.Util.cancelAnimFrame(this._animId);
|
59
|
+
|
60
|
+
this._inProgress = false;
|
61
|
+
this.fire('end');
|
62
|
+
},
|
63
|
+
|
64
|
+
_easeOut: function (t) {
|
65
|
+
return 1 - Math.pow(1 - t, this._easeOutPower);
|
66
|
+
}
|
67
|
+
});
|