@claviska/jquery-minicolors
Advanced tools
Comparing version 2.3.4 to 2.3.5
{ | ||
"name": "jquery-minicolors", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"homepage": "https://github.com/claviska/jquery-minicolors", | ||
@@ -5,0 +5,0 @@ "authors": [ |
{ | ||
"name": "jquery-minicolors", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"description": "jQuery MiniColors Plugin", | ||
@@ -5,0 +5,0 @@ "homepage": "", |
/* eslint-env node, es6 */ | ||
'use strict'; | ||
const gulp = require('gulp-help')(require('gulp')); | ||
const gulp = require('gulp'); | ||
const del = require('del'); | ||
@@ -10,11 +10,13 @@ const rename = require('gulp-rename'); | ||
// Clean | ||
gulp.task('clean', 'Clean up!', () => { | ||
gulp.task('clean', gulp.series(() => { | ||
return del('jquery.minicolors.min.js'); | ||
}); | ||
})); | ||
// Minify | ||
gulp.task('minify', 'Minify it!', ['clean'], () => { | ||
gulp.task('minify', gulp.series('clean', () => { | ||
return gulp.src('jquery.minicolors.js') | ||
.pipe(uglify({ | ||
preserveComments: 'license' | ||
output: { | ||
comments: require('uglify-save-license') | ||
} | ||
})) | ||
@@ -27,10 +29,10 @@ .on('error', (err) => { | ||
.pipe(gulp.dest(__dirname)); | ||
}); | ||
})); | ||
// Watch for changes | ||
gulp.task('watch', 'Watch for changes!', () => { | ||
gulp.task('watch', gulp.series(() => { | ||
gulp.watch('jquery.minicolors.js', ['minify']); | ||
}); | ||
})); | ||
// Default | ||
gulp.task('default', 'The default task.', ['minify']); | ||
gulp.task('default', gulp.series('minify')); |
@@ -51,87 +51,87 @@ // | ||
switch(method) { | ||
// Destroy the control | ||
case 'destroy': | ||
$(this).each(function() { | ||
destroy($(this)); | ||
}); | ||
return $(this); | ||
// Destroy the control | ||
case 'destroy': | ||
$(this).each(function() { | ||
destroy($(this)); | ||
}); | ||
return $(this); | ||
// Hide the color picker | ||
case 'hide': | ||
hide(); | ||
return $(this); | ||
// Hide the color picker | ||
case 'hide': | ||
hide(); | ||
return $(this); | ||
// Get/set opacity | ||
case 'opacity': | ||
// Getter | ||
if(data === undefined) { | ||
// Get/set opacity | ||
case 'opacity': | ||
// Getter | ||
return $(this).attr('data-opacity'); | ||
} else { | ||
// Setter | ||
$(this).each(function() { | ||
updateFromInput($(this).attr('data-opacity', data)); | ||
}); | ||
} | ||
return $(this); | ||
if(data === undefined) { | ||
// Getter | ||
return $(this).attr('data-opacity'); | ||
} else { | ||
// Setter | ||
$(this).each(function() { | ||
updateFromInput($(this).attr('data-opacity', data)); | ||
}); | ||
} | ||
return $(this); | ||
// Get an RGB(A) object based on the current color/opacity | ||
case 'rgbObject': | ||
return rgbObject($(this), method === 'rgbaObject'); | ||
// Get an RGB(A) object based on the current color/opacity | ||
case 'rgbObject': | ||
return rgbObject($(this), method === 'rgbaObject'); | ||
// Get an RGB(A) string based on the current color/opacity | ||
case 'rgbString': | ||
case 'rgbaString': | ||
return rgbString($(this), method === 'rgbaString'); | ||
// Get an RGB(A) string based on the current color/opacity | ||
case 'rgbString': | ||
case 'rgbaString': | ||
return rgbString($(this), method === 'rgbaString'); | ||
// Get/set settings on the fly | ||
case 'settings': | ||
if(data === undefined) { | ||
return $(this).data('minicolors-settings'); | ||
} else { | ||
// Setter | ||
$(this).each(function() { | ||
var settings = $(this).data('minicolors-settings') || {}; | ||
destroy($(this)); | ||
$(this).minicolors($.extend(true, settings, data)); | ||
}); | ||
} | ||
return $(this); | ||
// Get/set settings on the fly | ||
case 'settings': | ||
if(data === undefined) { | ||
return $(this).data('minicolors-settings'); | ||
} else { | ||
// Setter | ||
$(this).each(function() { | ||
var settings = $(this).data('minicolors-settings') || {}; | ||
destroy($(this)); | ||
$(this).minicolors($.extend(true, settings, data)); | ||
}); | ||
} | ||
return $(this); | ||
// Show the color picker | ||
case 'show': | ||
show($(this).eq(0)); | ||
return $(this); | ||
// Show the color picker | ||
case 'show': | ||
show($(this).eq(0)); | ||
return $(this); | ||
// Get/set the hex color value | ||
case 'value': | ||
if(data === undefined) { | ||
// Getter | ||
return $(this).val(); | ||
} else { | ||
// Setter | ||
// Get/set the hex color value | ||
case 'value': | ||
if(data === undefined) { | ||
// Getter | ||
return $(this).val(); | ||
} else { | ||
// Setter | ||
$(this).each(function() { | ||
if(typeof(data) === 'object' && data !== null) { | ||
if(data.opacity !== undefined) { | ||
$(this).attr('data-opacity', keepWithin(data.opacity, 0, 1)); | ||
} | ||
if(data.color) { | ||
$(this).val(data.color); | ||
} | ||
} else { | ||
$(this).val(data); | ||
} | ||
updateFromInput($(this)); | ||
}); | ||
} | ||
return $(this); | ||
// Initializes the control | ||
default: | ||
if(method !== 'create') data = method; | ||
$(this).each(function() { | ||
if(typeof(data) === 'object' && data !== null) { | ||
if(data.opacity !== undefined) { | ||
$(this).attr('data-opacity', keepWithin(data.opacity, 0, 1)); | ||
} | ||
if(data.color) { | ||
$(this).val(data.color); | ||
} | ||
} else { | ||
$(this).val(data); | ||
} | ||
updateFromInput($(this)); | ||
init($(this), data); | ||
}); | ||
} | ||
return $(this); | ||
return $(this); | ||
// Initializes the control | ||
default: | ||
if(method !== 'create') data = method; | ||
$(this).each(function() { | ||
init($(this), data); | ||
}); | ||
return $(this); | ||
} | ||
@@ -188,13 +188,13 @@ | ||
'<div class="minicolors-panel minicolors-slider-' + settings.control + '">' + | ||
'<div class="minicolors-slider minicolors-sprite">' + | ||
'<div class="minicolors-picker"></div>' + | ||
'</div>' + | ||
'<div class="minicolors-opacity-slider minicolors-sprite">' + | ||
'<div class="minicolors-picker"></div>' + | ||
'</div>' + | ||
'<div class="minicolors-grid minicolors-sprite">' + | ||
'<div class="minicolors-grid-inner"></div>' + | ||
'<div class="minicolors-picker"><div></div></div>' + | ||
'</div>' + | ||
'</div>' | ||
'<div class="minicolors-slider minicolors-sprite">' + | ||
'<div class="minicolors-picker"></div>' + | ||
'</div>' + | ||
'<div class="minicolors-opacity-slider minicolors-sprite">' + | ||
'<div class="minicolors-picker"></div>' + | ||
'</div>' + | ||
'<div class="minicolors-grid minicolors-sprite">' + | ||
'<div class="minicolors-grid-inner"></div>' + | ||
'<div class="minicolors-picker"><div></div></div>' + | ||
'</div>' + | ||
'</div>' | ||
); | ||
@@ -207,3 +207,3 @@ | ||
event.preventDefault(); | ||
input.focus(); | ||
input.trigger('focus'); | ||
}); | ||
@@ -238,3 +238,3 @@ } | ||
backgroundColor: rgb2hex(swatch), | ||
opacity: swatch.a | ||
opacity: String(swatch.a) | ||
}); | ||
@@ -422,73 +422,73 @@ settings.swatches[i] = swatch; | ||
switch(settings.control) { | ||
case 'wheel': | ||
// Calculate hue, saturation, and brightness | ||
x = (grid.width() / 2) - gridPos.x; | ||
y = (grid.height() / 2) - gridPos.y; | ||
r = Math.sqrt(x * x + y * y); | ||
phi = Math.atan2(y, x); | ||
if(phi < 0) phi += Math.PI * 2; | ||
if(r > 75) { | ||
r = 75; | ||
gridPos.x = 69 - (75 * Math.cos(phi)); | ||
gridPos.y = 69 - (75 * Math.sin(phi)); | ||
} | ||
saturation = keepWithin(r / 0.75, 0, 100); | ||
hue = keepWithin(phi * 180 / Math.PI, 0, 360); | ||
brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
case 'wheel': | ||
// Calculate hue, saturation, and brightness | ||
x = (grid.width() / 2) - gridPos.x; | ||
y = (grid.height() / 2) - gridPos.y; | ||
r = Math.sqrt(x * x + y * y); | ||
phi = Math.atan2(y, x); | ||
if(phi < 0) phi += Math.PI * 2; | ||
if(r > 75) { | ||
r = 75; | ||
gridPos.x = 69 - (75 * Math.cos(phi)); | ||
gridPos.y = 69 - (75 * Math.sin(phi)); | ||
} | ||
saturation = keepWithin(r / 0.75, 0, 100); | ||
hue = keepWithin(phi * 180 / Math.PI, 0, 360); | ||
brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 })); | ||
break; | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 })); | ||
break; | ||
case 'saturation': | ||
// Calculate hue, saturation, and brightness | ||
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360); | ||
saturation = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); | ||
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
case 'saturation': | ||
// Calculate hue, saturation, and brightness | ||
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360); | ||
saturation = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); | ||
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100); | ||
break; | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100); | ||
break; | ||
case 'brightness': | ||
// Calculate hue, saturation, and brightness | ||
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360); | ||
saturation = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); | ||
brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
case 'brightness': | ||
// Calculate hue, saturation, and brightness | ||
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360); | ||
saturation = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); | ||
brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (brightness / 100)); | ||
break; | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (brightness / 100)); | ||
break; | ||
default: | ||
// Calculate hue, saturation, and brightness | ||
hue = keepWithin(360 - parseInt(sliderPos.y * (360 / slider.height()), 10), 0, 360); | ||
saturation = keepWithin(Math.floor(gridPos.x * (100 / grid.width())), 0, 100); | ||
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
default: | ||
// Calculate hue, saturation, and brightness | ||
hue = keepWithin(360 - parseInt(sliderPos.y * (360 / slider.height()), 10), 0, 360); | ||
saturation = keepWithin(Math.floor(gridPos.x * (100 / grid.width())), 0, 100); | ||
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100); | ||
hex = hsb2hex({ | ||
h: hue, | ||
s: saturation, | ||
b: brightness | ||
}); | ||
// Update UI | ||
grid.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: 100 })); | ||
break; | ||
// Update UI | ||
grid.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: 100 })); | ||
break; | ||
} | ||
@@ -509,3 +509,3 @@ | ||
backgroundColor: hex, | ||
opacity: opacity | ||
opacity: String(opacity) | ||
}); | ||
@@ -569,3 +569,3 @@ | ||
backgroundColor: value, | ||
opacity: opacity | ||
opacity: String(opacity) | ||
}); | ||
@@ -634,3 +634,3 @@ | ||
input.attr('data-opacity', opacity); | ||
swatch.find('span').css('opacity', opacity); | ||
swatch.find('span').css('opacity', String(opacity)); | ||
@@ -644,3 +644,3 @@ // Set opacity picker position | ||
if(input.val().toLowerCase() === 'transparent') { | ||
swatch.find('span').css('opacity', 0); | ||
swatch.find('span').css('opacity', String(0)); | ||
} | ||
@@ -653,74 +653,74 @@ | ||
switch(settings.control) { | ||
case 'wheel': | ||
// Set grid position | ||
r = keepWithin(Math.ceil(hsb.s * 0.75), 0, grid.height() / 2); | ||
phi = hsb.h * Math.PI / 180; | ||
x = keepWithin(75 - Math.cos(phi) * r, 0, grid.width()); | ||
y = keepWithin(75 - Math.sin(phi) * r, 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
case 'wheel': | ||
// Set grid position | ||
r = keepWithin(Math.ceil(hsb.s * 0.75), 0, grid.height() / 2); | ||
phi = hsb.h * Math.PI / 180; | ||
x = keepWithin(75 - Math.cos(phi) * r, 0, grid.width()); | ||
y = keepWithin(75 - Math.sin(phi) * r, 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
// Set slider position | ||
y = 150 - (hsb.b / (100 / grid.height())); | ||
if(hex === '') y = 0; | ||
sliderPicker.css('top', y + 'px'); | ||
// Set slider position | ||
y = 150 - (hsb.b / (100 / grid.height())); | ||
if(hex === '') y = 0; | ||
sliderPicker.css('top', y + 'px'); | ||
// Update panel color | ||
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 })); | ||
break; | ||
// Update panel color | ||
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 })); | ||
break; | ||
case 'saturation': | ||
// Set grid position | ||
x = keepWithin((5 * hsb.h) / 12, 0, 150); | ||
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
case 'saturation': | ||
// Set grid position | ||
x = keepWithin((5 * hsb.h) / 12, 0, 150); | ||
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
// Set slider position | ||
y = keepWithin(slider.height() - (hsb.s * (slider.height() / 100)), 0, slider.height()); | ||
sliderPicker.css('top', y + 'px'); | ||
// Set slider position | ||
y = keepWithin(slider.height() - (hsb.s * (slider.height() / 100)), 0, slider.height()); | ||
sliderPicker.css('top', y + 'px'); | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: hsb.b })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', hsb.s / 100); | ||
break; | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: hsb.b })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', hsb.s / 100); | ||
break; | ||
case 'brightness': | ||
// Set grid position | ||
x = keepWithin((5 * hsb.h) / 12, 0, 150); | ||
y = keepWithin(grid.height() - Math.ceil(hsb.s / (100 / grid.height())), 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
case 'brightness': | ||
// Set grid position | ||
x = keepWithin((5 * hsb.h) / 12, 0, 150); | ||
y = keepWithin(grid.height() - Math.ceil(hsb.s / (100 / grid.height())), 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
// Set slider position | ||
y = keepWithin(slider.height() - (hsb.b * (slider.height() / 100)), 0, slider.height()); | ||
sliderPicker.css('top', y + 'px'); | ||
// Set slider position | ||
y = keepWithin(slider.height() - (hsb.b * (slider.height() / 100)), 0, slider.height()); | ||
sliderPicker.css('top', y + 'px'); | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (hsb.b / 100)); | ||
break; | ||
// Update UI | ||
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 })); | ||
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (hsb.b / 100)); | ||
break; | ||
default: | ||
// Set grid position | ||
x = keepWithin(Math.ceil(hsb.s / (100 / grid.width())), 0, grid.width()); | ||
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
default: | ||
// Set grid position | ||
x = keepWithin(Math.ceil(hsb.s / (100 / grid.width())), 0, grid.width()); | ||
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height()); | ||
gridPicker.css({ | ||
top: y + 'px', | ||
left: x + 'px' | ||
}); | ||
// Set slider position | ||
y = keepWithin(slider.height() - (hsb.h / (360 / slider.height())), 0, slider.height()); | ||
sliderPicker.css('top', y + 'px'); | ||
// Set slider position | ||
y = keepWithin(slider.height() - (hsb.h / (360 / slider.height())), 0, slider.height()); | ||
sliderPicker.css('top', y + 'px'); | ||
// Update panel color | ||
grid.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: 100 })); | ||
break; | ||
// Update panel color | ||
grid.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: 100 })); | ||
break; | ||
} | ||
@@ -938,5 +938,5 @@ | ||
return (rgb && rgb.length === 4) ? '#' + | ||
('0' + parseInt(rgb[1],10).toString(16)).slice(-2) + | ||
('0' + parseInt(rgb[2],10).toString(16)).slice(-2) + | ||
('0' + parseInt(rgb[3],10).toString(16)).slice(-2) : ''; | ||
('0' + parseInt(rgb[1],10).toString(16)).slice(-2) + | ||
('0' + parseInt(rgb[2],10).toString(16)).slice(-2) + | ||
('0' + parseInt(rgb[3],10).toString(16)).slice(-2) : ''; | ||
} | ||
@@ -1097,3 +1097,3 @@ | ||
.find('.minicolors-input-swatch > span') | ||
.css('opacity', swatchOpacity); | ||
.css('opacity', String(swatchOpacity)); | ||
@@ -1115,10 +1115,10 @@ // Set input value | ||
switch(event.which) { | ||
case 9: // tab | ||
hide(); | ||
break; | ||
case 13: // enter | ||
case 27: // esc | ||
hide(); | ||
input.blur(); | ||
break; | ||
case 9: // tab | ||
hide(); | ||
break; | ||
case 13: // enter | ||
case 27: // esc | ||
hide(); | ||
input.blur(); | ||
break; | ||
} | ||
@@ -1125,0 +1125,0 @@ }) |
@@ -8,2 +8,2 @@ // | ||
// | ||
!function(i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function(i){"use strict";function t(t,o){var s,a,n,e,r,l,h,d=i('<div class="minicolors" />'),p=i.minicolors.defaults;if(!t.data("minicolors-initialized")){if(o=i.extend(!0,{},p,o),d.addClass("minicolors-theme-"+o.theme).toggleClass("minicolors-with-opacity",o.opacity),void 0!==o.position&&i.each(o.position.split(" "),function(){d.addClass("minicolors-position-"+this)}),a="rgb"===o.format?o.opacity?"25":"20":o.keywords?"11":"7",t.addClass("minicolors-input").data("minicolors-initialized",!1).data("minicolors-settings",o).prop("size",a).wrap(d).after('<div class="minicolors-panel minicolors-slider-'+o.control+'"><div class="minicolors-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-opacity-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-grid minicolors-sprite"><div class="minicolors-grid-inner"></div><div class="minicolors-picker"><div></div></div></div></div>'),o.inline||(t.after('<span class="minicolors-swatch minicolors-sprite minicolors-input-swatch"><span class="minicolors-swatch-color"></span></span>'),t.next(".minicolors-input-swatch").on("click",function(i){i.preventDefault(),t.focus()})),l=t.parent().find(".minicolors-panel"),l.on("selectstart",function(){return!1}).end(),o.swatches&&0!==o.swatches.length)for(l.addClass("minicolors-with-swatches"),n=i('<ul class="minicolors-swatches"></ul>').appendTo(l),h=0;h<o.swatches.length;++h)"object"===i.type(o.swatches[h])?(s=o.swatches[h].name,e=o.swatches[h].color):(s="",e=o.swatches[h]),r=e,e=v(e)?g(e,!0):I(u(e,!0)),i('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color" title="'+s+'"></span></li>').appendTo(n).data("swatch-color",r).find(".minicolors-swatch-color").css({backgroundColor:C(e),opacity:e.a}),o.swatches[h]=e;o.inline&&t.parent().addClass("minicolors-inline"),c(t,!1),t.data("minicolors-initialized",!0)}}function o(i){var t=i.parent();i.removeData("minicolors-initialized").removeData("minicolors-settings").removeProp("size").removeClass("minicolors-input"),t.before(i).remove()}function s(i){var t=i.parent(),o=t.find(".minicolors-panel"),s=i.data("minicolors-settings");!i.data("minicolors-initialized")||i.prop("disabled")||t.hasClass("minicolors-inline")||t.hasClass("minicolors-focus")||(a(),t.addClass("minicolors-focus"),o.animate?o.stop(!0,!0).fadeIn(s.showSpeed,function(){s.show&&s.show.call(i.get(0))}):(o.show(),s.show&&s.show.call(i.get(0))))}function a(){i(".minicolors-focus").each(function(){var t=i(this),o=t.find(".minicolors-input"),s=t.find(".minicolors-panel"),a=o.data("minicolors-settings");s.animate?s.fadeOut(a.hideSpeed,function(){a.hide&&a.hide.call(o.get(0)),t.removeClass("minicolors-focus")}):(s.hide(),a.hide&&a.hide.call(o.get(0)),t.removeClass("minicolors-focus"))})}function n(i,t,o){var s,a,n,r,c,l=i.parents(".minicolors").find(".minicolors-input"),h=l.data("minicolors-settings"),d=i.find("[class$=-picker]"),p=i.offset().left,u=i.offset().top,g=Math.round(t.pageX-p),m=Math.round(t.pageY-u),f=o?h.animationSpeed:0;t.originalEvent.changedTouches&&(g=t.originalEvent.changedTouches[0].pageX-p,m=t.originalEvent.changedTouches[0].pageY-u),g<0&&(g=0),m<0&&(m=0),g>i.width()&&(g=i.width()),m>i.height()&&(m=i.height()),i.parent().is(".minicolors-slider-wheel")&&d.parent().is(".minicolors-grid")&&(s=75-g,a=75-m,n=Math.sqrt(s*s+a*a),r=Math.atan2(a,s),r<0&&(r+=2*Math.PI),n>75&&(n=75,g=75-75*Math.cos(r),m=75-75*Math.sin(r)),g=Math.round(g),m=Math.round(m)),c={top:m+"px"},i.is(".minicolors-grid")&&(c.left=g+"px"),d.animate?d.stop(!0).animate(c,f,h.animationEasing,function(){e(l,i)}):(d.css(c),e(l,i))}function e(i,t){function o(i,t){var o,s;return i.length&&t?(o=i.offset().left,s=i.offset().top,{x:o-t.offset().left+i.outerWidth()/2,y:s-t.offset().top+i.outerHeight()/2}):null}var s,a,n,e,c,h,d,p=i.val(),u=i.attr("data-opacity"),g=i.parent(),m=i.data("minicolors-settings"),v=g.find(".minicolors-input-swatch"),b=g.find(".minicolors-grid"),w=g.find(".minicolors-slider"),y=g.find(".minicolors-opacity-slider"),C=b.find("[class$=-picker]"),M=w.find("[class$=-picker]"),x=y.find("[class$=-picker]"),I=o(C,b),S=o(M,w),z=o(x,y);if(t.is(".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider")){switch(m.control){case"wheel":e=b.width()/2-I.x,c=b.height()/2-I.y,h=Math.sqrt(e*e+c*c),d=Math.atan2(c,e),d<0&&(d+=2*Math.PI),h>75&&(h=75,I.x=69-75*Math.cos(d),I.y=69-75*Math.sin(d)),a=f(h/.75,0,100),s=f(180*d/Math.PI,0,360),n=f(100-Math.floor(S.y*(100/w.height())),0,100),p=k({h:s,s:a,b:n}),w.css("backgroundColor",k({h:s,s:a,b:100}));break;case"saturation":s=f(parseInt(I.x*(360/b.width()),10),0,360),a=f(100-Math.floor(S.y*(100/w.height())),0,100),n=f(100-Math.floor(I.y*(100/b.height())),0,100),p=k({h:s,s:a,b:n}),w.css("backgroundColor",k({h:s,s:100,b:n})),g.find(".minicolors-grid-inner").css("opacity",a/100);break;case"brightness":s=f(parseInt(I.x*(360/b.width()),10),0,360),a=f(100-Math.floor(I.y*(100/b.height())),0,100),n=f(100-Math.floor(S.y*(100/w.height())),0,100),p=k({h:s,s:a,b:n}),w.css("backgroundColor",k({h:s,s:a,b:100})),g.find(".minicolors-grid-inner").css("opacity",1-n/100);break;default:s=f(360-parseInt(S.y*(360/w.height()),10),0,360),a=f(Math.floor(I.x*(100/b.width())),0,100),n=f(100-Math.floor(I.y*(100/b.height())),0,100),p=k({h:s,s:a,b:n}),b.css("backgroundColor",k({h:s,s:100,b:100}))}u=m.opacity?parseFloat(1-z.y/y.height()).toFixed(2):1,r(i,p,u)}else v.find("span").css({backgroundColor:p,opacity:u}),l(i,p,u)}function r(i,t,o){var s,a=i.parent(),n=i.data("minicolors-settings"),e=a.find(".minicolors-input-swatch");n.opacity&&i.attr("data-opacity",o),"rgb"===n.format?(s=v(t)?g(t,!0):I(u(t,!0)),o=""===i.attr("data-opacity")?1:f(parseFloat(i.attr("data-opacity")).toFixed(2),0,1),!isNaN(o)&&n.opacity||(o=1),t=i.minicolors("rgbObject").a<=1&&s&&n.opacity?"rgba("+s.r+", "+s.g+", "+s.b+", "+parseFloat(o)+")":"rgb("+s.r+", "+s.g+", "+s.b+")"):(v(t)&&(t=y(t)),t=p(t,n.letterCase)),i.val(t),e.find("span").css({backgroundColor:t,opacity:o}),l(i,t,o)}function c(t,o){var s,a,n,e,r,c,h,d,w,C,x=t.parent(),I=t.data("minicolors-settings"),S=x.find(".minicolors-input-swatch"),z=x.find(".minicolors-grid"),F=x.find(".minicolors-slider"),T=x.find(".minicolors-opacity-slider"),j=z.find("[class$=-picker]"),D=F.find("[class$=-picker]"),q=T.find("[class$=-picker]");switch(v(t.val())?(s=y(t.val()),r=f(parseFloat(b(t.val())).toFixed(2),0,1),r&&t.attr("data-opacity",r)):s=p(u(t.val(),!0),I.letterCase),s||(s=p(m(I.defaultValue,!0),I.letterCase)),a=M(s),e=I.keywords?i.map(I.keywords.split(","),function(t){return i.trim(t.toLowerCase())}):[],c=""!==t.val()&&i.inArray(t.val().toLowerCase(),e)>-1?p(t.val()):v(t.val())?g(t.val()):s,o||t.val(c),I.opacity&&(n=""===t.attr("data-opacity")?1:f(parseFloat(t.attr("data-opacity")).toFixed(2),0,1),isNaN(n)&&(n=1),t.attr("data-opacity",n),S.find("span").css("opacity",n),d=f(T.height()-T.height()*n,0,T.height()),q.css("top",d+"px")),"transparent"===t.val().toLowerCase()&&S.find("span").css("opacity",0),S.find("span").css("backgroundColor",s),I.control){case"wheel":w=f(Math.ceil(.75*a.s),0,z.height()/2),C=a.h*Math.PI/180,h=f(75-Math.cos(C)*w,0,z.width()),d=f(75-Math.sin(C)*w,0,z.height()),j.css({top:d+"px",left:h+"px"}),d=150-a.b/(100/z.height()),""===s&&(d=0),D.css("top",d+"px"),F.css("backgroundColor",k({h:a.h,s:a.s,b:100}));break;case"saturation":h=f(5*a.h/12,0,150),d=f(z.height()-Math.ceil(a.b/(100/z.height())),0,z.height()),j.css({top:d+"px",left:h+"px"}),d=f(F.height()-a.s*(F.height()/100),0,F.height()),D.css("top",d+"px"),F.css("backgroundColor",k({h:a.h,s:100,b:a.b})),x.find(".minicolors-grid-inner").css("opacity",a.s/100);break;case"brightness":h=f(5*a.h/12,0,150),d=f(z.height()-Math.ceil(a.s/(100/z.height())),0,z.height()),j.css({top:d+"px",left:h+"px"}),d=f(F.height()-a.b*(F.height()/100),0,F.height()),D.css("top",d+"px"),F.css("backgroundColor",k({h:a.h,s:a.s,b:100})),x.find(".minicolors-grid-inner").css("opacity",1-a.b/100);break;default:h=f(Math.ceil(a.s/(100/z.width())),0,z.width()),d=f(z.height()-Math.ceil(a.b/(100/z.height())),0,z.height()),j.css({top:d+"px",left:h+"px"}),d=f(F.height()-a.h/(360/F.height()),0,F.height()),D.css("top",d+"px"),z.css("backgroundColor",k({h:a.h,s:100,b:100}))}t.data("minicolors-initialized")&&l(t,c,n)}function l(i,t,o){var s,a,n,e=i.data("minicolors-settings"),r=i.data("minicolors-lastChange");if(!r||r.value!==t||r.opacity!==o){if(i.data("minicolors-lastChange",{value:t,opacity:o}),e.swatches&&0!==e.swatches.length){for(s=v(t)?g(t,!0):I(t),a=-1,n=0;n<e.swatches.length;++n)if(s.r===e.swatches[n].r&&s.g===e.swatches[n].g&&s.b===e.swatches[n].b&&s.a===e.swatches[n].a){a=n;break}i.parent().find(".minicolors-swatches .minicolors-swatch").removeClass("selected"),a!==-1&&i.parent().find(".minicolors-swatches .minicolors-swatch").eq(n).addClass("selected")}e.change&&(e.changeDelay?(clearTimeout(i.data("minicolors-changeTimeout")),i.data("minicolors-changeTimeout",setTimeout(function(){e.change.call(i.get(0),t,o)},e.changeDelay))):e.change.call(i.get(0),t,o)),i.trigger("change").trigger("input")}}function h(t){var o,s=i(t).attr("data-opacity");if(v(i(t).val()))o=g(i(t).val(),!0);else{var a=u(i(t).val(),!0);o=I(a)}return o?(void 0!==s&&i.extend(o,{a:parseFloat(s)}),o):null}function d(t,o){var s,a=i(t).attr("data-opacity");if(v(i(t).val()))s=g(i(t).val(),!0);else{var n=u(i(t).val(),!0);s=I(n)}return s?(void 0===a&&(a=1),o?"rgba("+s.r+", "+s.g+", "+s.b+", "+parseFloat(a)+")":"rgb("+s.r+", "+s.g+", "+s.b+")"):null}function p(i,t){return"uppercase"===t?i.toUpperCase():i.toLowerCase()}function u(i,t){return i=i.replace(/^#/g,""),i.match(/^[A-F0-9]{3,6}/gi)?3!==i.length&&6!==i.length?"":(3===i.length&&t&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),"#"+i):""}function g(i,t){var o=i.replace(/[^\d,.]/g,""),s=o.split(",");return s[0]=f(parseInt(s[0],10),0,255),s[1]=f(parseInt(s[1],10),0,255),s[2]=f(parseInt(s[2],10),0,255),void 0!==s[3]&&(s[3]=f(parseFloat(s[3],10),0,1)),t?void 0!==s[3]?{r:s[0],g:s[1],b:s[2],a:s[3]}:{r:s[0],g:s[1],b:s[2]}:"undefined"!=typeof s[3]&&s[3]<=1?"rgba("+s[0]+", "+s[1]+", "+s[2]+", "+s[3]+")":"rgb("+s[0]+", "+s[1]+", "+s[2]+")"}function m(i,t){return v(i)?g(i):u(i,t)}function f(i,t,o){return i<t&&(i=t),i>o&&(i=o),i}function v(i){var t=i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);return!(!t||4!==t.length)}function b(i){return i=i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+(\.\d{1,2})?|\.\d{1,2})[\s+]?/i),i&&6===i.length?i[4]:"1"}function w(i){var t={},o=Math.round(i.h),s=Math.round(255*i.s/100),a=Math.round(255*i.b/100);if(0===s)t.r=t.g=t.b=a;else{var n=a,e=(255-s)*a/255,r=(n-e)*(o%60)/60;360===o&&(o=0),o<60?(t.r=n,t.b=e,t.g=e+r):o<120?(t.g=n,t.b=e,t.r=n-r):o<180?(t.g=n,t.r=e,t.b=e+r):o<240?(t.b=n,t.r=e,t.g=n-r):o<300?(t.b=n,t.g=e,t.r=e+r):o<360?(t.r=n,t.g=e,t.b=n-r):(t.r=0,t.g=0,t.b=0)}return{r:Math.round(t.r),g:Math.round(t.g),b:Math.round(t.b)}}function y(i){return i=i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i),i&&4===i.length?"#"+("0"+parseInt(i[1],10).toString(16)).slice(-2)+("0"+parseInt(i[2],10).toString(16)).slice(-2)+("0"+parseInt(i[3],10).toString(16)).slice(-2):""}function C(t){var o=[t.r.toString(16),t.g.toString(16),t.b.toString(16)];return i.each(o,function(i,t){1===t.length&&(o[i]="0"+t)}),"#"+o.join("")}function k(i){return C(w(i))}function M(i){var t=x(I(i));return 0===t.s&&(t.h=360),t}function x(i){var t={h:0,s:0,b:0},o=Math.min(i.r,i.g,i.b),s=Math.max(i.r,i.g,i.b),a=s-o;return t.b=s,t.s=0!==s?255*a/s:0,0!==t.s?i.r===s?t.h=(i.g-i.b)/a:i.g===s?t.h=2+(i.b-i.r)/a:t.h=4+(i.r-i.g)/a:t.h=-1,t.h*=60,t.h<0&&(t.h+=360),t.s*=100/255,t.b*=100/255,t}function I(i){return i=parseInt(i.indexOf("#")>-1?i.substring(1):i,16),{r:i>>16,g:(65280&i)>>8,b:255&i}}i.minicolors={defaults:{animationSpeed:50,animationEasing:"swing",change:null,changeDelay:0,control:"hue",defaultValue:"",format:"hex",hide:null,hideSpeed:100,inline:!1,keywords:"",letterCase:"lowercase",opacity:!1,position:"bottom",show:null,showSpeed:100,theme:"default",swatches:[]}},i.extend(i.fn,{minicolors:function(n,e){switch(n){case"destroy":return i(this).each(function(){o(i(this))}),i(this);case"hide":return a(),i(this);case"opacity":return void 0===e?i(this).attr("data-opacity"):(i(this).each(function(){c(i(this).attr("data-opacity",e))}),i(this));case"rgbObject":return h(i(this),"rgbaObject"===n);case"rgbString":case"rgbaString":return d(i(this),"rgbaString"===n);case"settings":return void 0===e?i(this).data("minicolors-settings"):(i(this).each(function(){var t=i(this).data("minicolors-settings")||{};o(i(this)),i(this).minicolors(i.extend(!0,t,e))}),i(this));case"show":return s(i(this).eq(0)),i(this);case"value":return void 0===e?i(this).val():(i(this).each(function(){"object"==typeof e&&null!==e?(void 0!==e.opacity&&i(this).attr("data-opacity",f(e.opacity,0,1)),e.color&&i(this).val(e.color)):i(this).val(e),c(i(this))}),i(this));default:return"create"!==n&&(e=n),i(this).each(function(){t(i(this),e)}),i(this)}}}),i([document]).on("mousedown.minicolors touchstart.minicolors",function(t){i(t.target).parents().add(t.target).hasClass("minicolors")||a()}).on("mousedown.minicolors touchstart.minicolors",".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider",function(t){var o=i(this);t.preventDefault(),i(t.delegateTarget).data("minicolors-target",o),n(o,t,!0)}).on("mousemove.minicolors touchmove.minicolors",function(t){var o=i(t.delegateTarget).data("minicolors-target");o&&n(o,t)}).on("mouseup.minicolors touchend.minicolors",function(){i(this).removeData("minicolors-target")}).on("click.minicolors",".minicolors-swatches li",function(t){t.preventDefault();var o=i(this),s=o.parents(".minicolors").find(".minicolors-input"),a=o.data("swatch-color");r(s,a,b(a)),c(s)}).on("mousedown.minicolors touchstart.minicolors",".minicolors-input-swatch",function(t){var o=i(this).parent().find(".minicolors-input");t.preventDefault(),s(o)}).on("focus.minicolors",".minicolors-input",function(){var t=i(this);t.data("minicolors-initialized")&&s(t)}).on("blur.minicolors",".minicolors-input",function(){var t,o,s,a,n,e=i(this),r=e.data("minicolors-settings");e.data("minicolors-initialized")&&(t=r.keywords?i.map(r.keywords.split(","),function(t){return i.trim(t.toLowerCase())}):[],""!==e.val()&&i.inArray(e.val().toLowerCase(),t)>-1?n=e.val():(v(e.val())?s=g(e.val(),!0):(o=u(e.val(),!0),s=o?I(o):null),n=null===s?r.defaultValue:"rgb"===r.format?g(r.opacity?"rgba("+s.r+","+s.g+","+s.b+","+e.attr("data-opacity")+")":"rgb("+s.r+","+s.g+","+s.b+")"):C(s)),a=r.opacity?e.attr("data-opacity"):1,"transparent"===n.toLowerCase()&&(a=0),e.closest(".minicolors").find(".minicolors-input-swatch > span").css("opacity",a),e.val(n),""===e.val()&&e.val(m(r.defaultValue,!0)),e.val(p(e.val(),r.letterCase)))}).on("keydown.minicolors",".minicolors-input",function(t){var o=i(this);if(o.data("minicolors-initialized"))switch(t.which){case 9:a();break;case 13:case 27:a(),o.blur()}}).on("keyup.minicolors",".minicolors-input",function(){var t=i(this);t.data("minicolors-initialized")&&c(t,!0)}).on("paste.minicolors",".minicolors-input",function(){var t=i(this);t.data("minicolors-initialized")&&setTimeout(function(){c(t,!0)},1)})}); | ||
!function(i){"function"==typeof define&&define.amd?define(["jquery"],i):"object"==typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function(C){"use strict";function o(i){var t=i.parent();i.removeData("minicolors-initialized").removeData("minicolors-settings").removeProp("size").removeClass("minicolors-input"),t.before(i).remove()}function s(i){var t=i.parent(),o=t.find(".minicolors-panel"),s=i.data("minicolors-settings");!i.data("minicolors-initialized")||i.prop("disabled")||t.hasClass("minicolors-inline")||t.hasClass("minicolors-focus")||(a(),t.addClass("minicolors-focus"),o.animate?o.stop(!0,!0).fadeIn(s.showSpeed,function(){s.show&&s.show.call(i.get(0))}):(o.show(),s.show&&s.show.call(i.get(0))))}function a(){C(".minicolors-focus").each(function(){var i=C(this),t=i.find(".minicolors-input"),o=i.find(".minicolors-panel"),s=t.data("minicolors-settings");o.animate?o.fadeOut(s.hideSpeed,function(){s.hide&&s.hide.call(t.get(0)),i.removeClass("minicolors-focus")}):(o.hide(),s.hide&&s.hide.call(t.get(0)),i.removeClass("minicolors-focus"))})}function n(i,t,o){var s,a,n,r,e,c=i.parents(".minicolors").find(".minicolors-input"),l=c.data("minicolors-settings"),h=i.find("[class$=-picker]"),d=i.offset().left,p=i.offset().top,u=Math.round(t.pageX-d),g=Math.round(t.pageY-p),m=o?l.animationSpeed:0;t.originalEvent.changedTouches&&(u=t.originalEvent.changedTouches[0].pageX-d,g=t.originalEvent.changedTouches[0].pageY-p),u<0&&(u=0),g<0&&(g=0),u>i.width()&&(u=i.width()),g>i.height()&&(g=i.height()),i.parent().is(".minicolors-slider-wheel")&&h.parent().is(".minicolors-grid")&&(s=75-u,a=75-g,n=Math.sqrt(s*s+a*a),(r=Math.atan2(a,s))<0&&(r+=2*Math.PI),75<n&&(u=(n=75)-75*Math.cos(r),g=75-75*Math.sin(r)),u=Math.round(u),g=Math.round(g)),e={top:g+"px"},i.is(".minicolors-grid")&&(e.left=u+"px"),h.animate?h.stop(!0).animate(e,m,l.animationEasing,function(){f(c,i)}):(h.css(e),f(c,i))}function f(i,t){function o(i,t){var o,s;return i.length&&t?(o=i.offset().left,s=i.offset().top,{x:o-t.offset().left+i.outerWidth()/2,y:s-t.offset().top+i.outerHeight()/2}):null}var s,a,n,r,e,c,l,h=i.val(),d=i.attr("data-opacity"),p=i.parent(),u=i.data("minicolors-settings"),g=p.find(".minicolors-input-swatch"),m=p.find(".minicolors-grid"),f=p.find(".minicolors-slider"),v=p.find(".minicolors-opacity-slider"),b=m.find("[class$=-picker]"),w=f.find("[class$=-picker]"),y=v.find("[class$=-picker]"),C=o(b,m),k=o(w,f),M=o(y,v);if(t.is(".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider")){switch(u.control){case"wheel":r=m.width()/2-C.x,e=m.height()/2-C.y,c=Math.sqrt(r*r+e*e),(l=Math.atan2(e,r))<0&&(l+=2*Math.PI),75<c&&(c=75,C.x=69-75*Math.cos(l),C.y=69-75*Math.sin(l)),a=F(c/.75,0,100),h=q({h:s=F(180*l/Math.PI,0,360),s:a,b:n=F(100-Math.floor(k.y*(100/f.height())),0,100)}),f.css("backgroundColor",q({h:s,s:a,b:100}));break;case"saturation":h=q({h:s=F(parseInt(C.x*(360/m.width()),10),0,360),s:a=F(100-Math.floor(k.y*(100/f.height())),0,100),b:n=F(100-Math.floor(C.y*(100/m.height())),0,100)}),f.css("backgroundColor",q({h:s,s:100,b:n})),p.find(".minicolors-grid-inner").css("opacity",a/100);break;case"brightness":h=q({h:s=F(parseInt(C.x*(360/m.width()),10),0,360),s:a=F(100-Math.floor(C.y*(100/m.height())),0,100),b:n=F(100-Math.floor(k.y*(100/f.height())),0,100)}),f.css("backgroundColor",q({h:s,s:a,b:100})),p.find(".minicolors-grid-inner").css("opacity",1-n/100);break;default:h=q({h:s=F(360-parseInt(k.y*(360/f.height()),10),0,360),s:a=F(Math.floor(C.x*(100/m.width())),0,100),b:n=F(100-Math.floor(C.y*(100/m.height())),0,100)}),m.css("backgroundColor",q({h:s,s:100,b:100}))}x(i,h,d=u.opacity?parseFloat(1-M.y/v.height()).toFixed(2):1)}else g.find("span").css({backgroundColor:h,opacity:String(d)}),S(i,h,d)}function x(i,t,o){var s,a=i.parent(),n=i.data("minicolors-settings"),r=a.find(".minicolors-input-swatch");n.opacity&&i.attr("data-opacity",o),t="rgb"===n.format?(s=T(t)?I(t,!0):L(M(t,!0)),o=""===i.attr("data-opacity")?1:F(parseFloat(i.attr("data-opacity")).toFixed(2),0,1),!isNaN(o)&&n.opacity||(o=1),i.minicolors("rgbObject").a<=1&&s&&n.opacity?"rgba("+s.r+", "+s.g+", "+s.b+", "+parseFloat(o)+")":"rgb("+s.r+", "+s.g+", "+s.b+")"):(T(t)&&(t=j(t)),k(t,n.letterCase)),i.val(t),r.find("span").css({backgroundColor:t,opacity:String(o)}),S(i,t,o)}function d(i,t){var o,s,a,n,r,e,c,l,h,d,p=i.parent(),u=i.data("minicolors-settings"),g=p.find(".minicolors-input-swatch"),m=p.find(".minicolors-grid"),f=p.find(".minicolors-slider"),v=p.find(".minicolors-opacity-slider"),b=m.find("[class$=-picker]"),w=f.find("[class$=-picker]"),y=v.find("[class$=-picker]");switch(T(i.val())?(o=j(i.val()),(r=F(parseFloat(D(i.val())).toFixed(2),0,1))&&i.attr("data-opacity",r)):o=k(M(i.val(),!0),u.letterCase),s=function(i){var t=function(i){var t={h:0,s:0,b:0},o=Math.min(i.r,i.g,i.b),s=Math.max(i.r,i.g,i.b),a=s-o;t.b=s,t.s=0!==s?255*a/s:0,0!==t.s?i.r===s?t.h=(i.g-i.b)/a:i.g===s?t.h=2+(i.b-i.r)/a:t.h=4+(i.r-i.g)/a:t.h=-1;t.h*=60,t.h<0&&(t.h+=360);return t.s*=100/255,t.b*=100/255,t}(L(i));0===t.s&&(t.h=360);return t}(o=o||k(z(u.defaultValue,!0),u.letterCase)),n=u.keywords?C.map(u.keywords.split(","),function(i){return C.trim(i.toLowerCase())}):[],e=""!==i.val()&&-1<C.inArray(i.val().toLowerCase(),n)?k(i.val()):T(i.val())?I(i.val()):o,t||i.val(e),u.opacity&&(a=""===i.attr("data-opacity")?1:F(parseFloat(i.attr("data-opacity")).toFixed(2),0,1),isNaN(a)&&(a=1),i.attr("data-opacity",a),g.find("span").css("opacity",String(a)),l=F(v.height()-v.height()*a,0,v.height()),y.css("top",l+"px")),"transparent"===i.val().toLowerCase()&&g.find("span").css("opacity",String(0)),g.find("span").css("backgroundColor",o),u.control){case"wheel":h=F(Math.ceil(.75*s.s),0,m.height()/2),d=s.h*Math.PI/180,c=F(75-Math.cos(d)*h,0,m.width()),l=F(75-Math.sin(d)*h,0,m.height()),b.css({top:l+"px",left:c+"px"}),l=150-s.b/(100/m.height()),""===o&&(l=0),w.css("top",l+"px"),f.css("backgroundColor",q({h:s.h,s:s.s,b:100}));break;case"saturation":c=F(5*s.h/12,0,150),l=F(m.height()-Math.ceil(s.b/(100/m.height())),0,m.height()),b.css({top:l+"px",left:c+"px"}),l=F(f.height()-s.s*(f.height()/100),0,f.height()),w.css("top",l+"px"),f.css("backgroundColor",q({h:s.h,s:100,b:s.b})),p.find(".minicolors-grid-inner").css("opacity",s.s/100);break;case"brightness":c=F(5*s.h/12,0,150),l=F(m.height()-Math.ceil(s.s/(100/m.height())),0,m.height()),b.css({top:l+"px",left:c+"px"}),l=F(f.height()-s.b*(f.height()/100),0,f.height()),w.css("top",l+"px"),f.css("backgroundColor",q({h:s.h,s:s.s,b:100})),p.find(".minicolors-grid-inner").css("opacity",1-s.b/100);break;default:c=F(Math.ceil(s.s/(100/m.width())),0,m.width()),l=F(m.height()-Math.ceil(s.b/(100/m.height())),0,m.height()),b.css({top:l+"px",left:c+"px"}),l=F(f.height()-s.h/(360/f.height()),0,f.height()),w.css("top",l+"px"),m.css("backgroundColor",q({h:s.h,s:100,b:100}))}i.data("minicolors-initialized")&&S(i,e,a)}function S(i,t,o){var s,a,n,r=i.data("minicolors-settings"),e=i.data("minicolors-lastChange");if(!e||e.value!==t||e.opacity!==o){if(i.data("minicolors-lastChange",{value:t,opacity:o}),r.swatches&&0!==r.swatches.length){for(s=T(t)?I(t,!0):L(t),a=-1,n=0;n<r.swatches.length;++n)if(s.r===r.swatches[n].r&&s.g===r.swatches[n].g&&s.b===r.swatches[n].b&&s.a===r.swatches[n].a){a=n;break}i.parent().find(".minicolors-swatches .minicolors-swatch").removeClass("selected"),-1!==a&&i.parent().find(".minicolors-swatches .minicolors-swatch").eq(n).addClass("selected")}r.change&&(r.changeDelay?(clearTimeout(i.data("minicolors-changeTimeout")),i.data("minicolors-changeTimeout",setTimeout(function(){r.change.call(i.get(0),t,o)},r.changeDelay))):r.change.call(i.get(0),t,o)),i.trigger("change").trigger("input")}}function k(i,t){return"uppercase"===t?i.toUpperCase():i.toLowerCase()}function M(i,t){return!(i=i.replace(/^#/g,"")).match(/^[A-F0-9]{3,6}/gi)||3!==i.length&&6!==i.length?"":(3===i.length&&t&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),"#"+i)}function I(i,t){var o=i.replace(/[^\d,.]/g,"").split(",");return o[0]=F(parseInt(o[0],10),0,255),o[1]=F(parseInt(o[1],10),0,255),o[2]=F(parseInt(o[2],10),0,255),void 0!==o[3]&&(o[3]=F(parseFloat(o[3],10),0,1)),t?void 0!==o[3]?{r:o[0],g:o[1],b:o[2],a:o[3]}:{r:o[0],g:o[1],b:o[2]}:void 0!==o[3]&&o[3]<=1?"rgba("+o[0]+", "+o[1]+", "+o[2]+", "+o[3]+")":"rgb("+o[0]+", "+o[1]+", "+o[2]+")"}function z(i,t){return T(i)?I(i):M(i,t)}function F(i,t,o){return i<t&&(i=t),o<i&&(i=o),i}function T(i){var t=i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);return!(!t||4!==t.length)}function D(i){return(i=i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+(\.\d{1,2})?|\.\d{1,2})[\s+]?/i))&&6===i.length?i[4]:"1"}function j(i){return(i=i.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===i.length?"#"+("0"+parseInt(i[1],10).toString(16)).slice(-2)+("0"+parseInt(i[2],10).toString(16)).slice(-2)+("0"+parseInt(i[3],10).toString(16)).slice(-2):""}function p(i){var o=[i.r.toString(16),i.g.toString(16),i.b.toString(16)];return C.each(o,function(i,t){1===t.length&&(o[i]="0"+t)}),"#"+o.join("")}function q(i){return p((t=i,n={},r=Math.round(t.h),e=Math.round(255*t.s/100),c=Math.round(255*t.b/100),0===e?n.r=n.g=n.b=c:(a=r%60*((o=c)-(s=(255-e)*c/255))/60,360===r&&(r=0),r<60?(n.r=o,n.b=s,n.g=s+a):r<120?(n.g=o,n.b=s,n.r=o-a):r<180?(n.g=o,n.r=s,n.b=s+a):r<240?(n.b=o,n.r=s,n.g=o-a):r<300?(n.b=o,n.g=s,n.r=s+a):r<360?(n.r=o,n.g=s,n.b=o-a):(n.r=0,n.g=0,n.b=0)),{r:Math.round(n.r),g:Math.round(n.g),b:Math.round(n.b)}));var t,o,s,a,n,r,e,c}function L(i){return{r:(i=parseInt(-1<i.indexOf("#")?i.substring(1):i,16))>>16,g:(65280&i)>>8,b:255&i}}C.minicolors={defaults:{animationSpeed:50,animationEasing:"swing",change:null,changeDelay:0,control:"hue",defaultValue:"",format:"hex",hide:null,hideSpeed:100,inline:!1,keywords:"",letterCase:"lowercase",opacity:!1,position:"bottom",show:null,showSpeed:100,theme:"default",swatches:[]}},C.extend(C.fn,{minicolors:function(i,t){switch(i){case"destroy":return C(this).each(function(){o(C(this))}),C(this);case"hide":return a(),C(this);case"opacity":return void 0===t?C(this).attr("data-opacity"):(C(this).each(function(){d(C(this).attr("data-opacity",t))}),C(this));case"rgbObject":return function(i){var t,o=C(i).attr("data-opacity");{var s;t=T(C(i).val())?I(C(i).val(),!0):(s=M(C(i).val(),!0),L(s))}if(!t)return null;void 0!==o&&C.extend(t,{a:parseFloat(o)});return t}(C(this));case"rgbString":case"rgbaString":return function(i,t){var o,s=C(i).attr("data-opacity");{var a;o=T(C(i).val())?I(C(i).val(),!0):(a=M(C(i).val(),!0),L(a))}if(!o)return null;void 0===s&&(s=1);return t?"rgba("+o.r+", "+o.g+", "+o.b+", "+parseFloat(s)+")":"rgb("+o.r+", "+o.g+", "+o.b+")"}(C(this),"rgbaString"===i);case"settings":return void 0===t?C(this).data("minicolors-settings"):(C(this).each(function(){var i=C(this).data("minicolors-settings")||{};o(C(this)),C(this).minicolors(C.extend(!0,i,t))}),C(this));case"show":return s(C(this).eq(0)),C(this);case"value":return void 0===t?C(this).val():(C(this).each(function(){"object"==typeof t&&null!==t?(void 0!==t.opacity&&C(this).attr("data-opacity",F(t.opacity,0,1)),t.color&&C(this).val(t.color)):C(this).val(t),d(C(this))}),C(this));default:return"create"!==i&&(t=i),C(this).each(function(){!function(t,i){var o,s,a,n,r,e,c,l=C('<div class="minicolors" />'),h=C.minicolors.defaults;if(t.data("minicolors-initialized"))return;i=C.extend(!0,{},h,i),l.addClass("minicolors-theme-"+i.theme).toggleClass("minicolors-with-opacity",i.opacity),void 0!==i.position&&C.each(i.position.split(" "),function(){l.addClass("minicolors-position-"+this)});s="rgb"===i.format?i.opacity?"25":"20":i.keywords?"11":"7";t.addClass("minicolors-input").data("minicolors-initialized",!1).data("minicolors-settings",i).prop("size",s).wrap(l).after('<div class="minicolors-panel minicolors-slider-'+i.control+'"><div class="minicolors-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-opacity-slider minicolors-sprite"><div class="minicolors-picker"></div></div><div class="minicolors-grid minicolors-sprite"><div class="minicolors-grid-inner"></div><div class="minicolors-picker"><div></div></div></div></div>'),i.inline||(t.after('<span class="minicolors-swatch minicolors-sprite minicolors-input-swatch"><span class="minicolors-swatch-color"></span></span>'),t.next(".minicolors-input-swatch").on("click",function(i){i.preventDefault(),t.trigger("focus")}));if((e=t.parent().find(".minicolors-panel")).on("selectstart",function(){return!1}).end(),i.swatches&&0!==i.swatches.length)for(e.addClass("minicolors-with-swatches"),a=C('<ul class="minicolors-swatches"></ul>').appendTo(e),c=0;c<i.swatches.length;++c)n="object"===C.type(i.swatches[c])?(o=i.swatches[c].name,i.swatches[c].color):(o="",i.swatches[c]),n=T(r=n)?I(n,!0):L(M(n,!0)),C('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color" title="'+o+'"></span></li>').appendTo(a).data("swatch-color",r).find(".minicolors-swatch-color").css({backgroundColor:p(n),opacity:String(n.a)}),i.swatches[c]=n;i.inline&&t.parent().addClass("minicolors-inline");d(t,!1),t.data("minicolors-initialized",!0)}(C(this),t)}),C(this)}}}),C([document]).on("mousedown.minicolors touchstart.minicolors",function(i){C(i.target).parents().add(i.target).hasClass("minicolors")||a()}).on("mousedown.minicolors touchstart.minicolors",".minicolors-grid, .minicolors-slider, .minicolors-opacity-slider",function(i){var t=C(this);i.preventDefault(),C(i.delegateTarget).data("minicolors-target",t),n(t,i,!0)}).on("mousemove.minicolors touchmove.minicolors",function(i){var t=C(i.delegateTarget).data("minicolors-target");t&&n(t,i)}).on("mouseup.minicolors touchend.minicolors",function(){C(this).removeData("minicolors-target")}).on("click.minicolors",".minicolors-swatches li",function(i){i.preventDefault();var t=C(this),o=t.parents(".minicolors").find(".minicolors-input"),s=t.data("swatch-color");x(o,s,D(s)),d(o)}).on("mousedown.minicolors touchstart.minicolors",".minicolors-input-swatch",function(i){var t=C(this).parent().find(".minicolors-input");i.preventDefault(),s(t)}).on("focus.minicolors",".minicolors-input",function(){var i=C(this);i.data("minicolors-initialized")&&s(i)}).on("blur.minicolors",".minicolors-input",function(){var i,t,o,s,a,n=C(this),r=n.data("minicolors-settings");n.data("minicolors-initialized")&&(i=r.keywords?C.map(r.keywords.split(","),function(i){return C.trim(i.toLowerCase())}):[],a=""!==n.val()&&-1<C.inArray(n.val().toLowerCase(),i)?n.val():null===(o=T(n.val())?I(n.val(),!0):(t=M(n.val(),!0))?L(t):null)?r.defaultValue:"rgb"===r.format?r.opacity?I("rgba("+o.r+","+o.g+","+o.b+","+n.attr("data-opacity")+")"):I("rgb("+o.r+","+o.g+","+o.b+")"):p(o),s=r.opacity?n.attr("data-opacity"):1,"transparent"===a.toLowerCase()&&(s=0),n.closest(".minicolors").find(".minicolors-input-swatch > span").css("opacity",String(s)),n.val(a),""===n.val()&&n.val(z(r.defaultValue,!0)),n.val(k(n.val(),r.letterCase)))}).on("keydown.minicolors",".minicolors-input",function(i){var t=C(this);if(t.data("minicolors-initialized"))switch(i.which){case 9:a();break;case 13:case 27:a(),t.blur()}}).on("keyup.minicolors",".minicolors-input",function(){var i=C(this);i.data("minicolors-initialized")&&d(i,!0)}).on("paste.minicolors",".minicolors-input",function(){var i=C(this);i.data("minicolors-initialized")&&setTimeout(function(){d(i,!0)},1)})}); |
{ | ||
"name": "@claviska/jquery-minicolors", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"homepage": "https://github.com/claviska/jquery-minicolors", | ||
@@ -17,7 +17,7 @@ "author": "Cory LaViska", | ||
"devDependencies": { | ||
"del": "^2.2.0", | ||
"gulp": "^3.9.1", | ||
"gulp-help": "^1.6.1", | ||
"gulp-rename": "^1.4.0", | ||
"gulp-uglify": "^1.5.3" | ||
"del": "^5.1.0", | ||
"gulp": "^4.0.2", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-uglify": "^3.0.2", | ||
"uglify-save-license": "^0.4.1" | ||
}, | ||
@@ -24,0 +24,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165666
1490