diff --git a/.gitignore b/.gitignore index a8bb6f1..b22257e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,58 @@ -.DS_Store +# OSX +*.DS_Store +.AppleDouble +.LSOverride +# Icon must end with two \r +Icon +# Thumbnails +._* +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Windows image file caches +Thumbs.db +ehthumbs.db +# Folder config file +Desktop.ini +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Node.js +# Logs +logs +*.log +npm-debug.log* +# Runtime data +pids +*.pid +*.seed +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov +# Coverage directory used by tools like istanbul +coverage +# nyc test coverage +.nyc_output +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt +# node-waf configuration +.lock-wscript +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release +# Dependency directories +node_modules +jspm_packages +# Optional npm cache directory +.npm +# Optional REPL history +.node_repl_history + +# Misc .project .settings .idea -node_modules -coverage diff --git a/.jscsrc b/.jscsrc index c37d56d..15fbb0b 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,21 +1,9 @@ { - "preset": "google", - "fileExtensions": [".js"], + "preset": "jquery", + "requireSpacesInsideParentheses": false, + "validateQuoteMarks": true, + "requireSpacesInsideBrackets": false, + "requireSpacesInsideObjectBrackets": false, "maximumLineLength": 120, - "validateLineBreaks": "LF", - "validateIndentation": "\t", - "requireCamelCaseOrUpperCaseIdentifiers": null, - "disallowMultipleVarDecl": null, - "requireMultipleVarDecl": true, - "safeContextKeyword": ["that"], - "requireBlocksOnNewline": true, - "disallowSpaceAfterObjectKeys": true, - "requireSpaceBeforeObjectValues": true, - "requireCommaBeforeLineBreak": true, - "disallowTrailingComma": true, - "disallowKeywordsOnNewLine": ["else"], - "requireCapitalizedConstructors": true, - "requireSpaceAfterLineComment": true, - "validateParameterSeparator": ", ", - "excludeFiles": ["public/js/lib/**", "public/js/opinionLab/**"] -} + "requirePaddingNewLinesBeforeLineComments": false +} \ No newline at end of file diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index b60190f..0000000 --- a/.jshintrc +++ /dev/null @@ -1,16 +0,0 @@ -{ - "curly": true, - "smarttabs": true, - "eqeqeq": true, - "immed": true, - "latedef": true, - "newcap": true, - "noarg": true, - "sub": true, - "undef": true, - "unused": true, - "boss": true, - "eqnull": true, - "browser": true, - "devel": true -} diff --git a/.travis.yml b/.travis.yml index 0ce3be2..36e4353 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ language: node_js node_js: - - "0.10" -before_script: - - npm install -g grunt-cli \ No newline at end of file + - "4" + - "6" \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..36bee3d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,16 @@ +# How to contribute + +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 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, 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. Time is precious, use it wisely & Happy Coding :) \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 31340dd..688e29e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,53 +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: { - options: { - banner: '/*! <%= pkg.name %> <%= pkg.version %> <%=grunt.template.today("yyyy-mm-dd")%>*/' - }, - dist: { - src: ['src/timer.jquery.js'], - dest: 'dist/timer.jquery.min.js' - }, - }, - - // Implement coding guidelines jscs: { - src: ['src/timer.jquery.js', 'test/timer.jquery.spec.js'], - options: { - config: '.jscsrc' - } + src: ['Gruntfile.js', 'src/*.js', 'test/utils-test.js', 'test/basicTimerSpec', 'test/timedFuncSpec.js'] }, jshint: { - all: { - src: ['src/timer.jquery.js'], - options: { - jshintrc: '.jshintrc' - }, - globals: { - exports: true - } - } + all: ['Gruntfile.js', 'src/*.js', 'test/utils-test.js', 'test/basicTimerSpec', 'test/timedFuncSpec.js'] }, - karma: { - unit: { - configFile: 'karma.conf.js' + concat: { + options: { + banner: [ + '/*! <%= pkg.name %> <%= pkg.version %> <%=grunt.template.today("yyyy-mm-dd")%>*/\n', + '(function($) {\n' + ].join(''), + footer: '} (jQuery));' }, - continuous: { - configFile: 'karma.conf.js', - watch: false, - singleRun: true, - browsers: ['PhantomJS'] + dist: { + 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: ['src/timer.jquery.js', 'test/timer.jquery.spec.js'], - tasks: ['jscs', 'jshint', 'uglify'], + files: ['src/*.js'], + tasks: commonTasks, options: { nospawn: true } @@ -55,13 +48,11 @@ module.exports = function (grunt) { } }); - grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-jscs'); grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks("grunt-jscs"); - grunt.loadNpmTasks("grunt-karma"); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-watch'); - //register default task - grunt.registerTask('default', 'watch'); - grunt.registerTask('test', ['karma:continuous']); -} + grunt.registerTask('default', commonTasks); +}; diff --git a/LICENSE-MIT b/LICENSE-MIT index 29c7999..b9a8bc2 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2013 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 758ac2d..86721b8 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,26 @@ [Demo & Instructions][demo] | [Download][min] -[demo]: http://jquerytimer.com/ -[min]: https://github.com/walmik/timer.jquery/archive/master.zip +[demo]: https://walmik.github.io/timer.jquery/ +[min]: https://raw.githubusercontent.com/walmik/timer.jquery/master/dist/timer.jquery.min.js ## Getting started -In your web page: +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 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 + - - -
-