Skip to content

Commit 1fddb38

Browse files
committed
Merge branch 'release/3.15.4'
2 parents 3d4e802 + 2c490e5 commit 1fddb38

File tree

13 files changed

+217
-103
lines changed

13 files changed

+217
-103
lines changed

Diff for: RELEASING.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- Create a new branch to prepare the release:
1414

1515
```
16-
git flow release start 3.15.3
16+
git flow release start 3.15.4
1717
```
1818

1919
- Build CartoDB.js files, choosing the new version:
@@ -25,7 +25,7 @@ grunt release
2525
- Update the NEWS file and commit the changes. Take into account that new CartoDB.js version will be replaced in ```API.md```, ```RELEASING.md```, ```README.md```, ```package.json```, ```cartodb.js``` and ```examples``` files.
2626

2727
```
28-
git commit -am "Files changed for version 3.15.3"
28+
git commit -am "Files changed for version 3.15.4"
2929
```
3030

3131
- Release it.
@@ -36,8 +36,8 @@ grunt publish
3636

3737
- Check if those files have been updated in the CDN:
3838
```
39-
http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.15.3/cartodb.js
40-
http://libs.cartocdn.com/cartodb.js/v3/3.15.3/cartodb.js
39+
http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.15.4/cartodb.js
40+
http://libs.cartocdn.com/cartodb.js/v3/3.15.4/cartodb.js
4141
http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.13/cartodb.js
4242
http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js
4343
```
@@ -46,7 +46,7 @@ http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js
4646
- And to finish: close the release and push it.
4747

4848
```
49-
git flow release finish 3.15.3
49+
git flow release finish 3.15.4
5050
git push --all
5151
git push --tags
5252
```
@@ -75,7 +75,7 @@ grunt
7575
grunt publish
7676
```
7777

78-
For example, if we are in 3.15.3 and we want to go back to 3.13.4
78+
For example, if we are in 3.15.4 and we want to go back to 3.13.4
7979

8080
```
8181
git checkout 3.13.4

Diff for: doc/API.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1182,16 +1182,16 @@ cartodb.Image(vizjson_url)
11821182
An _Image_ object
11831183

11841184

1185-
#### Image.getURL(_callback(err, url)_)
1185+
#### Image.getUrl(_callback(err, url)_)
11861186

11871187
Gets the URL for the image requested.
11881188

1189-
<div class="image-geturl">Image.getURL</div>
1189+
<div class="image-geturl">Image.getUrl</div>
11901190
```javascript
11911191
<script>
11921192
cartodb.Image(vizjson_url)
11931193
.size(600, 400)
1194-
.getURL(function(err, url) {
1194+
.getUrl(function(err, url) {
11951195
console.log('image url',url);
11961196
})
11971197
</script>
@@ -1452,10 +1452,10 @@ Anytime you wish to push a stable version of your site to the web though, you ca
14521452
alert(cartodb.VERSION)
14531453
```
14541454
1455-
Once you know which version of CartoDB.js you're using, you can point your site to that release. If the current version of CartoDB.js is 3.15.3, the URL would be:
1455+
Once you know which version of CartoDB.js you're using, you can point your site to that release. If the current version of CartoDB.js is 3.15.4, the URL would be:
14561456
14571457
```html
1458-
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15.3/cartodb.js"></script>
1458+
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15.4/cartodb.js"></script>
14591459
```
14601460
14611461
You can do the same for the CSS documents we provide:

