index.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  5. <meta charset="utf-8">
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Colorpicker for Twitter Bootstrap</title>
  8. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-85082661-5"></script>
  9. <script>
  10. window.dataLayer = window.dataLayer || [];
  11. function gtag(){dataLayer.push(arguments);}
  12. gtag('js', new Date()); gtag('config', 'UA-85082661-5');
  13. </script>
  14. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
  15. <link href="//cdnjs.cloudflare.com/ajax/libs/octicons/3.5.0/octicons.min.css" rel="stylesheet">
  16. <link href="dist/css/bootstrap-colorpicker.min.css" rel="stylesheet">
  17. <link href="docs/assets/main.css" rel="stylesheet">
  18. <script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
  19. <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  20. <script src="dist/js/bootstrap-colorpicker.js"></script>
  21. </head>
  22. <body>
  23. <div class="container">
  24. <div class="page-header">
  25. <h1><i class="glyphicon glyphicon-tint"></i> Bootstrap Colorpicker 2.5.2
  26. <small>for Twitter Bootstrap</small>
  27. </h1>
  28. </div>
  29. <div class="row">
  30. <article class="col-md-12">
  31. <p>
  32. Fancy and customizable colorpicker plugin for Twitter Bootstrap.
  33. Originally written by <a
  34. href="https://twitter.com/stefanpetre/" target="_blank">Stefan Petre</a> and maintained by
  35. <a href="https://itsjavi.com/" target="_blank">Javi Aguilar</a> and the Github community.
  36. </p>
  37. <p class="alert alert-warning">
  38. <b>NOTE</b> That this is an older version of the library documentation, please check
  39. the project <a href="https://github.com/farbelous/bootstrap-colorpicker/blob/master/README.md">README</a>
  40. to find the documentation for the newer and latest versions.
  41. </p>
  42. </article>
  43. </div>
  44. <div class="row">
  45. <article class="col-md-12">
  46. <hr>
  47. <div class="social">
  48. <a href="https://github.com/farbelous/bootstrap-colorpicker/" target="_blank"
  49. class="btn btn-default btn-sm"><span class="octicon octicon-mark-github"></span>
  50. Source code
  51. </a>
  52. <a href="https://github.com/farbelous/bootstrap-colorpicker/releases" target="_blank"
  53. class="btn btn-default btn-sm">
  54. Latest Releases
  55. </a>
  56. <a href="https://github.com/farbelous/bootstrap-colorpicker/archive/2.5.2.zip" target="_blank"
  57. class="btn btn-success btn-sm"><i class="glyphicon glyphicon-download-alt"></i>
  58. Download v2.5.2
  59. </a>
  60. </div>
  61. <hr>
  62. </article>
  63. </div>
  64. <div class="row">
  65. <div class="col-md-7">
  66. <h2>Documentation</h2>
  67. <hr>
  68. <p>Call the colopicker via javascript:</p>
  69. <pre class="well">$('.sample-selector').colorpicker({ /*options...*/ });</pre>
  70. <h3>Options</h3>
  71. <p>
  72. You can set colorpicker options either as a plugin parameter or data-* attributes
  73. </p>
  74. <table class="table table-bordered table-striped">
  75. <thead>
  76. <tr>
  77. <th style="width: 100px;">Name</th>
  78. <th style="width: 50px;">Type</th>
  79. <th style="width: 100px;">Default</th>
  80. <th>Description</th>
  81. </tr>
  82. </thead>
  83. <tbody>
  84. <tr>
  85. <td>format</td>
  86. <td>string</td>
  87. <td>false</td>
  88. <td>If not false, forces the color format to be hex, rgb or rgba, otherwise the format is
  89. automatically detected.
  90. </td>
  91. </tr>
  92. <tr>
  93. <td>color</td>
  94. <td>string</td>
  95. <td>false</td>
  96. <td>If not false, sets the color to this value.</td>
  97. </tr>
  98. <tr>
  99. <td>container</td>
  100. <td>string or jQuery Element</td>
  101. <td>false</td>
  102. <td>If not false, the picker will be contained inside this element, otherwise it will be
  103. appended to the document body.
  104. </td>
  105. </tr>
  106. <tr>
  107. <td>component</td>
  108. <td>string or jQuery Element</td>
  109. <td>'.add-on, .input-group-addon'</td>
  110. <td>Children selector for the component or element that trigger the colorpicker and which
  111. background color will change (needs an inner &lt;i&gt; element).
  112. </td>
  113. </tr>
  114. <tr>
  115. <td>input</td>
  116. <td>string or jQuery Element</td>
  117. <td>'input'</td>
  118. <td>Children selector for the input that will store the picker selected value.</td>
  119. </tr>
  120. <tr>
  121. <td>hexNumberSignPrefix</td>
  122. <td>boolean</td>
  123. <td>true</td>
  124. <td>If true, put a '&num;' (number sign) before hex strings.
  125. </td>
  126. </tr>
  127. <tr>
  128. <td>horizontal</td>
  129. <td>boolean</td>
  130. <td>false</td>
  131. <td>If true, the hue and alpha channel bars will be rendered horizontally, above the saturation
  132. selector.
  133. </td>
  134. </tr>
  135. <tr>
  136. <td>inline</td>
  137. <td>boolean</td>
  138. <td>false</td>
  139. <td>If true, forces to show the colorpicker as an inline element.</td>
  140. </tr>
  141. <tr>
  142. <td>sliders</td>
  143. <td>object</td>
  144. <td><abbr title='please, read the source code to see this value'>[...]</abbr></td>
  145. <td>Vertical sliders configuration (read source code if you really need to tweak this).</td>
  146. </tr>
  147. <tr>
  148. <td>slidersHorz</td>
  149. <td>object</td>
  150. <td><abbr title='please, read the source code to see this value'>[...]</abbr></td>
  151. <td>Horizontal sliders configuration (read source code if you really need to tweak this).</td>
  152. </tr>
  153. <tr>
  154. <td>template</td>
  155. <td>string</td>
  156. <td><abbr title='please, read the source code to see this value'>[...]</abbr></td>
  157. <td>Customizes the default colorpicker HTML template.</td>
  158. </tr>
  159. <tr>
  160. <td>align</td>
  161. <td>string</td>
  162. <td>'right'</td>
  163. <td>By default, the colorpicker is aligned to the right of the input. If you need to switch it
  164. to the left, set align to 'left'.
  165. </td>
  166. </tr>
  167. <tr>
  168. <td>customClass</td>
  169. <td>string</td>
  170. <td>null</td>
  171. <td>Adds this class to the colorpicker widget.</td>
  172. </tr>
  173. <tr>
  174. <td>colorSelectors</td>
  175. <td>object</td>
  176. <td>null</td>
  177. <td>List of pre selected colors (hex format). If you choose one of these colors, the alias is returned instead of the hex
  178. code.
  179. </td>
  180. </tr>
  181. <tr>
  182. <td>fallbackColor</td>
  183. <td>string</td>
  184. <td>null</td>
  185. <td>
  186. Fallback color string that will be applied when the color failed to be parsed.
  187. If <var>null</var>, it will keep the current color if any.
  188. </td>
  189. </tr>
  190. <tr>
  191. <td>fallbackFormat</td>
  192. <td>string</td>
  193. <td>hex</td>
  194. <td>
  195. Fallback color format (e.g. when not specified or for alias mode, when selecting non aliased colors)
  196. </td>
  197. </tr>
  198. </tbody>
  199. </table>
  200. <h3>jQuery API Methods</h3>
  201. <p>General usage methods</p>
  202. <h4>.colorpicker(options)</h4>
  203. <p>Initializes an colorpicker.</p>
  204. <h4>.colorpicker('getValue', defaultValue)</h4>
  205. <p>Gets the value from the input or the data attribute (if has no input), otherwise returns the default
  206. value, which defaults to #000000 if not specified.</p>
  207. <h4>.colorpicker('setValue', value)</h4>
  208. <p>Set a new value for the color picker (also updates everything). Triggers 'changeColor' event.</p>
  209. <h4>.colorpicker('show')</h4>
  210. <p>Show the color picker</p>
  211. <h4>.colorpicker('hide')</h4>
  212. <p>Hide the color picker</p>
  213. <h4>.colorpicker('reposition')</h4>
  214. <p>Updates the color picker's position relative to the element</p>
  215. <h4>.colorpicker('update')</h4>
  216. <p>Refreshes the widget colors (this is done automatically)</p>
  217. <h4>.colorpicker('enable')</h4>
  218. <p>Enable the color picker.</p>
  219. <h4>.colorpicker('disable')</h4>
  220. <p>Disable the color picker.</p>
  221. <h4>.colorpicker('destroy')</h4>
  222. <p>Destroys the colorpicker widget and unbind all .colorpicker events from the element and component</p>
  223. <h4>.data('colorpicker')</h4>
  224. <p>Access to the colorpicker API directly</p>
  225. <h4>.data('colorpicker').color</h4>
  226. <p>Access to the colorpicker Color object information</p>
  227. <hr>
  228. <h3>Color object methods</h3>
  229. <p>Each triggered events have a color object (avaliable through event.color, see the example at the
  230. bottom) used internally by the picker. This object has several useful methods. These are the more
  231. commonly used:</p>
  232. <h4>.setColor(value)</h4>
  233. <p>Set a new color. The value is parsed and tries to do a quess on the format.</p>
  234. <h4>.setHue(value)</h4>
  235. <p>Set the HUE with a value between 0 and 1.</p>
  236. <h4>.setSaturation(value)</h4>
  237. <p>Set the saturation with a value between 0 and 1.</p>
  238. <h4>.setBrightness(value)</h4>
  239. <p>Set the brightness with a value between 0 and 1.</p>
  240. <h4>.setAlpha(value)</h4>
  241. <p>Set the transparency with a value between 0 and 1.</p>
  242. <h4>.toRGB()</h4>
  243. <p>Returns a hash with red, green, blue and alpha.</p>
  244. <h4>.toHex()</h4>
  245. <p>Returns a string with HEX format for the current color.</p>
  246. <h4>.toHSL()</h4>
  247. <p>Returns a hash with HSLA values.</p>
  248. <hr>
  249. <h3>Events</h3>
  250. <p>The colorpicker plugin exposes some events</p>
  251. <table class="table table-bordered table-striped">
  252. <thead>
  253. <tr>
  254. <th style="width: 150px;">Event</th>
  255. <th>Description</th>
  256. </tr>
  257. </thead>
  258. <tbody>
  259. <tr>
  260. <td>create</td>
  261. <td>This event fires immediately when the color picker is created.</td>
  262. </tr>
  263. <tr>
  264. <td>showPicker</td>
  265. <td>This event fires immediately when the color picker is displayed.</td>
  266. </tr>
  267. <tr>
  268. <td>hidePicker</td>
  269. <td>This event is fired immediately when the color picker is hidden.</td>
  270. </tr>
  271. <tr>
  272. <td>changeColor</td>
  273. <td>This event is fired when the color is changed.</td>
  274. </tr>
  275. <tr>
  276. <td>disable</td>
  277. <td>This event is fired immediately when the color picker is disabled, except if it was
  278. initialized as disabled.
  279. </td>
  280. </tr>
  281. <tr>
  282. <td>enable</td>
  283. <td>This event is fired immediately when the color picker is enabled, except upon
  284. initialization.
  285. </td>
  286. </tr>
  287. <tr>
  288. <td>destroy</td>
  289. <td>This event fires immediately when the color picker is destroyed.</td>
  290. </tr>
  291. </tbody>
  292. </table>
  293. </div>
  294. <div class="col-md-5">
  295. <h2>Examples</h2>
  296. <hr>
  297. <div class="example">
  298. <div class="example-title">Simple input field</div>
  299. <div class="example-content well">
  300. <div class="example-content-widget">
  301. <input id="cp1" type="text" class="form-control" value="#5367ce"/>
  302. <script>
  303. $(function () {
  304. $('#cp1').colorpicker();
  305. });
  306. </script>
  307. </div>
  308. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  309. <div class="example-code">&lt;input id=&quot;cp1&quot; type=&quot;text&quot; class=&quot;form-control&quot; value=&quot;#5367ce&quot; &#x2F;&gt;
  310. &lt;script&gt;
  311. $(function() {
  312. $(&#39;#cp1&#39;).colorpicker();
  313. });
  314. &lt;&#x2F;script&gt;</div> </div>
  315. </div>
  316. <div class="example">
  317. <div class="example-title">As a component</div>
  318. <div class="example-content well">
  319. <div class="example-content-widget">
  320. <div id="cp2" class="input-group colorpicker-component">
  321. <input type="text" value="#00AABB" class="form-control"/>
  322. <span class="input-group-addon"><i></i></span>
  323. </div>
  324. <script>
  325. $(function () {
  326. $('#cp2').colorpicker();
  327. });
  328. </script>
  329. </div>
  330. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  331. <div class="example-code">&lt;div id=&quot;cp2&quot; class=&quot;input-group colorpicker-component&quot;&gt;
  332. &lt;input type=&quot;text&quot; value=&quot;#00AABB&quot; class=&quot;form-control&quot; &#x2F;&gt;
  333. &lt;span class=&quot;input-group-addon&quot;&gt;&lt;i&gt;&lt;&#x2F;i&gt;&lt;&#x2F;span&gt;
  334. &lt;&#x2F;div&gt;
  335. &lt;script&gt;
  336. $(function() {
  337. $(&#39;#cp2&#39;).colorpicker();
  338. });
  339. &lt;&#x2F;script&gt;</div> </div>
  340. </div>
  341. <div class="example">
  342. <div class="example-title">With custom options</div>
  343. <div class="example-description">Sample overriding the initial color and format</div>
  344. <div class="example-content well">
  345. <div class="example-content-widget">
  346. <div id="cp3" class="input-group colorpicker-component">
  347. <input type="text" value="#00AABB" class="form-control"/>
  348. <span class="input-group-addon"><i></i></span>
  349. </div>
  350. <script>
  351. $(function () {
  352. $('#cp3').colorpicker({
  353. color: '#AA3399',
  354. format: 'rgb'
  355. });
  356. });
  357. </script>
  358. </div>
  359. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  360. <div class="example-code">&lt;div id=&quot;cp3&quot; class=&quot;input-group colorpicker-component&quot;&gt;
  361. &lt;input type=&quot;text&quot; value=&quot;#00AABB&quot; class=&quot;form-control&quot; &#x2F;&gt;
  362. &lt;span class=&quot;input-group-addon&quot;&gt;&lt;i&gt;&lt;&#x2F;i&gt;&lt;&#x2F;span&gt;
  363. &lt;&#x2F;div&gt;
  364. &lt;script&gt;
  365. $(function() {
  366. $(&#39;#cp3&#39;).colorpicker({
  367. color: &#39;#AA3399&#39;,
  368. format: &#39;rgb&#39;
  369. });
  370. });
  371. &lt;&#x2F;script&gt;</div> </div>
  372. </div>
  373. <div class="example">
  374. <div class="example-title">Working with events</div>
  375. <div class="example-content well">
  376. <div class="example-content-widget">
  377. <a href="#" class="btn btn-default" id="cp4">Change background color</a>
  378. <script>
  379. $(function () {
  380. $('#cp4').colorpicker().on('changeColor', function (e) {
  381. $('body')[0].style.backgroundColor = e.color.toString('rgba');
  382. });
  383. });
  384. </script>
  385. </div>
  386. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  387. <div class="example-code">&lt;a href=&quot;#&quot; class=&quot;btn btn-default&quot; id=&quot;cp4&quot;&gt;Change background color&lt;&#x2F;a&gt;
  388. &lt;script&gt;
  389. $(function() {
  390. $(&#39;#cp4&#39;).colorpicker().on(&#39;changeColor&#39;, function(e) {
  391. $(&#39;body&#39;)[0].style.backgroundColor = e.color.toString(
  392. &#39;rgba&#39;);
  393. });
  394. });
  395. &lt;&#x2F;script&gt;</div> </div>
  396. </div>
  397. <div class="example">
  398. <div class="example-title">Transparent color support</div>
  399. <div class="example-content well">
  400. <div class="example-content-widget">
  401. <input type="text" class="form-control" id="cp5"/>
  402. <script>
  403. $(function () {
  404. $('#cp5').colorpicker({
  405. color: "transparent",
  406. format: "hex"
  407. });
  408. });
  409. </script>
  410. </div>
  411. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  412. <div class="example-code">&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;cp5&quot; &#x2F;&gt;
  413. &lt;script&gt;
  414. $(function() {
  415. $(&#39;#cp5&#39;).colorpicker({
  416. color: &quot;transparent&quot;,
  417. format: &quot;hex&quot;
  418. });
  419. });
  420. &lt;&#x2F;script&gt;</div> </div>
  421. </div>
  422. <div class="example">
  423. <div class="example-title">Horizontal mode</div>
  424. <div class="example-content well">
  425. <div class="example-content-widget">
  426. <input type="text" class="form-control" id="cp6" />
  427. <script>
  428. $(function () {
  429. $('#cp6').colorpicker({
  430. color: "#88cc33",
  431. horizontal: true
  432. });
  433. });
  434. </script>
  435. </div>
  436. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  437. <div class="example-code">&lt;input type=&quot;text&quot; class=&quot;form-control&quot; id=&quot;cp6&quot; &#x2F;&gt;
  438. &lt;script&gt;
  439. $(function() {
  440. $(&#39;#cp6&#39;).colorpicker({
  441. color: &quot;#88cc33&quot;,
  442. horizontal: true
  443. });
  444. });
  445. &lt;&#x2F;script&gt;</div> </div>
  446. </div>
  447. <div class="example">
  448. <div class="example-title">Inline mode</div>
  449. <div class="example-content well">
  450. <div class="example-content-widget">
  451. <div id="cp7" class="inl-bl"></div>
  452. <style>
  453. .inl-bl {
  454. display: inline-block;
  455. }
  456. </style>
  457. <script>
  458. $(function () {
  459. $('#cp7').colorpicker({
  460. color:'#ffaa00',
  461. container: true,
  462. inline:true
  463. });
  464. });
  465. </script>
  466. </div>
  467. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  468. <div class="example-code">&lt;div id=&quot;cp7&quot; class=&quot;inl-bl&quot;&gt;&lt;&#x2F;div&gt;
  469. &lt;style&gt;
  470. .inl-bl {
  471. display: inline-block;
  472. }
  473. &lt;&#x2F;style&gt;
  474. &lt;script&gt;
  475. $(function() {
  476. $(&#39;#cp7&#39;).colorpicker({
  477. color: &#39;#ffaa00&#39;,
  478. container: true,
  479. inline: true
  480. });
  481. });
  482. &lt;&#x2F;script&gt;</div> </div>
  483. </div>
  484. <div class="example">
  485. <div class="example-title">Aliased color palette</div>
  486. <div class="example-content well">
  487. <div class="example-content-widget">
  488. <div id="cp8" data-format="alias" class="input-group colorpicker-component">
  489. <input type="text" value="primary" class="form-control"/>
  490. <span class="input-group-addon"><i></i></span>
  491. </div>
  492. <script>
  493. $(function () {
  494. $('#cp8').colorpicker({
  495. colorSelectors: {
  496. 'black': '#000000',
  497. 'white': '#ffffff',
  498. 'red': '#FF0000',
  499. 'default': '#777777',
  500. 'primary': '#337ab7',
  501. 'success': '#5cb85c',
  502. 'info': '#5bc0de',
  503. 'warning': '#f0ad4e',
  504. 'danger': '#d9534f'
  505. }
  506. });
  507. });
  508. </script>
  509. </div>
  510. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  511. <div class="example-code">&lt;div id=&quot;cp8&quot; data-format=&quot;alias&quot; class=&quot;input-group colorpicker-component&quot;&gt;
  512. &lt;input type=&quot;text&quot; value=&quot;primary&quot; class=&quot;form-control&quot; &#x2F;&gt;
  513. &lt;span class=&quot;input-group-addon&quot;&gt;&lt;i&gt;&lt;&#x2F;i&gt;&lt;&#x2F;span&gt;
  514. &lt;&#x2F;div&gt;
  515. &lt;script&gt;
  516. $(function() {
  517. $(&#39;#cp8&#39;).colorpicker({
  518. colorSelectors: {
  519. &#39;black&#39;: &#39;#000000&#39;,
  520. &#39;white&#39;: &#39;#ffffff&#39;,
  521. &#39;red&#39;: &#39;#FF0000&#39;,
  522. &#39;default&#39;: &#39;#777777&#39;,
  523. &#39;primary&#39;: &#39;#337ab7&#39;,
  524. &#39;success&#39;: &#39;#5cb85c&#39;,
  525. &#39;info&#39;: &#39;#5bc0de&#39;,
  526. &#39;warning&#39;: &#39;#f0ad4e&#39;,
  527. &#39;danger&#39;: &#39;#d9534f&#39;
  528. }
  529. });
  530. });
  531. &lt;&#x2F;script&gt;</div> </div>
  532. </div>
  533. <div class="example">
  534. <div class="example-title">Customized widget size</div>
  535. <div class="example-description">Also showing the support of HTML color names</div>
  536. <div class="example-content well">
  537. <div class="example-content-widget">
  538. <input id="cp9" type="text" class="form-control" value="pink"/>
  539. <style>
  540. .colorpicker-2x .colorpicker-saturation {
  541. width: 200px;
  542. height: 200px;
  543. }
  544. .colorpicker-2x .colorpicker-hue,
  545. .colorpicker-2x .colorpicker-alpha {
  546. width: 30px;
  547. height: 200px;
  548. }
  549. .colorpicker-2x .colorpicker-color,
  550. .colorpicker-2x .colorpicker-color div {
  551. height: 30px;
  552. }
  553. </style>
  554. <script>
  555. $(function () {
  556. $('#cp9').colorpicker({
  557. customClass: 'colorpicker-2x',
  558. sliders: {
  559. saturation: {
  560. maxLeft: 200,
  561. maxTop: 200
  562. },
  563. hue: {
  564. maxTop: 200
  565. },
  566. alpha: {
  567. maxTop: 200
  568. }
  569. }
  570. });
  571. });
  572. </script>
  573. </div>
  574. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  575. <div class="example-code">&lt;input id=&quot;cp9&quot; type=&quot;text&quot; class=&quot;form-control&quot; value=&quot;pink&quot; &#x2F;&gt;
  576. &lt;style&gt;
  577. .colorpicker-2x .colorpicker-saturation {
  578. width: 200px;
  579. height: 200px;
  580. }
  581. .colorpicker-2x .colorpicker-hue,
  582. .colorpicker-2x .colorpicker-alpha {
  583. width: 30px;
  584. height: 200px;
  585. }
  586. .colorpicker-2x .colorpicker-color,
  587. .colorpicker-2x .colorpicker-color div {
  588. height: 30px;
  589. }
  590. &lt;&#x2F;style&gt;
  591. &lt;script&gt;
  592. $(function() {
  593. $(&#39;#cp9&#39;).colorpicker({
  594. customClass: &#39;colorpicker-2x&#39;,
  595. sliders: {
  596. saturation: {
  597. maxLeft: 200,
  598. maxTop: 200
  599. },
  600. hue: {
  601. maxTop: 200
  602. },
  603. alpha: {
  604. maxTop: 200
  605. }
  606. }
  607. });
  608. });
  609. &lt;&#x2F;script&gt;</div> </div>
  610. </div>
  611. <div class="example">
  612. <div class="example-title">Disabled / enabled status</div>
  613. <div class="example-content well">
  614. <div class="example-content-widget">
  615. <div id="cp10" class="input-group colorpicker-component">
  616. <input disabled type="text" value="" class="form-control"/>
  617. <span class="input-group-addon"><i></i></span>
  618. </div>
  619. <br>
  620. <p>
  621. <a class="btn btn-sm btn-default enable-button" href="#">Enable</a>
  622. <a class="btn btn-sm btn-default disable-button" href="#">Disable</a>
  623. </p>
  624. <script>
  625. $(function () {
  626. $(".disable-button").click(function(e) {
  627. e.preventDefault();
  628. $("#cp10").colorpicker('disable');
  629. });
  630. $(".enable-button").click(function(e) {
  631. e.preventDefault();
  632. $("#cp10").colorpicker('enable');
  633. });
  634. $('#cp10').colorpicker();
  635. });
  636. </script>
  637. </div>
  638. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  639. <div class="example-code">&lt;div id=&quot;cp10&quot; class=&quot;input-group colorpicker-component&quot;&gt;
  640. &lt;input disabled type=&quot;text&quot; value=&quot;&quot; class=&quot;form-control&quot; &#x2F;&gt;
  641. &lt;span class=&quot;input-group-addon&quot;&gt;&lt;i&gt;&lt;&#x2F;i&gt;&lt;&#x2F;span&gt;
  642. &lt;&#x2F;div&gt;
  643. &lt;br&gt;
  644. &lt;p&gt;
  645. &lt;a class=&quot;btn btn-sm btn-default enable-button&quot; href=&quot;#&quot;&gt;Enable&lt;&#x2F;a&gt;
  646. &lt;a class=&quot;btn btn-sm btn-default disable-button&quot; href=&quot;#&quot;&gt;Disable&lt;&#x2F;a&gt;
  647. &lt;&#x2F;p&gt;
  648. &lt;script&gt;
  649. $(function() {
  650. $(&quot;.disable-button&quot;).click(function(e) {
  651. e.preventDefault();
  652. $(&quot;#cp10&quot;).colorpicker(&#39;disable&#39;);
  653. });
  654. $(&quot;.enable-button&quot;).click(function(e) {
  655. e.preventDefault();
  656. $(&quot;#cp10&quot;).colorpicker(&#39;enable&#39;);
  657. });
  658. $(&#39;#cp10&#39;).colorpicker();
  659. });
  660. &lt;&#x2F;script&gt;</div> </div>
  661. </div>
  662. <div class="example">
  663. <div class="example-title">Inside a modal</div>
  664. <div class="example-content well">
  665. <div class="example-content-widget">
  666. <button class="btn btn-primary btn-md" data-toggle="modal" data-target="#myModal">
  667. Show modal
  668. </button>
  669. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  670. <div class="modal-dialog">
  671. <div class="modal-content">
  672. <div class="modal-body">
  673. <div id="cp11" class="input-group colorpicker-component">
  674. <input type="text" value="" class="form-control"/>
  675. <span class="input-group-addon"><i></i></span>
  676. </div>
  677. </div>
  678. </div>
  679. </div>
  680. </div>
  681. <script>
  682. $(function () {
  683. $('#cp11').colorpicker();
  684. });
  685. </script>
  686. </div>
  687. <button type="button" class="btn btn-link btn-xs example-code-toggle" data-toggle="button">View source</button>
  688. <div class="example-code">&lt;button class=&quot;btn btn-primary btn-md&quot; data-toggle=&quot;modal&quot; data-target=&quot;#myModal&quot;&gt;
  689. Show modal
  690. &lt;&#x2F;button&gt;
  691. &lt;div class=&quot;modal fade&quot; id=&quot;myModal&quot; tabindex=&quot;-1&quot; role=&quot;dialog&quot; aria-labelledby=&quot;myModalLabel&quot;
  692. aria-hidden=&quot;true&quot;&gt;
  693. &lt;div class=&quot;modal-dialog&quot;&gt;
  694. &lt;div class=&quot;modal-content&quot;&gt;
  695. &lt;div class=&quot;modal-body&quot;&gt;
  696. &lt;div id=&quot;cp11&quot; class=&quot;input-group colorpicker-component&quot;&gt;
  697. &lt;input type=&quot;text&quot; value=&quot;&quot; class=&quot;form-control&quot; &#x2F;&gt;
  698. &lt;span class=&quot;input-group-addon&quot;&gt;&lt;i&gt;&lt;&#x2F;i&gt;&lt;&#x2F;span&gt;
  699. &lt;&#x2F;div&gt;
  700. &lt;&#x2F;div&gt;
  701. &lt;&#x2F;div&gt;
  702. &lt;&#x2F;div&gt;
  703. &lt;&#x2F;div&gt;
  704. &lt;script&gt;
  705. $(function() {
  706. $(&#39;#cp11&#39;).colorpicker();
  707. });
  708. &lt;&#x2F;script&gt;</div> </div>
  709. </div>
  710. <script>
  711. $(function () {
  712. $('.example-code-toggle').on('click', function () {
  713. $(this).parent().find('.example-code').toggle();
  714. });
  715. });
  716. </script>
  717. </div>
  718. </div>
  719. </div>
  720. </body>
  721. </html>