|
|
@ -2,10 +2,12 @@
|
|
|
|
'use strict';
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
|
|
var $document = $(document),
|
|
|
|
var $document = $(document),
|
|
|
|
|
|
|
|
_instance,
|
|
|
|
_colorPicker,
|
|
|
|
_colorPicker,
|
|
|
|
_color,
|
|
|
|
_color,
|
|
|
|
_options,
|
|
|
|
_options,
|
|
|
|
_cache = {},
|
|
|
|
_cache = {},
|
|
|
|
|
|
|
|
_selector = '',
|
|
|
|
_$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor,
|
|
|
|
_$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor,
|
|
|
|
_pointermove = 'touchmove mousemove pointermove',
|
|
|
|
_pointermove = 'touchmove mousemove pointermove',
|
|
|
|
_pointerup = 'touchend mouseup pointerup',
|
|
|
|
_pointerup = 'touchend mouseup pointerup',
|
|
|
@ -207,7 +209,7 @@
|
|
|
|
color: colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light
|
|
|
|
color: colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
toggled !== true && $element.val(text); // avoids carret jump
|
|
|
|
$element.val() !== text && $element.val(text); // avoids carret jump
|
|
|
|
|
|
|
|
|
|
|
|
// faster version (more than 2.5x)... though, no jQuery (colors, ...)
|
|
|
|
// faster version (more than 2.5x)... though, no jQuery (colors, ...)
|
|
|
|
|
|
|
|
|
|
|
@ -244,8 +246,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
// export as plugin to jQuery
|
|
|
|
// export as plugin to jQuery
|
|
|
|
$.fn.colorPicker = function(options) {
|
|
|
|
$.fn.colorPicker = function(options) {
|
|
|
|
var $that = this,
|
|
|
|
var noop = function(){};
|
|
|
|
noop = function(){};
|
|
|
|
|
|
|
|
|
|
|
|
_instance = _instance ? _instance.add(this) : this;
|
|
|
|
|
|
|
|
|
|
|
|
options = $.extend({
|
|
|
|
options = $.extend({
|
|
|
|
animationSpeed: 150,
|
|
|
|
animationSpeed: 150,
|
|
|
@ -262,26 +265,26 @@
|
|
|
|
// preventFocus: false
|
|
|
|
// preventFocus: false
|
|
|
|
}, options);
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
|
|
|
|
if (!_colorPicker) { // we only want one single instance...
|
|
|
|
_selector += (_selector ? ', ' : '') + this.selector;
|
|
|
|
_colorPicker = new ColorPicker(options);
|
|
|
|
|
|
|
|
|
|
|
|
$(options.body).off('.a').
|
|
|
|
$(options.body).on('touchstart mousedown pointerdown', function(e) {
|
|
|
|
on('touchstart.a mousedown.a pointerdown.a', function(e) {
|
|
|
|
var $target = $(e.target);
|
|
|
|
var $target = $(e.target);
|
|
|
|
|
|
|
|
|
|
|
|
if ($.inArray($target.closest($that.selector)[0],
|
|
|
|
if ($.inArray($target.closest(_selector)[0],
|
|
|
|
$that) === -1 &&
|
|
|
|
_instance) === -1 &&
|
|
|
|
!$target.closest(_$UI).length) {
|
|
|
|
!$target.closest(_$UI).length) {
|
|
|
|
toggle();
|
|
|
|
toggle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).
|
|
|
|
}).
|
|
|
|
on('focus click', this.selector, toggle).
|
|
|
|
on('focus.a click.a', _selector, toggle).
|
|
|
|
on('change', this.selector, function() {
|
|
|
|
on('change.a', _selector, function() {
|
|
|
|
_color.setColor(this.value);
|
|
|
|
_color.setColor(this.value);
|
|
|
|
$that.colorPicker.render();
|
|
|
|
_instance.colorPicker.render();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.colorPicker = _colorPicker;
|
|
|
|
this.colorPicker = _colorPicker ||
|
|
|
|
|
|
|
|
(_colorPicker = new ColorPicker(options));
|
|
|
|
|
|
|
|
|
|
|
|
return this.each(function() {
|
|
|
|
return this.each(function() {
|
|
|
|
var value = extractValue(this),
|
|
|
|
var value = extractValue(this),
|
|
|
|