Diff for: examples/header_overlay.html

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Header with createLayer | CartoDB.js</title>
5+
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
6+
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
7+
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
8+
<style>
9+
html, body, #map {
10+
height: 100%;
11+
padding: 0;
12+
margin: 0;
13+
}
14+
15+
body > div.cartodb-header{
16+
display: none;
17+
position: absolute;
18+
top:0px;
19+
width: 100%;
20+
background-color: rgba(0,0,0,.5);
21+
font-family: 'Helvetica Neue',Helvetica,sans-serif;
22+
line-height: normal;
23+
z-index: 99999;
24+
}
25+
</style>
26+
27+
<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.14/themes/css/cartodb.css" />
28+
</head>
29+
<body>
30+
<div id="map"></div>
31+
32+
<!-- include cartodb.js library -->
33+
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.14/cartodb.js"></script>
34+
35+
<script>
36+
function main() {
37+
var map = new L.Map('map', {
38+
zoomControl: false,
39+
center: [43, 0],
40+
zoom: 3
41+
});
42+
43+
L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
44+
attribution: 'Stamen',
45+
}).addTo(map);
46+
47+
cartodb.createLayer(map, 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json').addTo(map)
48+
.done(function(layer) {
49+
50+
var sublayer = layer.getSubLayer(0);
51+
52+
var i = new cdb.geo.ui.Header({
53+
model: new cdb.core.Model({
54+
extra: {
55+
title: "Title",
56+
description: "Description",
57+
show_title: true,
58+
show_description: true
59+
}
60+
}),
61+
template: cdb.core.Template.compile(
62+
' \
63+
<div class="content">\
64+
<div class="title">{{{ title }}}</div>\
65+
<div class="description">{{{ description }}}</div>\
66+
</div>',
67+
'mustache'
68+
)
69+
});
70+
71+
$('body').append(i.render().el);
72+
})
73+
.error(function(err) {
74+
console.log(err);
75+
});
76+
}
77+
window.onload = main;
78+
</script>
79+
</body>
80+
</html>

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cartodb.js",
3-
"version": "3.15.3",
3+
"version": "3.15.4",
44
"description": "CartoDB javascript library",
55
"repository": {
66
"type": "git",

Diff for: src/cartodb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
var cdb = root.cdb = {};
77

8-
cdb.VERSION = "3.15.3";
8+
cdb.VERSION = "3.15.4";
99
cdb.DEBUG = false;
1010

1111
cdb.CARTOCSS_VERSIONS = {

Diff for: src/geo/gmaps/gmaps.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ if(typeof(google) != "undefined" && typeof(google.maps) != "undefined") {
8383

8484
this._bindModel();
8585
this._addLayers();
86+
this.setAttribution();
8687

8788
google.maps.event.addListener(this.map_googlemaps, 'center_changed', function() {
8889
var c = self.map_googlemaps.getCenter();
@@ -116,7 +117,6 @@ if(typeof(google) != "undefined" && typeof(google.maps) != "undefined") {
116117
this.projector = new cdb.geo.CartoDBLayerGroupGMaps.Projector(this.map_googlemaps);
117118

118119
this.projector.draw = this._ready;
119-
120120
},
121121

122122
_ready: function() {
@@ -208,21 +208,7 @@ if(typeof(google) != "undefined" && typeof(google.maps) != "undefined") {
208208
cdb.log.error("layer type not supported");
209209
}
210210

211-
var attribution = layer.get('attribution');
212-
213-
if (attribution && attribution !== '') {
214-
// Setting attribution in map model
215-
// it doesn't persist in the backend, so this is needed.
216-
var attributions = _.clone(this.map.get('attribution')) || [];
217-
if (!_.contains(attributions, attribution)) {
218-
attributions.unshift(attribution);
219-
}
220-
221-
this.map.set({ attribution: attributions });
222-
}
223-
224211
return layer_view;
225-
226212
},
227213

228214
pixelToLatLon: function(pos) {
@@ -266,10 +252,10 @@ if(typeof(google) != "undefined" && typeof(google.maps) != "undefined") {
266252
return [ [0,0], [0,0] ];
267253
},
268254

269-
setAttribution: function(m) {
255+
setAttribution: function() {
270256
// Remove old one
271257
var old = document.getElementById("cartodb-gmaps-attribution")
272-
, attribution = m.get("attribution").join(", ");
258+
, attribution = this.map.get("attribution").join(", ");
273259

274260
// If div already exists, remove it
275261
if (old) {

Diff for: src/geo/leaflet/leaflet.js

+1-14
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@
7070
this.map.geometries.bind('remove', this._removeGeometry, this);
7171

7272
this._bindModel();
73-
7473
this._addLayers();
74+
this.setAttribution();
7575

7676
this.map_leaflet.on('layeradd', function(lyr) {
7777
this.trigger('layeradd', lyr, self);
@@ -254,19 +254,6 @@
254254
lv.setZIndex(lv.model.get('order'));
255255
}
256256

257-
var attribution = layer.get('attribution');
258-
259-
if (attribution && attribution !== '') {
260-
// Setting attribution in map model
261-
// it doesn't persist in the backend, so this is needed.
262-
var attributions = _.clone(this.map.get('attribution')) || [];
263-
if (!_.contains(attributions, attribution)) {
264-
attributions.unshift(attribution);
265-
}
266-
267-
this.map.set({ attribution: attributions });
268-
}
269-
270257
if(opts === undefined || !opts.silent) {
271258
this.trigger('newLayerView', layer_view, layer_view.model, this);
272259
}

Diff for: src/geo/map.js

+20-23
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,28 @@ cdb.geo.Map = cdb.core.Model.extend({
294294
}
295295
}, this);
296296

297+
this.layers.bind('reset', this._updateAttributions, this);
298+
this.layers.bind('add', this._updateAttributions, this);
299+
this.layers.bind('remove', this._updateAttributions, this);
300+
this.layers.bind('change:attribution', this._updateAttributions, this);
301+
297302
this.geometries = new cdb.geo.Geometries();
298303
},
299304

305+
_updateAttributions: function() {
306+
var defaultCartoDBAttribution = this.defaults.attribution[0];
307+
var attributions = _.chain(this.layers.models)
308+
.map(function(layer) { return layer.get('attribution'); })
309+
.reject(function(attribution) { return attribution == defaultCartoDBAttribution})
310+
.compact()
311+
.uniq()
312+
.value();
313+
314+
attributions.push(defaultCartoDBAttribution);
315+
316+
this.set('attribution', attributions);
317+
},
318+
300319
setView: function(latlng, zoom) {
301320
this.set({
302321
center: latlng,
@@ -462,24 +481,6 @@ cdb.geo.Map = cdb.core.Model.extend({
462481
}
463482
},
464483

465-
updateAttribution: function(old, new_) {
466-
var attributions = this.get("attribution") || [];
467-
468-
// Remove the old one
469-
if (old) {
470-
attributions = _.without(attributions, old);
471-
}
472-
473-
// Save the new one
474-
if (new_) {
475-
if (!_.contains(attributions, new_)) {
476-
attributions.push(new_);
477-
}
478-
}
479-
480-
this.set({ attribution: attributions });
481-
},
482-
483484
addGeometry: function(geom) {
484485
this.geometries.add(geom);
485486
},
@@ -663,7 +664,7 @@ cdb.geo.MapView = cdb.core.View.extend({
663664
this.map.bind('change:scrollwheel', this._setScrollWheel, this);
664665
this.map.bind('change:keyboard', this._setKeyboard, this);
665666
this.map.bind('change:center', this._setCenter, this);
666-
this.map.bind('change:attribution', this._setAttribution, this);
667+
this.map.bind('change:attribution', this.setAttribution, this);
667668
},
668669

669670
/** unbind model properties */
@@ -688,10 +689,6 @@ cdb.geo.MapView = cdb.core.View.extend({
688689
this.map.fitBounds(bounds, this.getSize())
689690
},
690691

691-
_setAttribution: function(m,attr) {
692-
this.setAttribution(m);
693-
},
694-
695692
_addLayers: function() {
696693
var self = this;
697694
this._removeLayers();

Diff for: src/geo/ui/fullscreen.js

+32-4
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,42 @@ cdb.ui.common.FullScreen = cdb.core.View.extend({
9999
},
100100

101101
render: function() {
102+
if (this._canFullScreenBeEnabled()) {
103+
var $el = this.$el;
104+
var options = _.extend(this.options);
105+
$el.html(this.options.template(options));
106+
} else {
107+
cdb.log.info('FullScreen is deprecated on insecure origins. See https://goo.gl/rStTGz for more details.');
108+
}
102109

103-
var $el = this.$el;
110+
return this;
111+
},
104112

105-
var options = _.extend(this.options);
113+
_canFullScreenBeEnabled: function() {
114+
// If frameElement exists, it means that the map
115+
// is embebed as an iframe so we need to check if
116+
// the parent has a secure protocol
117+
var frameElement = window && window.frameElement;
118+
if (frameElement) {
119+
var parentWindow = this._getFramedWindow(frameElement);
120+
var parentProtocol = parentWindow.location.protocol;
121+
if (parentProtocol.search('https:') !== 0) {
122+
return false;
123+
}
124+
}
106125

107-
$el.html(this.options.template(options));
126+
return true;
127+
},
108128

109-
return this;
129+
_getFramedWindow: function(f) {
130+
if (f.parentNode == null) {
131+
f = document.body.appendChild(f);
132+
}
133+
var w = (f.contentWindow || f.contentDocument);
134+
if (w && w.nodeType && w.nodeType==9) {
135+
w = (w.defaultView || w.parentWindow);
136+
}
137+
return w;
110138
}
111139

112140
});

0 commit comments

Comments
 (0)