leaflet-rails 0.4.2.beta1 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Leaflet
2
2
  module Rails
3
- VERSION = "0.4.2.beta1"
3
+ VERSION = "0.4.4"
4
4
  end
5
5
  end
@@ -21,7 +21,7 @@ if (typeof exports !== undefined + '') {
21
21
  window.L = L;
22
22
  }
23
23
 
24
- L.version = '0.4.2';
24
+ L.version = '0.4.4';
25
25
 
26
26
 
27
27
  /*
@@ -756,7 +756,7 @@ L.DomUtil = {
756
756
  value = Math.round(value * 100);
757
757
 
758
758
  if (filter) {
759
- filter.Enabled = (value === 100);
759
+ filter.Enabled = (value !== 100);
760
760
  filter.Opacity = value;
761
761
  } else {
762
762
  el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';
@@ -1347,7 +1347,8 @@ L.Map = L.Class.extend({
1347
1347
  if (!this._loaded) { return this; }
1348
1348
 
1349
1349
  var offset = oldSize.subtract(this.getSize()).divideBy(2, true);
1350
- if (animate) {
1350
+
1351
+ if (animate === true) {
1351
1352
  this.panBy(offset);
1352
1353
  } else {
1353
1354
  this._rawPanBy(offset);
@@ -2236,10 +2237,12 @@ L.TileLayer = L.Class.extend({
2236
2237
  // get unused tile - or create a new tile
2237
2238
  var tile = this._getTile();
2238
2239
 
2239
- // Chrome 20 layouts much faster with top/left (Verify with timeline, frames), Safari 5.1.7, iOS 5.1.1,
2240
- // android browser (4.0) have display issues with top/left and requires transform instead
2240
+ // Chrome 20 layouts much faster with top/left (Verify with timeline, frames)
2241
+ // android 4 browser has display issues with top/left and requires transform instead
2242
+ // android 3 browser not tested
2243
+ // android 2 browser requires top/left or tiles disappear on load or first drag (reappear after zoom) https://github.com/CloudMade/Leaflet/issues/866
2241
2244
  // (other browsers don't currently care) - see debug/hacks/jitter.html for an example
2242
- L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome);
2245
+ L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome || L.Browser.android23);
2243
2246
 
2244
2247
  this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;
2245
2248
 
@@ -3531,6 +3534,14 @@ L.FeatureGroup = L.LayerGroup.extend({
3531
3534
  return this.invoke('setStyle', style);
3532
3535
  },
3533
3536
 
3537
+ bringToFront: function () {
3538
+ return this.invoke('bringToFront');
3539
+ },
3540
+
3541
+ bringToBack: function () {
3542
+ return this.invoke('bringToBack');
3543
+ },
3544
+
3534
3545
  getBounds: function () {
3535
3546
  var bounds = new L.LatLngBounds();
3536
3547
  this.eachLayer(function (layer) {
@@ -3679,6 +3690,7 @@ L.Path = L.Path.extend({
3679
3690
  if (this._container) {
3680
3691
  this._map._pathRoot.appendChild(this._container);
3681
3692
  }
3693
+ return this;
3682
3694
  },
3683
3695
 
3684
3696
  bringToBack: function () {
@@ -3686,6 +3698,7 @@ L.Path = L.Path.extend({
3686
3698
  var root = this._map._pathRoot;
3687
3699
  root.insertBefore(this._container, root.firstChild);
3688
3700
  }
3701
+ return this;
3689
3702
  },
3690
3703
 
3691
3704
  getPathString: function () {
@@ -5058,27 +5071,42 @@ L.GeoJSON = L.FeatureGroup.extend({
5058
5071
  return this;
5059
5072
  }
5060
5073
 
5061
- var options = this.options,
5062
- style = options.style;
5074
+ var options = this.options;
5063
5075
 
5064
5076
  if (options.filter && !options.filter(geojson)) { return; }
5065
5077
 
5066
5078
  var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer);
5079
+ layer.feature = geojson;
5067
5080
 
5068
- if (style) {
5069
- if (typeof style === 'function') {
5070
- style = style(geojson);
5071
- }
5072
- if (layer.setStyle) {
5073
- layer.setStyle(style);
5074
- }
5075
- }
5081
+ this.resetStyle(layer);
5076
5082
 
5077
5083
  if (options.onEachFeature) {
5078
5084
  options.onEachFeature(geojson, layer);
5079
5085
  }
5080
5086
 
5081
5087
  return this.addLayer(layer);
5088
+ },
5089
+
5090
+ resetStyle: function (layer) {
5091
+ var style = this.options.style;
5092
+ if (style) {
5093
+ this._setLayerStyle(layer, style);
5094
+ }
5095
+ },
5096
+
5097
+ setStyle: function (style) {
5098
+ this.eachLayer(function (layer) {
5099
+ this._setLayerStyle(layer, style);
5100
+ }, this);
5101
+ },
5102
+
5103
+ _setLayerStyle: function (layer, style) {
5104
+ if (typeof style === 'function') {
5105
+ style = style(layer.feature);
5106
+ }
5107
+ if (layer.setStyle) {
5108
+ layer.setStyle(style);
5109
+ }
5082
5110
  }
5083
5111
  });
5084
5112
 
@@ -5158,6 +5186,7 @@ L.geoJson = function (geojson, options) {
5158
5186
  return new L.GeoJSON(geojson, options);
5159
5187
  };
5160
5188
 
5189
+
5161
5190
  /*
5162
5191
  * L.DomEvent contains functions for working with DOM events.
5163
5192
  */
