
diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..6253224 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "singleQuote": true +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3bdbcd9..e8c6c79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,11 +1,10 @@ #Setup + 1. [Fork **superplaceholder.js**](https://help.github.com/articles/fork-a-repo) and clone it on your system. 2. Create a new branch out off `master` for your fix/feature. `git checkout new-feature master` #Things to remember -- Use tabs. No spaces. - Do not fix multiple issues in a single commit. Keep them one thing per commit so that they can be picked easily incase only few commits require to be merged. - Before submitting a patch, rebase your branch on upstream `master` to make life easier for the merger. - **DO NOT** commit library builds (`dist/superplaceholder.js` & `dist/superplaceholder.min.js`) in your commits. - diff --git a/Gruntfile.js b/Gruntfile.js index f6fa4e2..bfd11f1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,55 +1,52 @@ /*global module:false*/ module.exports = function(grunt) { + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), - // Project configuration. - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), + meta: { + banner: + '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' + + '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + + ' Licensed <%= _.map(pkg.licenses, "type").join(", ") %> */\n\n' + }, + jshint: { + files: ['Gruntfile.js', 'src/<%= pkg.name %>.js'], + options: { + browser: true, + devel: true, + laxbreak: true + } + }, + uglify: { + dist: { + files: { + 'dist/<%= pkg.name %>.min.js': ['src/<%= pkg.name %>.js'] + } + } + }, + concat: { + options: { + banner: '<%= meta.banner %>' + }, + lib: { + src: ['src/<%= pkg.name %>.js'], + dest: 'dist/<%= pkg.name %>.js' + }, + minLib: { + src: ['dist/<%= pkg.name %>.min.js'], + dest: 'dist/<%= pkg.name %>.min.js' + } + } + }); - meta: { - banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + - '<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' + - '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + - '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + - ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n\n' - }, - jshint: { - files: ['Gruntfile.js', 'src/<%= pkg.name %>.js'], - options: { - browser: true, - devel: true - } - }, - uglify: { - dist: { - files: { - 'dist/<%= pkg.name %>.min.js': [ 'src/<%= pkg.name %>.js' ] - } - } - }, - concat: { - options: { - banner: '<%= meta.banner %>' - }, - lib: { - src: ['src/<%= pkg.name %>.js'], - dest: 'dist/<%= pkg.name %>.js' - }, - minLib: { - src: ['dist/<%= pkg.name %>.min.js'], - dest: 'dist/<%= pkg.name %>.min.js' - } - } - }); + // Dependencies + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-concat'); - // Dependencies - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-concat'); - - grunt.registerTask('build',[ - 'jshint', - 'uglify', - 'concat' - ]); - grunt.registerTask('default','build'); + grunt.registerTask('build', ['jshint', 'uglify', 'concat']); + grunt.registerTask('default', 'build'); }; diff --git a/README.md b/README.md index 055b8df..1cd9e4b 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,9 @@ Installation **superplaceholder.js** is *less than 1KB* minified & gzipped. -- Bower: `bower install superplaceholder` -- NPM: `npm install superplaceholder` +- **NPM**: `npm install superplaceholder` +- **Yarn**: `yarn add superplacholder` +- **Bower**: `bower install superplaceholder` - [Download zip](https://github.com/chinchang/superplaceholder.js/archive/master.zip). **Note**: **superplaceholder.js** supports AMD and commonJS module pattern out of the box. @@ -59,20 +60,42 @@ superplaceholder({ // delay between sentences (in milliseconds) sentenceDelay: 1000, // should start on input focus. Set false to autostart - startOnFocus: true, + startOnFocus: true, // [DEPRECATED] // loop through passed sentences - loop: true, + loop: false, // Initially shuffle the passed sentences shuffle: false, // Show cursor or not. Shows by default showCursor: true, // String to show as cursor - cursor: '|' + cursor: '|', + // Control onFocus behaviour. Default is `superplaceholder.Actions.START` + onFocusAction: superplaceholder.Actions.[NOTHING|START|STOP] + // Control onBlur behaviour. Default is `superplaceholder.Actions.STOP` + onBlurAction: superplaceholder.Actions.[NOTHING|START|STOP] } -}; }); ``` +Manually Controlling a superplaceholder instance: + +```js +// Complete manual control +const instance = superplaceholder({ + el: document.querySelector('input'), + sentences: [ 'Any format works', 'http://yahoo.com', 'www.facebook.com', 'airbnb.com' ], + options: { + onFocusAction: superplaceholder.Actions.NOTHING + onBlurAction: superplaceholder.Actions.NOTHING + } +}); + +// Later, whenever you want +instance.start(); +instance.stop(); +instance.destroy(); // to completely remove superplaceholder from an input +``` + Browser Support ----- @@ -95,5 +118,5 @@ See the [Changelog](https://github.com/chinchang/superplaceholder.js/wiki/Change License ----- -Copyright (c) 2016 Kushagra Gour, http://kushagragour.in +Copyright (c) 2019 Kushagra Gour, https://kushagragour.in This work is licensed under a [Creative Commons Attribution-NoDerivatives 4.0 International License](http://creativecommons.org/licenses/by-nd/4.0/). diff --git a/assets/logo.png b/assets/logo.png index 428bbd5..5ab0bf0 100644 Binary files a/assets/logo.png and b/assets/logo.png differ diff --git a/assets/superplaceholder.gif b/assets/superplaceholder.gif index 8f1a271..f5eab38 100644 Binary files a/assets/superplaceholder.gif and b/assets/superplaceholder.gif differ diff --git a/assets/superplaceholder.png b/assets/superplaceholder.png index 9f4b9af..0fd3b74 100644 Binary files a/assets/superplaceholder.png and b/assets/superplaceholder.png differ diff --git a/demo.html b/demo.html index cd6db03..5518dca 100644 --- a/demo.html +++ b/demo.html @@ -1,24 +1,26 @@ -
- - -