diff --git a/.jshintrc b/.jshintrc index 908cbc1..596aeaf 100644 --- a/.jshintrc +++ b/.jshintrc @@ -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 } diff --git a/Gruntfile.js b/Gruntfile.js index 2f75376..71cf0e5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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']); }; diff --git a/LICENSE b/LICENSE index 7595092..a128658 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 3599aba..e5bd57a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[Leaflet.zoomslider](http://kartena.github.com/Leaflet.zoomslider/) +[Leaflet.zoomslider][1] ================== ## Description @@ -6,19 +6,17 @@ 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 ``` @@ -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/ diff --git a/examples/index.html b/examples/index.html index dc98af5..505de84 100644 --- a/examples/index.html +++ b/examples/index.html @@ -3,28 +3,27 @@
- + - - + - - -