Permalink
Browse files

Extra demo to test color.set

  • Loading branch information...
Martijn van der Lee
Martijn van der Lee committed Jan 1, 2014
1 parent e26cdc3 commit 0ebce304878eb645cdd8bcc883b2aa908e60fffb
Showing with 29 additions and 0 deletions.
  1. +29 −0 demo.html
View
@@ -54,6 +54,7 @@ <h1>jQuery ColorPicker - Demo page</h1>
<li><a href="#tab-revert">Revert</a></li>
<li><a href="#tab-okonenter">Close on enter</a></li>
<li><a href="#tab-128">128-pixel map and bar</a></li>
+ <li><a href="#tab-customcolor">Custom color format</a></li>
</ul>
<div id="tab-input">
@@ -461,6 +462,34 @@ <h2>128-pixel map and bar</h2>
});
</script>
</div>
+
+ <div id="tab-customcolor">
+ <h2>Custom color format</h2>
+ <input type="text" size="80" class="cp-customcolor" value="0;83.782958984375;83.782958984375;4.736328125" style="display: inline-block; vertical-align: top;"/>
+
+ <script>
+ $(function() {
+ $.colorpicker.parsers['csv-cmyk'] = function (color) {
+ var m = /^(\d+(?:\.\d+)?)\s*[,;]\s*(\d+(?:\.\d+)?)\s*[,;]\s*(\d+(?:\.\d+)?)\s*[,;]\s*(\d+(?:\.\d+)?)/.exec(color);
+ if (m) {
+ return (new $.colorpicker.Color()).setCMYK(
+ m[1] / 100,
+ m[2] / 100,
+ m[3] / 100,
+ m[4] / 100
+ );
+ }
+ };
+
+ $('.cp-customcolor').colorpicker({
+ showOn: 'both',
+ colorFormat: ['cp,mp,yp,kp'],
+ buttonImageOnly: true,
+ buttonColorize: true,
+ });
+ });
+ </script>
+ </div>
</div>
</body>
</html>

0 comments on commit 0ebce30

Please sign in to comment.