| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>jQuery MiniColors</title> |
| 5 |
<meta charset="utf-8"> |
| 6 |
|
| 7 |
|
| •8 |
<script src="/javascript/jquery/jquery.min.js"></script> |
| 9 |
|
| 10 |
|
| •11 |
<link rel="stylesheet" href="/javascript/bootstrap4/css/bootstrap.min.css"> |
| 12 |
<script src="/javascript/bootstrap4/js/bootstrap.min.js"></script> |
| 13 |
|
| 14 |
|
| •15 |
<script src="/javascript/jquery-minicolors/jquery.minicolors.js"></script> |
| 16 |
<link rel="stylesheet" href="/javascript/jquery-minicolors/jquery.minicolors.css"> |
| 17 |
|
| 18 |
<style> |
| 19 |
dl { |
| 20 |
margin: 20px 0; |
| 21 |
} |
| 22 |
dt { |
| 23 |
font-size: 120%; |
| 24 |
} |
| 25 |
dd { |
| 26 |
padding: 10px 20px 20px 20px; |
| 27 |
} |
| 28 |
dd:last-child { |
| 29 |
border-bottom: none; |
| 30 |
} |
| 31 |
code { |
| 32 |
color: black; |
| 33 |
border: none; |
| 34 |
background: rgba(128, 128, 128, .1); |
| 35 |
} |
| 36 |
[dir=rtl] code { |
| 37 |
direction: ltr; |
| 38 |
} |
| 39 |
pre { |
| 40 |
background: #f8f8f8; |
| 41 |
border: none; |
| 42 |
color: #333; |
| 43 |
padding: 20px; |
| 44 |
} |
| 45 |
[dir=rtl] pre { |
| 46 |
direction: ltr; |
| 47 |
} |
| 48 |
h2 { |
| 49 |
margin-top: 50px; |
| 50 |
} |
| 51 |
h3 { |
| 52 |
color: #aaa; |
| 53 |
} |
| 54 |
.jumbotron { |
| 55 |
padding: 40px; |
| 56 |
} |
| 57 |
.jumbotron h1 { |
| 58 |
margin-top: 0; |
| 59 |
} |
| 60 |
.jumbotron p:last-child { |
| 61 |
margin-bottom: 0; |
| 62 |
} |
| 63 |
</style> |
| 64 |
|
| 65 |
<script> |
| 66 |
$(document).ready( function() { |
| 67 |
|
| 68 |
$('.demo').each( function() { |
| 69 |
// |
| 70 |
// Dear reader, it's actually very easy to initialize MiniColors. For example: |
| 71 |
// |
| 72 |
// $(selector).minicolors(); |
| 73 |
// |
| 74 |
// The way I've done it below is just for the demo, so don't get confused |
| 75 |
// by it. Also, data- attributes aren't supported at this time...they're |
| 76 |
// only used for this demo. |
| 77 |
// |
| 78 |
$(this).minicolors({ |
| 79 |
control: $(this).attr('data-control') || 'hue', |
| 80 |
defaultValue: $(this).attr('data-defaultValue') || '', |
| 81 |
format: $(this).attr('data-format') || 'hex', |
| 82 |
keywords: $(this).attr('data-keywords') || '', |
| 83 |
inline: $(this).attr('data-inline') === 'true', |
| 84 |
letterCase: $(this).attr('data-letterCase') || 'lowercase', |
| 85 |
opacity: $(this).attr('data-opacity'), |
| 86 |
position: $(this).attr('data-position') || 'bottom', |
| 87 |
swatches: $(this).attr('data-swatches') ? $(this).attr('data-swatches').split('|') : [], |
| 88 |
change: function(value, opacity) { |
| 89 |
if( !value ) return; |
| 90 |
if( opacity ) value += ', ' + opacity; |
| 91 |
if( typeof console === 'object' ) { |
| 92 |
console.log(value); |
| 93 |
} |
| 94 |
}, |
| 95 |
theme: 'bootstrap' |
| 96 |
}); |
| 97 |
|
| 98 |
}); |
| 99 |
|
| 100 |
}); |
| 101 |
</script> |
| 102 |
</head> |
| 103 |
<body> |
| 104 |
<div class="row" style="margin: 40px 40px;"> |
| 105 |
<div class="col-12"> |
| 106 |
|
| 107 |
|
| 108 |
<div id="intro" class="jumbotron"> |
| 109 |
<h1>jQuery MiniColors</h1> |
| 110 |
<p class="text-muted"> |
| 111 |
Now with Bootstrap 3 support! |
| 112 |
</p> |
| 113 |
<p> |
| 114 |
A project by <a href="https://www.abeautifulsite.net/">A Beautiful Site</a>, |
| 115 |
originally developed for <a href="https://www.surrealcms.com/">Surreal CMS</a>. |
| 116 |
</p> |
| 117 |
</div> |
| 118 |
|
| 119 |
|
| 120 |
<h2 id="contents">Contents</h2> |
| 121 |
<ul> |
| 122 |
<li><a href="#download">Download</a></li> |
| 123 |
<li><a href="#demos">Demos</a></li> |
| 124 |
<li><a href="#api">API</a> |
| 125 |
<ul> |
| 126 |
<li><a href="#instantiation">Instantiation</a></li> |
| 127 |
<li><a href="#settings">Settings</a></li> |
| 128 |
<li><a href="#methods">Methods</a></li> |
| 129 |
<li><a href="#events">Events</a></li> |
| 130 |
</ul> |
| 131 |
</li> |
| 132 |
<li><a href="#license">License</a></li> |
| 133 |
</ul> |
| 134 |
|
| 135 |
|
| 136 |
<h2 id="download">Download</h2> |
| 137 |
<p> |
| 138 |
This project is on GitHub. Feel free to post bug reports, feature requests, and code |
| 139 |
improvements on the official project page. |
| 140 |
</p> |
| 141 |
<p> |
| 142 |
<a href="https://github.com/claviska/jquery-minicolors" class="btn btn-success">Download on GitHub</a> |
| 143 |
</p> |
| 144 |
|
| 145 |
|
| 146 |
<h2 id="demos">Demos</h2> |
| 147 |
<p> |
| 148 |
This is the main demo page, which uses <a href="https://getbootstrap.com/">Bootstrap 3</a>, |
| 149 |
but this plugin works without Bootstrap as well. |
| 150 |
</p> |
| 151 |
<p> |
| 152 |
<a href="without-bootstrap.html" class="btn btn-primary">View Demo Without Bootstrap</a> |
| 153 |
</p> |
| 154 |
<p> |
| 155 |
<a class="btn btn-primary" onclick="$(body).attr('dir')=='rtl'?$(body).removeAttr('dir'):$(body).attr('dir', 'rtl')">Toggle LTR/RTL</a> |
| 156 |
</p> |
| 157 |
|
| 158 |
|
| 159 |
<h3>Control Types</h3> |
| 160 |
<div class="well"> |
| 161 |
<div class="row"> |
| 162 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 163 |
|
| 164 |
<div class="form-group"> |
| 165 |
<label for="hue-demo">Hue (default)</label> |
| 166 |
<input type="text" id="hue-demo" class="form-control demo" data-control="hue" value="#ff6161"> |
| 167 |
</div> |
| 168 |
<div class="form-group"> |
| 169 |
<label for="saturation-demo">Saturation</label> |
| 170 |
<input type="text" id="saturation-demo" class="form-control demo" data-control="saturation" value="#0088cc"> |
| 171 |
</div> |
| 172 |
</div> |
| 173 |
|
| 174 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 175 |
<div class="form-group"> |
| 176 |
<label for="brightness-demo">Brightness</label> |
| 177 |
<input type="text" id="brightness-demo" class="form-control demo" data-control="brightness" value="#00ffff"> |
| 178 |
</div> |
| 179 |
<div class="form-group"> |
| 180 |
<label for="wheel-demo">Wheel</label> |
| 181 |
<input type="text" id="wheel-demo" class="form-control demo" data-control="wheel" value="#ff99ee"> |
| 182 |
</div> |
| 183 |
</div> |
| 184 |
</div> |
| 185 |
</div> |
| 186 |
|
| 187 |
|
| 188 |
<h3>Input Modes</h3> |
| 189 |
<div class="well"> |
| 190 |
<div class="row"> |
| 191 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 192 |
<div class="form-group"> |
| 193 |
<label for="text-field">Text field</label> |
| 194 |
<br> |
| 195 |
<input type="text" id="text-field" class="form-control demo" value="#70c24a"> |
| 196 |
</div> |
| 197 |
<div class="form-group"> |
| 198 |
<label for="hidden-input">Hidden Input</label> |
| 199 |
<br> |
| 200 |
<input type="hidden" id="hidden-input" class="demo" value="#db913d"> |
| 201 |
</div> |
| 202 |
</div> |
| 203 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 204 |
<div class="form-group"> |
| 205 |
<label for="inline">Inline</label> |
| 206 |
<br> |
| 207 |
<input type="text" id="inline" class="form-control demo" data-inline="true" value="#4fc8db"> |
| 208 |
</div> |
| 209 |
</div> |
| 210 |
</div> |
| 211 |
</div> |
| 212 |
|
| 213 |
|
| 214 |
<h3>Positions</h3> |
| 215 |
<div class="well"> |
| 216 |
<p> |
| 217 |
Valid positions include <code>bottom left</code>, <code>bottom right</code>, <code>top |
| 218 |
left</code>, and <code>top right</code>. |
| 219 |
</p> |
| 220 |
<div class="row"> |
| 221 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 222 |
<div class="form-group"> |
| 223 |
<label for="position-bottom-left">bottom left (default)</label> |
| 224 |
<input type="text" id="position-bottom-left" class="form-control demo" data-position="bottom left" value="#0088cc"> |
| 225 |
</div> |
| 226 |
<div class="form-group"> |
| 227 |
<label for="position-top-left">top left</label> |
| 228 |
<input type="text" id="position-top-left" class="form-control demo" data-position="top left" value="#0088cc"> |
| 229 |
</div> |
| 230 |
</div> |
| 231 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 232 |
<div class="form-group"> |
| 233 |
<label for="position-bottom-right">bottom right</label> |
| 234 |
<input type="text" id="position-bottom-right" class="form-control demo" data-position="bottom right" value="#0088cc"> |
| 235 |
</div> |
| 236 |
<div class="form-group"> |
| 237 |
<label for="position-top-right">top right</label> |
| 238 |
<input type="text" id="position-top-right" class="form-control demo" data-position="top right" value="#0088cc"> |
| 239 |
</div> |
| 240 |
</div> |
| 241 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 242 |
</div> |
| 243 |
</div> |
| 244 |
</div> |
| 245 |
|
| 246 |
|
| 247 |
<h3>RGB(A)</h3> |
| 248 |
<div class="well"> |
| 249 |
<div class="row"> |
| 250 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 251 |
<div class="form-group"> |
| 252 |
<label for="rgb">RGB</label> |
| 253 |
<br> |
| 254 |
<input type="text" id="rgb" class="form-control demo" data-format="rgb" value="rgb(33, 147, 58)"> |
| 255 |
<span class="help-block"> |
| 256 |
RGB input can be assigned by setting the <code>format</code> option |
| 257 |
to <code>rgb</code>. |
| 258 |
</span> |
| 259 |
</div> |
| 260 |
</div> |
| 261 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 262 |
<div class="form-group"> |
| 263 |
<label for="rgba">RGBA</label> |
| 264 |
<br> |
| 265 |
<input type="text" id="rgba" class="form-control demo" data-format="rgb" data-opacity=".5" value="rgba(52, 64, 158, 0.5)"> |
| 266 |
<span class="help-block"> |
| 267 |
RGBA input can be assigned by setting the <code>format</code> |
| 268 |
option to <code>rgb</code> and <code>opacity</code> option to |
| 269 |
<code>true</code>. |
| 270 |
</span> |
| 271 |
</div> |
| 272 |
</div> |
| 273 |
</div> |
| 274 |
</div> |
| 275 |
|
| 276 |
|
| 277 |
<h3>…and more!</h3> |
| 278 |
<div class="well"> |
| 279 |
<div class="row"> |
| 280 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 281 |
<div class="form-group"> |
| 282 |
<label for="opacity">Opacity</label> |
| 283 |
<br> |
| 284 |
<input type="text" id="opacity" class="form-control demo" data-opacity=".5" value="#766fa8"> |
| 285 |
<span class="help-block"> |
| 286 |
Opacity can be assigned by including the <code>data-opacity</code> |
| 287 |
attribute or by setting the <code>opacity</code> option to |
| 288 |
<code>true</code>. |
| 289 |
</span> |
| 290 |
</div> |
| 291 |
</div> |
| 292 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 293 |
<div class="form-group"> |
| 294 |
<label for="keywords">Keywords</label> |
| 295 |
<br> |
| 296 |
<input type="text" id="keywords" class="form-control demo" data-keywords="transparent, initial, inherit" value="transparent"> |
| 297 |
<span class="help-block"> |
| 298 |
CSS-wide keywords can be assigned by setting the <code>keywords</code> |
| 299 |
option to a comma-separated list of valid keywords: <code>transparent, |
| 300 |
initial, inherit</code>. |
| 301 |
</span> |
| 302 |
</div> |
| 303 |
</div> |
| 304 |
</div> |
| 305 |
<div class="row"> |
| 306 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 307 |
<div class="form-group"> |
| 308 |
<label for="default-value">Default Value</label> |
| 309 |
<br> |
| 310 |
<input type="text" id="default-value" class="form-control demo" data-defaultValue="#ff6600"> |
| 311 |
<span class="help-block"> |
| 312 |
This field has a default value assigned to it, so it will never be empty. |
| 313 |
</span> |
| 314 |
</div> |
| 315 |
</div> |
| 316 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 317 |
<div class="form-group"> |
| 318 |
<label for="letter-case">Letter Case</label> |
| 319 |
<br> |
| 320 |
<input type="text" id="letter-case" class="form-control demo" data-letterCase="uppercase" value="#abcdef"> |
| 321 |
<span class="help-block"> |
| 322 |
This field will always be uppercase. |
| 323 |
</span> |
| 324 |
</div> |
| 325 |
</div> |
| 326 |
</div> |
| 327 |
<div class="row"> |
| 328 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 329 |
<div class="form-group"> |
| 330 |
<label for="input-group">Input Groups</label> |
| 331 |
<div class="input-group"> |
| 332 |
<input type="text" id="input-group" class="form-control demo" value="#ff0000"/> |
| 333 |
<span class="input-group-btn"> |
| 334 |
<button class="btn btn-default" type="button">Button</button> |
| 335 |
</span> |
| 336 |
</div> |
| 337 |
<span class="help-block"> |
| 338 |
Example using Bootstrap's input groups. |
| 339 |
</span> |
| 340 |
</div> |
| 341 |
</div> |
| 342 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 343 |
<div class="form-group"> |
| 344 |
<label for="more-input-group">More Input Groups</label> |
| 345 |
<div class="input-group"> |
| 346 |
<span class="input-group-addon">Color</span> |
| 347 |
<input type="text" id="more-input-group" class="form-control demo" value="#ff0000"/> |
| 348 |
<span class="input-group-btn"> |
| 349 |
<button class="btn btn-default" type="button">Button</button> |
| 350 |
</span> |
| 351 |
</div> |
| 352 |
<span class="help-block"> |
| 353 |
Input group example with addon. |
| 354 |
</span> |
| 355 |
</div> |
| 356 |
</div> |
| 357 |
</div> |
| 358 |
<div class="row"> |
| 359 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 360 |
<div class="form-group"> |
| 361 |
<label for="letter-case">Swatches</label> |
| 362 |
<br> |
| 363 |
<input type="text" id="swatches" class="form-control demo" data-swatches="#ef9a9a|#90caf9|#a5d6a7|#fff59d|#ffcc80|#bcaaa4|#eeeeee|#f44336|#2196f3|#4caf50|#ffeb3b|#ff9800|#795548|#9e9e9e" value="#abcdef"> |
| 364 |
<span class="help-block"> |
| 365 |
Example with swatches. |
| 366 |
</span> |
| 367 |
</div> |
| 368 |
</div> |
| 369 |
<div class="col-lg-4 col-sm-4 col-12"> |
| 370 |
<div class="form-group"> |
| 371 |
<label for="letter-case">Swatches and opacity</label> |
| 372 |
<br> |
| 373 |
<input type="text" id="swatches" class="form-control demo" data-format="rgb" data-opacity="1" data-swatches="#fff|#000|#f00|#0f0|#00f|#ff0|rgba(0,0,255,0.5)" value="rgba(14, 206, 235, .5)"> |
| 374 |
<span class="help-block"> |
| 375 |
Example with swatches and opacity. |
| 376 |
</span> |
| 377 |
</div> |
| 378 |
</div> |
| 379 |
</div> |
| 380 |
</div> |
| 381 |
|
| 382 |
|
| 383 |
<h2 id="api">API</h2> |
| 384 |
|
| 385 |
|
| 386 |
<h3 id="instantiation">Instantiation</h3> |
| 387 |
<p> |
| 388 |
Instantiate like any other jQuery plugin: |
| 389 |
</p> |
| 390 |
<pre>$('INPUT.minicolors').minicolors(settings);</pre> |
| 391 |
|
| 392 |
|
| 393 |
<h3 id="settings">Settings</h3> |
| 394 |
|
| 395 |
<p> |
| 396 |
Default settings are as follows: |
| 397 |
</p> |
| 398 |
<pre> |
| 399 |
$.minicolors = { |
| 400 |
defaults: { |
| 401 |
animationSpeed: 50, |
| 402 |
animationEasing: 'swing', |
| 403 |
change: null, |
| 404 |
changeDelay: 0, |
| 405 |
control: 'hue', |
| 406 |
defaultValue: '', |
| 407 |
format: 'hex', |
| 408 |
hide: null, |
| 409 |
hideSpeed: 100, |
| 410 |
inline: false, |
| 411 |
keywords: '', |
| 412 |
letterCase: 'lowercase', |
| 413 |
opacity: false, |
| 414 |
position: 'bottom left', |
| 415 |
show: null, |
| 416 |
showSpeed: 100, |
| 417 |
theme: 'default', |
| 418 |
swatches: [] |
| 419 |
} |
| 420 |
}; |
| 421 |
</pre> |
| 422 |
<p> |
| 423 |
For convenience, you can change default settings globally by assigning new values: |
| 424 |
</p> |
| 425 |
<pre> |
| 426 |
$.minicolors.defaults.changeDelay = 200; |
| 427 |
</pre> |
| 428 |
<p> |
| 429 |
To change multiple properties at once, use <code>$.extend()</code>: |
| 430 |
</p> |
| 431 |
<pre> |
| 432 |
$.minicolors.defaults = $.extend($.minicolors.defaults, { |
| 433 |
changeDelay: 200, |
| 434 |
letterCase: 'uppercase', |
| 435 |
theme: 'bootstrap' |
| 436 |
}); |
| 437 |
</pre> |
| 438 |
<p class="alert alert-warning"> |
| 439 |
<strong>Note:</strong> Changing default settings will <em>not</em> affect controls that |
| 440 |
are already initialized. |
| 441 |
</p> |
| 442 |
|
| 443 |
<dl> |
| 444 |
<dt>animationSpeed</dt> |
| 445 |
<dd> |
| 446 |
<p> |
| 447 |
The animation speed of the sliders when the user taps or clicks a new color. Set to |
| 448 |
<code>0</code> for no animation. |
| 449 |
</p> |
| 450 |
</dd> |
| 451 |
|
| 452 |
<dt>animationEasing</dt> |
| 453 |
<dd> |
| 454 |
<p> |
| 455 |
The easing to use when animating the sliders. |
| 456 |
</p> |
| 457 |
</dd> |
| 458 |
|
| 459 |
<dt>changeDelay</dt> |
| 460 |
<dd> |
| 461 |
<p> |
| 462 |
The time, in milliseconds, to defer the <code>change</code> event from firing while |
| 463 |
the user makes a selection. This is useful for preventing the <code>change</code> event |
| 464 |
from firing frequently as the user drags the color picker around. |
| 465 |
</p> |
| 466 |
<p> |
| 467 |
The default value is <code>0</code> (no delay). If your <code>change</code> callback |
| 468 |
features something resource-intensive (such as an AJAX request), you’ll probably want |
| 469 |
to set this to at least <code>200</code>. |
| 470 |
</p> |
| 471 |
</dd> |
| 472 |
|
| 473 |
<dt>control</dt> |
| 474 |
<dd> |
| 475 |
<p> |
| 476 |
Determines the type of control. Valid options are <code>hue</code>, <code>brightness</code>, |
| 477 |
<code>saturation</code>, and <code>wheel</code>. |
| 478 |
</p> |
| 479 |
</dd> |
| 480 |
|
| 481 |
<dt>defaultValue</dt> |
| 482 |
<dd> |
| 483 |
<p> |
| 484 |
To force a default color, set this to a valid hex string. When the user clears the |
| 485 |
control, it will revert to this color. |
| 486 |
</p> |
| 487 |
</dd> |
| 488 |
|
| 489 |
<dt>format</dt> |
| 490 |
<dd> |
| 491 |
<p> |
| 492 |
The format miniColors should use. Valid options are <code>hex</code> and |
| 493 |
<code>rgb</code>. |
| 494 |
</p> |
| 495 |
</dd> |
| 496 |
|
| 497 |
<dt>hideSpeed & showSpeed</dt> |
| 498 |
<dd> |
| 499 |
<p> |
| 500 |
The speed at which to hide and show the color picker. |
| 501 |
</p> |
| 502 |
</dd> |
| 503 |
|
| 504 |
<dt>inline</dt> |
| 505 |
<dd> |
| 506 |
<p> |
| 507 |
Set to <code>true</code> to force the color picker to appear inline. |
| 508 |
</p> |
| 509 |
</dd> |
| 510 |
|
| 511 |
<dt>keywords</dt> |
| 512 |
<dd> |
| 513 |
<p> |
| 514 |
A comma-separated list of keywords that the control should accept (e.g. inherit, |
| 515 |
transparent, initial). By default, no keywords are allowed. |
| 516 |
</p> |
| 517 |
</dd> |
| 518 |
|
| 519 |
<dt>letterCase</dt> |
| 520 |
<dd> |
| 521 |
<p> |
| 522 |
Determines the letter case of the hex code value. Valid options are <code>uppercase</code> |
| 523 |
or <code>lowercase</code>. |
| 524 |
</p> |
| 525 |
</dd> |
| 526 |
|
| 527 |
<dt>opacity</dt> |
| 528 |
<dd> |
| 529 |
<p> |
| 530 |
Set to <code>true</code> to enable the opacity slider. (Use the input element's |
| 531 |
<code>data-opacity</code> attribute to set a preset value.) |
| 532 |
</p> |
| 533 |
</dd> |
| 534 |
|
| 535 |
<dt>position</dt> |
| 536 |
<dd> |
| 537 |
<p> |
| 538 |
Sets the position of the dropdown. Valid options are <code>bottom left</code>, |
| 539 |
<code>bottom right</code>, <code>top left</code>, and <code>top right</code>. |
| 540 |
</p> |
| 541 |
<p class="alert alert-warning"> |
| 542 |
The <code>swatchPosition</code> setting has been removed in version 2.1. The position |
| 543 |
of the swatch is now determined by <code>position</code>. |
| 544 |
</p> |
| 545 |
</dd> |
| 546 |
|
| 547 |
<dt>theme</dt> |
| 548 |
<dd> |
| 549 |
<p> |
| 550 |
A string containing the name of the custom theme to be applied. In your CSS, prefix |
| 551 |
your selectors like this: |
| 552 |
</p> |
| 553 |
<pre> |
| 554 |
.minicolors-theme-yourThemeName { ... } |
| 555 |
</pre> |
| 556 |
<p> |
| 557 |
If you are using the default theme, you will probably need to adjust the swatch |
| 558 |
styles depending on your existing stylesheet rules. Version 2.1 removes as much |
| 559 |
styling on the <code>input</code> element as possible, which means it’s up to |
| 560 |
you to adjust your CSS to make sure the swatch aligns properly. |
| 561 |
</p> |
| 562 |
<p> |
| 563 |
To adjust the swatch, override these styles: |
| 564 |
</p> |
| 565 |
<pre> |
| 566 |
.minicolors-theme-default .minicolors-swatch { |
| 567 |
top: 5px; |
| 568 |
left: 5px; |
| 569 |
width: 18px; |
| 570 |
height: 18px; |
| 571 |
} |
| 572 |
.minicolors-theme-default.minicolors-position-right .minicolors-swatch { |
| 573 |
left: auto; |
| 574 |
right: 5px; |
| 575 |
} |
| 576 |
</pre> |
| 577 |
</div> |
| 578 |
</dd> |
| 579 |
|
| 580 |
<dt>swatches</dt> |
| 581 |
<dd> |
| 582 |
<p> |
| 583 |
An array containing one or more strings of hex colors that will show up under the main |
| 584 |
color grid. |
| 585 |
</p> |
| 586 |
<p> |
| 587 |
Alternatively, this can be an array of <code>{ name, color }</code> objects where |
| 588 |
<code>name</code> is a human-readable color name and <code>color</code> is a hex code. |
| 589 |
In this case, the name will be used to set the swatch's <code>title</code> attribute. |
| 590 |
</p> |
| 591 |
</dd> |
| 592 |
</dl> |
| 593 |
|
| 594 |
|
| 595 |
<h3 id="methods">Methods</h3> |
| 596 |
<p>Use this syntax for calling methods:</p> |
| 597 |
<pre>$(<em>selector</em>).minicolors('method', <em>[data]</em>);</pre> |
| 598 |
<dl> |
| 599 |
<dt>create</dt> |
| 600 |
<dd> |
| 601 |
<p> |
| 602 |
Initializes the control for all items matching your selector. This is the default |
| 603 |
method, so <code>data</code> may be passed in as the only argument. |
| 604 |
</p> |
| 605 |
<p> |
| 606 |
To set a preset color value, populate the <code>value</code> attribute of the original |
| 607 |
input element. |
| 608 |
</p> |
| 609 |
</dd> |
| 610 |
|
| 611 |
<dt>destroy</dt> |
| 612 |
<dd> |
| 613 |
<p> |
| 614 |
Returns the <em>input</em> element to its original, uninitialized state. |
| 615 |
</p> |
| 616 |
</dd> |
| 617 |
|
| 618 |
<dt>hide</dt> |
| 619 |
<dd> |
| 620 |
<p> |
| 621 |
Hides the color picker. |
| 622 |
</p> |
| 623 |
</dd> |
| 624 |
|
| 625 |
<dt>show</dt> |
| 626 |
<dd> |
| 627 |
<p> |
| 628 |
Shows the color picker. |
| 629 |
</p> |
| 630 |
</dd> |
| 631 |
|
| 632 |
<dt>opacity</dt> |
| 633 |
<dd> |
| 634 |
<p> |
| 635 |
Gets or sets a control's opacity level. To use this method as a setter, pass data in |
| 636 |
as a value between 0 and 1. (You can also obtain this value by checking the input |
| 637 |
element's <code>data-opacity</code> attribute.) |
| 638 |
</p> |
| 639 |
<p> |
| 640 |
To set a preset opacity value, populate the <code>data-opacity</code> attribute of the |
| 641 |
original input element. |
| 642 |
</p> |
| 643 |
</dd> |
| 644 |
|
| 645 |
<dt>rgbObject</dt> |
| 646 |
<dd> |
| 647 |
<p> |
| 648 |
Returns an object containing red, green, blue, and alpha properties that correspond to |
| 649 |
the control's current value. Example: |
| 650 |
</p> |
| 651 |
<pre>{ r: 0, g: 82, b: 148, a: 0.75 }</pre> |
| 652 |
</dd> |
| 653 |
|
| 654 |
<dt>rgbString & rgbaString</dt> |
| 655 |
<dd> |
| 656 |
<p> |
| 657 |
Returns an RGB or RGBA string suitable for use in your CSS. Examples: |
| 658 |
</p> |
| 659 |
<pre> |
| 660 |
rgb(0, 82, 148) |
| 661 |
rgba(0, 82, 148, .75) |
| 662 |
</pre> |
| 663 |
</dd> |
| 664 |
|
| 665 |
<dt>settings</dt> |
| 666 |
<dd> |
| 667 |
<p> |
| 668 |
Gets or sets a control's settings. If new settings are passed in, the control will |
| 669 |
destroy and re-initialize itself with any new settings overriding the old ones. |
| 670 |
</p> |
| 671 |
</dd> |
| 672 |
|
| 673 |
<dt>value</dt> |
| 674 |
<dd> |
| 675 |
<p> |
| 676 |
Gets or sets a control's color value. To use this method as a setter, pass |
| 677 |
in a color string or an object (ex: <code>{color: '#fc0', opacity: .5}</code>). |
| 678 |
</p> |
| 679 |
</dd> |
| 680 |
</dl> |
| 681 |
|
| 682 |
|
| 683 |
<h3 id="events">Events</h3> |
| 684 |
<dl> |
| 685 |
<dt>change</dt> |
| 686 |
<dd> |
| 687 |
<p>Fires when the value of the color picker changes. The <code>this</code> keyword will reference the original input element. |
| 688 |
<pre> |
| 689 |
$(<em>selector</em>).minicolors({ |
| 690 |
change: function(value, opacity) { |
| 691 |
console.log(value + ' - ' + opacity); |
| 692 |
} |
| 693 |
}); |
| 694 |
</pre> |
| 695 |
<p class="alert alert-warning"> |
| 696 |
<strong>Warning!</strong> This event will fire a lot when the user drags the |
| 697 |
color picker around. Use the <code>changeDelay</code> setting to reduce its |
| 698 |
frequency. |
| 699 |
</p> |
| 700 |
</dd> |
| 701 |
|
| 702 |
<dt>hide</dt> |
| 703 |
<dd> |
| 704 |
<p> |
| 705 |
Fires when the color picker is hidden. The <code>this</code> keyword will reference |
| 706 |
the original input element. |
| 707 |
</p> |
| 708 |
<pre> |
| 709 |
$(<em>selector</em>).minicolors({ |
| 710 |
hide: function() { |
| 711 |
console.log('Hide event triggered!'); |
| 712 |
} |
| 713 |
}); |
| 714 |
</pre> |
| 715 |
</dd> |
| 716 |
|
| 717 |
<dt>show</dt> |
| 718 |
<dd> |
| 719 |
<p> |
| 720 |
Fires when the color picker is shown. The <code>this</code> keyword will reference |
| 721 |
the original input element. |
| 722 |
</p> |
| 723 |
<pre> |
| 724 |
$(<em>selector</em>).minicolors({ |
| 725 |
show: function() { |
| 726 |
console.log('Show event triggered!'); |
| 727 |
} |
| 728 |
}); |
| 729 |
</pre> |
| 730 |
</dd> |
| 731 |
</dl> |
| 732 |
|
| 733 |
<h2 id="license">License</h2> |
| 734 |
<p> |
| 735 |
Licensed under the <a href="https://opensource.org/licenses/MIT">MIT license</a>, |
| 736 |
same as <a href="https://jquery.org/license/">jQuery</a>. |
| 737 |
</p> |
| 738 |
<p> |
| 739 |
©2013 <a href="https://www.abeautifulsite.net/">A Beautiful Site, LLC.</a> |
| 740 |
</p> |
| 741 |
</div> |
| 742 |
</div> |
| 743 |
</body> |
| 744 |
</html> |