AMD / CommonJS / bower

pull/53/head 1.0.1
peterd 8 years ago
parent 046c0c5619
commit 10ee8931e0

@ -24,21 +24,14 @@ Supported color spaces are: rgb, hsv(b), hsl, HEX
</script> </script>
``` ```
## AMD wrapper ## AMD / CommonJS wrapper
tinyColorPicker now supports AMD (thanks to [Munawwar](https://github.com/Munawwar)). Both files colors.js and jqColorPicker.js return their constructors so that it is easy to wrap them inside colors-amd-wrapper.js and jqColorPicker-amd-wrapper.js. So, if you want to use require.js or other module loaders just follow the instructions inside those 2 files. (Maybe someone of you wants to write a grunt task to automate this ;o) tinyColorPicker now supports AMD and CommonJS import (thanks to [Munawwar](https://github.com/Munawwar)).
If you don't want to use AMD but would like to store the constructor `Colors` on a different name space you can change this in color.js where you find: ## bower support
```javascript tinyColorPicker can be received by bower:
window.Colors = (function...
// change this to what you want
window.myNameSpace.ColorTool = (function...
```
If you do so you also need to change this reference in jqColorPicker.js at the very end:
```javascript ```javascript
})(window, jQuery, Colors); bower install tinyColorPicker
// changes to
})(window, jQuery, myNameSpace.ColorTool);
``` ```
##jqColorPicker.js ##jqColorPicker.js

