Skip to content

Commit

Permalink
Merges with master fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
xavijam committed Sep 8, 2015
2 parents 8d628d7 + d8b7dc5 commit 3d4e802
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 60 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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).
7 changes: 6 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

16 changes: 8 additions & 8 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.2
git flow release start 3.15.3
```

- 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.2"
git commit -am "Files changed for version 3.15.3"
```

- Release it.
Expand All @@ -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
```
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions doc/API.md
Original file line number Diff line number Diff line change
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.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
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15.2/cartodb.js"></script>
<script src="http://libs.cartocdn.com/cartodb.js/v3/3.15.3/cartodb.js"></script>
```
You can do the same for the CSS documents we provide:
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cartodb.js",
"version": "3.15.2",
"version": "3.15.3",
"description": "CartoDB javascript library",
"repository": {
"type": "git",
Expand Down Expand Up @@ -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",
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.2";
cdb.VERSION = "3.15.3";
cdb.DEBUG = false;

cdb.CARTOCSS_VERSIONS = {
Expand Down
6 changes: 3 additions & 3 deletions src/geo/gmaps/gmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
6 changes: 1 addition & 5 deletions src/geo/gmaps/gmaps_cartodb_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions src/geo/gmaps/gmaps_cartodb_layergroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/geo/gmaps/torque.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
19 changes: 13 additions & 6 deletions src/geo/leaflet/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 1 addition & 5 deletions src/geo/leaflet/leaflet_cartodb_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions src/geo/leaflet/leaflet_cartodb_layergroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/geo/leaflet/torque.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion src/geo/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
24 changes: 10 additions & 14 deletions test/spec/geo/gmaps/gmaps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\'http://cartodb.com/attributions\' target=\'_blank\'>attribution</a>'
]);
});

*/

});

14 changes: 14 additions & 0 deletions test/spec/geo/leaflet/leaflet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href=\'http://cartodb.com/attributions\' target=\'_blank\'>attribution</a>'
]);
});

// Test cases for gmaps substitutes since the support is deprecated.
_({ // GMaps basemap base_type: expected substitute data
//empty = defaults to gray_roadmap
Expand Down

0 comments on commit 3d4e802

Please sign in to comment.