diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index fb4b5ad7ed..1e2293159b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -5,6 +5,7 @@
3. [Filling a ticket](#filling-a-ticket)
4. [Contributing code](#contributing-code)
5. [Completing documentation](#completing-documentation)
+6. [Submitting contributions](#submitting-contributions)
### CartoDB.js quick start
@@ -86,3 +87,7 @@ If you want more detailed information, this [GitHub guide](https://guides.github
CartoDB.js documentation is located in ```doc/API.md```. That file is the content that appears in [CartoDB platform documentation](http://docs.cartodb.com/cartodb-platform/cartodb-js.html).
Just follow the instructions described in [contributing code](#contributing-code) and after accepting your pull request, we will make it appear online :).
+
+## Submitting contributions
+
+You will need to sign a Contributor License Agreement (CLA) before making a submission. [Learn more here](https://cartodb.com/contributing).
diff --git a/NEWS b/NEWS
index 85ad40f0ce..8448a517bc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,9 @@
-3.X ()
+3.X.X ()
+
+
+3.15.3 (08//09//2015)
+* Display custom attribution of layers (#5216).
+* Updated grunt-contrib-imagemin package version.
3.15.2 (01//09//2015)
* Take `visible` attribute into account when determining visibility of layers and serializing maps (#546)
diff --git a/README.md b/README.md
index c56ce12af9..02c9a2df15 100644
--- a/README.md
+++ b/README.md
@@ -72,3 +72,9 @@ Build CartoDB.js library:
- Install ruby dependencies: `bundle install` (necessary for compass gem)
- Start the server: `grunt build`
- Happy mapping!
+ -
+
+## Submitting Contributions
+
+You will need to sign a Contributor License Agreement (CLA) before making a submission. [Learn more here.](https://cartodb.com/contributing)
+
diff --git a/RELEASING.md b/RELEASING.md
index 306a53e6e3..ee71752d7c 100644
--- a/RELEASING.md
+++ b/RELEASING.md
@@ -13,7 +13,7 @@
- Create a new branch to prepare the release:
```
-git flow release start 3.15.2
+git flow release start 3.15.3
```
- Build CartoDB.js files, choosing the new version:
@@ -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.2"
+git commit -am "Files changed for version 3.15.3"
```
- Release it.
@@ -36,17 +36,17 @@ grunt publish
- Check if those files have been updated in the CDN:
```
-http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.15.2/cartodb.js
-http://libs.cartocdn.com/cartodb.js/v3/3.15.2/cartodb.js
-http://libs.cartocdn.com.s3.amazonaws.com/cartodb.js/v3/3.15/cartodb.js
-http://libs.cartocdn.com/cartodb.js/v3/3.15/cartodb.js
+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.13/cartodb.js
+http://libs.cartocdn.com/cartodb.js/v3/3.13/cartodb.js
```
- Sometimes It takes more than 10 minutes, if it is not updated, execute ```grunt invalidate```.
- And to finish: close the release and push it.
```
-git flow release finish 3.15.2
+git flow release finish 3.15.3
git push --all
git push --tags
```
@@ -75,7 +75,7 @@ grunt
grunt publish
```
-For example, if we are in 3.15.2 and we want to go back to 3.13.4
+For example, if we are in 3.15.3 and we want to go back to 3.13.4
```
git checkout 3.13.4
diff --git a/doc/API.md b/doc/API.md
index 72f7024deb..cc0a496228 100644
--- a/doc/API.md
+++ b/doc/API.md
@@ -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.2, 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.3, the URL would be:
```html
-
+
```
You can do the same for the CSS documents we provide:
diff --git a/package.json b/package.json
index 8603e0ca79..47d0e458a8 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "cartodb.js",
- "version": "3.15.2",
+ "version": "3.15.3",
"description": "CartoDB javascript library",
"repository": {
"type": "git",
@@ -38,7 +38,7 @@
"grunt-contrib-csslint": "~0.2.0",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-contrib-htmlmin": "~0.1.3",
- "grunt-contrib-imagemin": "~0.7.0",
+ "grunt-contrib-imagemin": "~0.9.4",
"grunt-contrib-jshint": "~0.8.0",
"grunt-contrib-uglify": "~0.3.0",
"grunt-replace": "0.6.2",
diff --git a/src/cartodb.js b/src/cartodb.js
index da8922b5c4..2293829efa 100644
--- a/src/cartodb.js
+++ b/src/cartodb.js
@@ -5,7 +5,7 @@
var cdb = root.cdb = {};
- cdb.VERSION = "3.15.2";
+ cdb.VERSION = "3.15.3";
cdb.DEBUG = false;
cdb.CARTOCSS_VERSIONS = {
diff --git a/src/geo/gmaps/gmaps.js b/src/geo/gmaps/gmaps.js
index b6c01e4363..11bb085462 100644
--- a/src/geo/gmaps/gmaps.js
+++ b/src/geo/gmaps/gmaps.js
@@ -210,12 +210,12 @@ if(typeof(google) != "undefined" && typeof(google.maps) != "undefined") {
var attribution = layer.get('attribution');
- if (attribution) {
+ if (attribution && attribution !== '') {
// Setting attribution in map model
// it doesn't persist in the backend, so this is needed.
- var attributions = this.map.get('attribution') || [];
+ var attributions = _.clone(this.map.get('attribution')) || [];
if (!_.contains(attributions, attribution)) {
- attributions.push(attribution);
+ attributions.unshift(attribution);
}
this.map.set({ attribution: attributions });
diff --git a/src/geo/gmaps/gmaps_cartodb_layer.js b/src/geo/gmaps/gmaps_cartodb_layer.js
index c8c3802d53..f1421a2881 100644
--- a/src/geo/gmaps/gmaps_cartodb_layer.js
+++ b/src/geo/gmaps/gmaps_cartodb_layer.js
@@ -28,7 +28,7 @@ var CartoDBLayer = function(options) {
var default_options = {
query: "SELECT * FROM {{table_name}}",
opacity: 0.99,
- attribution: "CartoDB",
+ attribution: cdb.config.get('cartodb_attributions'),
opacity: 1,
debug: false,
visible: true,
@@ -80,10 +80,6 @@ var GMapsCartoDBLayerView = function(layerModel, gmapsMap) {
_.bindAll(this, 'featureOut', 'featureOver', 'featureClick');
- // CartoDB new attribution,
- // also we have the logo
- layerModel.attributes.attribution = cdb.config.get('cartodb_attributions');
-
var opts = _.clone(layerModel.attributes);
opts.map = gmapsMap;
diff --git a/src/geo/gmaps/gmaps_cartodb_layergroup.js b/src/geo/gmaps/gmaps_cartodb_layergroup.js
index f8f08d5e8d..24292b468c 100644
--- a/src/geo/gmaps/gmaps_cartodb_layergroup.js
+++ b/src/geo/gmaps/gmaps_cartodb_layergroup.js
@@ -26,7 +26,7 @@ Projector.prototype.pixelToLatLng = function(point) {
var default_options = {
opacity: 0.99,
- attribution: "CartoDB",
+ attribution: cdb.config.get('cartodb_attributions'),
debug: false,
visible: true,
added: false,
@@ -318,10 +318,6 @@ function LayerGroupView(base) {
_.bindAll(this, 'featureOut', 'featureOver', 'featureClick');
- // CartoDB new attribution,z
- // also we have the logo
- layerModel.attributes.attribution = cdb.config.get('cartodb_attributions');
-
var opts = _.clone(layerModel.attributes);
opts.map = gmapsMap;
diff --git a/src/geo/gmaps/torque.js b/src/geo/gmaps/torque.js
index a913d3a27b..dea43b27ab 100644
--- a/src/geo/gmaps/torque.js
+++ b/src/geo/gmaps/torque.js
@@ -7,7 +7,6 @@ if(typeof(google) == "undefined" || typeof(google.maps) == "undefined")
var GMapsTorqueLayerView = function(layerModel, gmapsMap) {
var extra = layerModel.get('extra_params');
- layerModel.attributes.attribution = cdb.config.get('cartodb_attributions');
cdb.geo.GMapsLayerView.call(this, layerModel, this, gmapsMap);
var query = this._getQuery(layerModel);
diff --git a/src/geo/leaflet/leaflet.js b/src/geo/leaflet/leaflet.js
index 0ddab93790..317efc4a07 100644
--- a/src/geo/leaflet/leaflet.js
+++ b/src/geo/leaflet/leaflet.js
@@ -58,7 +58,6 @@
// unset bounds to not change mapbounds
self.map.unset('view_bounds_sw', { silent: true });
self.map.unset('view_bounds_ne', { silent: true });
-
}
this.map.bind('set_view', this._setView, this);
@@ -257,11 +256,12 @@
var attribution = layer.get('attribution');
- if (attribution) {
+ if (attribution && attribution !== '') {
// Setting attribution in map model
- var attributions = this.map.get('attribution') || [];
+ // it doesn't persist in the backend, so this is needed.
+ var attributions = _.clone(this.map.get('attribution')) || [];
if (!_.contains(attributions, attribution)) {
- attributions.push(attribution);
+ attributions.unshift(attribution);
}
this.map.set({ attribution: attributions });
@@ -294,8 +294,15 @@
];
},
- setAttribution: function(m) {
- // Leaflet takes care of attribution by its own.
+ setAttribution: function() {
+
+ // Attributions have already been set but we override them with
+ // the ones in the map object that are in the right order and include
+ // the default CartoDB attribution
+ this.map_leaflet.attributionControl._attributions = {};
+ _.each(this.map.get('attribution'), function(attribution){
+ this.map_leaflet.attributionControl.addAttribution(attribution);
+ }.bind(this));
},
getSize: function() {
diff --git a/src/geo/leaflet/leaflet_cartodb_layer.js b/src/geo/leaflet/leaflet_cartodb_layer.js
index 86a12fca8f..57c42e388a 100755
--- a/src/geo/leaflet/leaflet_cartodb_layer.js
+++ b/src/geo/leaflet/leaflet_cartodb_layer.js
@@ -9,7 +9,7 @@ L.CartoDBLayer = L.CartoDBGroupLayer.extend({
options: {
query: "SELECT * FROM {{table_name}}",
opacity: 0.99,
- attribution: "CartoDB",
+ attribution: cdb.config.get('cartodb_attributions'),
debug: false,
visible: true,
added: false,
@@ -76,10 +76,6 @@ var LeafLetLayerCartoDBView = L.CartoDBLayer.extend({
_.bindAll(this, 'featureOut', 'featureOver', 'featureClick');
- // CartoDB new attribution,
- // also we have the logo
- layerModel.attributes.attribution = cdb.config.get('cartodb_attributions');
-
var opts = _.clone(layerModel.attributes);
opts.map = leafletMap;
diff --git a/src/geo/leaflet/leaflet_cartodb_layergroup.js b/src/geo/leaflet/leaflet_cartodb_layergroup.js
index e9aa41216d..052c4cddb5 100644
--- a/src/geo/leaflet/leaflet_cartodb_layergroup.js
+++ b/src/geo/leaflet/leaflet_cartodb_layergroup.js
@@ -17,7 +17,7 @@ L.CartoDBGroupLayerBase = L.TileLayer.extend({
options: {
opacity: 0.99,
- attribution: "CartoDB",
+ attribution: cdb.config.get('cartodb_attributions'),
debug: false,
visible: true,
added: false,
@@ -317,10 +317,6 @@ function layerView(base) {
var self = this;
var hovers = [];
- // CartoDB new attribution,
- // also we have the logo
- layerModel.attributes.attribution = cdb.config.get('cartodb_attributions');
-
var opts = _.clone(layerModel.attributes);
opts.map = leafletMap;
diff --git a/src/geo/leaflet/torque.js b/src/geo/leaflet/torque.js
index 7c47a5ca44..2091e2e9e7 100644
--- a/src/geo/leaflet/torque.js
+++ b/src/geo/leaflet/torque.js
@@ -11,7 +11,6 @@ var LeafLetTorqueLayer = L.TorqueLayer.extend({
initialize: function(layerModel, leafletMap) {
var extra = layerModel.get('extra_params');
- layerModel.attributes.attribution = cdb.config.get('cartodb_attributions');
var query = this._getQuery(layerModel);
diff --git a/src/geo/map.js b/src/geo/map.js
index 07cad7ad31..e1c9217871 100644
--- a/src/geo/map.js
+++ b/src/geo/map.js
@@ -135,7 +135,7 @@ cdb.geo.TorqueLayer = cdb.geo.MapLayer.extend({
cdb.geo.CartoDBLayer = cdb.geo.MapLayer.extend({
defaults: {
- attribution: 'CartoDB',
+ attribution: cdb.config.get('cartodb_attributions'),
type: 'CartoDB',
active: true,
query: null,
@@ -275,6 +275,7 @@ cdb.geo.Layers = Backbone.Collection.extend({
cdb.geo.Map = cdb.core.Model.extend({
defaults: {
+ attribution: [cdb.config.get('cartodb_attributions')],
center: [0, 0],
zoom: 3,
minZoom: 0,
diff --git a/test/spec/geo/gmaps/gmaps.spec.js b/test/spec/geo/gmaps/gmaps.spec.js
index 94513fe8e4..991e5c76ce 100644
--- a/test/spec/geo/gmaps/gmaps.spec.js
+++ b/test/spec/geo/gmaps/gmaps.spec.js
@@ -235,23 +235,19 @@
}, 2000);
});
-/*
-
- it("should inser layer in specified order", function() {
- var layer = new cdb.geo.CartoDBLayer({});
- map.addLayer(layer);
-
- spyOn(mapView.map_leaflet,'addLayer');
- layer = new cdb.geo.PlainLayer({});
- map.addLayer(layer, {at: 0});
-
- expect(mapView.map_leaflet.addLayer.mostRecentCall.args[1]).toEqual(true);
- //expect(mapView.map_leaflet.addLayer).toHaveBeenCalledWith(mapView.layers[layer.cid].leafletLayer, true);
+ it("should set the attributions on the map when layers are added", function() {
+ var layer1 = new cdb.geo.CartoDBLayer({ type: 'cartodb', attribution: 'attribution1', table_name: "table1", tile_style: 'test', user_name: 'test' });
+ var layer2 = new cdb.geo.CartoDBLayer({ type: 'cartodb', attribution: 'attribution2', table_name: "table2", tile_style: 'test', user_name: 'test' });
+ var layer3 = new cdb.geo.CartoDBLayer({ type: 'cartodb', attribution: '', table_name: "table2", tile_style: 'test', user_name: 'test' });
+ map.layers.reset([layer1, layer2, layer3]);
+ expect(map.get('attribution')).toEqual([
+ 'attribution2',
+ 'attribution1',
+ 'CartoDB attribution'
+ ]);
});
-*/
-
});
diff --git a/test/spec/geo/leaflet/leaflet.spec.js b/test/spec/geo/leaflet/leaflet.spec.js
index bf64753e8d..af7687afd0 100644
--- a/test/spec/geo/leaflet/leaflet.spec.js
+++ b/test/spec/geo/leaflet/leaflet.spec.js
@@ -293,6 +293,20 @@ describe('LeafletMapView', function() {
expect(mapView.layers[newLayer.cid].check).toEqual('testing');
});
+ it("should set the attributions on the map when layers are added", function() {
+ var layer1 = new cdb.geo.CartoDBLayer({ type: 'cartodb', attribution: 'attribution1', table_name: "table1", tile_style: 'test', user_name: 'test' });
+ var layer2 = new cdb.geo.CartoDBLayer({ type: 'cartodb', attribution: 'attribution2', table_name: "table2", tile_style: 'test', user_name: 'test' });
+ var layer3 = new cdb.geo.CartoDBLayer({ type: 'cartodb', attribution: '', table_name: "table2", tile_style: 'test', user_name: 'test' });
+
+ map.layers.reset([layer1, layer2, layer3]);
+
+ expect(map.get('attribution')).toEqual([
+ 'attribution2',
+ 'attribution1',
+ 'CartoDB attribution'
+ ]);
+ });
+
// Test cases for gmaps substitutes since the support is deprecated.
_({ // GMaps basemap base_type: expected substitute data
//empty = defaults to gray_roadmap