Skip to content

Commit

Permalink
Merge branch 'release/3.15.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
xavijam committed Sep 11, 2015
2 parents 3d4e802 + 2c490e5 commit 1fddb38
Show file tree
Hide file tree
Showing 13 changed files with 217 additions and 103 deletions.
12 changes: 6 additions & 6 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- Create a new branch to prepare the release:

```
git flow release start 3.15.3
git flow release start 3.15.4
```

- Build CartoDB.js files, choosing the new version:
Expand All @@ -25,7 +25,7 @@ grunt release
- 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.

```
git commit -am "Files changed for version 3.15.3"
git commit -am "Files changed for version 3.15.4"
```

- Release it.
Expand All @@ -36,8 +36,8 @@ grunt publish

- Check if those files have been updated in the CDN:
```
http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.15.3/cartodb.js
http://libs.cartocdn.com/cartodb.js/v3/3.15.3/cartodb.js
http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.15.4/cartodb.js
http://libs.cartocdn.com/cartodb.js/v3/3.15.4/cartodb.js
http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.13/cartodb.js
http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js
```
Expand All @@ -46,7 +46,7 @@ http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js
- And to finish: close the release and push it.

```
git flow release finish 3.15.3
git flow release finish 3.15.4
git push --all
git push --tags
```
Expand Down Expand Up @@ -75,7 +75,7 @@ grunt
grunt publish
```

For example, if we are in 3.15.3 and we want to go back to 3.13.4
For example, if we are in 3.15.4 and we want to go back to 3.13.4

```
git checkout 3.13.4
Expand Down
10 changes: 5 additions & 5 deletions doc/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1182,16 +1182,16 @@ cartodb.Image(vizjson_url)
An _Image_ object


#### Image.getURL(_callback(err, url)_)
#### Image.getUrl(_callback(err, url)_)

Gets the URL for the image requested.

<div class="image-geturl">Image.getURL</div>
<div class="image-geturl">Image.getUrl</div>
```javascript
<script>
cartodb.Image(vizjson_url)
.size(600, 400)
.getURL(function(err, url) {
.getUrl(function(err, url) {
console.log('image url',url);
})
</script>
Expand Down Expand Up @@ -1452,10 +1452,10 @@ Anytime you wish to push a stable version of your site to the web though, you ca
alert(cartodb.VERSION)
```
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:
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:
```html
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15.3/cartodb.js"></script>
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15.4/cartodb.js"></script>
```
You can do the same for the CSS documents we provide:
Expand Down
80 changes: 80 additions & 0 deletions examples/header_overlay.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<title>Header with createLayer | CartoDB.js</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}

body > div.cartodb-header{
display: none;
position: absolute;
top:0px;
width: 100%;
background-color: rgba(0,0,0,.5);
font-family: 'Helvetica Neue',Helvetica,sans-serif;
line-height: normal;
z-index: 99999;
}
</style>

<link rel="stylesheet" href="http://libs.cartocdn.com/cartodb.js/v3/3.14/themes/css/cartodb.css" />
</head>
<body>
<div id="map"></div>

<!-- include cartodb.js library -->
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.14/cartodb.js"></script>

<script>
function main() {
var map = new L.Map('map', {
zoomControl: false,
center: [43, 0],
zoom: 3
});

L.tileLayer('http://tile.stamen.com/toner/{z}/{x}/{y}.png', {
attribution: 'Stamen',
}).addTo(map);

cartodb.createLayer(map, 'http://documentation.cartodb.com/api/v2/viz/2b13c956-e7c1-11e2-806b-5404a6a683d5/viz.json').addTo(map)
.done(function(layer) {

var sublayer = layer.getSubLayer(0);

var i = new cdb.geo.ui.Header({
model: new cdb.core.Model({
extra: {
title: "Title",
description: "Description",
show_title: true,
show_description: true
}
}),
template: cdb.core.Template.compile(
' \
<div class="content">\
<div class="title">{{{ title }}}</div>\
<div class="description">{{{ description }}}</div>\
</div>',
'mustache'
)
});

$('body').append(i.render().el);
})
.error(function(err) {
console.log(err);
});
}
window.onload = main;
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cartodb.js",
"version": "3.15.3",
"version": "3.15.4",
"description": "CartoDB javascript library",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/cartodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

var cdb = root.cdb = {};

cdb.VERSION = "3.15.3";
cdb.VERSION = "3.15.4";
cdb.DEBUG = false;

