mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 17:10:45 +02:00
[Case 4315] ESLint Pass; Simple errors addressed (details below).
Initial ESLint Pass on colpick.js. Issue Count reduced from 185 to 100 via: eslint -c .eslintrc.js scripts/system/html/js/colpick.js --fix Changes Committed: modified: scripts/system/html/js/colpick.js
This commit is contained in:
parent
6c5961820c
commit
35bf8f1d01
1 changed files with 85 additions and 64 deletions
|
@ -250,7 +250,9 @@ For usage and examples: colpick.com/plugin
|
|||
}
|
||||
// Hide when user clicks outside
|
||||
$('html').mousedown({cal:cal}, hide);
|
||||
cal.mousedown(function(ev){ev.stopPropagation();})
|
||||
cal.mousedown(function(ev){
|
||||
ev.stopPropagation();
|
||||
});
|
||||
},
|
||||
hide = function (ev) {
|
||||
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
||||
|
@ -310,7 +312,7 @@ For usage and examples: colpick.com/plugin
|
|||
init: function (opt) {
|
||||
opt = $.extend({}, defaults, opt||{});
|
||||
// Set color
|
||||
if (typeof opt.color == 'string') {
|
||||
if (typeof opt.color === 'string') {
|
||||
opt.color = hexToHsb(opt.color);
|
||||
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
||||
opt.color = rgbToHsb(opt.color);
|
||||
|
@ -413,7 +415,7 @@ For usage and examples: colpick.com/plugin
|
|||
// Sets a color as new and current (default)
|
||||
setColor: function(col, setCurrent) {
|
||||
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
||||
if (typeof col == 'string') {
|
||||
if (typeof col === 'string') {
|
||||
col = hexToHsb(col);
|
||||
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
||||
col = rgbToHsb(col);
|
||||
|
@ -459,12 +461,20 @@ For usage and examples: colpick.com/plugin
|
|||
hsb.b = max;
|
||||
hsb.s = max != 0 ? 255 * delta / max : 0;
|
||||
if (hsb.s != 0) {
|
||||
if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta;
|
||||
else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
||||
else hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
||||
} else hsb.h = -1;
|
||||
if (rgb.r == max) {
|
||||
hsb.h = (rgb.g - rgb.b) / delta;
|
||||
} else if (rgb.g == max) {
|
||||
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
||||
} else {
|
||||
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
||||
}
|
||||
} else {
|
||||
hsb.h = -1;
|
||||
}
|
||||
hsb.h *= 60;
|
||||
if (hsb.h < 0) hsb.h += 360;
|
||||
if (hsb.h < 0) {
|
||||
hsb.h += 360;
|
||||
}
|
||||
hsb.s *= 100/255;
|
||||
hsb.b *= 100/255;
|
||||
return hsb;
|
||||
|
@ -480,14 +490,24 @@ For usage and examples: colpick.com/plugin
|
|||
var t1 = v;
|
||||
var t2 = (255-s)*v/255;
|
||||
var t3 = (t1-t2)*(h%60)/60;
|
||||
if(h==360) h = 0;
|
||||
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
||||
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
||||
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
||||
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
||||
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
||||
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
||||
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
||||
if (h==360) {
|
||||
h = 0;
|
||||
}
|
||||
if (h<60) {
|
||||
rgb.r=t1; rgb.b=t2; rgb.g=t2+t3;
|
||||
} else if (h<120) {
|
||||
rgb.g=t1; rgb.b=t2; rgb.r=t1-t3;
|
||||
} else if (h<180) {
|
||||
rgb.g=t1; rgb.r=t2; rgb.b=t2+t3;
|
||||
} else if (h<240) {
|
||||
rgb.b=t1; rgb.r=t2; rgb.g=t1-t3;
|
||||
} else if (h<300) {
|
||||
rgb.b=t1; rgb.g=t2; rgb.r=t2+t3;
|
||||
} else if (h<360) {
|
||||
rgb.r=t1; rgb.g=t2; rgb.b=t1-t3;
|
||||
} else {
|
||||
rgb.r=0; rgb.g=0; rgb.b=0;
|
||||
}
|
||||
}
|
||||
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
|
||||
};
|
||||
|
@ -524,3 +544,4 @@ For usage and examples: colpick.com/plugin
|
|||
}
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
|
|
Loading…
Reference in a new issue