diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 7b37dd5..0000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["es2015"] -} diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 78ab966..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "google", - "installedESLint": true, - "rules": { - "indent": ["error", "tab"], - "max-len": ["error", 120] - } -} diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..15fbb0b --- /dev/null +++ b/.jscsrc @@ -0,0 +1,9 @@ +{ + "preset": "jquery", + "requireSpacesInsideParentheses": false, + "validateQuoteMarks": true, + "requireSpacesInsideBrackets": false, + "requireSpacesInsideObjectBrackets": false, + "maximumLineLength": 120, + "requirePaddingNewLinesBeforeLineComments": false +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9e91ce9..36e4353 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,4 @@ language: node_js node_js: - - "0.10" - - "0.12" - "4" - - "5" - "6" \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0d33d3a..36bee3d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,15 +2,15 @@ This project is an outcome of a lot of contributions from developers who have been kind enough to point out any issues and/or have taken the time to create pull requests that fix issues or add new features to this repo. In other words, contributions are welcome :) Here are some guidelines to consider: -- The jQuery timer plugin is written in ES6. It uses babel along with webpack for transpiling to ES5 +- The jQuery timer plugin is written in ES 5. It was written in ES 6 when I once felt that the browsers will catchup to ES6 and we ll not have to transpile anymore. The transpiled version of the jQuery timer adds 30% cruft to the code just to manage the fancy syntax. I moved away from it coz I realized users of this plugin don't care about that and should not be subjected to it. - All source code is in the `src` directory. Any changes you make should ideally happen in the files inside `src` (unless you are making changes to the README or this file itself) - To start contributing code changes, fork this repo to your Github account and clone it in your local computer - Run `npm install` to install all the dependencies -- The package.json has all the required commands for you to test and transpile - * `npm test` to run eslint and the unit tests - * `npm run webpack` to transpile the scripts from the _src_ directory to _dist/timer.jquery.js_ - * `npm grunt` for minifying the transpiled file to _dist/timer.jquery.min.js_ +- The package.json has all the required commands for you to test, lint, style check and put together a production file + * `npm test` to run unit tests + * `npm run build` for running jscs, jshint, concat and uglify to generate timer.jquery.js and timer.jquery.min.js inside dist/ + * `npm run watch` Watch over files from src and test as you work on them to running jscs, jshint, concat and uglify on changes - Once you ve made the changes and are sure that the existing tests pass, commit them to your _origin_ and issue a Pull Request to the upstream (this repo) - Please write tests for your changes -That's it. Happy coding! \ No newline at end of file +That's it. Time is precious, use it wisely & Happy Coding :) \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index a48d244..688e29e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,21 +1,46 @@ -module.exports = function (grunt) { +module.exports = function(grunt) { + var commonTasks = ['jscs', 'jshint', 'concat', 'uglify']; grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - uglify: { + jscs: { + src: ['Gruntfile.js', 'src/*.js', 'test/utils-test.js', 'test/basicTimerSpec', 'test/timedFuncSpec.js'] + }, + + jshint: { + all: ['Gruntfile.js', 'src/*.js', 'test/utils-test.js', 'test/basicTimerSpec', 'test/timedFuncSpec.js'] + }, + + concat: { options: { - banner: '/*! <%= pkg.name %> <%= pkg.version %> <%=grunt.template.today("yyyy-mm-dd")%>*/' + banner: [ + '/*! <%= pkg.name %> <%= pkg.version %> <%=grunt.template.today("yyyy-mm-dd")%>*/\n', + '(function($) {\n' + ].join(''), + footer: '} (jQuery));' }, dist: { - src: ['dist/timer.jquery.js'], + src: [ + 'src/constants.js', + 'src/utils.js', + 'src/Timer.js', + 'src/index.js' + ], + dest: 'dist/timer.jquery.js' + } + }, + + uglify: { + dist: { + src: 'dist/timer.jquery.js', dest: 'dist/timer.jquery.min.js' - }, + } }, watch: { scripts: { - files: ['dist/timer.jquery.js'], - tasks: ['uglify'], + files: ['src/*.js'], + tasks: commonTasks, options: { nospawn: true } @@ -23,9 +48,11 @@ module.exports = function (grunt) { } }); + grunt.loadNpmTasks('grunt-jscs'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); - //register default task - grunt.registerTask('default', 'watch'); -} + grunt.registerTask('default', commonTasks); +}; diff --git a/LICENSE-MIT b/LICENSE-MIT index fd1c181..b9a8bc2 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2016 Walmik Deshpande +Copyright (c) 2017 Walmik Deshpande Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation diff --git a/README.md b/README.md index 21c1b16..86721b8 100644 --- a/README.md +++ b/README.md @@ -8,20 +8,26 @@ [Demo & Instructions][demo] | [Download][min] -[demo]: http://jquerytimer.com/ +[demo]: https://walmik.github.io/timer.jquery/ [min]: https://raw.githubusercontent.com/walmik/timer.jquery/master/dist/timer.jquery.min.js ## Getting started +Load the plugin in a script tag (right after loading jQuery) directly from CDNjs using this URL, + +```html +https://cdnjs.cloudflare.com/ajax/libs/timer.jquery/0.7.0/timer.jquery.js +``` + If you are using bower, ```bash bower install timer.jquery ``` -Alternatively you can [download][min] the jQuery timer plugin. Then, in your web page: +Alternatively you can [download][min] the jQuery timer plugin and host it relative to your HTML file. Once you have your preferred way to get jquery and the timer plugin, in your web page: ```html - + - - -
-