diff --git a/examples/conditionformat2/css/config.css b/examples/conditionformat2/css/config.css
index ea22447..2786725 100644
--- a/examples/conditionformat2/css/config.css
+++ b/examples/conditionformat2/css/config.css
@@ -57,11 +57,8 @@
}
.cf-plugin-column5, .cf-plugin-column6 {
- width: 90px;
-}
-
-.cf-plugin-column5-color, .cf-plugin-column6-color{
- display:none;
+ width: 120px;
+ box-shadow: none;
}
.color-paint-brush {
@@ -70,6 +67,81 @@
border-bottom: 3px solid #000000;
}
-.cf-plugin-column9{
+.cf-plugin-column9 {
min-width: 70px;
-}
\ No newline at end of file
+}
+
+.cf-plugin-submit {
+ margin-top: 50px;
+}
+
+/* color picker */
+.kintone-ui.cp-color-picker {
+ background: #fff;
+ box-sizing: border-box;
+ width: 330px;
+ border-radius: 0px;
+ box-shadow: 0 0 8px 2px rgba(0,0,0,.1);
+}
+
+.kintone-ui.cp-color-picker .cp-panel {
+ width: 75px;
+ line-height: 21px;
+ float: right;
+ padding: 0 1px 0 8px;
+ margin-top: -1px;
+ overflow: visible
+}
+.kintone-ui.cp-color-picker .cp-panel div {
+ margin-bottom: 4px;
+ padding-left: 10px;
+ display: inline-block;
+}
+.kintone-ui.cp-color-picker .cp-panel div label {
+ width: 10px;
+ float: left;
+ text-align: left;
+ line-height: 20px;
+ padding-right: 4px;
+ display: inline-block;
+}
+.kintone-ui.cp-color-picker .cp-panel div input {
+ width: 50px;
+ height: 20px;
+ font-size: 12px;
+ padding: 4px 2px;
+ box-sizing: border-box;
+ text-align: right;
+ color: #a7a7a7;
+ background-color: #ffffff;
+ border: 1px solid #e3e7e8;
+ box-shadow: 2px 2px 6px #f5f5f5 inset, -2px -2px 6px #f5f5f5 inset;
+ display: inline-block;
+}
+.kintone-ui.cp-color-picker .cp-panel div input:focus {
+ background-color: #e2f2fe;
+ box-shadow: none;
+}
+.kintone-ui.cp-color-picker .cp-panel hr {
+ border-top: 1px solid #e3e7e8;
+ border-left: none;
+ border-right: none;
+ border-bottom: none;
+}
+.kintone-ui.cp-color-picker .cp-panel .cp-HEX {
+ width: 65px;
+ float: right;
+}
+
+.kintone-ui.cp-color-picker .cp-z-slider {
+ height: 200px;
+}
+
+.kintone-ui.cp-color-picker .cp-xy-slider {
+ width: 200px;
+ height: 200px;
+}
+.kintone-ui.cp-color-picker .cp-xy-slider:active {
+ cursor: none;
+}
+/* color picker */
diff --git a/examples/conditionformat2/html/config.html b/examples/conditionformat2/html/config.html
index f7f994d..6688a84 100644
--- a/examples/conditionformat2/html/config.html
+++ b/examples/conditionformat2/html/config.html
@@ -104,8 +104,6 @@
+
diff --git a/examples/conditionformat2/js/config.js b/examples/conditionformat2/js/config.js
index b22e798..19b94fb 100644
--- a/examples/conditionformat2/js/config.js
+++ b/examples/conditionformat2/js/config.js
@@ -30,6 +30,60 @@ jQuery.noConflict();
DATE_ROW_NUM = 10;
}
+ function createColorPickerConfig(callback) {
+ return {
+ opacity: false,
+ doRender: false,
+ buildCallback: function($elm) {
+ $elm.addClass('kintone-ui');
+
+ var colorInstance = this.color,
+ colorPicker = this;
+
+ $elm.prepend('
').on('change', 'input', function(e) {
+ var value = this.value,
+ className = this.className,
+ type = className.split('-')[1],
+ color = {};
+
+ color[type] = value;
+ colorInstance.setColor(type === 'HEX' ? value : color,
+ type === 'HEX' ? 'HEX' : /(?:r|g|b)/.test(type) ? 'rgb' : 'hsv');
+ colorPicker.render();
+ this.blur();
+ });
+ },
+ renderCallback: function($elm, toggled) {
+ var colors = this.color.colors.RND,
+ modes = {
+ r: colors.rgb.r, g: colors.rgb.g, b: colors.rgb.b,
+ h: colors.hsv.h, s: colors.hsv.s, v: colors.hsv.v,
+ HEX: this.color.colors.HEX
+ };
+
+ $('input', '.cp-panel').each(function() {
+ this.value = modes[this.className.substr(3)];
+ });
+
+ this.$trigger = $elm;
+ callback(this.color.colors.HEX);
+ },
+ positionCallback: function($elm) {
+ this.color.setColor($elm.val());
+ }
+ }
+ }
+
$(document).ready(function() {
var terms = {
'ja': {
@@ -251,29 +305,23 @@ jQuery.noConflict();
$('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column3').val(CONF['text_row' + ti]['value']);
$('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column4').
val(CONF['text_row' + ti]['targetfield']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column5').
- val(CONF['text_row' + ti]['targetcolor']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column6').
- val(CONF['text_row' + ti]['targetbgcolor']);
$('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column7').
val(CONF['text_row' + ti]['targetsize']);
$('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column8').
val(CONF['text_row' + ti]['targetfont']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column5').
- css('color', CONF['text_row' + ti]['targetcolor']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column6').
- css('background-color', CONF['text_row' + ti]['targetbgcolor']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column5').
- parent('div').find('i').css('border-bottom-color', CONF['text_row' + ti]['targetcolor']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column6').
- parent('div').find('i').css('border-bottom-color', CONF['text_row' + ti]['targetbgcolor']);
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column5-color').
- val(CONF['text_row' + ti]['targetcolor']);
+
+ var $fontColor = $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column5');
+ $fontColor.val(CONF['text_row' + ti]['targetcolor']);
+ $fontColor.css('color', CONF['text_row' + ti]['targetcolor']);
+
+ var $backgroundColor = $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column6');
+ $backgroundColor.css('color', CONF['text_row' + ti]['targetcolor']);
if (CONF['text_row' + ti]['targetbgcolor'] !== '#') {
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column6-color').
- val(CONF['text_row' + ti]['targetbgcolor']);
+ $backgroundColor.val(CONF['text_row' + ti]['targetbgcolor']);
+ $backgroundColor.css('background-color', CONF['text_row' + ti]['targetbgcolor']);
} else {
- $('#cf-plugin-text-tbody > tr:eq(' + ti + ') .cf-plugin-column6-color').val('#808080');
+ $backgroundColor.val('#808080');
+ $backgroundColor.css('background-color', '#808080');
}
}
}
@@ -290,32 +338,25 @@ jQuery.noConflict();
val(CONF['date_row' + di]['type2']);
$('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column4').
val(CONF['date_row' + di]['targetfield']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column5').
- val(CONF['date_row' + di]['targetcolor']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column6').
- val(CONF['date_row' + di]['targetbgcolor']);
$('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column7').
val(CONF['date_row' + di]['targetsize']);
$('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column8').
val(CONF['date_row' + di]['targetfont']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column5').
- css('color', CONF['date_row' + di]['targetcolor']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column6').
- css('background-color', CONF['date_row' + di]['targetbgcolor']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column5').
- parent('div').find('i').css('border-bottom-color', CONF['date_row' + di]['targetcolor']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column6').
- parent('div').find('i').css('border-bottom-color', CONF['date_row' + di]['targetbgcolor']);
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column5-color').
- val(CONF['date_row' + di]['targetcolor']);
+
+ var $fontColor = $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column5');
+ $fontColor.val(CONF['date_row' + di]['targetcolor']);
+ $fontColor.css('color', CONF['date_row' + di]['targetcolor']);
+
+ var $backgroundColor = $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column6');
+ $backgroundColor.css('color', CONF['date_row' + di]['targetcolor']);
if (CONF['date_row' + di]['targetbgcolor'] !== '#') {
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column6-color').
- val(CONF['date_row' + di]['targetbgcolor']);
+ $backgroundColor.val(CONF['date_row' + di]['targetbgcolor']);
+ $backgroundColor.css('background-color', CONF['date_row' + di]['targetbgcolor']);
} else {
- $('#cf-plugin-date-tbody > tr:eq(' + di + ') .cf-plugin-column6-color').val('#808080');
+ $backgroundColor.val('#808080');
+ $backgroundColor.css('background-color', '#808080');
}
}
-
}
function setDefault() {
@@ -447,45 +488,36 @@ jQuery.noConflict();
});
}
- // Change color
- $('.cf-plugin-column5').change(function() {
- $(this).css('color', $(this).val());
- $(this).parent('div').find('i').css('border-bottom-color', $(this).val());
- return true;
+ $('.cf-plugin-column5').focus(function(event) {
+ var $fontColorInput = $(this);
+ var $backgroundColorInput = $fontColorInput.parents('td').next().find('.cf-plugin-column6');
+ $(this).colorPicker(createColorPickerConfig(function(colorCode) {
+ $fontColorInput.css('color', '#' + colorCode);
+ $backgroundColorInput.css('color', '#' + colorCode);
+ }));
});
- // Change backgroundcolor
- $('.cf-plugin-column6').change(function() {
- $(this).css('background-color', $(this).val());
- $(this).parent('div').find('i').css('border-bottom-color', $(this).val());
- return true;
+ $('.cf-plugin-column6').focus(function(event) {
+ var $backgroundColorInput = $(this);
+ $(this).colorPicker(createColorPickerConfig(function(colorCode) {
+ $backgroundColorInput.css('background-color', '#' + colorCode);
+ }));
});
// Change color
- $('.cf-plugin-column5-color').change(function() {
- var color_code = $(this).parent('div').find('input[type="color"]').val();
- var $el = $(this).parent('div').find('input[type="text"]');
- $el.val(color_code);
- $el.css('color', color_code);
- $(this).parent('div').find('i').css('border-bottom-color', $(this).val());
+ $('.cf-plugin-column5').change(function() {
+ var $fontColorInput = $(this);
+ $fontColorInput.css('color', $fontColorInput.val());
+ $fontColorInput.parents('td').next().find('.cf-plugin-column6').css('color', $fontColorInput.val());
return true;
});
- // Change color
- $('.cf-plugin-column6-color').change(function() {
- var color_code = $(this).parent('div').find('input[type="color"]').val();
- var $el = $(this).parent('div').find('input[type="text"]');
- $el.val(color_code);
- $el.css('background-color', color_code);
- $(this).parent('div').find('i').css('border-bottom-color', $(this).val());
+ // Change backgroundcolor
+ $('.cf-plugin-column6').change(function() {
+ $(this).css('background-color', $(this).val());
return true;
});
- // Color picker
- $('.color-paint-brush').click(function() {
- $($(this).parents('td')[0]).find('input[type="color"]').click();
- });
-
// Add Row
$('#cf-plugin-text-tbody .addList').click(function() {
$('#cf-plugin-text-tbody > tr').eq(0).clone(true).insertAfter($(this).parent().parent());
diff --git a/examples/conditionformat2/manifest.json b/examples/conditionformat2/manifest.json
index a8c9c4d..9919685 100644
--- a/examples/conditionformat2/manifest.json
+++ b/examples/conditionformat2/manifest.json
@@ -4,12 +4,12 @@
"type": "APP",
"name": {
"ja": "新条件書式プラグイン",
- "en": "New conditional format plug-in",
+ "en": "Conditional Format",
"zh": "新条件格式插件"
},
"description": {
"ja": "新デザインに対応した条件により表示するアイテムの色、背景色等を変更するプラグインです。",
- "en": "It is plug-in which changes the color etc. of the item displayed according to conditions. ",
+ "en": "This plug-in changes colors and styles of fields",
"zh": "是變更根據條件表示的條款的顏色等的插件。"
},
"icon": "image/icon.png",
@@ -32,6 +32,7 @@
"js": [
"https://js.cybozu.com/jquery/2.1.4/jquery.min.js",
"https://js.cybozu.com/jsrender/0.9.83/jsrender.min.js",
+ "thirdparties/jqColorPicker.min.js",
"js/config.js"
],
"css": [
diff --git a/examples/conditionformat2/thirdparties/jqColorPicker.min.js b/examples/conditionformat2/thirdparties/jqColorPicker.min.js
new file mode 100644
index 0000000..e1d9078
--- /dev/null
+++ b/examples/conditionformat2/thirdparties/jqColorPicker.min.js
@@ -0,0 +1,3 @@
+/*! tinyColorPicker - v1.1.1 2016-08-30 */
+
+!function(a,b){"object"==typeof exports?module.exports=b(a):"function"==typeof define&&define.amd?define("colors",[],function(){return b(a)}):a.Colors=b(a)}(this,function(a,b){"use strict";function c(a,c,d,f,g){if("string"==typeof c){var c=v.txt2color(c);d=c.type,p[d]=c[d],g=g!==b?g:c.alpha}else if(c)for(var h in c)a[d][h]=k(c[h]/l[d][h][1],0,1);return g!==b&&(a.alpha=k(+g,0,1)),e(d,f?a:b)}function d(a,b,c){var d=o.options.grey,e={};return e.RGB={r:a.r,g:a.g,b:a.b},e.rgb={r:b.r,g:b.g,b:b.b},e.alpha=c,e.equivalentGrey=n(d.r*a.r+d.g*a.g+d.b*a.b),e.rgbaMixBlack=i(b,{r:0,g:0,b:0},c,1),e.rgbaMixWhite=i(b,{r:1,g:1,b:1},c,1),e.rgbaMixBlack.luminance=h(e.rgbaMixBlack,!0),e.rgbaMixWhite.luminance=h(e.rgbaMixWhite,!0),o.options.customBG&&(e.rgbaMixCustom=i(b,o.options.customBG,c,1),e.rgbaMixCustom.luminance=h(e.rgbaMixCustom,!0),o.options.customBG.luminance=h(o.options.customBG,!0)),e}function e(a,b){var c,e,k,q=b||p,r=v,s=o.options,t=l,u=q.RND,w="",x="",y={hsl:"hsv",rgb:a},z=u.rgb;if("alpha"!==a){for(var A in t)if(!t[A][A]){a!==A&&(x=y[A]||"rgb",q[A]=r[x+"2"+A](q[x])),u[A]||(u[A]={}),c=q[A];for(w in c)u[A][w]=n(c[w]*t[A][w][1])}z=u.rgb,q.HEX=r.RGB2HEX(z),q.equivalentGrey=s.grey.r*q.rgb.r+s.grey.g*q.rgb.g+s.grey.b*q.rgb.b,q.webSave=e=f(z,51),q.webSmart=k=f(z,17),q.saveColor=z.r===e.r&&z.g===e.g&&z.b===e.b?"web save":z.r===k.r&&z.g===k.g&&z.b===k.b?"web smart":"",q.hueRGB=v.hue2RGB(q.hsv.h),b&&(q.background=d(z,q.rgb,q.alpha))}var B,C,D,E=q.rgb,F=q.alpha,G="luminance",H=q.background;return B=i(E,{r:0,g:0,b:0},F,1),B[G]=h(B,!0),q.rgbaMixBlack=B,C=i(E,{r:1,g:1,b:1},F,1),C[G]=h(C,!0),q.rgbaMixWhite=C,s.customBG&&(D=i(E,H.rgbaMixCustom,F,1),D[G]=h(D,!0),D.WCAG2Ratio=j(D[G],H.rgbaMixCustom[G]),q.rgbaMixBGMixCustom=D,D.luminanceDelta=m.abs(D[G]-H.rgbaMixCustom[G]),D.hueDelta=g(H.rgbaMixCustom,D,!0)),q.RGBLuminance=h(z),q.HUELuminance=h(q.hueRGB),s.convertCallback&&s.convertCallback(q,a),q}function f(a,b){var c={},d=0,e=b/2;for(var f in a)d=a[f]%b,c[f]=a[f]+(d>e?b-d:-d);return c}function g(a,b,c){return(m.max(a.r-b.r,b.r-a.r)+m.max(a.g-b.g,b.g-a.g)+m.max(a.b-b.b,b.b-a.b))*(c?255:1)/765}function h(a,b){for(var c=b?1:255,d=[a.r/c,a.g/c,a.b/c],e=o.options.luminance,f=d.length;f--;)d[f]=d[f]<=.03928?d[f]/12.92:m.pow((d[f]+.055)/1.055,2.4);return e.r*d[0]+e.g*d[1]+e.b*d[2]}function i(a,c,d,e){var f={},g=d!==b?d:1,h=e!==b?e:1,i=g+h*(1-g);for(var j in a)f[j]=(a[j]*g+c[j]*h*(1-g))/i;return f.a=i,f}function j(a,b){var c=1;return c=a>=b?(a+.05)/(b+.05):(b+.05)/(a+.05),n(100*c)/100}function k(a,b,c){return a>c?c:b>a?b:a}var l={rgb:{r:[0,255],g:[0,255],b:[0,255]},hsv:{h:[0,360],s:[0,100],v:[0,100]},hsl:{h:[0,360],s:[0,100],l:[0,100]},alpha:{alpha:[0,1]},HEX:{HEX:[0,16777215]}},m=a.Math,n=m.round,o={},p={},q={r:.298954,g:.586434,b:.114612},r={r:.2126,g:.7152,b:.0722},s=function(a){this.colors={RND:{}},this.options={color:"rgba(0,0,0,0)",grey:q,luminance:r,valueRanges:l},t(this,a||{})},t=function(a,d){var e,f=a.options;u(a);for(var g in d)d[g]!==b&&(f[g]=d[g]);e=f.customBG,f.customBG="string"==typeof e?v.txt2color(e).rgb:e,p=c(a.colors,f.color,b,!0)},u=function(a){o!==a&&(o=a,p=a.colors)};s.prototype.setColor=function(a,d,f){return u(this),a?c(this.colors,a,d,b,f):(f!==b&&(this.colors.alpha=k(f,0,1)),e(d))},s.prototype.setCustomBackground=function(a){return u(this),this.options.customBG="string"==typeof a?v.txt2color(a).rgb:a,c(this.colors,b,"rgb")},s.prototype.saveAsBackground=function(){return u(this),c(this.colors,b,"rgb",!0)},s.prototype.toString=function(a,b){return v.color2text((a||"rgb").toLowerCase(),this.colors,b)};var v={txt2color:function(a){var b={},c=a.replace(/(?:#|\)|%)/g,"").split("("),d=(c[1]||"").split(/,\s*/),e=c[1]?c[0].substr(0,3):"rgb",f="";if(b.type=e,b[e]={},c[1])for(var g=3;g--;)f=e[g]||e.charAt(g),b[e][f]=+d[g]/l[e][f][1];else b.rgb=v.HEX2rgb(c[0]);return b.alpha=d[3]?+d[3]:1,b},color2text:function(a,b,c){var d=c!==!1&&n(100*b.alpha)/100,e="number"==typeof d&&c!==!1&&(c||1!==d),f=b.RND.rgb,g=b.RND.hsl,h="hex"===a&&e,i="hex"===a&&!h,j="rgb"===a||h,k=j?f.r+", "+f.g+", "+f.b:i?"#"+b.HEX:g.h+", "+g.s+"%, "+g.l+"%";return i?k:(h?"rgb":a)+(e?"a":"")+"("+k+(e?", "+d:"")+")"},RGB2HEX:function(a){return((a.r<16?"0":"")+a.r.toString(16)+(a.g<16?"0":"")+a.g.toString(16)+(a.b<16?"0":"")+a.b.toString(16)).toUpperCase()},HEX2rgb:function(a){return a=a.split(""),{r:+("0x"+a[0]+a[a[3]?1:0])/255,g:+("0x"+a[a[3]?2:1]+(a[3]||a[1]))/255,b:+("0x"+(a[4]||a[2])+(a[5]||a[2]))/255}},hue2RGB:function(a){var b=6*a,c=~~b%6,d=6===b?0:b-c;return{r:n(255*[1,1-d,0,0,d,1][c]),g:n(255*[d,1,1,1-d,0,0][c]),b:n(255*[0,0,d,1,1,1-d][c])}},rgb2hsv:function(a){var b,c,d,e=a.r,f=a.g,g=a.b,h=0;return g>f&&(f=g+(g=f,0),h=-1),c=g,f>e&&(e=f+(f=e,0),h=-2/6-h,c=m.min(f,g)),b=e-c,d=e?b/e:0,{h:1e-15>d?p&&p.hsl&&p.hsl.h||0:b?m.abs(h+(f-g)/(6*b)):0,s:e?b/e:p&&p.hsv&&p.hsv.s||0,v:e}},hsv2rgb:function(a){var b=6*a.h,c=a.s,d=a.v,e=~~b,f=b-e,g=d*(1-c),h=d*(1-f*c),i=d*(1-(1-f)*c),j=e%6;return{r:[d,h,g,g,i,d][j],g:[i,d,d,h,g,g][j],b:[g,g,i,d,d,h][j]}},hsv2hsl:function(a){var b=(2-a.s)*a.v,c=a.s*a.v;return c=a.s?1>b?b?c/b:0:c/(2-b):0,{h:a.h,s:a.v||c?c:p&&p.hsl&&p.hsl.s||0,l:b/2}},rgb2hsl:function(a,b){var c=v.rgb2hsv(a);return v.hsv2hsl(b?c:p.hsv=c)},hsl2rgb:function(a){var b=6*a.h,c=a.s,d=a.l,e=.5>d?d*(1+c):d+c-c*d,f=d+d-e,g=e?(e-f)/e:0,h=~~b,i=b-h,j=e*g*i,k=f+j,l=e-j,m=h%6;return{r:[e,l,f,f,k,e][m],g:[k,e,e,l,f,f][m],b:[f,f,k,e,e,l][m]}}};return s}),function(a,b){"object"==typeof exports?module.exports=b(a,require("jquery"),require("colors")):"function"==typeof define&&define.amd?define(["jquery","colors"],function(c,d){return b(a,c,d)}):b(a,a.jQuery,a.Colors)}(this,function(a,b,c,d){"use strict";function e(a){return a.value||a.getAttribute("value")||b(a).css("background-color")||"#FFF"}function f(a){return a=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a,a.originalEvent?a.originalEvent:a}function g(a){return b(a.find(r.doRender)[0]||a[0])}function h(c){var d=b(this),f=d.offset(),h=b(a),k=r.gap;c?(s=g(d),s._colorMode=s.data("colorMode"),p.$trigger=d,(t||i()).css(r.positionCallback.call(p,d)||{left:(t._left=f.left)-((t._left+=t._width-(h.scrollLeft()+h.width()))+k>0?t._left+k:0),top:(t._top=f.top+d.outerHeight())-((t._top+=t._height-(h.scrollTop()+h.height()))+k>0?t._top+k:0)}).show(r.animationSpeed,function(){c!==!0&&(y.toggle(!!r.opacity)._width=y.width(),v._width=v.width(),v._height=v.height(),u._height=u.height(),q.setColor(e(s[0])),n(!0))}).off(".tcp").on(D,".cp-xy-slider,.cp-z-slider,.cp-alpha",j)):p.$trigger&&b(t).hide(r.animationSpeed,function(){n(!1),p.$trigger=null}).off(".tcp")}function i(){return b("head")[r.cssPrepend?"prepend":"append"]('"),b(H).css({margin:r.margin}).appendTo("body").show(0,function(){p.$UI=t=b(this),F=r.GPU&&t.css("perspective")!==d,u=b(".cp-z-slider",this),v=b(".cp-xy-slider",this),w=b(".cp-xy-cursor",this),x=b(".cp-z-cursor",this),y=b(".cp-alpha",this),z=b(".cp-alpha-cursor",this),r.buildCallback.call(p,t),t.prepend("
").children().eq(0).css("width",t.children().eq(0).width()),t._width=this.offsetWidth,t._height=this.offsetHeight}).hide()}function j(a){var c=this.className.replace(/cp-(.*?)(?:\s*|$)/,"$1").replace("-","_");(a.button||a.which)>1||(a.preventDefault&&a.preventDefault(),a.returnValue=!1,s._offset=b(this).offset(),(c="xy_slider"===c?k:"z_slider"===c?l:m)(a),n(),A.on(E,function(){A.off(".tcp")}).on(C,function(a){c(a),n()}))}function k(a){var b=f(a),c=b.pageX-s._offset.left,d=b.pageY-s._offset.top;q.setColor({s:c/v._width*100,v:100-d/v._height*100},"hsv")}function l(a){var b=f(a).pageY-s._offset.top;q.setColor({h:360-b/u._height*360},"hsv")}function m(a){var b=f(a).pageX-s._offset.left,c=b/y._width;q.setColor({},"rgb",c)}function n(a){var b=q.colors,c=b.hueRGB,e=(b.RND.rgb,b.RND.hsl,r.dark),f=r.light,g=q.toString(s._colorMode,r.forceAlpha),h=b.HUELuminance>.22?e:f,i=b.rgbaMixBlack.luminance>.22?e:f,j=(1-b.hsv.h)*u._height,k=b.hsv.s*v._width,l=(1-b.hsv.v)*v._height,m=b.alpha*y._width,n=F?"translate3d":"",p=s[0].value,t=s[0].hasAttribute("value")&&""===p&&a!==d;v._css={backgroundColor:"rgb("+c.r+","+c.g+","+c.b+")"},w._css={transform:n+"("+k+"px, "+l+"px, 0)",left:F?"":k,top:F?"":l,borderColor:b.RGBLuminance>.22?e:f},x._css={transform:n+"(0, "+j+"px, 0)",top:F?"":j,borderColor:"transparent "+h},y._css={backgroundColor:"#"+b.HEX},z._css={transform:n+"("+m+"px, 0, 0)",left:F?"":m,borderColor:i+" transparent"},s._css={backgroundColor:t?"":g,color:t?"":b.rgbaMixBGMixCustom.luminance>.22?e:f},s.text=t?"":p!==g?g:"",a!==d?o(a):G(o)}function o(a){v.css(v._css),w.css(w._css),x.css(x._css),y.css(y._css),z.css(z._css),r.doRender&&s.css(s._css),s.text&&s.val(s.text),r.renderCallback.call(p,s,"boolean"==typeof a?a:d)}var p,q,r,s,t,u,v,w,x,y,z,A=b(document),B=b(),C="touchmove.tcp mousemove.tcp pointermove.tcp",D="touchstart.tcp mousedown.tcp pointerdown.tcp",E="touchend.tcp mouseup.tcp pointerup.tcp",F=!1,G=a.requestAnimationFrame||a.webkitRequestAnimationFrame||function(a){a()},H='
',I=".cp-color-picker{position:absolute;overflow:hidden;padding:6px 6px 0;background-color:#444;color:#bbb;font-family:Arial,Helvetica,sans-serif;font-size:12px;font-weight:400;cursor:default;border-radius:5px}.cp-color-picker>div{position:relative;overflow:hidden}.cp-xy-slider{float:left;height:128px;width:128px;margin-bottom:6px;background:linear-gradient(to right,#FFF,rgba(255,255,255,0))}.cp-white{height:100%;width:100%;background:linear-gradient(rgba(0,0,0,0),#000)}.cp-xy-cursor{position:absolute;top:0;width:10px;height:10px;margin:-5px;border:1px solid #fff;border-radius:100%;box-sizing:border-box}.cp-z-slider{float:right;margin-left:6px;height:128px;width:20px;background:linear-gradient(red 0,#f0f 17%,#00f 33%,#0ff 50%,#0f0 67%,#ff0 83%,red 100%)}.cp-z-cursor{position:absolute;margin-top:-4px;width:100%;border:4px solid #fff;border-color:transparent #fff;box-sizing:border-box}.cp-alpha{clear:both;width:100%;height:16px;margin:6px 0;background:linear-gradient(to right,#444,rgba(0,0,0,0))}.cp-alpha-cursor{position:absolute;margin-left:-4px;height:100%;border:4px solid #fff;border-color:#fff transparent;box-sizing:border-box}",J=function(a){q=this.color=new c(a),r=q.options,p=this};J.prototype={render:n,toggle:h},b.fn.colorPicker=function(c){var d=this,f=function(){};return c=b.extend({animationSpeed:150,GPU:!0,doRender:!0,customBG:"#FFF",opacity:!0,renderCallback:f,buildCallback:f,positionCallback:f,body:document.body,scrollResize:!0,gap:4,dark:"#222",light:"#DDD"},c),!p&&c.scrollResize&&b(a).on("resize.tcp scroll.tcp",function(){p.$trigger&&p.toggle.call(p.$trigger[0],!0)}),B=B.add(this),this.colorPicker=p||new J(c),this.options=c,b(c.body).off(".tcp").on(D,function(a){-1===B.add(t).add(b(t).find(a.target)).index(a.target)&&h()}),this.on("focusin.tcp click.tcp",function(a){p.color.options=b.extend(p.color.options,r=d.options),h.call(this,a)}).on("change.tcp",function(){q.setColor(this.value||"#FFF"),d.colorPicker.render(!0)}).each(function(){var a=e(this),d=a.split("("),f=g(b(this));f.data("colorMode",d[1]?d[0].substr(0,3):"HEX").attr("readonly",r.preventFocus),c.doRender&&f.css({"background-color":a,color:function(){return q.setColor(a).rgbaMixBGMixCustom.luminance>.22?c.dark:c.light}})})},b.fn.colorPicker.destroy=function(){b("*").off(".tcp"),p.toggle(!1),B=b()}});
\ No newline at end of file