index.html 29 KB

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