Skip to content

Commit

Permalink
Merge pull request #59 from kartena/wip/0.7
Browse files Browse the repository at this point in the history
Updates for 0.7 release
  • Loading branch information
mattiasb committed Jan 3, 2014
2 parents bafb7b8 + fe15d36 commit 6520e14
Show file tree
Hide file tree
Showing 23 changed files with 283 additions and 385 deletions.
88 changes: 38 additions & 50 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,52 +1,40 @@
{
/*
* ENVIRONMENTS
* =================
*/

// Define globals exposed by modern browsers.
"browser": true,

// Define globals exposed by jQuery.
"jquery": true,

"globals": {"L": false},

/*
* ENFORCING OPTIONS
* =================
*/

// Force all variable names to use either camelCase style or UPPER_CASE
// with underscores.
"camelcase": true,

// Prohibit use of == and != in favor of === and !==.
"eqeqeq": true,

// Suppress warnings about == null comparisons.
"eqnull": true,

// Enforce tab width of 2 spaces.
"indent": 2,

"smarttabs": true,

// Prohibit use of a variable before it is defined.
"latedef": true,

// Require capitalized names for constructor functions.
"newcap": true,

// Enforce use of single quotation marks for strings.
"quotmark": "single",

// Prohibit trailing whitespace.
"trailing": true,

// Prohibit use of explicitly undeclared variables.
"undef": true,

// Warn when variables are defined but never used.
"unused": true
// environment
"browser": true,
"node": true,
"globals": {
"L": true,
"define": true
},
"strict": false,
"es3": true,

// code style
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"forin": false,
"immed": true,
"latedef": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonew": true,
"undef": true,
"unused": true,
"quotmark": "single",

// whitespace
"indent": 4,
"trailing": true,
"white": true,
"smarttabs": true,
"maxlen": 120

// code simplicity - not enforced but nice to check from time to time
// "maxstatements": 20,
// "maxcomplexity": 5
// "maxparams": 4,
// "maxdepth": 4
}
86 changes: 56 additions & 30 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,61 @@
/*global module:false*/
module.exports = function(grunt) {
module.exports = function (grunt) {

// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json')
});
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: [
'Gruntfile.js',
'src/L.Control.Zoomslider.js',
'spec/**/*.js'
],
options: {
jshintrc: '.jshintrc',
ignores: [
'spec/happen.js'
]
}
},
karma: {
options: {
files: [
'node_modules/expect.js/expect.js',
'spec/happen.js',
'node_modules/leaflet/dist/leaflet-src.js',
'src/L.Control.Zoomslider.js',
'spec/before.js',
'spec/suites/*.js'
],
singleRun: true,
plugins: [
'karma-mocha',
'karma-chrome-launcher',
'karma-firefox-launcher',
'karma-phantomjs-launcher'
],
frameworks: ['mocha']

// Test suite
grunt.registerTask('test', function() {
var karma = require('karma'),
testConfig = { configFile: __dirname+'/spec/karma.conf.js' };
},
phantomjs: {
browsers: ['PhantomJS']
},
firefox: {
browsers: ['Firefox']
},
chrome : {
browsers: ['Chrome']
},
all: {
browsers: ['Chrome', 'Firefox', 'PhantomJS']
}
}
});

this.async();
testConfig.singleRun = true;
testConfig.autoWatch = false;
testConfig.browsers = ['PhantomJS'];
if (isArgv('--chrome')) {
testConfig.browsers.push('Chrome');
}
if (isArgv('--ff')) {
testConfig.browsers.push('Firefox');
}
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-karma');

karma.server.start(testConfig);

function isArgv(optName) {
return process.argv.indexOf(optName) !== -1;
}
});