cdb.CARTOCSS_VERSIONS = {
Expand Down
20 changes: 3 additions & 17 deletions src/geo/gmaps/gmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ if(typeof(google) != "undefined" && typeof(google.maps) != "undefined") {

this._bindModel();
this._addLayers();
this.setAttribution();

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

this.projector.draw = this._ready;

},

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

var attribution = layer.get('attribution');

if (attribution && attribution !== '') {
// Setting attribution in map model
// it doesn't persist in the backend, so this is needed.
var attributions = _.clone(this.map.get('attribution')) || [];
if (!_.contains(attributions, attribution)) {
attributions.unshift(attribution);
}

this.map.set({ attribution: attributions });
}

return layer_view;

},

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

setAttribution: function(m) {
setAttribution: function() {
// Remove old one
var old = document.getElementById("cartodb-gmaps-attribution")
, attribution = m.get("attribution").join(", ");
, attribution = this.map.get("attribution").join(", ");

// If div already exists, remove it
if (old) {
Expand Down
15 changes: 1 addition & 14 deletions src/geo/leaflet/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
this.map.geometries.bind('remove', this._removeGeometry, this);

this._bindModel();

this._addLayers();
this.setAttribution();

this.map_leaflet.on('layeradd', function(lyr) {
this.trigger('layeradd', lyr, self);
Expand Down Expand Up @@ -254,19 +254,6 @@
lv.setZIndex(lv.model.get('order'));
}

var attribution = layer.get('attribution');

if (attribution && attribution !== '') {
// Setting attribution in map model
// it doesn't persist in the backend, so this is needed.
var attributions = _.clone(this.map.get('attribution')) || [];
if (!_.contains(attributions, attribution)) {
attributions.unshift(attribution);
}

this.map.set({ attribution: attributions });
}

if(opts === undefined || !opts.silent) {
this.trigger('newLayerView', layer_view, layer_view.model, this);
}
Expand Down
43 changes: 20 additions & 23 deletions src/geo/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,28 @@ cdb.geo.Map = cdb.core.Model.extend({
}
}, this);

this.layers.bind('reset', this._updateAttributions, this);
this.layers.bind('add', this._updateAttributions, this);
this.layers.bind('remove', this._updateAttributions, this);
this.layers.bind('change:attribution', this._updateAttributions, this);

this.geometries = new cdb.geo.Geometries();
},

_updateAttributions: function() {
var defaultCartoDBAttribution = this.defaults.attribution[0];
var attributions = _.chain(this.layers.models)
.map(function(layer) { return layer.get('attribution'); })
.reject(function(attribution) { return attribution == defaultCartoDBAttribution})
.compact()
.uniq()
.value();

attributions.push(defaultCartoDBAttribution);

this.set('attribution', attributions);
},

setView: function(latlng, zoom) {
this.set({
center: latlng,
Expand Down Expand Up @@ -462,24 +481,6 @@ cdb.geo.Map = cdb.core.Model.extend({
}
},

updateAttribution: function(old, new_) {
var attributions = this.get("attribution") || [];

// Remove the old one
if (old) {
attributions = _.without(attributions, old);
}

// Save the new one
if (new_) {
if (!_.contains(attributions, new_)) {
attributions.push(new_);
}
}

this.set({ attribution: attributions });
},

addGeometry: function(geom) {
this.geometries.add(geom);
},
Expand Down Expand Up @@ -663,7 +664,7 @@ cdb.geo.MapView = cdb.core.View.extend({
this.map.bind('change:scrollwheel', this._setScrollWheel, this);
this.map.bind('change:keyboard', this._setKeyboard, this);
this.map.bind('change:center', this._setCenter, this);
this.map.bind('change:attribution', this._setAttribution, this);
this.map.bind('change:attribution', this.setAttribution, this);
},

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

_setAttribution: function(m,attr) {
this.setAttribution(m);
},

_addLayers: function() {
var self = this;
this._removeLayers();
Expand Down
36 changes: 32 additions & 4 deletions src/geo/ui/fullscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,42 @@ cdb.ui.common.FullScreen = cdb.core.View.extend({
},

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

var $el = this.$el;
return this;
},

var options = _.extend(this.options);
_canFullScreenBeEnabled: function() {
// If frameElement exists, it means that the map
// is embebed as an iframe so we need to check if
// the parent has a secure protocol
var frameElement = window && window.frameElement;
if (frameElement) {
var parentWindow = this._getFramedWindow(frameElement);
var parentProtocol = parentWindow.location.protocol;
if (parentProtocol.search('https:') !== 0) {
return false;
}
}

$el.html(this.options.template(options));
return true;
},

return this;
_getFramedWindow: function(f) {
if (f.parentNode == null) {
f = document.body.appendChild(f);
}
var w = (f.contentWindow || f.contentDocument);
if (w && w.nodeType && w.nodeType==9) {
w = (w.defaultView || w.parentWindow);
}
return w;
}

});
Loading

0 comments on commit 1fddb38

Please sign in to comment.