leaflet-js 0.6.beta4 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. checksums.yaml +6 -14
  2. data/CHANGELOG.rdoc +3 -0
  3. data/leaflet-js.gemspec +2 -2
  4. data/lib/leaflet.draw/CHANGELOG.md +45 -0
  5. data/lib/leaflet.draw/README.md +70 -23
  6. data/lib/leaflet.draw/build/deps.js +1 -0
  7. data/lib/leaflet.draw/dist/images/spritesheet-2x.png +0 -0
  8. data/lib/leaflet.draw/dist/images/spritesheet.png +0 -0
  9. data/lib/leaflet.draw/dist/leaflet.draw-src.js +489 -136
  10. data/lib/leaflet.draw/dist/leaflet.draw.css +34 -2
  11. data/lib/leaflet.draw/dist/leaflet.draw.ie.css +5 -0
  12. data/lib/leaflet.draw/dist/leaflet.draw.js +2 -2
  13. data/lib/leaflet.draw/examples/basic.html +14 -7
  14. data/lib/leaflet.draw/examples/libs/images/layers-2x.png +0 -0
  15. data/lib/leaflet.draw/examples/libs/images/layers.png +0 -0
  16. data/lib/leaflet.draw/examples/libs/images/marker-icon-2x.png +0 -0
  17. data/lib/leaflet.draw/examples/libs/leaflet-src.js +1129 -608
  18. data/lib/leaflet.draw/examples/libs/leaflet.css +85 -66
  19. data/lib/leaflet.draw/package.json +2 -2
  20. data/lib/leaflet.draw/spec/suites/DrawControlSpec.js +1 -1
  21. data/lib/leaflet.draw/spec/suites/GeometryUtilSpec.js +25 -0
  22. data/lib/leaflet.draw/spec/suites/LatLngUtilSpec.js +9 -0
  23. data/lib/leaflet.draw/src/Control.Draw.js +1 -0
  24. data/lib/leaflet.draw/src/Leaflet.draw.js +89 -1
  25. data/lib/leaflet.draw/src/Toolbar.js +2 -6
  26. data/lib/leaflet.draw/src/Tooltip.js +20 -7
  27. data/lib/leaflet.draw/src/draw/DrawToolbar.js +26 -22
  28. data/lib/leaflet.draw/src/draw/handler/Draw.Circle.js +11 -6
  29. data/lib/leaflet.draw/src/draw/handler/Draw.Feature.js +6 -2
  30. data/lib/leaflet.draw/src/draw/handler/Draw.Marker.js +7 -2
  31. data/lib/leaflet.draw/src/draw/handler/Draw.Polygon.js +29 -7
  32. data/lib/leaflet.draw/src/draw/handler/Draw.Polyline.js +44 -21
  33. data/lib/leaflet.draw/src/draw/handler/Draw.Rectangle.js +3 -3
  34. data/lib/leaflet.draw/src/draw/handler/Draw.SimpleShape.js +14 -1
  35. data/lib/leaflet.draw/src/edit/EditToolbar.js +86 -16
  36. data/lib/leaflet.draw/src/edit/handler/Edit.Poly.js +10 -7
  37. data/lib/leaflet.draw/src/edit/handler/Edit.SimpleShape.js +1 -2
  38. data/lib/leaflet.draw/src/edit/handler/EditToolbar.Delete.js +15 -3
  39. data/lib/leaflet.draw/src/edit/handler/EditToolbar.Edit.js +56 -38
  40. data/lib/leaflet.draw/src/ext/GeometryUtil.js +68 -0
  41. data/lib/leaflet.draw/src/images/spritesheet.svg +41 -0
  42. data/lib/leaflet.label/CHANGELOG.md +32 -0
  43. data/lib/leaflet.label/README.md +21 -4
  44. data/lib/leaflet.label/build/build.js +2 -2
  45. data/lib/leaflet.label/build/deps.js +2 -0
  46. data/lib/leaflet.label/build/hintrc.js +4 -0
  47. data/lib/leaflet.label/dist/leaflet.label-src.js +266 -83
  48. data/lib/leaflet.label/dist/leaflet.label.css +23 -4
  49. data/lib/leaflet.label/dist/leaflet.label.js +1 -1
  50. data/lib/leaflet.label/example/label.html +6 -3
  51. data/lib/leaflet.label/libs/leaflet/images/layers-2x.png +0 -0
  52. data/lib/leaflet.label/libs/leaflet/images/layers.png +0 -0
  53. data/lib/leaflet.label/libs/leaflet/images/marker-icon-2x.png +0 -0
  54. data/lib/leaflet.label/libs/leaflet/leaflet-src.js +1129 -608
  55. data/lib/leaflet.label/libs/leaflet/leaflet.css +85 -66
  56. data/lib/leaflet.label/libs/leaflet/leaflet.js +6 -5
  57. data/lib/leaflet.label/package.json +19 -0
  58. data/lib/leaflet.label/src/BaseMarkerMethods.js +129 -0
  59. data/lib/leaflet.label/src/CircleMarker.Label.js +7 -0
  60. data/lib/leaflet.label/src/Label.js +161 -37
  61. data/lib/leaflet.label/src/Leaflet.label.js +1 -1
  62. data/lib/leaflet.label/src/Map.Label.js +0 -2
  63. data/lib/leaflet.label/src/Marker.Label.js +15 -120
  64. data/lib/leaflet.label/src/Path.Label.js +11 -11
  65. data/lib/leaflet/CHANGELOG.md +299 -31
  66. data/lib/leaflet/CONTRIBUTING.md +3 -3
  67. data/lib/leaflet/FAQ.md +138 -0
  68. data/lib/leaflet/Jakefile.js +24 -4
  69. data/lib/leaflet/PLUGIN-GUIDE.md +127 -0
  70. data/lib/leaflet/README.md +10 -6
  71. data/lib/leaflet/build/build.html +3 -19
  72. data/lib/leaflet/build/build.js +21 -51
  73. data/lib/leaflet/build/deps.js +10 -7
  74. data/lib/leaflet/build/hintrc.js +6 -4
  75. data/lib/leaflet/debug/hacks/jitter.html +0 -1
  76. data/lib/leaflet/debug/map/canvas.html +11 -12
  77. data/lib/leaflet/debug/map/controls.html +3 -4
  78. data/lib/leaflet/debug/map/geolocation.html +0 -1
  79. data/lib/leaflet/debug/map/iframe.html +11 -0
  80. data/lib/leaflet/debug/map/image-overlay.html +0 -1
  81. data/lib/leaflet/debug/map/map-mobile.html +0 -1
  82. data/lib/leaflet/debug/map/map.html +1 -2
  83. data/lib/leaflet/debug/map/max-bounds.html +2 -1
  84. data/lib/leaflet/debug/map/opacity.html +223 -0
  85. data/lib/leaflet/debug/map/scroll.html +6 -1
  86. data/lib/leaflet/debug/map/simple-proj.html +0 -1
  87. data/lib/leaflet/debug/map/wms-marble.html +4 -5
  88. data/lib/leaflet/debug/map/wms.html +0 -1
  89. data/lib/leaflet/debug/map/zoomlevels.html +0 -1
  90. data/lib/leaflet/debug/tests/add_remove_layers.html +5 -6
  91. data/lib/leaflet/debug/tests/bringtoback.html +0 -1
  92. data/lib/leaflet/debug/tests/canvasloop.html +47 -0
  93. data/lib/leaflet/debug/tests/click_on_canvas.html +0 -1
  94. data/lib/leaflet/debug/tests/dragging_and_copyworldjump.html +61 -0
  95. data/lib/leaflet/debug/tests/opacity.html +0 -1
  96. data/lib/leaflet/debug/tests/popupcontextmenuclicks.html +59 -0
  97. data/lib/leaflet/debug/tests/remove_while_dragging.html +4 -5
  98. data/lib/leaflet/debug/tests/removetilewhilepan.html +0 -1
  99. data/lib/leaflet/debug/tests/reuse_popups.html +0 -1
  100. data/lib/leaflet/debug/tests/rtl.html +42 -0
  101. data/lib/leaflet/debug/tests/rtl2.html +27 -0
  102. data/lib/leaflet/debug/tests/set_icon_reuse_dom.html +43 -0
  103. data/lib/leaflet/debug/tests/svg_clicks.html +3 -4
  104. data/lib/leaflet/debug/vector/bounds-extend.html +0 -1
  105. data/lib/leaflet/debug/vector/feature-group-bounds.html +0 -1
  106. data/lib/leaflet/debug/vector/geojson.html +0 -1
  107. data/lib/leaflet/debug/vector/rectangle.html +0 -1
  108. data/lib/leaflet/debug/vector/touchzoomemu.html +2 -3
  109. data/lib/leaflet/debug/vector/vector-bounds.html +0 -1
  110. data/lib/leaflet/debug/vector/vector-canvas.html +0 -1
  111. data/lib/leaflet/debug/vector/vector-mobile.html +0 -1
  112. data/lib/leaflet/debug/vector/vector-simple.html +0 -1
  113. data/lib/leaflet/debug/vector/vector.html +0 -1
  114. data/lib/leaflet/dist/images/layers-2x.png +0 -0
  115. data/lib/leaflet/dist/images/layers.png +0 -0
  116. data/lib/leaflet/dist/leaflet.css +85 -66
  117. data/lib/leaflet/package.json +25 -20
  118. data/lib/leaflet/spec/after.js +1 -1
  119. data/lib/leaflet/spec/index.html +21 -13
  120. data/lib/leaflet/spec/karma.conf.js +51 -50
  121. data/lib/leaflet/spec/spec.hintrc.js +25 -0
  122. data/lib/leaflet/spec/suites/LeafletSpec.js +2 -2
  123. data/lib/leaflet/spec/suites/SpecHelper.js +37 -21
  124. data/lib/leaflet/spec/suites/control/Control.LayersSpec.js +1 -1
  125. data/lib/leaflet/spec/suites/core/ClassSpec.js +12 -12
  126. data/lib/leaflet/spec/suites/core/EventsSpec.js +74 -18
  127. data/lib/leaflet/spec/suites/core/UtilSpec.js +69 -25
  128. data/lib/leaflet/spec/suites/dom/DomEventSpec.js +16 -16
  129. data/lib/leaflet/spec/suites/dom/DomUtilSpec.js +9 -16
  130. data/lib/leaflet/spec/suites/dom/PosAnimationSpec.js +27 -0
  131. data/lib/leaflet/spec/suites/geo/CRSSpec.js +47 -0
  132. data/lib/leaflet/spec/suites/geo/LatLngBoundsSpec.js +22 -14
  133. data/lib/leaflet/spec/suites/geo/LatLngSpec.js +22 -8
  134. data/lib/leaflet/spec/suites/geo/ProjectionSpec.js +21 -20
  135. data/lib/leaflet/spec/suites/geometry/BoundsSpec.js +15 -15
  136. data/lib/leaflet/spec/suites/geometry/PointSpec.js +12 -12
  137. data/lib/leaflet/spec/suites/geometry/TransformationSpec.js +4 -4
  138. data/lib/leaflet/spec/suites/layer/FeatureGroupSpec.js +59 -9
  139. data/lib/leaflet/spec/suites/layer/GeoJSONSpec.js +213 -17
  140. data/lib/leaflet/spec/suites/layer/LayerGroupSpec.js +6 -6
  141. data/lib/leaflet/spec/suites/layer/PopupSpec.js +65 -5
  142. data/lib/leaflet/spec/suites/layer/TileLayerSpec.js +16 -15
  143. data/lib/leaflet/spec/suites/layer/marker/MarkerSpec.js +94 -0
  144. data/lib/leaflet/spec/suites/layer/vector/CircleMarkerSpec.js +7 -7
  145. data/lib/leaflet/spec/suites/layer/vector/PolygonSpec.js +38 -2
  146. data/lib/leaflet/spec/suites/layer/vector/PolylineGeometrySpec.js +4 -4
  147. data/lib/leaflet/spec/suites/layer/vector/PolylineSpec.js +2 -2
  148. data/lib/leaflet/spec/suites/map/MapSpec.js +318 -26
  149. data/lib/leaflet/spec/suites/map/handler/Map.DragSpec.js +38 -0
  150. data/lib/leaflet/src/Leaflet.js +2 -2
  151. data/lib/leaflet/src/control/Control.Attribution.js +6 -0
  152. data/lib/leaflet/src/control/Control.Layers.js +33 -24
  153. data/lib/leaflet/src/control/Control.Zoom.js +12 -4
  154. data/lib/leaflet/src/control/Control.js +10 -0
  155. data/lib/leaflet/src/copyright.js +2 -1
  156. data/lib/leaflet/src/core/Browser.js +11 -10
  157. data/lib/leaflet/src/core/Events.js +15 -11
  158. data/lib/leaflet/src/core/Util.js +19 -14
  159. data/lib/leaflet/src/dom/DomEvent.DoubleTap.js +13 -12
  160. data/lib/leaflet/src/dom/DomEvent.Pointer.js +155 -0
  161. data/lib/leaflet/src/dom/DomEvent.js +57 -19
  162. data/lib/leaflet/src/dom/DomUtil.js +89 -34
  163. data/lib/leaflet/src/dom/Draggable.js +26 -89
  164. data/lib/leaflet/src/dom/PosAnimation.js +13 -2
  165. data/lib/leaflet/src/geo/LatLng.js +16 -5
  166. data/lib/leaflet/src/geo/LatLngBounds.js +5 -2
  167. data/lib/leaflet/src/geo/crs/CRS.EPSG3395.js +2 -2
  168. data/lib/leaflet/src/geo/crs/CRS.js +5 -0
  169. data/lib/leaflet/src/geo/projection/Projection.Mercator.js +3 -3
  170. data/lib/leaflet/src/geometry/LineUtil.js +2 -2
  171. data/lib/leaflet/src/images/layers.svg +8 -0
  172. data/lib/leaflet/src/images/marker.svg +61 -1
  173. data/lib/leaflet/src/layer/FeatureGroup.js +24 -7
  174. data/lib/leaflet/src/layer/GeoJSON.js +97 -56
  175. data/lib/leaflet/src/layer/ImageOverlay.js +9 -0
  176. data/lib/leaflet/src/layer/LayerGroup.js +8 -3
  177. data/lib/leaflet/src/layer/Popup.js +56 -34
  178. data/lib/leaflet/src/layer/marker/DivIcon.js +4 -2
  179. data/lib/leaflet/src/layer/marker/Icon.Default.js +1 -1
  180. data/lib/leaflet/src/layer/marker/Icon.js +15 -18
  181. data/lib/leaflet/src/layer/marker/Marker.Drag.js +7 -5
  182. data/lib/leaflet/src/layer/marker/Marker.Popup.js +22 -5
  183. data/lib/leaflet/src/layer/marker/Marker.js +75 -32
  184. data/lib/leaflet/src/layer/tile/TileLayer.Anim.js +14 -26
  185. data/lib/leaflet/src/layer/tile/TileLayer.Canvas.js +7 -6
  186. data/lib/leaflet/src/layer/tile/TileLayer.WMS.js +14 -10
  187. data/lib/leaflet/src/layer/tile/TileLayer.js +53 -32
  188. data/lib/leaflet/src/layer/vector/CircleMarker.js +11 -0
  189. data/lib/leaflet/src/layer/vector/MultiPoly.js +10 -0
  190. data/lib/leaflet/src/layer/vector/Path.SVG.js +14 -3
  191. data/lib/leaflet/src/layer/vector/Path.VML.js +12 -2
  192. data/lib/leaflet/src/layer/vector/Path.js +7 -3
  193. data/lib/leaflet/src/layer/vector/Polygon.js +14 -3
  194. data/lib/leaflet/src/layer/vector/canvas/CircleMarker.Canvas.js +9 -0
  195. data/lib/leaflet/src/layer/vector/canvas/Path.Canvas.js +1 -0
  196. data/lib/leaflet/src/map/Map.js +192 -125
  197. data/lib/leaflet/src/map/anim/Map.PanAnimation.js +29 -19
  198. data/lib/leaflet/src/map/anim/Map.ZoomAnimation.js +21 -9
  199. data/lib/leaflet/src/map/ext/Map.Geolocation.js +11 -4
  200. data/lib/leaflet/src/map/handler/Map.BoxZoom.js +26 -12
  201. data/lib/leaflet/src/map/handler/Map.DoubleClickZoom.js +10 -3
  202. data/lib/leaflet/src/map/handler/Map.Drag.js +12 -6
  203. data/lib/leaflet/src/map/handler/Map.Keyboard.js +5 -2
  204. data/lib/leaflet/src/map/handler/Map.ScrollWheelZoom.js +7 -1
  205. data/lib/leaflet/src/map/handler/Map.Tap.js +107 -0
  206. data/lib/leaflet/src/map/handler/Map.TouchZoom.js +9 -3
  207. data/vendor/assets/images/layers-2x.png +0 -0
  208. data/vendor/assets/images/layers.png +0 -0
  209. data/vendor/assets/images/spritesheet-2x.png +0 -0
  210. data/vendor/assets/images/spritesheet.png +0 -0
  211. data/vendor/assets/javascripts/leaflet.draw.js +2 -4
  212. data/vendor/assets/javascripts/leaflet.js +3 -1
  213. data/vendor/assets/javascripts/leaflet.label.js +2 -0
  214. data/vendor/assets/stylesheets/leaflet.css.erb +337 -318
  215. data/vendor/assets/stylesheets/leaflet.draw.css.erb +35 -3
  216. data/vendor/assets/stylesheets/leaflet.draw.ie.css +5 -0
  217. data/vendor/assets/stylesheets/leaflet.label.css +23 -4
  218. metadata +40 -14
  219. data/lib/leaflet.draw/examples/libs/leaflet.ie.css +0 -51
  220. data/lib/leaflet.label/libs/leaflet/leaflet.ie.css +0 -51
  221. data/lib/leaflet/dist/leaflet-src.js +0 -8579
  222. data/lib/leaflet/dist/leaflet.ie.css +0 -51
  223. data/lib/leaflet/dist/leaflet.js +0 -8
  224. data/lib/leaflet/spec/happen.js +0 -93
  225. data/lib/leaflet/src/dom/DomEvent.MsTouch.js +0 -146
  226. data/vendor/assets/stylesheets/leaflet.ie.css +0 -51
