mirror of
https://github.com/PitPik/colorPicker.git
synced 2025-09-07 08:12:36 -06:00
Fixes loading in header and right mouse button
This commit is contained in:
parent
91b3f2d618
commit
557f47285a
6
color.all.min.js
vendored
6
color.all.min.js
vendored
File diff suppressed because one or more lines are too long
@ -13,8 +13,8 @@
|
||||
// _bgsPng: ..., // some more icon sprite images
|
||||
// }
|
||||
_devMode = !_data, // if no _data we assume that colorPicker.data.js is missing (for development)
|
||||
_isIE = document.createStyleSheet !== undefined && document.getElementById || !!window.MSInputMethodContext,
|
||||
_doesOpacity = typeof document.body.style.opacity !== 'undefined',
|
||||
_isIE = false,
|
||||
_doesOpacity = false,
|
||||
// _isIE8 = _isIE && document.querySelectorAll,
|
||||
|
||||
_valueRanges = {}, // will be assigned in initInstance() by Colors instance
|
||||
@ -213,6 +213,8 @@
|
||||
for (var option in options) { // deep copy ??
|
||||
THIS.options[option] = options[option];
|
||||
}
|
||||
_isIE = document.createStyleSheet !== undefined && document.getElementById || !!window.MSInputMethodContext;
|
||||
_doesOpacity = typeof document.body.style.opacity !== 'undefined';
|
||||
_colorInstance = new Colors(THIS.options);
|
||||
// We transfer the responsibility to the instance of Color (to save space and memory)
|
||||
delete THIS.options;
|
||||
@ -438,9 +440,10 @@
|
||||
onOffEvent(_nodes.colorPicker, 'mousedown', function(e) {
|
||||
var event = e || window.event,
|
||||
page = getPageXY(event),
|
||||
target = event.target || event.srcElement,
|
||||
target = (event.button || event.which) < 2 ?
|
||||
(event.target || event.srcElement) : {},
|
||||
className = target.className;
|
||||
|
||||
|
||||
focusInstance(THIS);
|
||||
_mainTarget = target;
|
||||
stopChange(undefined, 'resetEventListener');
|
||||
|
File diff suppressed because one or more lines are too long
31
colors.js
31
colors.js
@ -17,7 +17,7 @@
|
||||
_colors = {},
|
||||
|
||||
// http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html for more
|
||||
XYZMatrix = { // Observer = 2° (CIE 1931), Illuminant = D65
|
||||
XYZMatrix = { // Observer = 2° (CIE 1931), Illuminant = D65
|
||||
X: [ 0.4124564, 0.3575761, 0.1804375],
|
||||
Y: [ 0.2126729, 0.7151522, 0.0721750],
|
||||
Z: [ 0.0193339, 0.1191920, 0.9503041],
|
||||
@ -28,8 +28,8 @@
|
||||
grey = {r: 0.298954, g: 0.586434, b: 0.114612}, // CIE-XYZ 1931
|
||||
luminance = {r: 0.2126, g: 0.7152, b: 0.0722}, // W3C 2.0
|
||||
|
||||
_math = Math,
|
||||
_parseint = parseInt,
|
||||
_math = window.Math,
|
||||
_parseint = window.parseInt,
|
||||
|
||||
Colors = window.Colors = function(options) {
|
||||
this.colors = {RND: {}};
|
||||
@ -64,7 +64,7 @@
|
||||
};
|
||||
customBG = _options.customBG;
|
||||
_options.customBG = (typeof customBG === 'string') ? ColorConverter.txt2color(customBG).rgb : customBG;
|
||||
_colors = setColor(THIS.colors, _options.color, undefined, true); // THIS.colors = _colors =
|
||||
_colors = setColor(THIS.colors, _options.color, undefined, true); // THIS.colors = _colors =
|
||||
},
|
||||
focusInstance = function(THIS) {
|
||||
if (_instance !== THIS) {
|
||||
@ -117,7 +117,7 @@
|
||||
var convert = ColorConverter,
|
||||
ranges = _valueRanges,
|
||||
types = type.split('2'),
|
||||
fromType = types[0],
|
||||
fromType = types[0],
|
||||
toType = types[1],
|
||||
test = /(?:RG|HS|CM|LA)/,
|
||||
normalizeFrom = test.test(fromType),
|
||||
@ -132,7 +132,7 @@
|
||||
_math.round(color[n] * (Lab || ranges[type][n][1])) :
|
||||
color[n] / (Lab || ranges[type][n][1]);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
@ -144,9 +144,9 @@
|
||||
}
|
||||
color = fromType === toType ? color : ( // same type; returns same/normalized version
|
||||
convert[fromType + '2' + toType] ? convert[fromType + '2' + toType](color, true) : // existing converter
|
||||
toType === 'HEX' ? convert.RGB2HEX(type === 'RGB2HEX' ? color : normalize(fromType === 'rgb' ? color :
|
||||
toType === 'HEX' ? convert.RGB2HEX(type === 'RGB2HEX' ? color : normalize(fromType === 'rgb' ? color :
|
||||
convert[fromType + '2rgb'](color, true), 'rgb', true)) :
|
||||
convert['rgb2' + toType](convert[fromType + '2rgb'](color, true), true) // not in ColorConverter
|
||||
convert['rgb2' + toType](convert[fromType + '2rgb'](color, true), true) // not in ColorConverter
|
||||
);
|
||||
if (normalizeTo) { // from abc to ABC
|
||||
color = normalize(color, toType, true);
|
||||
@ -167,7 +167,8 @@
|
||||
alpha = alpha !== undefined ? alpha : color.alpha;
|
||||
} else if (color) {
|
||||
for (var n in color) {
|
||||
colors[type][n] = limitValue(color[n] / _valueRanges[type][n][1], 0 , 1);
|
||||
colors[type][n] = type === 'Lab' ? color[n] :
|
||||
limitValue(color[n] / _valueRanges[type][n][1], 0 , 1);
|
||||
}
|
||||
}
|
||||
if (alpha !== undefined) {
|
||||
@ -256,7 +257,7 @@
|
||||
alpha = colors.alpha,
|
||||
luminance = 'luminance',
|
||||
background = colors.background,
|
||||
rgbaMixBlack, rgbaMixWhite, rgbaMixCustom,
|
||||
rgbaMixBlack, rgbaMixWhite, rgbaMixCustom,
|
||||
rgbaMixBG, rgbaMixBGMixBlack, rgbaMixBGMixWhite, rgbaMixBGMixCustom,
|
||||
_mixColors = mixColors,
|
||||
_getLuminance = getLuminance,
|
||||
@ -487,10 +488,10 @@
|
||||
|
||||
// ------------------------ CMYK ------------------------ //
|
||||
// Quote from Wikipedia:
|
||||
// "Since RGB and CMYK spaces are both device-dependent spaces, there is no
|
||||
// simple or general conversion formula that converts between them.
|
||||
// Conversions are generally done through color management systems, using
|
||||
// color profiles that describe the spaces being converted. Nevertheless, the
|
||||
// "Since RGB and CMYK spaces are both device-dependent spaces, there is no
|
||||
// simple or general conversion formula that converts between them.
|
||||
// Conversions are generally done through color management systems, using
|
||||
// color profiles that describe the spaces being converted. Nevertheless, the
|
||||
// conversions cannot be exact, since these spaces have very different gamuts."
|
||||
// Translation: the following are just simple RGB to CMY(K) and visa versa conversion functions.
|
||||
|
||||
@ -707,4 +708,4 @@
|
||||
// return Math.max(min, Math.min(max, value)); // faster??
|
||||
return (value > max ? max : value < min ? min : value);
|
||||
}
|
||||
})(window);
|
||||
})(window);
|
||||
|
2
index.js
2
index.js
@ -163,7 +163,7 @@
|
||||
type = child.id.substr(0, len),
|
||||
mode = child.id.charAt(len).toLowerCase();
|
||||
|
||||
if (child.id) child.children[0].style.width = (color.RND[type][mode] / max[type][mode] * 100) + '%';
|
||||
child.children[0].style.width = (color.RND[type][mode] / max[type][mode] * 100) + '%';
|
||||
}
|
||||
};
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user