|
25 | 25 | _pointerdown = 'touchstart.tcp mousedown.tcp pointerdown.tcp', |
26 | 26 | _pointerup = 'touchend.tcp mouseup.tcp pointerup.tcp', |
27 | 27 | _GPU = false, |
28 | | - _round = Math.round, |
29 | 28 | _animate = window.requestAnimationFrame || |
30 | 29 | window.webkitRequestAnimationFrame || function(cb){cb()}, |
31 | 30 | _html = '<div class="cp-color-picker"><div class="cp-z-slider"><div c' + |
|
92 | 91 | _colorPicker.$trigger = $this; |
93 | 92 |
|
94 | 93 | (_$UI || build()).css({ |
95 | | - // 'width': _$UI[0]._width, |
96 | | - 'left': (_$UI[0]._left = position.left) - |
97 | | - ((_$UI[0]._left += _$UI[0]._width - |
| 94 | + 'left': (_$UI._left = position.left) - |
| 95 | + ((_$UI._left += _$UI._width - |
98 | 96 | ($window.scrollLeft() + $window.width())) + gap > 0 ? |
99 | | - _$UI[0]._left + gap : 0), |
100 | | - 'top': (_$UI[0]._top = position.top + $this.outerHeight()) - |
101 | | - ((_$UI[0]._top += _$UI[0]._height - |
| 97 | + _$UI._left + gap : 0), |
| 98 | + 'top': (_$UI._top = position.top + $this.outerHeight()) - |
| 99 | + ((_$UI._top += _$UI._height - |
102 | 100 | ($window.scrollTop() + $window.height())) + gap > 0 ? |
103 | | - _$UI[0]._top + gap : 0) |
| 101 | + _$UI._top + gap : 0) |
104 | 102 | }).show(_options.animationSpeed, function() { |
105 | 103 | if (event === true) { // resize, scroll |
106 | 104 | return; |
|
127 | 125 | $('head').append('<style type="text/css" id="tinyColorPickerStyles">' + |
128 | 126 | (_options.css || _css) + (_options.cssAddon || '') + '</style>'); |
129 | 127 |
|
130 | | - return _colorPicker.$UI = _$UI = |
131 | | - $(_html).css({'margin': _options.margin}) |
| 128 | + return $(_html).css({'margin': _options.margin}) |
132 | 129 | .appendTo('body') |
133 | 130 | .show(0, function() { |
134 | | - var $this = $(this); |
| 131 | + _colorPicker.$UI = _$UI = $(this); |
135 | 132 |
|
136 | | - _GPU = _options.GPU && $this.css('perspective') !== undefined; |
| 133 | + _GPU = _options.GPU && _$UI.css('perspective') !== undefined; |
137 | 134 | _$z_slider = $('.cp-z-slider', this); |
138 | 135 | _$xy_slider = $('.cp-xy-slider', this); |
139 | 136 | _$xy_cursor = $('.cp-xy-cursor', this); |
140 | 137 | _$z_cursor = $('.cp-z-cursor', this); |
141 | 138 | _$alpha = $('.cp-alpha', this); |
142 | 139 | _$alpha_cursor = $('.cp-alpha-cursor', this); |
143 | | - _options.buildCallback.call(_colorPicker, $this); |
144 | | - $this.prepend('<div>').children().eq(0).css('width', |
145 | | - $this.children().eq(0).width() // stabilizer |
146 | | - ); |
147 | | - this._width = this.offsetWidth; |
148 | | - this._height = this.offsetHeight; |
| 140 | + _options.buildCallback.call(_colorPicker, _$UI); |
| 141 | + _$UI.prepend('<div>').children().eq(0).css('width', |
| 142 | + _$UI.children().eq(0).width()); // stabilizer |
| 143 | + _$UI._width = this.offsetWidth; |
| 144 | + _$UI._height = this.offsetHeight; |
149 | 145 | }).hide(); |
150 | 146 | } |
151 | 147 |
|
|
201 | 197 | hueRGB = colors.hueRGB, |
202 | 198 | RGB = colors.RND.rgb, |
203 | 199 | HSL = colors.RND.hsl, |
204 | | - dark = '#222', |
205 | | - light = '#ddd', |
| 200 | + dark = _options.dark, |
| 201 | + light = _options.light, |
206 | 202 | colorText = _color.toString(_$trigger._colorMode, _options.forceAlpha), |
207 | 203 | HUEContrast = colors.HUELuminance > 0.22 ? dark : light, |
208 | 204 | alphaContrast = colors.rgbaMixBlack.luminance > 0.22 ? dark : light, |
|
282 | 278 | body: document.body, |
283 | 279 | scrollResize: true, |
284 | 280 | gap: 4, |
| 281 | + dark: '#222', |
| 282 | + light: '#DDD' |
285 | 283 | // forceAlpha: undefined, |
286 | 284 | // css: '', |
287 | 285 | // cssAddon: '', |
|
324 | 322 | $elm.css({'background-color': value, |
325 | 323 | 'color': function() { |
326 | 324 | return _color.setColor(value) |
327 | | - .rgbaMixBGMixCustom.luminance > 0.22 ? '#222' : '#DDD' |
| 325 | + .rgbaMixBGMixCustom.luminance > 0.22 ? |
| 326 | + options.dark : options.light |
328 | 327 | } |
329 | 328 | }); |
330 | 329 | }); |
|
0 commit comments