// Default task.
grunt.registerTask('default', ['test']);
// Default task.
grunt.registerTask('default', ['jshint', 'karma:phantomjs']);
grunt.registerTask('test', ['jshint', 'karma:all']);
};
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012, Kartena AB
Copyright (c) 2012-2014, Kartena AB, Mattias Bengtsson
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
[Leaflet.zoomslider](http://kartena.github.com/Leaflet.zoomslider/)
[Leaflet.zoomslider][1]
==================

## Description
A zoom slider widget for [Leaflet][2]

Tested with Chrome, IE 7-9 and Firefox.

Also see [Leaflet.Pancontrol][1]

## Branches
- 0.4 — tracks Leaflet 0.4.x and should be stable.
- 0.5 — tracks Leaflet 0.5.x and should be stable.
- 0.6 — tracks Leaflet 0.6.x and should be stable.
- 0.6 — tracks Leaflet 0.6.x and should be stable.
- 0.7 — tracks Leaflet 0.7.x and should be stable.
- master — tracks Leaflet master and can be considered unstable (but please file bugs!).

## Tests

Install the needed dependencies:
```
$ git submodule update --init
$ npm install
```

Expand All @@ -27,13 +25,11 @@ $ npm install
$ open spec/index.html # xdg-open on Linux
```

### Node.js
### Node.js / phantomjs
```
$ brew install phantomjs # or get it from http://phantomjs.org/
$ npm install -g grunt-cli
$ grunt test
$ npm install -g grunt-cli phantomjs
$ grunt
```


[1]: https://github.com/kartena/Leaflet.Pancontrol
[1]: http://kartena.github.io/Leaflet.zoomslider/
[2]: http://leafletjs.com/
29 changes: 14 additions & 15 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,27 @@
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="lib/Leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../src/L.Control.Zoomslider.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="lib/Leaflet/dist/leaflet.ie.css" />
<link rel="stylesheet" href="../src/L.Control.Zoomslider.ie.css" />
<![endif]-->
</head>
<body>
<div id="map"></div>
<script src="lib/Leaflet/dist/leaflet-src.js"></script>
<script src="../node_modules/leaflet/dist/leaflet-src.js"></script>
<script src="../src/L.Control.Zoomslider.js" ></script>
<script src="lib/leaflet-tilejson/src/tilejson.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="osm.tilejson.js"></script>
<script>
// The zoomslider will be used by default if you include L.Control.Zoomslider
var map = L.TileJSON.createMap('map', osmTileJSON, { mapConfig: { zoomsliderControl: true,
zoomControl: false }});

var layer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});

// You can add the control via the settings object
var map = L.map('map', {
zoomsliderControl: true,
zoomControl: false,
layers: [layer]
}).setView([57.7, 11.9], 8);

// You can also add it manually:
// var map = L.TileJSON.createMap('map', osmTileJSON, { mapOptions: { zoomControl: false }});
// map.addControl(new L.Control.Zoomslider());
// map.addControl(new L.Control.Zoomslider());
</script>
</body>
</html>
1 change: 0 additions & 1 deletion examples/lib/Leaflet
Submodule Leaflet deleted from ae5bc1
1 change: 0 additions & 1 deletion examples/lib/leaflet-tilejson
Submodule leaflet-tilejson deleted from db5aac
49 changes: 20 additions & 29 deletions examples/markers.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="lib/Leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../node_modules/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../src/L.Control.Zoomslider.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="lib/Leaflet/dist/leaflet.ie.css" />
<link rel="stylesheet" href="../src/L.Control.Zoomslider.ie.css" />
<![endif]-->
</head>
<body>
<div id="map"></div>
<script src="lib/Leaflet/dist/leaflet-src.js"></script>
<script src="../node_modules/leaflet/dist/leaflet-src.js"></script>
<script src="../src/L.Control.Zoomslider.js" ></script>
<script src="lib/leaflet-tilejson/src/tilejson.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="osm.tilejson.js"></script>
<script>
// The zoomslider will be used by default if you include L.Control.Zoomslider
var map = L.TileJSON.createMap('map', osmTileJSON, { mapConfig: { zoomsliderControl: true, zoomControl: false }} );

var layer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
});

// You can add the control via the settings object
var map = L.map('map', {
zoomsliderControl: true,
zoomControl: false,
layers: [layer]
}).setView([57.7, 11.9], 8);

// Test performance when having many markers on the map

function getRandomLatLng(map) {
var bounds = map.getBounds(),
southWest = bounds.getSouthWest(),
northEast = bounds.getNorthEast(),
lngSpan = northEast.lng - southWest.lng,
latSpan = northEast.lat - southWest.lat;
southWest = bounds.getSouthWest(),
northEast = bounds.getNorthEast(),
lngSpan = northEast.lng - southWest.lng,
latSpan = northEast.lat - southWest.lat;

return new L.LatLng(
southWest.lat + latSpan * Math.random(),
Expand All @@ -37,20 +40,8 @@

// Throw 100 markers at the map
for (var i = 0; i < 100; i++) {
// markers.addLayer(markersList[i]);
feature_group.addLayer( L.marker(getRandomLatLng(map)) );
feature_group.addLayer( L.marker(getRandomLatLng(map)) );
}

// You can turn it off and add it manually by using the option zoomSliderControl: false
// var map = L.TileJSON.createMap('map', osmTileJSON, { mapOptions: { zoomsliderControl: false }});
// map.addControl(new L.Control.Zoomslider());

// You can restore the original control by turning the zoomslider off and turning the zoomControl on
//var map = L.TileJSON.createMap('map', osmTileJSON, { mapOptions: { zoomsliderControl: false, zoomControl: true }});

// Or turn them both on.
//var map = L.TileJSON.createMap('map', osmTileJSON, { mapOptions: { zoomsliderControl: true, zoomControl: true }});

</script>
</body>
</html>
17 changes: 0 additions & 17 deletions examples/osm.tilejson.js

This file was deleted.

Loading

0 comments on commit 6520e14

Please sign in to comment.