Version Description
- Compatibility with jQuery 3.0
Download this release
Release Info
Developer | giucu91 |
Plugin | Custom Login Page Customizer by Colorlib |
Version | 1.2.98 |
Comparing to | |
See all releases |
Code changes from version 1.2.97 to 1.2.98
- assets/js/jquery.minicolors.js +309 -291
- assets/js/jquery.minicolors.min.js +1 -2
- colorlib-login-customizer.php +3 -3
- languages/colorlib-login-customizer.po +4 -4
- readme.txt +5 -2
assets/js/jquery.minicolors.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
//
|
2 |
-
|
3 |
// jQuery MiniColors: A tiny color picker built on jQuery
|
4 |
//
|
5 |
// Developed by Cory LaViska for A Beautiful Site, LLC
|
@@ -36,7 +35,7 @@
|
|
36 |
keywords: '',
|
37 |
letterCase: 'lowercase',
|
38 |
opacity: false,
|
39 |
-
position: 'bottom
|
40 |
show: null,
|
41 |
showSpeed: 100,
|
42 |
theme: 'default',
|
@@ -49,90 +48,90 @@
|
|
49 |
minicolors: function(method, data) {
|
50 |
|
51 |
switch(method) {
|
52 |
-
|
53 |
-
|
54 |
-
$(this).each(function() {
|
55 |
-
destroy($(this));
|
56 |
-
});
|
57 |
-
return $(this);
|
58 |
-
|
59 |
-
// Hide the color picker
|
60 |
-
case 'hide':
|
61 |
-
hide();
|
62 |
-
return $(this);
|
63 |
-
|
64 |
-
// Get/set opacity
|
65 |
-
case 'opacity':
|
66 |
-
// Getter
|
67 |
-
if(data === undefined) {
|
68 |
-
// Getter
|
69 |
-
return $(this).attr('data-opacity');
|
70 |
-
} else {
|
71 |
-
// Setter
|
72 |
$(this).each(function() {
|
73 |
-
updateFromInput($(this).attr('data-opacity', data));
|
74 |
-
});
|
75 |
-
}
|
76 |
-
return $(this);
|
77 |
-
|
78 |
-
// Get an RGB(A) object based on the current color/opacity
|
79 |
-
case 'rgbObject':
|
80 |
-
return rgbObject($(this), method === 'rgbaObject');
|
81 |
-
|
82 |
-
// Get an RGB(A) string based on the current color/opacity
|
83 |
-
case 'rgbString':
|
84 |
-
case 'rgbaString':
|
85 |
-
return rgbString($(this), method === 'rgbaString');
|
86 |
-
|
87 |
-
// Get/set settings on the fly
|
88 |
-
case 'settings':
|
89 |
-
if(data === undefined) {
|
90 |
-
return $(this).data('minicolors-settings');
|
91 |
-
} else {
|
92 |
-
// Setter
|
93 |
-
$(this).each(function() {
|
94 |
-
var settings = $(this).data('minicolors-settings') || {};
|
95 |
destroy($(this));
|
96 |
-
$(this).minicolors($.extend(true, settings, data));
|
97 |
});
|
98 |
-
|
99 |
-
return $(this);
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
if(data === undefined) {
|
109 |
// Getter
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
}
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
});
|
126 |
-
}
|
127 |
-
return $(this);
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
|
137 |
}
|
138 |
|
@@ -143,9 +142,11 @@
|
|
143 |
function init(input, settings) {
|
144 |
var minicolors = $('<div class="minicolors" />');
|
145 |
var defaults = $.minicolors.defaults;
|
|
|
146 |
var size;
|
147 |
var swatches;
|
148 |
var swatch;
|
|
|
149 |
var panel;
|
150 |
var i;
|
151 |
|
@@ -157,8 +158,8 @@
|
|
157 |
|
158 |
// The wrapper
|
159 |
minicolors
|
160 |
-
|
161 |
-
|
162 |
|
163 |
// Custom positioning
|
164 |
if(settings.position !== undefined) {
|
@@ -176,32 +177,32 @@
|
|
176 |
|
177 |
// The input
|
178 |
input
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
|
199 |
// The swatch
|
200 |
if(!settings.inline) {
|
201 |
input.after('<span class="minicolors-swatch minicolors-sprite minicolors-input-swatch"><span class="minicolors-swatch-color"></span></span>');
|
202 |
input.next('.minicolors-input-swatch').on('click', function(event) {
|
203 |
event.preventDefault();
|
204 |
-
input.focus
|
205 |
});
|
206 |
}
|
207 |
|
@@ -213,18 +214,26 @@
|
|
213 |
if(settings.swatches && settings.swatches.length !== 0) {
|
214 |
panel.addClass('minicolors-with-swatches');
|
215 |
swatches = $('<ul class="minicolors-swatches"></ul>')
|
216 |
-
|
217 |
for(i = 0; i < settings.swatches.length; ++i) {
|
218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
swatch = isRgb(swatch) ? parseRgb(swatch, true) : hex2rgb(parseHex(swatch, true));
|
220 |
-
$('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></li>')
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
settings.swatches[i] = swatch;
|
229 |
}
|
230 |
}
|
@@ -269,11 +278,16 @@
|
|
269 |
hide();
|
270 |
|
271 |
minicolors.addClass('minicolors-focus');
|
272 |
-
panel
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
|
|
|
|
|
|
|
|
|
|
277 |
}
|
278 |
|
279 |
// Hides all dropdown panels
|
@@ -284,11 +298,16 @@
|
|
284 |
var panel = minicolors.find('.minicolors-panel');
|
285 |
var settings = input.data('minicolors-settings');
|
286 |
|
287 |
-
panel.
|
288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
minicolors.removeClass('minicolors-focus');
|
290 |
-
}
|
291 |
-
|
292 |
});
|
293 |
}
|
294 |
|
@@ -302,7 +321,7 @@
|
|
302 |
var x = Math.round(event.pageX - offsetX);
|
303 |
var y = Math.round(event.pageY - offsetY);
|
304 |
var duration = animate ? settings.animationSpeed : 0;
|
305 |
-
var wx, wy, r, phi;
|
306 |
|
307 |
// Touch support
|
308 |
if(event.originalEvent.changedTouches) {
|
@@ -333,23 +352,22 @@
|
|
333 |
}
|
334 |
|
335 |
// Move the picker
|
|
|
|
|
|
|
336 |
if(target.is('.minicolors-grid')) {
|
|
|
|
|
|
|
337 |
picker
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
}, duration, settings.animationEasing, function() {
|
343 |
-
updateFromControl(input, target);
|
344 |
-
});
|
345 |
} else {
|
346 |
picker
|
347 |
-
|
348 |
-
|
349 |
-
top: y + 'px'
|
350 |
-
}, duration, settings.animationEasing, function() {
|
351 |
-
updateFromControl(input, target);
|
352 |
-
});
|
353 |
}
|
354 |
}
|
355 |
|
@@ -397,77 +415,77 @@
|
|
397 |
|
398 |
// Determine HSB values
|
399 |
switch(settings.control) {
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
// Update UI
|
422 |
-
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
|
423 |
-
break;
|
424 |
-
|
425 |
-
case 'saturation':
|
426 |
-
// Calculate hue, saturation, and brightness
|
427 |
-
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
|
428 |
-
saturation = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
|
429 |
-
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
|
430 |
-
hex = hsb2hex({
|
431 |
-
h: hue,
|
432 |
-
s: saturation,
|
433 |
-
b: brightness
|
434 |
-
});
|
435 |
-
|
436 |
-
// Update UI
|
437 |
-
slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness }));
|
438 |
-
minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100);
|
439 |
-
break;
|
440 |
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
|
|
|
|
|
|
|
|
451 |
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
456 |
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
|
|
|
|
|
|
|
|
|
|
467 |
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
}
|
472 |
|
473 |
// Handle opacity
|
@@ -483,7 +501,7 @@
|
|
483 |
// Set swatch color
|
484 |
swatch.find('span').css({
|
485 |
backgroundColor: hex,
|
486 |
-
opacity: opacity
|
487 |
});
|
488 |
|
489 |
// Handle change event
|
@@ -542,7 +560,7 @@
|
|
542 |
// Set swatch color
|
543 |
swatch.find('span').css({
|
544 |
backgroundColor: value,
|
545 |
-
opacity: opacity
|
546 |
});
|
547 |
|
548 |
// Handle change event
|
@@ -606,7 +624,7 @@
|
|
606 |
opacity = input.attr('data-opacity') === '' ? 1 : keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2), 0, 1);
|
607 |
if(isNaN(opacity)) opacity = 1;
|
608 |
input.attr('data-opacity', opacity);
|
609 |
-
swatch.find('span').css('opacity', opacity);
|
610 |
|
611 |
// Set opacity picker position
|
612 |
y = keepWithin(opacitySlider.height() - (opacitySlider.height() * opacity), 0, opacitySlider.height());
|
@@ -615,7 +633,7 @@
|
|
615 |
|
616 |
// Set opacity to zero if input value is transparent
|
617 |
if(input.val().toLowerCase() === 'transparent') {
|
618 |
-
swatch.find('span').css('opacity', 0);
|
619 |
}
|
620 |
|
621 |
// Update swatch
|
@@ -623,78 +641,78 @@
|
|
623 |
|
624 |
// Determine picker locations
|
625 |
switch(settings.control) {
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
case 'saturation':
|
647 |
-
// Set grid position
|
648 |
-
x = keepWithin((5 * hsb.h) / 12, 0, 150);
|
649 |
-
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height());
|
650 |
-
gridPicker.css({
|
651 |
-
top: y + 'px',
|
652 |
-
left: x + 'px'
|
653 |
-
});
|
654 |
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
case 'brightness':
|
665 |
-
// Set grid position
|
666 |
-
x = keepWithin((5 * hsb.h) / 12, 0, 150);
|
667 |
-
y = keepWithin(grid.height() - Math.ceil(hsb.s / (100 / grid.height())), 0, grid.height());
|
668 |
-
gridPicker.css({
|
669 |
-
top: y + 'px',
|
670 |
-
left: x + 'px'
|
671 |
-
});
|
672 |
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
|
695 |
-
|
696 |
-
|
697 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
}
|
699 |
|
700 |
// Fire change event, but only if minicolors is fully initialized
|
@@ -815,13 +833,13 @@
|
|
815 |
rgba[0] = keepWithin(parseInt(rgba[0], 10), 0, 255);
|
816 |
rgba[1] = keepWithin(parseInt(rgba[1], 10), 0, 255);
|
817 |
rgba[2] = keepWithin(parseInt(rgba[2], 10), 0, 255);
|
818 |
-
if(rgba[3]) {
|
819 |
rgba[3] = keepWithin(parseFloat(rgba[3], 10), 0, 1);
|
820 |
}
|
821 |
|
822 |
// Return RGBA object
|
823 |
if( obj ) {
|
824 |
-
if (rgba[3]) {
|
825 |
return {
|
826 |
r: rgba[0],
|
827 |
g: rgba[1],
|
@@ -907,9 +925,9 @@
|
|
907 |
function rgbString2hex(rgb){
|
908 |
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
|
909 |
return (rgb && rgb.length === 4) ? '#' +
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
}
|
914 |
|
915 |
// Converts an RGB object to a hex string
|
@@ -1052,8 +1070,8 @@
|
|
1052 |
value = settings.defaultValue;
|
1053 |
} else if(settings.format === 'rgb') {
|
1054 |
value = settings.opacity ?
|
1055 |
-
|
1056 |
-
|
1057 |
} else {
|
1058 |
value = rgb2hex(rgba);
|
1059 |
}
|
@@ -1063,9 +1081,9 @@
|
|
1063 |
swatchOpacity = settings.opacity ? input.attr('data-opacity') : 1;
|
1064 |
if(value.toLowerCase() === 'transparent') swatchOpacity = 0;
|
1065 |
input
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
|
1070 |
// Set input value
|
1071 |
input.val(value);
|
@@ -1081,15 +1099,15 @@
|
|
1081 |
.on('keydown.minicolors', '.minicolors-input', function(event) {
|
1082 |
var input = $(this);
|
1083 |
if(!input.data('minicolors-initialized')) return;
|
1084 |
-
switch(event.
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
}
|
1094 |
})
|
1095 |
// Update on keyup
|
1 |
+
//
|
|
|
2 |
// jQuery MiniColors: A tiny color picker built on jQuery
|
3 |
//
|
4 |
// Developed by Cory LaViska for A Beautiful Site, LLC
|
35 |
keywords: '',
|
36 |
letterCase: 'lowercase',
|
37 |
opacity: false,
|
38 |
+
position: 'bottom',
|
39 |
show: null,
|
40 |
showSpeed: 100,
|
41 |
theme: 'default',
|
48 |
minicolors: function(method, data) {
|
49 |
|
50 |
switch(method) {
|
51 |
+
// Destroy the control
|
52 |
+
case 'destroy':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
$(this).each(function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
destroy($(this));
|
|
|
55 |
});
|
56 |
+
return $(this);
|
|
|
57 |
|
58 |
+
// Hide the color picker
|
59 |
+
case 'hide':
|
60 |
+
hide();
|
61 |
+
return $(this);
|
62 |
|
63 |
+
// Get/set opacity
|
64 |
+
case 'opacity':
|
|
|
65 |
// Getter
|
66 |
+
if(data === undefined) {
|
67 |
+
// Getter
|
68 |
+
return $(this).attr('data-opacity');
|
69 |
+
} else {
|
70 |
+
// Setter
|
71 |
+
$(this).each(function() {
|
72 |
+
updateFromInput($(this).attr('data-opacity', data));
|
73 |
+
});
|
74 |
+
}
|
75 |
+
return $(this);
|
76 |
+
|
77 |
+
// Get an RGB(A) object based on the current color/opacity
|
78 |
+
case 'rgbObject':
|
79 |
+
return rgbObject($(this), method === 'rgbaObject');
|
80 |
+
|
81 |
+
// Get an RGB(A) string based on the current color/opacity
|
82 |
+
case 'rgbString':
|
83 |
+
case 'rgbaString':
|
84 |
+
return rgbString($(this), method === 'rgbaString');
|
85 |
+
|
86 |
+
// Get/set settings on the fly
|
87 |
+
case 'settings':
|
88 |
+
if(data === undefined) {
|
89 |
+
return $(this).data('minicolors-settings');
|
90 |
+
} else {
|
91 |
+
// Setter
|
92 |
+
$(this).each(function() {
|
93 |
+
var settings = $(this).data('minicolors-settings') || {};
|
94 |
+
destroy($(this));
|
95 |
+
$(this).minicolors($.extend(true, settings, data));
|
96 |
+
});
|
97 |
+
}
|
98 |
+
return $(this);
|
99 |
+
|
100 |
+
// Show the color picker
|
101 |
+
case 'show':
|
102 |
+
show($(this).eq(0));
|
103 |
+
return $(this);
|
104 |
+
|
105 |
+
// Get/set the hex color value
|
106 |
+
case 'value':
|
107 |
+
if(data === undefined) {
|
108 |
+
// Getter
|
109 |
+
return $(this).val();
|
110 |
+
} else {
|
111 |
+
// Setter
|
112 |
+
$(this).each(function() {
|
113 |
+
if(typeof(data) === 'object' && data !== null) {
|
114 |
+
if(data.opacity !== undefined) {
|
115 |
+
$(this).attr('data-opacity', keepWithin(data.opacity, 0, 1));
|
116 |
+
}
|
117 |
+
if(data.color) {
|
118 |
+
$(this).val(data.color);
|
119 |
+
}
|
120 |
+
} else {
|
121 |
+
$(this).val(data);
|
122 |
}
|
123 |
+
updateFromInput($(this));
|
124 |
+
});
|
125 |
+
}
|
126 |
+
return $(this);
|
|
|
|
|
|
|
127 |
|
128 |
+
// Initializes the control
|
129 |
+
default:
|
130 |
+
if(method !== 'create') data = method;
|
131 |
+
$(this).each(function() {
|
132 |
+
init($(this), data);
|
133 |
+
});
|
134 |
+
return $(this);
|
135 |
|
136 |
}
|
137 |
|
142 |
function init(input, settings) {
|
143 |
var minicolors = $('<div class="minicolors" />');
|
144 |
var defaults = $.minicolors.defaults;
|
145 |
+
var name;
|
146 |
var size;
|
147 |
var swatches;
|
148 |
var swatch;
|
149 |
+
var swatchString;
|
150 |
var panel;
|
151 |
var i;
|
152 |
|
158 |
|
159 |
// The wrapper
|
160 |
minicolors
|
161 |
+
.addClass('minicolors-theme-' + settings.theme)
|
162 |
+
.toggleClass('minicolors-with-opacity', settings.opacity);
|
163 |
|
164 |
// Custom positioning
|
165 |
if(settings.position !== undefined) {
|
177 |
|
178 |
// The input
|
179 |
input
|
180 |
+
.addClass('minicolors-input')
|
181 |
+
.data('minicolors-initialized', false)
|
182 |
+
.data('minicolors-settings', settings)
|
183 |
+
.prop('size', size)
|
184 |
+
.wrap(minicolors)
|
185 |
+
.after(
|
186 |
+
'<div class="minicolors-panel minicolors-slider-' + settings.control + '">' +
|
187 |
+
'<div class="minicolors-slider minicolors-sprite">' +
|
188 |
+
'<div class="minicolors-picker"></div>' +
|
189 |
+
'</div>' +
|
190 |
+
'<div class="minicolors-opacity-slider minicolors-sprite">' +
|
191 |
+
'<div class="minicolors-picker"></div>' +
|
192 |
+
'</div>' +
|
193 |
+
'<div class="minicolors-grid minicolors-sprite">' +
|
194 |
+
'<div class="minicolors-grid-inner"></div>' +
|
195 |
+
'<div class="minicolors-picker"><div></div></div>' +
|
196 |
+
'</div>' +
|
197 |
+
'</div>'
|
198 |
+
);
|
199 |
|
200 |
// The swatch
|
201 |
if(!settings.inline) {
|
202 |
input.after('<span class="minicolors-swatch minicolors-sprite minicolors-input-swatch"><span class="minicolors-swatch-color"></span></span>');
|
203 |
input.next('.minicolors-input-swatch').on('click', function(event) {
|
204 |
event.preventDefault();
|
205 |
+
input.trigger('focus');
|
206 |
});
|
207 |
}
|
208 |
|
214 |
if(settings.swatches && settings.swatches.length !== 0) {
|
215 |
panel.addClass('minicolors-with-swatches');
|
216 |
swatches = $('<ul class="minicolors-swatches"></ul>')
|
217 |
+
.appendTo(panel);
|
218 |
for(i = 0; i < settings.swatches.length; ++i) {
|
219 |
+
// allow for custom objects as swatches
|
220 |
+
if($.type(settings.swatches[i]) === 'object') {
|
221 |
+
name = settings.swatches[i].name;
|
222 |
+
swatch = settings.swatches[i].color;
|
223 |
+
} else {
|
224 |
+
name = '';
|
225 |
+
swatch = settings.swatches[i];
|
226 |
+
}
|
227 |
+
swatchString = swatch;
|
228 |
swatch = isRgb(swatch) ? parseRgb(swatch, true) : hex2rgb(parseHex(swatch, true));
|
229 |
+
$('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color" title="' + name + '"></span></li>')
|
230 |
+
.appendTo(swatches)
|
231 |
+
.data('swatch-color', swatchString)
|
232 |
+
.find('.minicolors-swatch-color')
|
233 |
+
.css({
|
234 |
+
backgroundColor: rgb2hex(swatch),
|
235 |
+
opacity: String(swatch.a)
|
236 |
+
});
|
237 |
settings.swatches[i] = swatch;
|
238 |
}
|
239 |
}
|
278 |
hide();
|
279 |
|
280 |
minicolors.addClass('minicolors-focus');
|
281 |
+
if (panel.animate) {
|
282 |
+
panel
|
283 |
+
.stop(true, true)
|
284 |
+
.fadeIn(settings.showSpeed, function () {
|
285 |
+
if (settings.show) settings.show.call(input.get(0));
|
286 |
+
});
|
287 |
+
} else {
|
288 |
+
panel.show();
|
289 |
+
if (settings.show) settings.show.call(input.get(0));
|
290 |
+
}
|
291 |
}
|
292 |
|
293 |
// Hides all dropdown panels
|
298 |
var panel = minicolors.find('.minicolors-panel');
|
299 |
var settings = input.data('minicolors-settings');
|
300 |
|
301 |
+
if (panel.animate) {
|
302 |
+
panel.fadeOut(settings.hideSpeed, function () {
|
303 |
+
if (settings.hide) settings.hide.call(input.get(0));
|
304 |
+
minicolors.removeClass('minicolors-focus');
|
305 |
+
});
|
306 |
+
} else {
|
307 |
+
panel.hide();
|
308 |
+
if (settings.hide) settings.hide.call(input.get(0));
|
309 |
minicolors.removeClass('minicolors-focus');
|
310 |
+
}
|
|
|
311 |
});
|
312 |
}
|
313 |
|
321 |
var x = Math.round(event.pageX - offsetX);
|
322 |
var y = Math.round(event.pageY - offsetY);
|
323 |
var duration = animate ? settings.animationSpeed : 0;
|
324 |
+
var wx, wy, r, phi, styles;
|
325 |
|
326 |
// Touch support
|
327 |
if(event.originalEvent.changedTouches) {
|
352 |
}
|
353 |
|
354 |
// Move the picker
|
355 |
+
styles = {
|
356 |
+
top: y + 'px'
|
357 |
+
};
|
358 |
if(target.is('.minicolors-grid')) {
|
359 |
+
styles.left = x + 'px';
|
360 |
+
}
|
361 |
+
if (picker.animate) {
|
362 |
picker
|
363 |
+
.stop(true)
|
364 |
+
.animate(styles, duration, settings.animationEasing, function() {
|
365 |
+
updateFromControl(input, target);
|
366 |
+
});
|
|
|
|
|
|
|
367 |
} else {
|
368 |
picker
|
369 |
+
.css(styles);
|
370 |
+
updateFromControl(input, target);
|
|
|
|
|
|
|
|
|
371 |
}
|
372 |
}
|
373 |
|
415 |
|
416 |
// Determine HSB values
|
417 |
switch(settings.control) {
|
418 |
+
case 'wheel':
|
419 |
+
// Calculate hue, saturation, and brightness
|
420 |
+
x = (grid.width() / 2) - gridPos.x;
|
421 |
+
y = (grid.height() / 2) - gridPos.y;
|
422 |
+
r = Math.sqrt(x * x + y * y);
|
423 |
+
phi = Math.atan2(y, x);
|
424 |
+
if(phi < 0) phi += Math.PI * 2;
|
425 |
+
if(r > 75) {
|
426 |
+
r = 75;
|
427 |
+
gridPos.x = 69 - (75 * Math.cos(phi));
|
428 |
+
gridPos.y = 69 - (75 * Math.sin(phi));
|
429 |
+
}
|
430 |
+
saturation = keepWithin(r / 0.75, 0, 100);
|
431 |
+
hue = keepWithin(phi * 180 / Math.PI, 0, 360);
|
432 |
+
brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
|
433 |
+
hex = hsb2hex({
|
434 |
+
h: hue,
|
435 |
+
s: saturation,
|
436 |
+
b: brightness
|
437 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
|
439 |
+
// Update UI
|
440 |
+
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
|
441 |
+
break;
|
442 |
+
|
443 |
+
case 'saturation':
|
444 |
+
// Calculate hue, saturation, and brightness
|
445 |
+
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
|
446 |
+
saturation = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
|
447 |
+
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
|
448 |
+
hex = hsb2hex({
|
449 |
+
h: hue,
|
450 |
+
s: saturation,
|
451 |
+
b: brightness
|
452 |
+
});
|
453 |
|
454 |
+
// Update UI
|
455 |
+
slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness }));
|
456 |
+
minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100);
|
457 |
+
break;
|
458 |
+
|
459 |
+
case 'brightness':
|
460 |
+
// Calculate hue, saturation, and brightness
|
461 |
+
hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
|
462 |
+
saturation = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
|
463 |
+
brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
|
464 |
+
hex = hsb2hex({
|
465 |
+
h: hue,
|
466 |
+
s: saturation,
|
467 |
+
b: brightness
|
468 |
+
});
|
469 |
|
470 |
+
// Update UI
|
471 |
+
slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
|
472 |
+
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (brightness / 100));
|
473 |
+
break;
|
474 |
+
|
475 |
+
default:
|
476 |
+
// Calculate hue, saturation, and brightness
|
477 |
+
hue = keepWithin(360 - parseInt(sliderPos.y * (360 / slider.height()), 10), 0, 360);
|
478 |
+
saturation = keepWithin(Math.floor(gridPos.x * (100 / grid.width())), 0, 100);
|
479 |
+
brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
|
480 |
+
hex = hsb2hex({
|
481 |
+
h: hue,
|
482 |
+
s: saturation,
|
483 |
+
b: brightness
|
484 |
+
});
|
485 |
|
486 |
+
// Update UI
|
487 |
+
grid.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: 100 }));
|
488 |
+
break;
|
489 |
}
|
490 |
|
491 |
// Handle opacity
|
501 |
// Set swatch color
|
502 |
swatch.find('span').css({
|
503 |
backgroundColor: hex,
|
504 |
+
opacity: String(opacity)
|
505 |
});
|
506 |
|
507 |
// Handle change event
|
560 |
// Set swatch color
|
561 |
swatch.find('span').css({
|
562 |
backgroundColor: value,
|
563 |
+
opacity: String(opacity)
|
564 |
});
|
565 |
|
566 |
// Handle change event
|
624 |
opacity = input.attr('data-opacity') === '' ? 1 : keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2), 0, 1);
|
625 |
if(isNaN(opacity)) opacity = 1;
|
626 |
input.attr('data-opacity', opacity);
|
627 |
+
swatch.find('span').css('opacity', String(opacity));
|
628 |
|
629 |
// Set opacity picker position
|
630 |
y = keepWithin(opacitySlider.height() - (opacitySlider.height() * opacity), 0, opacitySlider.height());
|
633 |
|
634 |
// Set opacity to zero if input value is transparent
|
635 |
if(input.val().toLowerCase() === 'transparent') {
|
636 |
+
swatch.find('span').css('opacity', String(0));
|
637 |
}
|
638 |
|
639 |
// Update swatch
|
641 |
|
642 |
// Determine picker locations
|
643 |
switch(settings.control) {
|
644 |
+
case 'wheel':
|
645 |
+
// Set grid position
|
646 |
+
r = keepWithin(Math.ceil(hsb.s * 0.75), 0, grid.height() / 2);
|
647 |
+
phi = hsb.h * Math.PI / 180;
|
648 |
+
x = keepWithin(75 - Math.cos(phi) * r, 0, grid.width());
|
649 |
+
y = keepWithin(75 - Math.sin(phi) * r, 0, grid.height());
|
650 |
+
gridPicker.css({
|
651 |
+
top: y + 'px',
|
652 |
+
left: x + 'px'
|
653 |
+
});
|
654 |
|
655 |
+
// Set slider position
|
656 |
+
y = 150 - (hsb.b / (100 / grid.height()));
|
657 |
+
if(hex === '') y = 0;
|
658 |
+
sliderPicker.css('top', y + 'px');
|
659 |
+
|
660 |
+
// Update panel color
|
661 |
+
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 }));
|
662 |
+
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
663 |
|
664 |
+
case 'saturation':
|
665 |
+
// Set grid position
|
666 |
+
x = keepWithin((5 * hsb.h) / 12, 0, 150);
|
667 |
+
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height());
|
668 |
+
gridPicker.css({
|
669 |
+
top: y + 'px',
|
670 |
+
left: x + 'px'
|
671 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
672 |
|
673 |
+
// Set slider position
|
674 |
+
y = keepWithin(slider.height() - (hsb.s * (slider.height() / 100)), 0, slider.height());
|
675 |
+
sliderPicker.css('top', y + 'px');
|
676 |
+
|
677 |
+
// Update UI
|
678 |
+
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: hsb.b }));
|
679 |
+
minicolors.find('.minicolors-grid-inner').css('opacity', hsb.s / 100);
|
680 |
+
break;
|
681 |
+
|
682 |
+
case 'brightness':
|
683 |
+
// Set grid position
|
684 |
+
x = keepWithin((5 * hsb.h) / 12, 0, 150);
|
685 |
+
y = keepWithin(grid.height() - Math.ceil(hsb.s / (100 / grid.height())), 0, grid.height());
|
686 |
+
gridPicker.css({
|
687 |
+
top: y + 'px',
|
688 |
+
left: x + 'px'
|
689 |
+
});
|
690 |
|
691 |
+
// Set slider position
|
692 |
+
y = keepWithin(slider.height() - (hsb.b * (slider.height() / 100)), 0, slider.height());
|
693 |
+
sliderPicker.css('top', y + 'px');
|
694 |
|
695 |
+
// Update UI
|
696 |
+
slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 }));
|
697 |
+
minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (hsb.b / 100));
|
698 |
+
break;
|
699 |
+
|
700 |
+
default:
|
701 |
+
// Set grid position
|
702 |
+
x = keepWithin(Math.ceil(hsb.s / (100 / grid.width())), 0, grid.width());
|
703 |
+
y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height());
|
704 |
+
gridPicker.css({
|
705 |
+
top: y + 'px',
|
706 |
+
left: x + 'px'
|
707 |
+
});
|
708 |
+
|
709 |
+
// Set slider position
|
710 |
+
y = keepWithin(slider.height() - (hsb.h / (360 / slider.height())), 0, slider.height());
|
711 |
+
sliderPicker.css('top', y + 'px');
|
712 |
+
|
713 |
+
// Update panel color
|
714 |
+
grid.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: 100 }));
|
715 |
+
break;
|
716 |
}
|
717 |
|
718 |
// Fire change event, but only if minicolors is fully initialized
|
833 |
rgba[0] = keepWithin(parseInt(rgba[0], 10), 0, 255);
|
834 |
rgba[1] = keepWithin(parseInt(rgba[1], 10), 0, 255);
|
835 |
rgba[2] = keepWithin(parseInt(rgba[2], 10), 0, 255);
|
836 |
+
if(rgba[3] !== undefined) {
|
837 |
rgba[3] = keepWithin(parseFloat(rgba[3], 10), 0, 1);
|
838 |
}
|
839 |
|
840 |
// Return RGBA object
|
841 |
if( obj ) {
|
842 |
+
if (rgba[3] !== undefined) {
|
843 |
return {
|
844 |
r: rgba[0],
|
845 |
g: rgba[1],
|
925 |
function rgbString2hex(rgb){
|
926 |
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
|
927 |
return (rgb && rgb.length === 4) ? '#' +
|
928 |
+
('0' + parseInt(rgb[1],10).toString(16)).slice(-2) +
|
929 |
+
('0' + parseInt(rgb[2],10).toString(16)).slice(-2) +
|
930 |
+
('0' + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
|
931 |
}
|
932 |
|
933 |
// Converts an RGB object to a hex string
|
1070 |
value = settings.defaultValue;
|
1071 |
} else if(settings.format === 'rgb') {
|
1072 |
value = settings.opacity ?
|
1073 |
+
parseRgb('rgba(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ',' + input.attr('data-opacity') + ')') :
|
1074 |
+
parseRgb('rgb(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ')');
|
1075 |
} else {
|
1076 |
value = rgb2hex(rgba);
|
1077 |
}
|
1081 |
swatchOpacity = settings.opacity ? input.attr('data-opacity') : 1;
|
1082 |
if(value.toLowerCase() === 'transparent') swatchOpacity = 0;
|
1083 |
input
|
1084 |
+
.closest('.minicolors')
|
1085 |
+
.find('.minicolors-input-swatch > span')
|
1086 |
+
.css('opacity', String(swatchOpacity));
|
1087 |
|
1088 |
// Set input value
|
1089 |
input.val(value);
|
1099 |
.on('keydown.minicolors', '.minicolors-input', function(event) {
|
1100 |
var input = $(this);
|
1101 |
if(!input.data('minicolors-initialized')) return;
|
1102 |
+
switch(event.which) {
|
1103 |
+
case 9: // tab
|
1104 |
+
hide();
|
1105 |
+
break;
|
1106 |
+
case 13: // enter
|
1107 |
+
case 27: // esc
|
1108 |
+
hide();
|
1109 |
+
input.blur();
|
1110 |
+
break;
|
1111 |
}
|
1112 |
})
|
1113 |
// Update on keyup
|
assets/js/jquery.minicolors.min.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
// jscs:disable
|
2 |
//
|
3 |
// jQuery MiniColors: A tiny color picker built on jQuery
|
4 |
//
|
@@ -6,4 +5,4 @@
|
|
6 |
//
|
7 |
// Licensed under the MIT license: http://opensource.org/licenses/MIT
|
8 |
//
|
9 |
-
!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,r,e,l=i('<div class="minicolors" />'),h=i.minicolors.defaults;if(!t.data("minicolors-initialized")){if(o=i.extend(!0,{},h,o),l.addClass("minicolors-theme-"+o.theme).toggleClass("minicolors-with-opacity",o.opacity),void 0!==o.position&&i.each(o.position.split(" "),function(){l.addClass("minicolors-position-"+this)}),s="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",s).wrap(l).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()})),r=t.parent().find(".minicolors-panel"),r.on("selectstart",function(){return!1}).end(),o.swatches&&0!==o.swatches.length)for(r.addClass("minicolors-with-swatches"),a=i('<ul class="minicolors-swatches"></ul>').appendTo(r),e=0;e<o.swatches.length;++e)n=o.swatches[e],n=v(n)?g(n,!0):I(u(n,!0)),i('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></li>').appendTo(a).data("swatch-color",o.swatches[e]).find(".minicolors-swatch-color").css({backgroundColor:C(n),opacity:n.a}),o.swatches[e]=n;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.stop(!0,!0).fadeIn(s.showSpeed,function(){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.fadeOut(a.hideSpeed,function(){a.hide&&a.hide.call(o.get(0)),t.removeClass("minicolors-focus")})})}function n(i,t,o){var s,a,n,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),e=Math.atan2(a,s),e<0&&(e+=2*Math.PI),n>75&&(n=75,u=75-75*Math.cos(e),g=75-75*Math.sin(e)),u=Math.round(u),g=Math.round(g)),i.is(".minicolors-grid")?h.stop(!0).animate({top:g+"px",left:u+"px"},m,l.animationEasing,function(){r(c,i)}):h.stop(!0).animate({top:g+"px"},m,l.animationEasing,function(){r(c,i)})}function r(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,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":r=b.width()/2-I.x,c=b.height()/2-I.y,h=Math.sqrt(r*r+c*c),d=Math.atan2(c,r),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,e(i,p,u)}else v.find("span").css({backgroundColor:p,opacity:u}),l(i,p,u)}function e(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),"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),r.find("span").css({backgroundColor:t,opacity:o}),l(i,t,o)}function c(t,o){var s,a,n,r,e,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"),D=z.find("[class$=-picker]"),j=F.find("[class$=-picker]"),q=T.find("[class$=-picker]");switch(v(t.val())?(s=y(t.val()),e=f(parseFloat(b(t.val())).toFixed(2),0,1),e&&t.attr("data-opacity",e)):s=p(u(t.val(),!0),I.letterCase),s||(s=p(m(I.defaultValue,!0),I.letterCase)),a=M(s),r=I.keywords?i.map(I.keywords.split(","),function(t){return i.trim(t.toLowerCase())}):[],c=""!==t.val()&&i.inArray(t.val().toLowerCase(),r)>-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()),D.css({top:d+"px",left:h+"px"}),d=150-a.b/(100/z.height()),""===s&&(d=0),j.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()),D.css({top:d+"px",left:h+"px"}),d=f(F.height()-a.s*(F.height()/100),0,F.height()),j.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()),D.css({top:d+"px",left:h+"px"}),d=f(F.height()-a.b*(F.height()/100),0,F.height()),j.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()),D.css({top:d+"px",left:h+"px"}),d=f(F.height()-a.h/(360/F.height()),0,F.height()),j.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,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=v(t)?g(t,!0):I(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"),a!==-1&&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 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),s[3]&&(s[3]=f(parseFloat(s[3],10),0,1)),t?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,r=(255-s)*a/255,e=(n-r)*(o%60)/60;360===o&&(o=0),o<60?(t.r=n,t.b=r,t.g=r+e):o<120?(t.g=n,t.b=r,t.r=n-e):o<180?(t.g=n,t.r=r,t.b=r+e):o<240?(t.b=n,t.r=r,t.g=n-e):o<300?(t.b=n,t.g=r,t.r=r+e):o<360?(t.r=n,t.g=r,t.b=n-e):(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 left",show:null,showSpeed:100,theme:"default",swatches:[]}},i.extend(i.fn,{minicolors:function(n,r){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===r?i(this).attr("data-opacity"):(i(this).each(function(){c(i(this).attr("data-opacity",r))}),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===r?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,r))}),i(this));case"show":return s(i(this).eq(0)),i(this);case"value":return void 0===r?i(this).val():(i(this).each(function(){"object"==typeof r&&null!==r?(r.opacity&&i(this).attr("data-opacity",f(r.opacity,0,1)),r.color&&i(this).val(r.color)):i(this).val(r),c(i(this))}),i(this));default:return"create"!==n&&(r=n),i(this).each(function(){t(i(this),r)}),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");e(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,r=i(this),e=r.data("minicolors-settings");r.data("minicolors-initialized")&&(t=e.keywords?i.map(e.keywords.split(","),function(t){return i.trim(t.toLowerCase())}):[],""!==r.val()&&i.inArray(r.val().toLowerCase(),t)>-1?n=r.val():(v(r.val())?s=g(r.val(),!0):(o=u(r.val(),!0),s=o?I(o):null),n=null===s?e.defaultValue:"rgb"===e.format?g(e.opacity?"rgba("+s.r+","+s.g+","+s.b+","+r.attr("data-opacity")+")":"rgb("+s.r+","+s.g+","+s.b+")"):C(s)),a=e.opacity?r.attr("data-opacity"):1,"transparent"===n.toLowerCase()&&(a=0),r.closest(".minicolors").find(".minicolors-input-swatch > span").css("opacity",a),r.val(n),""===r.val()&&r.val(m(e.defaultValue,!0)),r.val(p(r.val(),e.letterCase)))}).on("keydown.minicolors",".minicolors-input",function(t){var o=i(this);if(o.data("minicolors-initialized"))switch(t.keyCode){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)})});
|
|
|
1 |
//
|
2 |
// jQuery MiniColors: A tiny color picker built on jQuery
|
3 |
//
|
5 |
//
|
6 |
// Licensed under the MIT license: http://opensource.org/licenses/MIT
|
7 |
//
|
8 |
+
!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)})});
|
colorlib-login-customizer.php
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Colorlib Login Customizer
|
4 |
-
* Version: 1.2.
|
5 |
* Description: Colorlib Login Customizer is an awesome and intuitive plugin that helps you personalize your login form directly from the Customizer. The plugin fully supports the Live Customizer feature and you can see all the changes in real time and edit them.
|
6 |
* Author: Colorlib
|
7 |
* Author URI: https://colorlib.com/
|
8 |
-
* Tested up to: 5.
|
9 |
* Requires: 4.6 or higher
|
10 |
* License: GPLv3 or later
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -48,7 +48,7 @@ require_once 'includes/class-colorlib-login-customizer-backwards-compatibility.p
|
|
48 |
* @return object Colorlib_Login_Customizer
|
49 |
*/
|
50 |
function colorlib_login_customizer() {
|
51 |
-
$instance = Colorlib_Login_Customizer::instance( __FILE__, '1.2.
|
52 |
|
53 |
if (is_null($instance->settings)) {
|
54 |
$instance->settings = Colorlib_Login_Customizer_Settings::instance($instance);
|
1 |
<?php
|
2 |
/**
|
3 |
* Plugin Name: Colorlib Login Customizer
|
4 |
+
* Version: 1.2.98
|
5 |
* Description: Colorlib Login Customizer is an awesome and intuitive plugin that helps you personalize your login form directly from the Customizer. The plugin fully supports the Live Customizer feature and you can see all the changes in real time and edit them.
|
6 |
* Author: Colorlib
|
7 |
* Author URI: https://colorlib.com/
|
8 |
+
* Tested up to: 5.6
|
9 |
* Requires: 4.6 or higher
|
10 |
* License: GPLv3 or later
|
11 |
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
48 |
* @return object Colorlib_Login_Customizer
|
49 |
*/
|
50 |
function colorlib_login_customizer() {
|
51 |
+
$instance = Colorlib_Login_Customizer::instance( __FILE__, '1.2.98' );
|
52 |
|
53 |
if (is_null($instance->settings)) {
|
54 |
$instance->settings = Colorlib_Login_Customizer_Settings::instance($instance);
|
languages/colorlib-login-customizer.po
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
# Copyright (C)
|
2 |
# This file is distributed under the GPLv3 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: Colorlib Login Customizer 1.2.
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/colorlib-login-customizer\n"
|
8 |
-
"POT-Creation-Date:
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
-
"PO-Revision-Date:
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"Language: en\n"
|
1 |
+
# Copyright (C) 2021 Colorlib
|
2 |
# This file is distributed under the GPLv3 or later.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: Colorlib Login Customizer 1.2.98\n"
|
6 |
"Report-Msgid-Bugs-To: "
|
7 |
"https://wordpress.org/support/plugin/colorlib-login-customizer\n"
|
8 |
+
"POT-Creation-Date: 2021-01-21 11:52:07+00:00\n"
|
9 |
"MIME-Version: 1.0\n"
|
10 |
"Content-Type: text/plain; charset=utf-8\n"
|
11 |
"Content-Transfer-Encoding: 8bit\n"
|
12 |
+
"PO-Revision-Date: 2021-MO-DA HO:MI+ZONE\n"
|
13 |
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14 |
"Language-Team: LANGUAGE <LL@li.org>\n"
|
15 |
"Language: en\n"
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: silkalns
|
3 |
Tags: customize login, login, custom login, customize wordpress login, wordpress login, customizer, custom admin, login logo, logo, login customizer, custom wp-login
|
4 |
Requires at least: 4.7
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 1.2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
@@ -93,6 +93,9 @@ If you enjoy using Colorlib Login Customizer for WordPress please leave a [posit
|
|
93 |
|
94 |
== Changelog ==
|
95 |
|
|
|
|
|
|
|
96 |
= 1.2.97 =
|
97 |
* Hide logo settings if hide logo is toggled on
|
98 |
* Add option to use both image logo and text
|
2 |
Contributors: silkalns
|
3 |
Tags: customize login, login, custom login, customize wordpress login, wordpress login, customizer, custom admin, login logo, logo, login customizer, custom wp-login
|
4 |
Requires at least: 4.7
|
5 |
+
Tested up to: 5.6
|
6 |
+
Stable tag: 1.2.98
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
9 |
|
93 |
|
94 |
== Changelog ==
|
95 |
|
96 |
+
= 1.2.98 =
|
97 |
+
* Compatibility with jQuery 3.0
|
98 |
+
|
99 |
= 1.2.97 =
|
100 |
* Hide logo settings if hide logo is toggled on
|
101 |
* Add option to use both image logo and text
|