mirror of
https://github.com/PitPik/tinyColorPicker
synced 2025-07-20 08:24:29 -06:00
better jQuery support
$(…) can not only hold selector but also elements. Now tcp supports native jQuery selection support.
This commit is contained in:
parent
2d23b9553b
commit
fe4b4def67
@ -6,7 +6,6 @@
|
|||||||
_colorPicker,
|
_colorPicker,
|
||||||
_color,
|
_color,
|
||||||
_options,
|
_options,
|
||||||
_selector = '',
|
|
||||||
|
|
||||||
_$trigger,
|
_$trigger,
|
||||||
_$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor,
|
_$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor,
|
||||||
@ -103,7 +102,6 @@
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$(_$UI).hide(_options.animationSpeed, function() {
|
$(_$UI).hide(_options.animationSpeed, function() {
|
||||||
_$trigger.blur();
|
|
||||||
preRender(false);
|
preRender(false);
|
||||||
_colorPicker.$trigger = null;
|
_colorPicker.$trigger = null;
|
||||||
});
|
});
|
||||||
@ -267,7 +265,7 @@
|
|||||||
$.fn.colorPicker = function(options) {
|
$.fn.colorPicker = function(options) {
|
||||||
var noop = function(){};
|
var noop = function(){};
|
||||||
|
|
||||||
options = $.extend({
|
options = $.extend({
|
||||||
animationSpeed: 150,
|
animationSpeed: 150,
|
||||||
GPU: true,
|
GPU: true,
|
||||||
doRender: true,
|
doRender: true,
|
||||||
@ -293,19 +291,15 @@
|
|||||||
_instance = _instance ? _instance.add(this) : this;
|
_instance = _instance ? _instance.add(this) : this;
|
||||||
_instance.colorPicker = _colorPicker ||
|
_instance.colorPicker = _colorPicker ||
|
||||||
(_colorPicker = new ColorPicker(options));
|
(_colorPicker = new ColorPicker(options));
|
||||||
_selector += (_selector ? ', ' : '') + this.selector;
|
|
||||||
|
|
||||||
$(options.body).off('.a').
|
$(options.body).off('.a').
|
||||||
on(_pointerdown, function(e) {
|
on(_pointerdown, function(e) {
|
||||||
var $target = $(e.target);
|
!_instance.add(_$UI).find(e.target).
|
||||||
|
add(_instance.filter(e.target))[0] && toggle();
|
||||||
|
});
|
||||||
|
|
||||||
if ($.inArray($target.closest(_selector)[0], _instance) === -1 &&
|
this.on('focusin.a click.a', toggle).
|
||||||
!$target.closest(_$UI).length) {
|
on('change.a', function() {
|
||||||
_instance.colorPicker.$trigger && toggle();
|
|
||||||
}
|
|
||||||
}).
|
|
||||||
on('focusin.a click.a', _selector, toggle).
|
|
||||||
on('change.a', _selector, function() {
|
|
||||||
_color.setColor(this.value || '#FFF');
|
_color.setColor(this.value || '#FFF');
|
||||||
_instance.colorPicker.render(true);
|
_instance.colorPicker.render(true);
|
||||||
});
|
});
|
||||||
@ -328,10 +322,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$.fn.colorPicker.destroy = function() {
|
$.fn.colorPicker.destroy = function() {
|
||||||
|
_colorPicker.$UI.off('.a');
|
||||||
|
this.off('.a');
|
||||||
$(_colorPicker.color.options.body).off('.a');
|
$(_colorPicker.color.options.body).off('.a');
|
||||||
_colorPicker.toggle(false);
|
_colorPicker.toggle(false);
|
||||||
_instance = null;
|
_instance = null;
|
||||||
_selector = '';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return $;
|
return $;
|
||||||
|
File diff suppressed because one or more lines are too long
4
jqColorPicker.min.js
vendored
4
jqColorPicker.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user