@@ -1,16 +1,16 @@
1
- describe('Util', function() {
1
+ describe('Util', function () {
2
2
 
3
- describe('#extend', function() {
3
+ describe('#extend', function () {
4
4
  var a;
5
5
 
6
- beforeEach(function() {
6
+ beforeEach(function () {
7
7
  a = {
8
8
  foo: 5,
9
9
  bar: 'asd'
10
10
  };
11
11
  });
12
12
 
13
- it('extends the first argument with the properties of the second', function() {
13
+ it('extends the first argument with the properties of the second', function () {
14
14
  L.Util.extend(a, {
15
15
  bar: 7,
16
16
  baz: 3
@@ -23,7 +23,7 @@ describe('Util', function() {
23
23
  });
24
24
  });
25
25
 
26
- it('accepts more than 2 arguments', function() {
26
+ it('accepts more than 2 arguments', function () {
27
27
  L.Util.extend(a, {bar: 7}, {baz: 3});
28
28
 
29
29
  expect(a).to.eql({
@@ -34,9 +34,9 @@ describe('Util', function() {
34
34
  });
35
35
  });
36
36
 
37
- describe('#bind', function() {
38
- it('returns the given function with the given context', function() {
39
- var fn = function() {
37
+ describe('#bind', function () {
38
+ it('returns the given function with the given context', function () {
39
+ var fn = function () {
40
40
  return this;
41
41
  };
42
42
 
@@ -59,8 +59,8 @@ describe('Util', function() {
59
59
  });
60
60
  });
61
61
 
62
- describe('#stamp', function() {
63
- it('sets a unique id on the given object and returns it', function() {
62
+ describe('#stamp', function () {
63
+ it('sets a unique id on the given object and returns it', function () {
64
64
  var a = {},
65
65
  id = L.Util.stamp(a);
66
66
 
@@ -115,38 +115,37 @@ describe('Util', function() {
115
115
  });
116
116
 
117
117
 
118
- describe('#getParamString', function() {
119
- it('creates a valid query string for appending depending on url input', function() {
118
+ describe('#getParamString', function () {
119
+ it('creates a valid query string for appending depending on url input', function () {
120
120
  var a = {
121
- url: "http://example.com/get",
121
+ url: 'http://example.com/get',
122
122
  obj: {bar: 7, baz: 3},
123
- result: "?bar=7&baz=3"
123
+ result: '?bar=7&baz=3'
124
124
  };
125
125
 
126
- expect(L.Util.getParamString(a.obj,a.url)).to.eql(a.result);
126
+ expect(L.Util.getParamString(a.obj, a.url)).to.eql(a.result);
127
127
 
128
128
  var b = {
129
- url: "http://example.com/get?justone=qs",
129
+ url: 'http://example.com/get?justone=qs',
130
130
  obj: {bar: 7, baz: 3},
131
- result: "&bar=7&baz=3"
131
+ result: '&bar=7&baz=3'
132
132
  };
133
133
 
134
- expect(L.Util.getParamString(b.obj,b.url)).to.eql(b.result);
134
+ expect(L.Util.getParamString(b.obj, b.url)).to.eql(b.result);
135
135
 
136
136
  var c = {
137
137
  url: undefined,
138
138
  obj: {bar: 7, baz: 3},
139
- result: "?bar=7&baz=3"
139
+ result: '?bar=7&baz=3'
140
140
  };
141
141
 
142
- expect(L.Util.getParamString(c.obj,c.url)).to.eql(c.result);
142
+ expect(L.Util.getParamString(c.obj, c.url)).to.eql(c.result);
143
143
  });
144
144
  });
145
145
 
146
146
  describe('#requestAnimFrame', function () {
147
147
  it('calles a function on next frame, unless canceled', function (done) {
148
148
  var spy = sinon.spy(),
149
- spy2 = sinon.spy(),
150
149
  foo = {};
151
150
 
152
151
  L.Util.requestAnimFrame(spy);
@@ -160,7 +159,7 @@ describe('Util', function() {
160
159
  });
161
160
  });
162
161
 
163
- describe('#limitExecByInterval', function() {
162
+ describe('#limitExecByInterval', function () {
164
163
  it('limits execution to not more often than specified time interval', function (done) {
165
164
  var spy = sinon.spy();
166
165
 
@@ -189,24 +188,69 @@ describe('Util', function() {
189
188
 
190
189
  describe('#template', function () {
191
190
  it('evaluates templates with a given data object', function () {
192
- var tpl = 'Hello {foo} and {bar}!';
191
+ var tpl = 'Hello {foo} and {baz }!';
193
192
 
194
193
  var str = L.Util.template(tpl, {
195
194
  foo: 'Vlad',
196
- bar: 'Dave'
195
+ bar: 'Dave',
196
+ baz: function (o) {
197
+ return o.bar;
198
+ }
197
199
  });
198
200
 
199
201
  expect(str).to.eql('Hello Vlad and Dave!');
200
202
  });
201
203
 
204
+ it('check the cache', function () {
205
+ var tpl = 'Hello {foo} and {baz }!';
206
+
207
+ var str = L.Util._templateCache[tpl]({
208
+ foo: 'ladies',
209
+ baz: function () {
210
+ return 'gentlemen';
211
+ }
212
+ });
213
+
214
+ expect(str).to.eql('Hello ladies and gentlemen!');
215
+ });
216
+
217
+ it('evaluates templates with a function', function () {
218
+ var tpl = L.Util.compileTemplate('Hello { foo } and { bar}!', {});
219
+
220
+ var str1 = tpl({
221
+ foo: 'Vlad',
222
+ bar: 'Dave'
223
+ });
224
+ var str2 = tpl({
225
+ foo: '{Calvin}',
226
+ bar: '{Simon}'
227
+ });
228
+
229
+ expect(str1).to.eql('Hello Vlad and Dave!');
230
+ expect(str2).to.eql('Hello {Calvin} and {Simon}!');
231
+ });
232
+
202
233
  it('does not modify text without a token variable', function () {
203
234
  expect(L.Util.template('foo', {})).to.eql('foo');
204
235
  });
205
236
 
237
+ it('supports templates with double quotes', function () {
238
+ expect(L.Util.template('He said: "{foo}"!', {
239
+ foo: 'Hello'
240
+ })).to.eql('He said: "Hello"!');
241
+ });
242
+
206
243
  it('throws when a template token is not given', function () {
207
244
  expect(function () {
208
- L.Util.template(tpl, {foo: 'bar'});
245
+ L.Util.template(undefined, {foo: 'bar'});
209
246
  }).to.throwError();
210
247
  });
211
248
  });
249
+
250
+ describe('#isArray', function () {
251
+ expect(L.Util.isArray([1, 2, 3])).to.be(true);
252
+ expect(L.Util.isArray(new Array(1, 2, 3))).to.be(true);
253
+ expect(L.Util.isArray('blabla')).to.be(false);
254
+ expect(L.Util.isArray({0: 1, 1: 2})).to.be(false);
255
+ });
212
256
  });
@@ -1,10 +1,10 @@
1
- describe('DomEvent', function() {
1
+ describe('DomEvent', function () {
2
2
  var el;
3
3
 
4
4
  function simulateClick(el) {
5
5
  if (document.createEvent) {
6
6
  var e = document.createEvent('MouseEvents');
7
- e.initMouseEvent('click', true, true, window,
7
+ e.initMouseEvent('click', true, true, window,
8
8
  0, 0, 0, 0, 0, false, false, false, false, 0, null);
9
9
  return el.dispatchEvent(e);
10
10
  } else if (el.fireEvent) {
@@ -12,19 +12,19 @@ describe('DomEvent', function() {
12
12
  }
13
13
  }
14
14
 
15
- beforeEach(function() {
15
+ beforeEach(function () {
16
16
  el = document.createElement('div');
17
17
  el.style.position = 'absolute';
18
18
  el.style.top = el.style.left = '-10000px';
19
19
  document.body.appendChild(el);
20
20
  });
21
21
 
22
- afterEach(function() {
22
+ afterEach(function () {
23
23
  document.body.removeChild(el);
24
24
  });
25
25
 
26
- describe('#addListener', function() {
27
- it('adds a listener and calls it on event', function() {
26
+ describe('#addListener', function () {
27
+ it('adds a listener and calls it on event', function () {
28
28
  var listener1 = sinon.spy(),
29
29
  listener2 = sinon.spy();
30
30
 
@@ -37,11 +37,11 @@ describe('DomEvent', function() {
37
37
  expect(listener2.called).to.be.ok();
38
38
  });
39
39
 
40
- it('binds "this" to the given context', function() {
40
+ it('binds "this" to the given context', function () {
41
41
  var obj = {foo: 'bar'},
42
42
  result;
43
43
 
44
- L.DomEvent.addListener(el, 'click', function() {
44
+ L.DomEvent.addListener(el, 'click', function () {
45
45
  result = this;
46
46
  }, obj);
47
47
 
@@ -50,10 +50,10 @@ describe('DomEvent', function() {
50
50
  expect(result).to.eql(obj);
51
51
  });
52
52
 
53
- it('passes an event object to the listener', function() {
53
+ it('passes an event object to the listener', function () {
54
54
  var type;
55
55
 
56
- L.DomEvent.addListener(el, 'click', function(e) {
56
+ L.DomEvent.addListener(el, 'click', function (e) {
57
57
  type = e && e.type;
58
58
  });
59
59
  simulateClick(el);
@@ -62,8 +62,8 @@ describe('DomEvent', function() {
62
62
  });
63
63
  });
64
64
 
65
- describe('#removeListener', function() {
66
- it('removes a previously added listener', function() {
65
+ describe('#removeListener', function () {
66
+ it('removes a previously added listener', function () {
67
67
  var listener = sinon.spy();
68
68
 
69
69
  L.DomEvent.addListener(el, 'click', listener);
@@ -75,8 +75,8 @@ describe('DomEvent', function() {
75
75
  });
76
76
  });
77
77
 
78
- describe('#stopPropagation', function() {
79
- it('stops propagation of the given event', function() {
78
+ describe('#stopPropagation', function () {
79
+ it('stops propagation of the given event', function () {
80
80
  var child = document.createElement('div'),
81
81
  listener = sinon.spy();
82
82
 
@@ -92,8 +92,8 @@ describe('DomEvent', function() {
92
92
  el.removeChild(child);
93
93
  });
94
94
  });
95
- describe('#preventDefault', function() {
96
- it('prevents the default action of event', function() {
95
+ describe('#preventDefault', function () {
96
+ it('prevents the default action of event', function () {
97
97
  L.DomEvent.addListener(el, 'click', L.DomEvent.preventDefault);
98
98
 
99
99
  expect(simulateClick(el)).to.be(false);
@@ -1,30 +1,30 @@
1
- describe('DomUtil', function() {
1
+ describe('DomUtil', function () {
2
2
  var el;
3
3
 
4
- beforeEach(function() {
4
+ beforeEach(function () {
5
5
  el = document.createElement('div');
6
6
  el.style.position = 'absolute';
7
7
  el.style.top = el.style.left = '-10000px';
8
8
  document.body.appendChild(el);
9
9
  });
10
10
 
11
- afterEach(function() {
11
+ afterEach(function () {
12
12
  document.body.removeChild(el);
13
13
  });
14
14
 
15
- describe('#get', function() {
16
- it('gets element by id if the given argument is string', function() {
15
+ describe('#get', function () {
16
+ it('gets element by id if the given argument is string', function () {
17
17
  el.id = 'testId';
18
18
  expect(L.DomUtil.get(el.id)).to.eql(el);
19
19
  });
20
20
 
21
- it('returns the element if it is given as an argument', function() {
21
+ it('returns the element if it is given as an argument', function () {
22
22
  expect(L.DomUtil.get(el)).to.eql(el);
23
23
  });
24
24
  });
25
25
 
26
- describe('#addClass, #removeClass, #hasClass', function() {
27
- it('has defined class for test element', function() {
26
+ describe('#addClass, #removeClass, #hasClass', function () {
27
+ it('has defined class for test element', function () {
28
28
  el.className = 'bar foo baz ';
29
29
  expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
30
30
  expect(L.DomUtil.hasClass(el, 'bar')).to.be.ok();
@@ -32,7 +32,7 @@ describe('DomUtil', function() {
32
32
  expect(L.DomUtil.hasClass(el, 'boo')).to.not.be.ok();
33
33
  });
34
34
 
35
- it('adds or removes the class', function() {
35
+ it('adds or removes the class', function () {
36
36
  el.className = '';
37
37
  L.DomUtil.addClass(el, 'foo');
38
38
 
@@ -53,13 +53,6 @@ describe('DomUtil', function() {
53
53
  });
54
54
  });
55
55
 
56
- describe('#documentIsLtr', function () {
57
- it('returns true if doc direction is ltr', function () {
58
- expect(L.DomUtil.documentIsLtr()).to.eql(true);
59
- expect(L.DomUtil.documentIsLtr()).to.eql(true); // cached
60
- });
61
- });
62
-
63
56
  describe('#getViewportOffset', function () {
64
57
  it('calculates the viewport offset of an element', function () {
65
58
  var div = document.createElement('div');
@@ -0,0 +1,27 @@
1
+ describe('PosAnimation', function () {
2
+ var el;
3
+
4
+ beforeEach(function () {
5
+ el = document.createElement('div');
6
+ this.subject = new L.PosAnimation();
7
+ this.subject._el = el;
8
+ });
9
+
10
+ describe('#_onStep', function () {
11
+ it("sets element position and fires step event if it is able to get current position", function () {
12
+ var point = new L.Point(5, 5, true);
13
+ sinon.stub(this.subject, '_getPos').returns(point);
14
+ this.subject.fire = sinon.stub();
15
+ this.subject._onStep();
16
+ expect(this.subject.fire.withArgs('step').calledOnce).to.be(true);
17
+ expect(L.DomUtil.getPosition(this.subject._el)).to.be(point);
18
+ });
19
+
20
+ it('stops transition if a position returned', function () {
21
+ sinon.stub(this.subject, '_onTransitionEnd');
22
+ sinon.stub(this.subject, '_getPos').returns(undefined);
23
+ this.subject._onStep();
24
+ expect(this.subject._onTransitionEnd.calledOnce).to.be(true);
25
+ });
26
+ });
27
+ });
@@ -0,0 +1,47 @@
1
+ describe("CRS.EPSG3395", function () {
2
+ var crs = L.CRS.EPSG3395;
3
+
4
+ describe("#latLngToPoint", function () {
5
+ it("projects a center point", function () {
6
+ expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
7
+ });
8
+
9
+ it("projects the northeast corner of the world", function () {
10
+ expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0));
11
+ });
12
+ });
13
+
14
+ describe("#pointToLatLng", function () {
15
+ it("reprojects a center point", function () {
16
+ expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
17
+ });
18
+
19
+ it("reprojects the northeast corner of the world", function () {
20
+ expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180));
21
+ });
22
+ });
23
+ });
24
+
25
+ describe("CRS.EPSG3857", function () {
26
+ var crs = L.CRS.EPSG3857;
27
+
28
+ describe("#latLngToPoint", function () {
29
+ it("projects a center point", function () {
30
+ expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
31
+ });
32
+
33
+ it("projects the northeast corner of the world", function () {
34
+ expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0));
35
+ });
36
+ });
37
+
38
+ describe("#pointToLatLng", function () {
39
+ it("reprojects a center point", function () {
40
+ expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
41
+ });
42
+
43
+ it("reprojects the northeast corner of the world", function () {
44
+ expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
45
+ });
46
+ });
47
+ });
@@ -1,7 +1,7 @@
1
- describe('LatLngBounds', function() {
1
+ describe('LatLngBounds', function () {
2
2
  var a, c;
3
3
 
4
- beforeEach(function() {
4
+ beforeEach(function () {
5
5
  a = new L.LatLngBounds(
6
6
  new L.LatLng(14, 12),
7
7
  new L.LatLng(30, 40));
@@ -27,9 +27,17 @@ describe('LatLngBounds', function() {
27
27
 
28
28
  it('extends the bounds by given bounds', function () {
29
29
  a.extend([[20, 50], [8, 40]]);
30
-
31
30
  expect(a.getSouthEast()).to.eql(new L.LatLng(8, 50));
32
31
  });
32
+
33
+ it('extends the bounds by undefined', function () {
34
+ expect(a.extend()).to.eql(a);
35
+ });
36
+
37
+ it('extends the bounds by raw object', function () {
38
+ a.extend({lat: 20, lng: 50});
39
+ expect(a.getNorthEast()).to.eql(new L.LatLng(30, 50));
40
+ });
33
41
  });
34
42
 
35
43
  describe('#getCenter', function () {
@@ -54,62 +62,62 @@ describe('LatLngBounds', function() {
54
62
  });
55
63
  });
56
64
 
57
- describe('#isValid', function() {
58
- it('returns true if properly set up', function() {
65
+ describe('#isValid', function () {
66
+ it('returns true if properly set up', function () {
59
67
  expect(a.isValid()).to.be.ok();
60
68
  });
61
- it('returns false if is invalid', function() {
69
+ it('returns false if is invalid', function () {
62
70
  expect(c.isValid()).to.not.be.ok();
63
71
  });
64
- it('returns true if extended', function() {
72
+ it('returns true if extended', function () {
65
73
  c.extend([0, 0]);
66
74
  expect(c.isValid()).to.be.ok();
67
75
  });
68
76
  });
69
77
 
70
78
  describe('#getWest', function () {
71
- it('returns a proper bbox west value', function() {
79
+ it('returns a proper bbox west value', function () {
72
80
  expect(a.getWest()).to.eql(12);
73
81
  });
74
82
  });
75
83
 
76
84
  describe('#getSouth', function () {
77
- it('returns a proper bbox south value', function() {
85
+ it('returns a proper bbox south value', function () {
78
86
  expect(a.getSouth()).to.eql(14);
79
87
  });
80
88
 
81
89
  });
82
90
 
83
91
  describe('#getEast', function () {
84
- it('returns a proper bbox east value', function() {
92
+ it('returns a proper bbox east value', function () {
85
93
  expect(a.getEast()).to.eql(40);
86
94
  });
87
95
 
88
96
  });
89
97
 
90
98
  describe('#getNorth', function () {
91
- it('returns a proper bbox north value', function() {
99
+ it('returns a proper bbox north value', function () {
92
100
  expect(a.getNorth()).to.eql(30);
93
101
  });
94
102
 
95
103
  });
96
104
 
97
105
  describe('#toBBoxString', function () {
98
- it('returns a proper left,bottom,right,top bbox', function() {
106
+ it('returns a proper left,bottom,right,top bbox', function () {
99
107
  expect(a.toBBoxString()).to.eql("12,14,40,30");
100
108
  });
101
109
 
102
110
  });
103
111
 
104
112
  describe('#getNorthWest', function () {
105
- it('returns a proper north-west LatLng', function() {
113
+ it('returns a proper north-west LatLng', function () {
106
114
  expect(a.getNorthWest()).to.eql(new L.LatLng(a.getNorth(), a.getWest()));
107
115
  });
108
116
 
109
117
  });
110
118
 
111
119
  describe('#getSouthEast', function () {
112
- it('returns a proper south-east LatLng', function() {
120
+ it('returns a proper south-east LatLng', function () {
113
121
  expect(a.getSouthEast()).to.eql(new L.LatLng(a.getSouth(), a.getEast()));
114
122
  });
115
123
  });