@@ -5400,11 +5429,6 @@ L.Draggable = L.Class.extend({
5400
5429
  return;
5401
5430
  }
5402
5431
 
5403
- if (!L.Browser.touch) {
5404
- L.DomUtil.disableTextSelection();
5405
- this._setMovingCursor();
5406
- }
5407
-
5408
5432
  this._startPos = this._newPos = L.DomUtil.getPosition(this._element);
5409
5433
  this._startPoint = new L.Point(first.clientX, first.clientY);
5410
5434
 
@@ -5426,6 +5450,11 @@ L.Draggable = L.Class.extend({
5426
5450
  if (!this._moved) {
5427
5451
  this.fire('dragstart');
5428
5452
  this._moved = true;
5453
+
5454
+ if (!L.Browser.touch) {
5455
+ L.DomUtil.disableTextSelection();
5456
+ this._setMovingCursor();
5457
+ }
5429
5458
  }
5430
5459
 
5431
5460
  this._newPos = this._startPos.add(diffVec);
@@ -6042,8 +6071,8 @@ L.Map.Keyboard = L.Handler.extend({
6042
6071
  right: [39],
6043
6072
  down: [40],
6044
6073
  up: [38],
6045
- zoomIn: [187, 61, 107],
6046
- zoomOut: [189, 109, 0]
6074
+ zoomIn: [187, 107, 61],
6075
+ zoomOut: [189, 109]
6047
6076
  },
6048
6077
 
6049
6078
  initialize: function (map) {
@@ -7087,7 +7116,7 @@ L.Transition = L.Transition.extend({
7087
7116
 
7088
7117
  this._el.style[L.Transition.DURATION] = this.options.duration + 's';
7089
7118
  this._el.style[L.Transition.EASING] = this.options.easing;
7090
- this._el.style[L.Transition.PROPERTY] = propsList.join(', ');
7119
+ this._el.style[L.Transition.PROPERTY] = 'all';
7091
7120
 
7092
7121
  for (prop in props) {
7093
7122
  if (props.hasOwnProperty(prop)) {
@@ -7095,9 +7124,10 @@ L.Transition = L.Transition.extend({
7095
7124
  }
7096
7125
  }
7097
7126
 
7098
- this._inProgress = true;
7127
+ // Chrome flickers for some reason if you don't do this
7128
+ L.Util.falseFn(this._el.offsetWidth);
7099
7129
 
7100
- this.fire('start');
7130
+ this._inProgress = true;
7101
7131
 
7102
7132
  if (L.Browser.mobileWebkit) {
7103
7133
  // Set up a slightly delayed call to a backup event if webkitTransitionEnd doesn't fire properly
@@ -7353,11 +7383,18 @@ L.Map.mergeOptions({
7353
7383
  zoomAnimation: L.DomUtil.TRANSITION && !L.Browser.android23 && !L.Browser.mobileOpera
7354
7384
  });
7355
7385
 
7386
+ if (L.DomUtil.TRANSITION) {
7387
+ L.Map.addInitHook(function () {
7388
+ L.DomEvent.on(this._mapPane, L.Transition.END, this._catchTransitionEnd, this);
7389
+ });
7390
+ }
7391
+
7356
7392
  L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7357
7393
 
7358
7394
  _zoomToIfClose: function (center, zoom) {
7359
7395
 
7360
7396
  if (this._animatingZoom) { return true; }
7397
+
7361
7398
  if (!this.options.zoomAnimation) { return false; }
7362
7399
 
7363
7400
  var scale = this.getZoomScale(zoom),
@@ -7372,8 +7409,6 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7372
7409
  .fire('movestart')
7373
7410
  .fire('zoomstart');
7374
7411
 
7375
- this._prepareTileBg();
7376
-
7377
7412
  this.fire('zoomanim', {
7378
7413
  center: center,
7379
7414
  zoom: zoom
@@ -7381,17 +7416,22 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7381
7416
 
7382
7417
  var origin = this._getCenterLayerPoint().add(offset);
7383
7418
 
7419
+ this._prepareTileBg();
7384
7420
  this._runAnimation(center, zoom, scale, origin);
7385
7421
 
7386
7422
  return true;
7387
7423
  },
7388
7424
 
7425
+ _catchTransitionEnd: function (e) {
7426
+ if (this._animatingZoom) {
7427
+ this._onZoomTransitionEnd();
7428
+ }
7429
+ },
7389
7430
 
7390
7431
  _runAnimation: function (center, zoom, scale, origin, backwardsTransform) {
7391
- this._animatingZoom = true;
7392
-
7393
7432
  this._animateToCenter = center;
7394
7433
  this._animateToZoom = zoom;
7434
+ this._animatingZoom = true;
7395
7435
 
7396
7436
  var transform = L.DomUtil.TRANSFORM,
7397
7437
  tileBg = this._tileBg;
@@ -7403,29 +7443,14 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7403
7443
  tileBg.style[transform] += ' translate(0,0)';
7404
7444
  }
7405
7445
 
7406
- var scaleStr;
7407
-
7408
- // Android 2.* doesn't like translate/scale chains, transformOrigin + scale works better but
7409
- // it breaks touch zoom which Anroid doesn't support anyway, so that's a really ugly hack
7410
-
7411
- // TODO work around this prettier
7412
- if (L.Browser.android23) {
7413
- tileBg.style[transform + 'Origin'] = origin.x + 'px ' + origin.y + 'px';
7414
- scaleStr = 'scale(' + scale + ')';
7415
- } else {
7416
- scaleStr = L.DomUtil.getScaleString(scale, origin);
7417
- }
7418
-
7419
7446
  L.Util.falseFn(tileBg.offsetWidth); //hack to make sure transform is updated before running animation
7420
7447
 
7421
- var options = {};
7422
- if (backwardsTransform) {
7423
- options[transform] = tileBg.style[transform] + ' ' + scaleStr;
7424
- } else {
7425
- options[transform] = scaleStr + ' ' + tileBg.style[transform];
7426
- }
7448
+ var scaleStr = L.DomUtil.getScaleString(scale, origin),
7449
+ oldTransform = tileBg.style[transform];
7427
7450
 
7428
- tileBg.transition.run(options);
7451
+ tileBg.style[transform] = backwardsTransform ?
7452
+ oldTransform + ' ' + scaleStr :
7453
+ scaleStr + ' ' + oldTransform;
7429
7454
  },
7430
7455
 
7431
7456
  _prepareTileBg: function () {
@@ -7433,8 +7458,7 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7433
7458
  tileBg = this._tileBg;
7434
7459
 
7435
7460
  // If foreground layer doesn't have many tiles but bg layer does, keep the existing bg layer and just zoom it some more
7436
- // (disable this for Android due to it not supporting double translate)
7437
- if (!L.Browser.android23 && tileBg &&
7461
+ if (tileBg &&
7438
7462
  this._getLoadedTilesPercentage(tileBg) > 0.5 &&
7439
7463
  this._getLoadedTilesPercentage(tilePane) < 0.5) {
7440
7464
 
@@ -7461,14 +7485,7 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7461
7485
  this._tilePane = this._panes.tilePane = tileBg;
7462
7486
  var newTileBg = this._tileBg = tilePane;
7463
7487
 
7464
- if (!newTileBg.transition) {
7465
- // TODO move to Map options
7466
- newTileBg.transition = new L.Transition(newTileBg, {
7467
- duration: 0.25,
7468
- easing: 'cubic-bezier(0.25,0.1,0.25,0.75)'
7469
- });
7470
- newTileBg.transition.on('end', this._onZoomTransitionEnd, this);
7471
- }
7488
+ L.DomUtil.addClass(newTileBg, 'leaflet-zoom-animated');
7472
7489
 
7473
7490
  this._stopLoadingImages(newTileBg);
7474
7491
  },
@@ -7505,7 +7522,6 @@ L.Map.include(!L.DomUtil.TRANSITION ? {} : {
7505
7522
 
7506
7523
  _onZoomTransitionEnd: function () {
7507
7524
  this._restoreTileFront();
7508
-
7509
7525
  L.Util.falseFn(this._tileBg.offsetWidth); // force reflow
7510
7526
  this._resetView(this._animateToCenter, this._animateToZoom, true, true);
7511
7527
 
@@ -365,9 +365,8 @@
365
365
  .leaflet-popup-content-wrapper, .leaflet-popup-tip {
366
366
  background: white;
367
367
 
368
- box-shadow: 0 3px 10px #888;
369
- -moz-box-shadow: 0 3px 10px #888;
370
- -webkit-box-shadow: 0 3px 14px #999;
368
+ box-shadow: 0 3px 14px rgba(0,0,0,0.35);
369
+ -webkit-box-shadow: 0 3px 18px rgba(0,0,0,0.33);
371
370
  }
372
371
  .leaflet-popup-content-wrapper {
373
372
  -moz-border-radius: 20px;
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leaflet-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2.beta1
5
- prerelease: 6
4
+ version: 0.4.4
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Akshay Joshi
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-02 00:00:00.000000000 Z
12
+ date: 2012-08-23 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: This gem provides the leaflet.js map display library for your Rails 3
15
15
  application.
@@ -31,7 +31,6 @@ files:
31
31
  - vendor/assets/images/layers.png
32
32
  - vendor/assets/images/marker-icon.png
33
33
  - vendor/assets/images/marker-shadow.png
34
- - vendor/assets/images/popup-close.png
35
34
  - vendor/assets/images/zoom-in.png
36
35
  - vendor/assets/images/zoom-out.png
37
36
  - vendor/assets/javascripts/leaflet.js.erb
@@ -51,13 +50,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
50
  version: '0'
52
51
  segments:
53
52
  - 0
54
- hash: -734423042529007207
53
+ hash: -1604447338588129085
55
54
  required_rubygems_version: !ruby/object:Gem::Requirement
56
55
  none: false
57
56
  requirements:
58
- - - ! '>'
57
+ - - ! '>='
59
58
  - !ruby/object:Gem::Version
60
- version: 1.3.1
59
+ version: '0'
60
+ segments:
61
+ - 0
62
+ hash: -1604447338588129085
61
63
  requirements: []
62
64
  rubyforge_project: leaflet-rails
63
65
  rubygems_version: 1.8.23
Binary file