|
| 1 | +# ColorPick.js |
| 2 | + |
| 3 | +ColorPick.js is a simple and minimal jQuery color picker plugin. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +– Simplicity of integration |
| 8 | + |
| 9 | +– The recently used colors are automatically saved to local storage |
| 10 | + |
| 11 | +– Gorgeous modern design that will suit almost every website |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +You can clone [this repository](https://github.com/philzet/ColorPick.js) or download the latest build as a zip from here - http://github.com/philzet/ColorPick.js/zipball/master |
| 16 | + |
| 17 | +ColorPick.js requires jQuery. This is the only dependency. Make sure to load it before ColorPick.js. |
| 18 | + |
| 19 | +Basic example: |
| 20 | +```html |
| 21 | +<head> |
| 22 | + <link rel="stylesheet" href="css/colorPick.min.css"> |
| 23 | +</head> |
| 24 | +<body> |
| 25 | + <div class="colorPickSelector"></div> |
| 26 | + |
| 27 | + <script src="js/jquery.min.js"></script> |
| 28 | + <script src="js/ColorPick.min.js"></script> |
| 29 | + <script> |
| 30 | + $(".colorPickSelector").colorPick(); |
| 31 | + </script> |
| 32 | +</body> |
| 33 | +``` |
| 34 | + |
| 35 | +Result: |
| 36 | + |
| 37 | + |
| 38 | +## Options |
| 39 | + |
| 40 | +**Initial color** |
| 41 | +By default, the initial color is #3498db. |
| 42 | + |
| 43 | +```javascript |
| 44 | +$(".picker").colorPick({ 'initialColor': '#27ae60' }); |
| 45 | +``` |
| 46 | + |
| 47 | +**Custom action** |
| 48 | + |
| 49 | +You can specify your own action event which will be called as soon as the color is selected. |
| 50 | +The hex color which has been selected can be referred to as "this.color". |
| 51 | + |
| 52 | +```javascript |
| 53 | +$(".picker").colorPick({ |
| 54 | + 'onColorSelected': function() { |
| 55 | + console.log("The user has selected the color: " + this.color) |
| 56 | + this.element.css({'backgroundColor': this.color, 'color': this.color}); |
| 57 | + } |
| 58 | +}); |
| 59 | +``` |
| 60 | + |
| 61 | +**Allowing saving recent colors and specifying their number** |
| 62 | +By default, recent colors are allowed, and their max number is 5. |
| 63 | + |
| 64 | +```javascript |
| 65 | +$(".picker").colorPick({ 'allowRecent': true, 'recentMax': 5 }); |
| 66 | +``` |
| 67 | + |
| 68 | +**Custom colors database** |
| 69 | +By default, we use Flat UI color database. |
| 70 | + |
| 71 | +```javascript |
| 72 | +$(".picker").colorPick({ 'palette': ["#1abc9c", "#16a085", "#2ecc71"] }); |
| 73 | +``` |
| 74 | + |
| 75 | +## License |
| 76 | + |
| 77 | +MIT License |
| 78 | + |
| 79 | +Copyright (c) 2017 Phil Zet (a.k.a. Philipp Zakharchenko) |
| 80 | + |
| 81 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 82 | +of this software and associated documentation files (the "Software"), to deal |
| 83 | +in the Software without restriction, including without limitation the rights |
| 84 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 85 | +copies of the Software, and to permit persons to whom the Software is |
| 86 | +furnished to do so, subject to the following conditions: |
| 87 | + |
| 88 | +The above copyright notice and this permission notice shall be included in all |
| 89 | +copies or substantial portions of the Software. |
| 90 | + |
| 91 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 92 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 93 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 94 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 95 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 96 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 97 | +SOFTWARE. |
0 commit comments