@ -3,7 +3,7 @@
"description": "Tiny jQuery color picker for mobile and desktop with alpha channel", "description": "Tiny jQuery color picker for mobile and desktop with alpha channel",
"main": "jqColorPicker.min.js", "main": "jqColorPicker.min.js",
"authors": [ "authors": [
"peterd <peter@dematte.at>" "Peter Dematté <peter@dematte.at>"
], ],
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
@ -18,7 +18,9 @@
], ],
"homepage": "https://github.com/PitPik/tinyColorPicker", "homepage": "https://github.com/PitPik/tinyColorPicker",
"moduleType": [ "moduleType": [
"globals" "amd",
"globals",
"node"
], ],
"ignore": [ "ignore": [
"**/.*", "**/.*",

@ -1,4 +1,14 @@
window.Colors = (function(window, undefined){ (function (root, factory) {
if (typeof exports === 'object') {
module.exports = factory(root);
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return factory(root);
});
} else {
root.Colors = factory(root);
}
}(this, function(window, undefined) {
"use strict" "use strict"
var _valueRanges = { var _valueRanges = {
@ -417,4 +427,4 @@ window.Colors = (function(window, undefined){
} }
return Colors; return Colors;
})(window); }));

@ -1,331 +1,341 @@
(function(window, $, Colors, undefined){ (function (root, factory) {
'use strict'; if (typeof exports === 'object') {
module.exports = factory(root, require('jquery'), require('colors'));
var $document = $(document), } else if (typeof define === 'function' && define.amd) {
_instance = $(), define(['jquery', 'colors'], function (jQuery, Colors) {
_colorPicker, return factory(root, jQuery, Colors);
_color, });
_options, } else {
factory(root, root.jQuery, root.Colors);
_$trigger, }
_$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor, }(this, function(window, $, Colors, undefined){
'use strict';
_pointermove = 'touchmove.a mousemove.a pointermove.a',
_pointerdown = 'touchstart.a mousedown.a pointerdown.a', var $document = $(document),
_pointerup = 'touchend.a mouseup.a pointerup.a', _instance = $(),
_GPU = false, _colorPicker,
_round = Math.round, _color,
_animate = window.requestAnimationFrame || _options,
window.webkitRequestAnimationFrame || function(cb){cb()},
_html = '<div class="cp-color-picker"><div class="cp-z-slider"><div c' + _$trigger,
'lass="cp-z-cursor"></div></div><div class="cp-xy-slider"><div cl' + _$UI, _$xy_slider, _$xy_cursor, _$z_cursor , _$alpha , _$alpha_cursor,
'ass="cp-white"></div><div class="cp-xy-cursor"></div></div><div ' +
'class="cp-alpha"><div class="cp-alpha-cursor"></div></div></div>', _pointermove = 'touchmove.a mousemove.a pointermove.a',
// 'grunt-contrib-uglify' puts all this back to one single string... _pointerdown = 'touchstart.a mousedown.a pointerdown.a',
_css = '.cp-color-picker{position:absolute;overflow:hidden;padding:6p' + _pointerup = 'touchend.a mouseup.a pointerup.a',
'x 6px 0;background-color:#444;color:#bbb;font-family:Arial,Helve' + _GPU = false,
'tica,sans-serif;font-size:12px;font-weight:400;cursor:default;bo' + _round = Math.round,
'rder-radius:5px}.cp-color-picker>div{position:relative;overflow:' + _animate = window.requestAnimationFrame ||
'hidden}.cp-xy-slider{float:left;height:128px;width:128px;margin-' + window.webkitRequestAnimationFrame || function(cb){cb()},
'bottom:6px;background:linear-gradient(to right,#FFF,rgba(255,255' + _html = '<div class="cp-color-picker"><div class="cp-z-slider"><div c' +
',255,0))}.cp-white{height:100%;width:100%;background:linear-grad' + 'lass="cp-z-cursor"></div></div><div class="cp-xy-slider"><div cl' +
'ient(rgba(0,0,0,0),#000)}.cp-xy-cursor{position:absolute;top:0;w' + 'ass="cp-white"></div><div class="cp-xy-cursor"></div></div><div ' +
'idth:10px;height:10px;margin:-5px;border:1px solid #fff;border-r' + 'class="cp-alpha"><div class="cp-alpha-cursor"></div></div></div>',
'adius:100%;box-sizing:border-box}.cp-z-slider{float:right;margin' + // 'grunt-contrib-uglify' puts all this back to one single string...
'-left:6px;height:128px;width:20px;background:linear-gradient(red' + _css = '.cp-color-picker{position:absolute;overflow:hidden;padding:6p' +
' 0,#f0f 17%,#00f 33%,#0ff 50%,#0f0 67%,#ff0 83%,red 100%)}.cp-z-' + 'x 6px 0;background-color:#444;color:#bbb;font-family:Arial,Helve' +
'cursor{position:absolute;margin-top:-4px;width:100%;border:4px s' + 'tica,sans-serif;font-size:12px;font-weight:400;cursor:default;bo' +
'olid #fff;border-color:transparent #fff;box-sizing:border-box}.c' + 'rder-radius:5px}.cp-color-picker>div{position:relative;overflow:' +
'p-alpha{clear:both;width:100%;height:16px;margin:6px 0;backgroun' + 'hidden}.cp-xy-slider{float:left;height:128px;width:128px;margin-' +
'd:linear-gradient(to right,#444,rgba(0,0,0,0))}.cp-alpha-cursor{' + 'bottom:6px;background:linear-gradient(to right,#FFF,rgba(255,255' +
'position:absolute;margin-left:-4px;height:100%;border:4px solid ' + ',255,0))}.cp-white{height:100%;width:100%;background:linear-grad' +
'#fff;border-color:#fff transparent;box-sizing:border-box}', 'ient(rgba(0,0,0,0),#000)}.cp-xy-cursor{position:absolute;top:0;w' +
'idth:10px;height:10px;margin:-5px;border:1px solid #fff;border-r' +
ColorPicker = function(options) { 'adius:100%;box-sizing:border-box}.cp-z-slider{float:right;margin' +
_color = this.color = new Colors(options); '-left:6px;height:128px;width:20px;background:linear-gradient(red' +
_options = _color.options; ' 0,#f0f 17%,#00f 33%,#0ff 50%,#0f0 67%,#ff0 83%,red 100%)}.cp-z-' +
_colorPicker = this; 'cursor{position:absolute;margin-top:-4px;width:100%;border:4px s' +
}; 'olid #fff;border-color:transparent #fff;box-sizing:border-box}.c' +
'p-alpha{clear:both;width:100%;height:16px;margin:6px 0;backgroun' +
ColorPicker.prototype = { 'd:linear-gradient(to right,#444,rgba(0,0,0,0))}.cp-alpha-cursor{' +
render: preRender, 'position:absolute;margin-left:-4px;height:100%;border:4px solid ' +
toggle: toggle '#fff;border-color:#fff transparent;box-sizing:border-box}',
};
ColorPicker = function(options) {
function extractValue(elm) { _color = this.color = new Colors(options);
return elm.value || elm.getAttribute('value') || _options = _color.options;
$(elm).css('background-color') || '#fff'; _colorPicker = this;
} };
function resolveEventType(event) { ColorPicker.prototype = {
event = event.originalEvent && event.originalEvent.touches ? render: preRender,
event.originalEvent.touches[0] : event; toggle: toggle
};
return event.originalEvent ? event.originalEvent : event;
} function extractValue(elm) {
return elm.value || elm.getAttribute('value') ||
function findElement($elm) { $(elm).css('background-color') || '#fff';
return $($elm.find(_options.doRender)[0] || $elm[0]); }
}
function resolveEventType(event) {
function toggle(event) { event = event.originalEvent && event.originalEvent.touches ?
var $this = $(this), event.originalEvent.touches[0] : event;
position = $this.offset(),
$window = $(window), return event.originalEvent ? event.originalEvent : event;
gap = _options.gap; }
if (event) { function findElement($elm) {
_$trigger = findElement($this); return $($elm.find(_options.doRender)[0] || $elm[0]);
_$trigger._colorMode = _$trigger.data('colorMode'); }
_colorPicker.$trigger = $this; function toggle(event) {
var $this = $(this),
(_$UI || build()).css({ position = $this.offset(),
// 'width': _$UI[0]._width, $window = $(window),
'left': (_$UI[0]._left = position.left) - gap = _options.gap;
((_$UI[0]._left = _$UI[0]._left + _$UI[0]._width -
($window.scrollLeft() + $window.width())) + gap > 0 ? if (event) {
_$UI[0]._left + gap : 0), _$trigger = findElement($this);
'top': (_$UI[0]._top = position.top + $this.outerHeight()) - _$trigger._colorMode = _$trigger.data('colorMode');
((_$UI[0]._top = _$UI[0]._top + _$UI[0]._height -
($window.scrollTop() + $window.height())) + gap > 0 ? _colorPicker.$trigger = $this;
_$UI[0]._top + gap : 0)
}).show(_options.animationSpeed, function() { (_$UI || build()).css({
if (event === true) { // 'width': _$UI[0]._width,
return; 'left': (_$UI[0]._left = position.left) -
} ((_$UI[0]._left = _$UI[0]._left + _$UI[0]._width -
_$alpha._width = _$alpha.width(); ($window.scrollLeft() + $window.width())) + gap > 0 ?
_$xy_slider._width = _$xy_slider.width(); _$UI[0]._left + gap : 0),
_$xy_slider._height = _$xy_slider.height(); 'top': (_$UI[0]._top = position.top + $this.outerHeight()) -
_color.setColor(extractValue(_$trigger[0])); ((_$UI[0]._top = _$UI[0]._top + _$UI[0]._height -
($window.scrollTop() + $window.height())) + gap > 0 ?
preRender(true); _$UI[0]._top + gap : 0)
}); }).show(_options.animationSpeed, function() {
} else { if (event === true) {
$(_$UI).hide(_options.animationSpeed, function() { return;
preRender(false); }
_colorPicker.$trigger = null; _$alpha._width = _$alpha.width();
}); _$xy_slider._width = _$xy_slider.width();
} _$xy_slider._height = _$xy_slider.height();
} _color.setColor(extractValue(_$trigger[0]));
function build() { preRender(true);
$('head').append('<style type="text/css">' + });
(_options.css || _css) + (_options.cssAddon || '') + '</style>'); } else {
$(_$UI).hide(_options.animationSpeed, function() {
return _colorPicker.$UI = _$UI = preRender(false);
$(_html).css({'margin': _options.margin}) _colorPicker.$trigger = null;
.appendTo('body') });
.show(0, function() { }
var $this = $(this); }
_GPU = _options.GPU && $this.css('perspective') !== undefined; function build() {
_$xy_slider = $('.cp-xy-slider', this); $('head').append('<style type="text/css">' +
_$xy_cursor = $('.cp-xy-cursor', this); (_options.css || _css) + (_options.cssAddon || '') + '</style>');
_$z_cursor = $('.cp-z-cursor', this);
_$alpha = $('.cp-alpha', this).toggle(!!_options.opacity); return _colorPicker.$UI = _$UI =
_$alpha_cursor = $('.cp-alpha-cursor', this); $(_html).css({'margin': _options.margin})
_options.buildCallback.call(_colorPicker, $this); .appendTo('body')
$this.prepend('<div>').children().eq(0).css('width', .show(0, function() {
$this.children().eq(0).width() // stabilizer var $this = $(this);
);
this._width = this.offsetWidth; _GPU = _options.GPU && $this.css('perspective') !== undefined;
this._height = this.offsetHeight; _$xy_slider = $('.cp-xy-slider', this);
}).hide() _$xy_cursor = $('.cp-xy-cursor', this);
.on(_pointerdown, _$z_cursor = $('.cp-z-cursor', this);
'.cp-xy-slider,.cp-z-slider,.cp-alpha', pointerdown); _$alpha = $('.cp-alpha', this).toggle(!!_options.opacity);
} _$alpha_cursor = $('.cp-alpha-cursor', this);
_options.buildCallback.call(_colorPicker, $this);
function pointerdown(e) { $this.prepend('<div>').children().eq(0).css('width',
var action = this.className $this.children().eq(0).width() // stabilizer
.replace(/cp-(.*?)(?:\s*|$)/, '$1').replace('-', '_'); );
this._width = this.offsetWidth;
if ((e.button || e.which) > 1) return; this._height = this.offsetHeight;
}).hide()
e.preventDefault && e.preventDefault(); .on(_pointerdown,
e.returnValue = false; '.cp-xy-slider,.cp-z-slider,.cp-alpha', pointerdown);
}
_$trigger._offset = $(this).offset();
function pointerdown(e) {
(action = action === 'xy_slider' ? xy_slider : var action = this.className
action === 'z_slider' ? z_slider : alpha)(e); .replace(/cp-(.*?)(?:\s*|$)/, '$1').replace('-', '_');
preRender();
if ((e.button || e.which) > 1) return;
$document.on(_pointerup, function(e) {
$document.off('.a'); e.preventDefault && e.preventDefault();
}).on(_pointermove, function(e) { e.returnValue = false;
action(e);
preRender(); _$trigger._offset = $(this).offset();
});
} (action = action === 'xy_slider' ? xy_slider :
action === 'z_slider' ? z_slider : alpha)(e);
function xy_slider(event) { preRender();
var e = resolveEventType(event),
x = e.pageX - _$trigger._offset.left, $document.on(_pointerup, function(e) {
y = e.pageY - _$trigger._offset.top; $document.off('.a');
}).on(_pointermove, function(e) {
_color.setColor({ action(e);
s: x / _$xy_slider._width * 100, preRender();
v: 100 - (y / _$xy_slider._height * 100) });
}, 'hsv'); }
}
function xy_slider(event) {
function z_slider(event) { var e = resolveEventType(event),
var z = resolveEventType(event).pageY - _$trigger._offset.top; x = e.pageX - _$trigger._offset.left,
y = e.pageY - _$trigger._offset.top;
_color.setColor({h: 360 - (z / _$xy_slider._height * 360)}, 'hsv');
} _color.setColor({
s: x / _$xy_slider._width * 100,
function alpha(event) { v: 100 - (y / _$xy_slider._height * 100)
var x = resolveEventType(event).pageX - _$trigger._offset.left, }, 'hsv');
alpha = x / _$alpha._width; }
_color.setColor({}, 'rgb', alpha); function z_slider(event) {
} var z = resolveEventType(event).pageY - _$trigger._offset.top;
function preRender(toggled) { _color.setColor({h: 360 - (z / _$xy_slider._height * 360)}, 'hsv');
var colors = _color.colors, }
hueRGB = colors.hueRGB,
RGB = colors.RND.rgb, function alpha(event) {
HSL = colors.RND.hsl, var x = resolveEventType(event).pageX - _$trigger._offset.left,
dark = '#222', alpha = x / _$alpha._width;
light = '#ddd',
colorMode = _$trigger._colorMode, _color.setColor({}, 'rgb', alpha);
isAlpha = colors.alpha !== 1, }
alpha = _round(colors.alpha * 100) / 100,
RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b, function preRender(toggled) {
text = (colorMode === 'HEX' && !isAlpha ? '#' + colors.HEX : var colors = _color.colors,
colorMode === 'rgb' || (colorMode === 'HEX' && isAlpha) ? hueRGB = colors.hueRGB,
(!isAlpha ? 'rgb(' + RGBInnerText + ')' : RGB = colors.RND.rgb,
'rgba(' + RGBInnerText + ', ' + alpha + ')') : HSL = colors.RND.hsl,
('hsl' + (isAlpha ? 'a(' : '(') + HSL.h + ', ' + HSL.s + '%, ' + dark = '#222',
HSL.l + '%' + (isAlpha ? ', ' + alpha : '') + ')')), light = '#ddd',
HUEContrast = colors.HUELuminance > 0.22 ? dark : light, colorMode = _$trigger._colorMode,
alphaContrast = colors.rgbaMixBlack.luminance > 0.22 ? dark : light, isAlpha = colors.alpha !== 1,
h = (1 - colors.hsv.h) * _$xy_slider._height, alpha = _round(colors.alpha * 100) / 100,
s = colors.hsv.s * _$xy_slider._width, RGBInnerText = RGB.r + ', ' + RGB.g + ', ' + RGB.b,
v = (1 - colors.hsv.v) * _$xy_slider._height, text = (colorMode === 'HEX' && !isAlpha ? '#' + colors.HEX :
a = alpha * _$alpha._width, colorMode === 'rgb' || (colorMode === 'HEX' && isAlpha) ?
translate3d = _GPU ? 'translate3d' : '', (!isAlpha ? 'rgb(' + RGBInnerText + ')' :
triggerValue = _$trigger[0].value, 'rgba(' + RGBInnerText + ', ' + alpha + ')') :
hasNoValue = _$trigger[0].hasAttribute('value') && // question this ('hsl' + (isAlpha ? 'a(' : '(') + HSL.h + ', ' + HSL.s + '%, ' +
triggerValue === '' && toggled !== undefined; HSL.l + '%' + (isAlpha ? ', ' + alpha : '') + ')')),
HUEContrast = colors.HUELuminance > 0.22 ? dark : light,
_$xy_slider._css = { alphaContrast = colors.rgbaMixBlack.luminance > 0.22 ? dark : light,
backgroundColor: 'rgb(' + h = (1 - colors.hsv.h) * _$xy_slider._height,
hueRGB.r + ',' + hueRGB.g + ',' + hueRGB.b + ')'}; s = colors.hsv.s * _$xy_slider._width,
_$xy_cursor._css = { v = (1 - colors.hsv.v) * _$xy_slider._height,
transform: translate3d + '(' + s + 'px, ' + v + 'px, 0)', a = alpha * _$alpha._width,
left: !_GPU ? s : '', translate3d = _GPU ? 'translate3d' : '',
top: !_GPU ? v : '', triggerValue = _$trigger[0].value,
borderColor : colors.RGBLuminance > 0.22 ? dark : light hasNoValue = _$trigger[0].hasAttribute('value') && // question this
}; triggerValue === '' && toggled !== undefined;
_$z_cursor._css = {
transform: translate3d + '(0, ' + h + 'px, 0)', _$xy_slider._css = {
top: !_GPU ? h : '', backgroundColor: 'rgb(' +
borderColor : 'transparent ' + HUEContrast hueRGB.r + ',' + hueRGB.g + ',' + hueRGB.b + ')'};
}; _$xy_cursor._css = {
_$alpha._css = {backgroundColor: 'rgb(' + RGBInnerText + ')'}; transform: translate3d + '(' + s + 'px, ' + v + 'px, 0)',
_$alpha_cursor._css = { left: !_GPU ? s : '',
transform: translate3d + '(' + a + 'px, 0, 0)', top: !_GPU ? v : '',
left: !_GPU ? a : '', borderColor : colors.RGBLuminance > 0.22 ? dark : light
borderColor : alphaContrast + ' transparent' };
}; _$z_cursor._css = {
_$trigger._css = { transform: translate3d + '(0, ' + h + 'px, 0)',
backgroundColor : hasNoValue ? '' : text, top: !_GPU ? h : '',
color: hasNoValue ? '' : borderColor : 'transparent ' + HUEContrast
colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light };
}; _$alpha._css = {backgroundColor: 'rgb(' + RGBInnerText + ')'};
_$trigger.text = hasNoValue ? '' : triggerValue !== text ? text : ''; _$alpha_cursor._css = {
transform: translate3d + '(' + a + 'px, 0, 0)',
toggled !== undefined ? render(toggled) : _animate(render); left: !_GPU ? a : '',
} borderColor : alphaContrast + ' transparent'
};
// As _animate() is actually requestAnimationFrame(), render() gets called _$trigger._css = {
// decoupled from any pointer action (whenever the browser decides to do backgroundColor : hasNoValue ? '' : text,
// so) as an event. preRender() is coupled to toggle() and all pointermove color: hasNoValue ? '' :
// actions; that's where all the calculations happen. render() can now be colors.rgbaMixBGMixCustom.luminance > 0.22 ? dark : light
// called without extra calculations which results in faster rendering. };
function render(toggled) { _$trigger.text = hasNoValue ? '' : triggerValue !== text ? text : '';
_$xy_slider.css(_$xy_slider._css);
_$xy_cursor.css(_$xy_cursor._css); toggled !== undefined ? render(toggled) : _animate(render);
_$z_cursor.css(_$z_cursor._css); }
_$alpha.css(_$alpha._css);
_$alpha_cursor.css(_$alpha_cursor._css); // As _animate() is actually requestAnimationFrame(), render() gets called
// decoupled from any pointer action (whenever the browser decides to do
_options.doRender && _$trigger.css(_$trigger._css); // so) as an event. preRender() is coupled to toggle() and all pointermove
_$trigger.text && _$trigger.val(_$trigger.text); // actions; that's where all the calculations happen. render() can now be
// called without extra calculations which results in faster rendering.
_options.renderCallback.call( function render(toggled) {
_colorPicker, _$xy_slider.css(_$xy_slider._css);
_$trigger, _$xy_cursor.css(_$xy_cursor._css);
typeof toggled === 'boolean' ? toggled : undefined _$z_cursor.css(_$z_cursor._css);
); _$alpha.css(_$alpha._css);
} _$alpha_cursor.css(_$alpha_cursor._css);
$.fn.colorPicker = function(options) { _options.doRender && _$trigger.css(_$trigger._css);
var noop = function(){}; _$trigger.text && _$trigger.val(_$trigger.text);
options = $.extend({ _options.renderCallback.call(
animationSpeed: 150, _colorPicker,
GPU: true, _$trigger,
doRender: true, typeof toggled === 'boolean' ? toggled : undefined
customBG: '#FFF', );
opacity: true, }
renderCallback: noop,
buildCallback: noop, $.fn.colorPicker = function(options) {
body: document.body, var noop = function(){};
scrollResize: true,
gap: 4 options = $.extend({
// css: '', animationSpeed: 150,
// cssAddon: '', GPU: true,
// margin: '', doRender: true,
// preventFocus: false customBG: '#FFF',
}, options); opacity: true,
renderCallback: noop,
!_colorPicker && options.scrollResize && $(window) buildCallback: noop,
.on('resize.a scroll.a', function() { body: document.body,
if (_colorPicker.$trigger) { scrollResize: true,
_colorPicker.toggle.call(_colorPicker.$trigger[0], true); gap: 4
} // css: '',
}); // cssAddon: '',
_instance = _instance.add(this); // margin: '',
this.colorPicker = _instance.colorPicker = // preventFocus: false
_colorPicker || new ColorPicker(options); }, options);
$(options.body).off('.a').on(_pointerdown, function(e) { !_colorPicker && options.scrollResize && $(window)
!_instance.add(_$UI).find(e.target) .on('resize.a scroll.a', function() {
.add(_instance.filter(e.target))[0] && toggle(); if (_colorPicker.$trigger) {
}); _colorPicker.toggle.call(_colorPicker.$trigger[0], true);
}
return this.on('focusin.a click.a', toggle) });
.on('change.a', function() { _instance = _instance.add(this);
_color.setColor(this.value || '#FFF'); this.colorPicker = _instance.colorPicker =
_instance.colorPicker.render(true); _colorPicker || new ColorPicker(options);
})
.each(function() { $(options.body).off('.a').on(_pointerdown, function(e) {
var value = extractValue(this), !_instance.add(_$UI).find(e.target)
mode = value.split('('), .add(_instance.filter(e.target))[0] && toggle();
$elm = findElement($(this)); });
$elm.data('colorMode', mode[1] ? mode[0].substr(0, 3) : 'HEX') return this.on('focusin.a click.a', toggle)
.attr('readonly', _options.preventFocus); .on('change.a', function() {
options.doRender && _color.setColor(this.value || '#FFF');
$elm.css({'background-color': value, _instance.colorPicker.render(true);
'color': function() { })
return _color.setColor(value) .each(function() {
.rgbaMixBGMixCustom.luminance > 0.22 ? '#222' : '#ddd' var value = extractValue(this),
} mode = value.split('('),
}); $elm = findElement($(this));
});
}; $elm.data('colorMode', mode[1] ? mode[0].substr(0, 3) : 'HEX')
.attr('readonly', _options.preventFocus);
$.fn.colorPicker.destroy = function() { options.doRender &&
_instance.add(_options.body).off('.a'); // saver $elm.css({'background-color': value,
_colorPicker.toggle(false); 'color': function() {
_instance = $(); return _color.setColor(value)
}; .rgbaMixBGMixCustom.luminance > 0.22 ? '#222' : '#ddd'
}
return $; });
});
})(window, jQuery, Colors); };
$.fn.colorPicker.destroy = function() {
_instance.add(_options.body).off('.a'); // saver
_colorPicker.toggle(false);
_instance = $();
};
return $;
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,6 +1,6 @@
{ {
"name": "tinyColorPicker", "name": "tinyColorPicker",
"version": "1.0.0", "version": "1.0.1",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "http://github.com/PitPik/tinyColorPicker.git" "url": "http://github.com/PitPik/tinyColorPicker.git"

Loading…
Cancel
Save