yh-hiprint 2.2.10 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/HiprintDesigner.vue +5 -5
  2. package/column-field.js +4 -6
  3. package/designer.vue +4 -4
  4. package/font-size.js +3 -4
  5. package/index.js +3 -4
  6. package/libs/hiprint.bundle.js +1325 -1328
  7. package/libs/jquery.js +10620 -0
  8. package/libs/jsbarcode/JsBarcode.js +251 -0
  9. package/libs/jsbarcode/barcodes/Barcode.js +17 -0
  10. package/libs/jsbarcode/barcodes/CODE128/CODE128.js +167 -0
  11. package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +42 -0
  12. package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +42 -0
  13. package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +42 -0
  14. package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +41 -0
  15. package/libs/jsbarcode/barcodes/CODE128/auto.js +73 -0
  16. package/libs/jsbarcode/barcodes/CODE128/constants.js +54 -0
  17. package/libs/jsbarcode/barcodes/CODE128/index.js +29 -0
  18. package/libs/jsbarcode/barcodes/CODE39/index.js +105 -0
  19. package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +92 -0
  20. package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +119 -0
  21. package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +58 -0
  22. package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +65 -0
  23. package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +81 -0
  24. package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +165 -0
  25. package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +185 -0
  26. package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +30 -0
  27. package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +27 -0
  28. package/libs/jsbarcode/barcodes/EAN_UPC/index.js +39 -0
  29. package/libs/jsbarcode/barcodes/GenericBarcode/index.js +55 -0
  30. package/libs/jsbarcode/barcodes/ITF/ITF.js +69 -0
  31. package/libs/jsbarcode/barcodes/ITF/ITF14.js +55 -0
  32. package/libs/jsbarcode/barcodes/ITF/constants.js +9 -0
  33. package/libs/jsbarcode/barcodes/ITF/index.js +19 -0
  34. package/libs/jsbarcode/barcodes/MSI/MSI.js +74 -0
  35. package/libs/jsbarcode/barcodes/MSI/MSI10.js +33 -0
  36. package/libs/jsbarcode/barcodes/MSI/MSI1010.js +35 -0
  37. package/libs/jsbarcode/barcodes/MSI/MSI11.js +33 -0
  38. package/libs/jsbarcode/barcodes/MSI/MSI1110.js +35 -0
  39. package/libs/jsbarcode/barcodes/MSI/checksums.js +29 -0
  40. package/libs/jsbarcode/barcodes/MSI/index.js +34 -0
  41. package/libs/jsbarcode/barcodes/codabar/index.js +92 -0
  42. package/libs/jsbarcode/barcodes/index.js +33 -0
  43. package/libs/jsbarcode/barcodes/index.tmp.js +33 -0
  44. package/libs/jsbarcode/barcodes/pharmacode/index.js +73 -0
  45. package/libs/jsbarcode/exceptions/ErrorHandler.js +54 -0
  46. package/libs/jsbarcode/exceptions/exceptions.js +67 -0
  47. package/libs/jsbarcode/help/fixOptions.js +17 -0
  48. package/libs/jsbarcode/help/getOptionsFromElement.js +41 -0
  49. package/libs/jsbarcode/help/getRenderProperties.js +108 -0
  50. package/libs/jsbarcode/help/linearizeEncodings.js +27 -0
  51. package/libs/jsbarcode/help/merge.js +11 -0
  52. package/libs/jsbarcode/help/optionsFromStrings.js +27 -0
  53. package/libs/jsbarcode/options/defaults.js +28 -0
  54. package/libs/jsbarcode/renderers/canvas.js +158 -0
  55. package/libs/jsbarcode/renderers/index.js +21 -0
  56. package/libs/jsbarcode/renderers/object.js +30 -0
  57. package/libs/jsbarcode/renderers/shared.js +101 -0
  58. package/libs/jsbarcode/renderers/svg.js +189 -0
  59. package/libs/plugins/jquery.hiwprint.js +13 -14
  60. package/libs/plugins/jquery.minicolors.js +1114 -0
  61. package/package.json +1 -4
@@ -0,0 +1,1114 @@
1
+ //
2
+ // jQuery MiniColors: A tiny color picker built on jQuery
3
+ //
4
+ // Developed by Cory LaViska for A Beautiful Site, LLC
5
+ //
6
+ // Licensed under the MIT license: http://opensource.org/licenses/MIT
7
+ //
8
+
9
+ // Defaults
10
+ hiprintJQuery.minicolors = {
11
+ defaults: {
12
+ animationSpeed: 50,
13
+ animationEasing: 'swing',
14
+ change: null,
15
+ changeDelay: 0,
16
+ control: 'hue',
17
+ defaultValue: '',
18
+ format: 'hex',
19
+ hide: null,
20
+ hideSpeed: 100,
21
+ inline: false,
22
+ keywords: '',
23
+ letterCase: 'lowercase',
24
+ opacity: false,
25
+ position: 'bottom',
26
+ show: null,
27
+ showSpeed: 100,
28
+ theme: 'default',
29
+ swatches: []
30
+ }
31
+ };
32
+
33
+ // Public methods
34
+ hiprintJQuery.extend(hiprintJQuery.fn, {
35
+ minicolors: function (method, data) {
36
+
37
+ switch (method) {
38
+ // Destroy the control
39
+ case 'destroy':
40
+ hiprintJQuery(this).each(function () {
41
+ destroy(hiprintJQuery(this));
42
+ });
43
+ return hiprintJQuery(this);
44
+
45
+ // Hide the color picker
46
+ case 'hide':
47
+ hide();
48
+ return hiprintJQuery(this);
49
+
50
+ // Get/set opacity
51
+ case 'opacity':
52
+ // Getter
53
+ if (data === undefined) {
54
+ // Getter
55
+ return hiprintJQuery(this).attr('data-opacity');
56
+ } else {
57
+ // Setter
58
+ hiprintJQuery(this).each(function () {
59
+ updateFromInput(hiprintJQuery(this).attr('data-opacity', data));
60
+ });
61
+ }
62
+ return hiprintJQuery(this);
63
+
64
+ // Get an RGB(A) object based on the current color/opacity
65
+ case 'rgbObject':
66
+ return rgbObject(hiprintJQuery(this), method === 'rgbaObject');
67
+
68
+ // Get an RGB(A) string based on the current color/opacity
69
+ case 'rgbString':
70
+ case 'rgbaString':
71
+ return rgbString(hiprintJQuery(this), method === 'rgbaString');
72
+
73
+ // Get/set settings on the fly
74
+ case 'settings':
75
+ if (data === undefined) {
76
+ return hiprintJQuery(this).data('minicolors-settings');
77
+ } else {
78
+ // Setter
79
+ hiprintJQuery(this).each(function () {
80
+ var settings = hiprintJQuery(this).data('minicolors-settings') || {};
81
+ destroy(hiprintJQuery(this));
82
+ hiprintJQuery(this).minicolors(hiprintJQuery.extend(true, settings, data));
83
+ });
84
+ }
85
+ return hiprintJQuery(this);
86
+
87
+ // Show the color picker
88
+ case 'show':
89
+ show(hiprintJQuery(this).eq(0));
90
+ return hiprintJQuery(this);
91
+
92
+ // Get/set the hex color value
93
+ case 'value':
94
+ if (data === undefined) {
95
+ // Getter
96
+ return hiprintJQuery(this).val();
97
+ } else {
98
+ // Setter
99
+ hiprintJQuery(this).each(function () {
100
+ if (typeof (data) === 'object' && data !== null) {
101
+ if (data.opacity !== undefined) {
102
+ hiprintJQuery(this).attr('data-opacity', keepWithin(data.opacity, 0, 1));
103
+ }
104
+ if (data.color) {
105
+ hiprintJQuery(this).val(data.color);
106
+ }
107
+ } else {
108
+ hiprintJQuery(this).val(data);
109
+ }
110
+ updateFromInput(hiprintJQuery(this));
111
+ });
112
+ }
113
+ return hiprintJQuery(this);
114
+
115
+ // Initializes the control
116
+ default:
117
+ if (method !== 'create') data = method;
118
+ hiprintJQuery(this).each(function () {
119
+ init(hiprintJQuery(this), data);
120
+ });
121
+ return hiprintJQuery(this);
122
+
123
+ }
124
+
125
+ }
126
+ });
127
+
128
+ // Initialize input elements
129
+ function init (input, settings) {
130
+ var minicolors = hiprintJQuery('<div class="minicolors" />');
131
+ var defaults = hiprintJQuery.minicolors.defaults;
132
+ var name;
133
+ var size;
134
+ var swatches;
135
+ var swatch;
136
+ var swatchString;
137
+ var panel;
138
+ var i;
139
+
140
+ // Do nothing if already initialized
141
+ if (input.data('minicolors-initialized')) return;
142
+
143
+ // Handle settings
144
+ settings = hiprintJQuery.extend(true, {}, defaults, settings);
145
+
146
+ // The wrapper
147
+ minicolors
148
+ .addClass('minicolors-theme-' + settings.theme)
149
+ .toggleClass('minicolors-with-opacity', settings.opacity);
150
+
151
+ // Custom positioning
152
+ if (settings.position !== undefined) {
153
+ hiprintJQuery.each(settings.position.split(' '), function () {
154
+ minicolors.addClass('minicolors-position-' + this);
155
+ });
156
+ }
157
+
158
+ // Input size
159
+ if (settings.format === 'rgb') {
160
+ size = settings.opacity ? '25' : '20';
161
+ } else {
162
+ size = settings.keywords ? '11' : '7';
163
+ }
164
+
165
+ // The input
166
+ input
167
+ .addClass('minicolors-input')
168
+ .data('minicolors-initialized', false)
169
+ .data('minicolors-settings', settings)
170
+ .prop('size', size)
171
+ .wrap(minicolors)
172
+ .after(
173
+ '<div class="minicolors-panel minicolors-slider-' + settings.control + '">' +
174
+ '<div class="minicolors-slider minicolors-sprite">' +
175
+ '<div class="minicolors-picker"></div>' +
176
+ '</div>' +
177
+ '<div class="minicolors-opacity-slider minicolors-sprite">' +
178
+ '<div class="minicolors-picker"></div>' +
179
+ '</div>' +
180
+ '<div class="minicolors-grid minicolors-sprite">' +
181
+ '<div class="minicolors-grid-inner"></div>' +
182
+ '<div class="minicolors-picker"><div></div></div>' +
183
+ '</div>' +
184
+ '</div>'
185
+ );
186
+
187
+ // The swatch
188
+ if (!settings.inline) {
189
+ input.after('<span class="minicolors-swatch minicolors-sprite minicolors-input-swatch"><span class="minicolors-swatch-color"></span></span>');
190
+ input.next('.minicolors-input-swatch').on('click', function (event) {
191
+ event.preventDefault();
192
+ input.trigger('focus');
193
+ });
194
+ }
195
+
196
+ // Prevent text selection in IE
197
+ panel = input.parent().find('.minicolors-panel');
198
+ panel.on('selectstart', function () { return false; }).end();
199
+
200
+ // Swatches
201
+ if (settings.swatches && settings.swatches.length !== 0) {
202
+ panel.addClass('minicolors-with-swatches');
203
+ swatches = hiprintJQuery('<ul class="minicolors-swatches"></ul>')
204
+ .appendTo(panel);
205
+ for (i = 0; i < settings.swatches.length; ++i) {
206
+ // allow for custom objects as swatches
207
+ if (typeof settings.swatches[i] === 'object') {
208
+ name = settings.swatches[i].name;
209
+ swatch = settings.swatches[i].color;
210
+ } else {
211
+ name = '';
212
+ swatch = settings.swatches[i];
213
+ }
214
+ swatchString = swatch;
215
+ swatch = isRgb(swatch) ? parseRgb(swatch, true) : hex2rgb(parseHex(swatch, true));
216
+ hiprintJQuery('<li class="minicolors-swatch minicolors-sprite"><span class="minicolors-swatch-color"></span></li>')
217
+ .attr("title", name)
218
+ .appendTo(swatches)
219
+ .data('swatch-color', swatchString)
220
+ .find('.minicolors-swatch-color')
221
+ .css({
222
+ backgroundColor: ((swatchString !== 'transparent') ? rgb2hex(swatch) : 'transparent'),
223
+ opacity: String(swatch.a)
224
+ });
225
+ settings.swatches[i] = swatch;
226
+ }
227
+ }
228
+
229
+ // Inline controls
230
+ if (settings.inline) input.parent().addClass('minicolors-inline');
231
+
232
+ updateFromInput(input, false);
233
+
234
+ input.data('minicolors-initialized', true);
235
+ }
236
+
237
+ // Returns the input back to its original state
238
+ function destroy (input) {
239
+ var minicolors = input.parent();
240
+
241
+ // Revert the input element
242
+ input
243
+ .removeData('minicolors-initialized')
244
+ .removeData('minicolors-settings')
245
+ .removeProp('size')
246
+ .removeClass('minicolors-input');
247
+
248
+ // Remove the wrap and destroy whatever remains
249
+ minicolors.before(input).remove();
250
+ }
251
+
252
+ // Shows the specified dropdown panel
253
+ function show (input) {
254
+ var minicolors = input.parent();
255
+ var panel = minicolors.find('.minicolors-panel');
256
+ var settings = input.data('minicolors-settings');
257
+
258
+ // Do nothing if uninitialized, disabled, inline, or already open
259
+ if (
260
+ !input.data('minicolors-initialized') ||
261
+ input.prop('disabled') ||
262
+ minicolors.hasClass('minicolors-inline') ||
263
+ minicolors.hasClass('minicolors-focus')
264
+ ) return;
265
+
266
+ hide();
267
+
268
+ minicolors.addClass('minicolors-focus');
269
+ if (panel.animate) {
270
+ panel
271
+ .stop(true, true)
272
+ .fadeIn(settings.showSpeed, function () {
273
+ if (settings.show) settings.show.call(input.get(0));
274
+ });
275
+ } else {
276
+ panel.show();
277
+ if (settings.show) settings.show.call(input.get(0));
278
+ }
279
+ }
280
+
281
+ // Hides all dropdown panels
282
+ function hide () {
283
+ hiprintJQuery('.minicolors-focus').each(function () {
284
+ var minicolors = hiprintJQuery(this);
285
+ var input = minicolors.find('.minicolors-input');
286
+ var panel = minicolors.find('.minicolors-panel');
287
+ var settings = input.data('minicolors-settings');
288
+
289
+ if (panel.animate) {
290
+ panel.fadeOut(settings.hideSpeed, function () {
291
+ if (settings.hide) settings.hide.call(input.get(0));
292
+ minicolors.removeClass('minicolors-focus');
293
+ });
294
+ } else {
295
+ panel.hide();
296
+ if (settings.hide) settings.hide.call(input.get(0));
297
+ minicolors.removeClass('minicolors-focus');
298
+ }
299
+ });
300
+ }
301
+
302
+ // Moves the selected picker
303
+ function move (target, event, animate) {
304
+ var input = target.parents('.minicolors').find('.minicolors-input');
305
+ var settings = input.data('minicolors-settings');
306
+ var picker = target.find('[class$=-picker]');
307
+ var offsetX = target.offset().left;
308
+ var offsetY = target.offset().top;
309
+ var x = Math.round(event.pageX - offsetX);
310
+ var y = Math.round(event.pageY - offsetY);
311
+ var duration = animate ? settings.animationSpeed : 0;
312
+ var wx, wy, r, phi, styles;
313
+
314
+ // Touch support
315
+ if (event.originalEvent.changedTouches) {
316
+ x = event.originalEvent.changedTouches[0].pageX - offsetX;
317
+ y = event.originalEvent.changedTouches[0].pageY - offsetY;
318
+ }
319
+
320
+ // Constrain picker to its container
321
+ if (x < 0) x = 0;
322
+ if (y < 0) y = 0;
323
+ if (x > target.width()) x = target.width();
324
+ if (y > target.height()) y = target.height();
325
+
326
+ // Constrain color wheel values to the wheel
327
+ if (target.parent().is('.minicolors-slider-wheel') && picker.parent().is('.minicolors-grid')) {
328
+ wx = 75 - x;
329
+ wy = 75 - y;
330
+ r = Math.sqrt(wx * wx + wy * wy);
331
+ phi = Math.atan2(wy, wx);
332
+ if (phi < 0) phi += Math.PI * 2;
333
+ if (r > 75) {
334
+ r = 75;
335
+ x = 75 - (75 * Math.cos(phi));
336
+ y = 75 - (75 * Math.sin(phi));
337
+ }
338
+ x = Math.round(x);
339
+ y = Math.round(y);
340
+ }
341
+
342
+ // Move the picker
343
+ styles = {
344
+ top: y + 'px'
345
+ };
346
+ if (target.is('.minicolors-grid')) {
347
+ styles.left = x + 'px';
348
+ }
349
+ if (picker.animate) {
350
+ picker
351
+ .stop(true)
352
+ .animate(styles, duration, settings.animationEasing, function () {
353
+ updateFromControl(input, target);
354
+ });
355
+ } else {
356
+ picker
357
+ .css(styles);
358
+ updateFromControl(input, target);
359
+ }
360
+ }
361
+
362
+ // Sets the input based on the color picker values
363
+ function updateFromControl (input, target) {
364
+
365
+ function getCoords (picker, container) {
366
+ var left, top;
367
+ if (!picker.length || !container) return null;
368
+ left = picker.offset().left;
369
+ top = picker.offset().top;
370
+
371
+ return {
372
+ x: left - container.offset().left + (picker.outerWidth() / 2),
373
+ y: top - container.offset().top + (picker.outerHeight() / 2)
374
+ };
375
+ }
376
+
377
+ var hue, saturation, brightness, x, y, r, phi;
378
+ var hex = input.val();
379
+ var opacity = input.attr('data-opacity');
380
+
381
+ // Helpful references
382
+ var minicolors = input.parent();
383
+ var settings = input.data('minicolors-settings');
384
+ var swatch = minicolors.find('.minicolors-input-swatch');
385
+
386
+ // Panel objects
387
+ var grid = minicolors.find('.minicolors-grid');
388
+ var slider = minicolors.find('.minicolors-slider');
389
+ var opacitySlider = minicolors.find('.minicolors-opacity-slider');
390
+
391
+ // Picker objects
392
+ var gridPicker = grid.find('[class$=-picker]');
393
+ var sliderPicker = slider.find('[class$=-picker]');
394
+ var opacityPicker = opacitySlider.find('[class$=-picker]');
395
+
396
+ // Picker positions
397
+ var gridPos = getCoords(gridPicker, grid);
398
+ var sliderPos = getCoords(sliderPicker, slider);
399
+ var opacityPos = getCoords(opacityPicker, opacitySlider);
400
+
401
+ // Handle colors
402
+ if (target.is('.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider')) {
403
+
404
+ // Determine HSB values
405
+ switch (settings.control) {
406
+ case 'wheel':
407
+ // Calculate hue, saturation, and brightness
408
+ x = (grid.width() / 2) - gridPos.x;
409
+ y = (grid.height() / 2) - gridPos.y;
410
+ r = Math.sqrt(x * x + y * y);
411
+ phi = Math.atan2(y, x);
412
+ if (phi < 0) phi += Math.PI * 2;
413
+ if (r > 75) {
414
+ r = 75;
415
+ gridPos.x = 69 - (75 * Math.cos(phi));
416
+ gridPos.y = 69 - (75 * Math.sin(phi));
417
+ }
418
+ saturation = keepWithin(r / 0.75, 0, 100);
419
+ hue = keepWithin(phi * 180 / Math.PI, 0, 360);
420
+ brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
421
+ hex = hsb2hex({
422
+ h: hue,
423
+ s: saturation,
424
+ b: brightness
425
+ });
426
+
427
+ // Update UI
428
+ slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
429
+ break;
430
+
431
+ case 'saturation':
432
+ // Calculate hue, saturation, and brightness
433
+ hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
434
+ saturation = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
435
+ brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
436
+ hex = hsb2hex({
437
+ h: hue,
438
+ s: saturation,
439
+ b: brightness
440
+ });
441
+
442
+ // Update UI
443
+ slider.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: brightness }));
444
+ minicolors.find('.minicolors-grid-inner').css('opacity', saturation / 100);
445
+ break;
446
+
447
+ case 'brightness':
448
+ // Calculate hue, saturation, and brightness
449
+ hue = keepWithin(parseInt(gridPos.x * (360 / grid.width()), 10), 0, 360);
450
+ saturation = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
451
+ brightness = keepWithin(100 - Math.floor(sliderPos.y * (100 / slider.height())), 0, 100);
452
+ hex = hsb2hex({
453
+ h: hue,
454
+ s: saturation,
455
+ b: brightness
456
+ });
457
+
458
+ // Update UI
459
+ slider.css('backgroundColor', hsb2hex({ h: hue, s: saturation, b: 100 }));
460
+ minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (brightness / 100));
461
+ break;
462
+
463
+ default:
464
+ // Calculate hue, saturation, and brightness
465
+ hue = keepWithin(360 - parseInt(sliderPos.y * (360 / slider.height()), 10), 0, 360);
466
+ saturation = keepWithin(Math.floor(gridPos.x * (100 / grid.width())), 0, 100);
467
+ brightness = keepWithin(100 - Math.floor(gridPos.y * (100 / grid.height())), 0, 100);
468
+ hex = hsb2hex({
469
+ h: hue,
470
+ s: saturation,
471
+ b: brightness
472
+ });
473
+
474
+ // Update UI
475
+ grid.css('backgroundColor', hsb2hex({ h: hue, s: 100, b: 100 }));
476
+ break;
477
+ }
478
+
479
+ // Handle opacity
480
+ if (settings.opacity) {
481
+ opacity = parseFloat(1 - (opacityPos.y / opacitySlider.height())).toFixed(2);
482
+ } else {
483
+ opacity = 1;
484
+ }
485
+
486
+ updateInput(input, hex, opacity);
487
+ }
488
+ else {
489
+ // Set swatch color
490
+ swatch.find('span').css({
491
+ backgroundColor: hex,
492
+ opacity: String(opacity)
493
+ });
494
+
495
+ // Handle change event
496
+ doChange(input, hex, opacity);
497
+ }
498
+ }
499
+
500
+ // Sets the value of the input and does the appropriate conversions
501
+ // to respect settings, also updates the swatch
502
+ function updateInput (input, value, opacity) {
503
+ var rgb;
504
+
505
+ // Helpful references
506
+ var minicolors = input.parent();
507
+ var settings = input.data('minicolors-settings');
508
+ var swatch = minicolors.find('.minicolors-input-swatch');
509
+
510
+ if (settings.opacity) input.attr('data-opacity', opacity);
511
+
512
+ // Set color string
513
+ if (settings.format === 'rgb') {
514
+ // Returns RGB(A) string
515
+
516
+ // Checks for input format and does the conversion
517
+ if (isRgb(value)) {
518
+ rgb = parseRgb(value, true);
519
+ }
520
+ else {
521
+ rgb = hex2rgb(parseHex(value, true));
522
+ }
523
+
524
+ opacity = input.attr('data-opacity') === '' ? 1 : keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2), 0, 1);
525
+ if (isNaN(opacity) || !settings.opacity) opacity = 1;
526
+
527
+ if (input.minicolors('rgbObject').a <= 1 && rgb && settings.opacity) {
528
+ // Set RGBA string if alpha
529
+ value = 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + parseFloat(opacity) + ')';
530
+ } else {
531
+ // Set RGB string (alpha = 1)
532
+ value = 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')';
533
+ }
534
+ } else {
535
+ // Returns hex color
536
+
537
+ // Checks for input format and does the conversion
538
+ if (isRgb(value)) {
539
+ value = rgbString2hex(value);
540
+ }
541
+
542
+ value = convertCase(value, settings.letterCase);
543
+ }
544
+
545
+ // Update value from picker
546
+ input.val(value);
547
+
548
+ // Set swatch color
549
+ swatch.find('span').css({
550
+ backgroundColor: value,
551
+ opacity: String(opacity)
552
+ });
553
+
554
+ // Handle change event
555
+ doChange(input, value, opacity);
556
+ }
557
+
558
+ // Sets the color picker values from the input
559
+ function updateFromInput (input, preserveInputValue) {
560
+ var hex, hsb, opacity, keywords, alpha, value, x, y, r, phi;
561
+
562
+ // Helpful references
563
+ var minicolors = input.parent();
564
+ var settings = input.data('minicolors-settings');
565
+ var swatch = minicolors.find('.minicolors-input-swatch');
566
+
567
+ // Panel objects
568
+ var grid = minicolors.find('.minicolors-grid');
569
+ var slider = minicolors.find('.minicolors-slider');
570
+ var opacitySlider = minicolors.find('.minicolors-opacity-slider');
571
+
572
+ // Picker objects
573
+ var gridPicker = grid.find('[class$=-picker]');
574
+ var sliderPicker = slider.find('[class$=-picker]');
575
+ var opacityPicker = opacitySlider.find('[class$=-picker]');
576
+
577
+ // Determine hex/HSB values
578
+ if (isRgb(input.val())) {
579
+ // If input value is a rgb(a) string, convert it to hex color and update opacity
580
+ hex = rgbString2hex(input.val());
581
+ alpha = keepWithin(parseFloat(getAlpha(input.val())).toFixed(2), 0, 1);
582
+ if (alpha) {
583
+ input.attr('data-opacity', alpha);
584
+ }
585
+ } else {
586
+ hex = convertCase(parseHex(input.val(), true), settings.letterCase);
587
+ }
588
+
589
+ if (!hex) {
590
+ hex = convertCase(parseInput(settings.defaultValue, true), settings.letterCase);
591
+ }
592
+ hsb = hex2hsb(hex);
593
+
594
+ // Get array of lowercase keywords
595
+ keywords = !settings.keywords ? [] : hiprintJQuery.map(settings.keywords.split(','), function (a) {
596
+ return a.toLowerCase().trim();
597
+ });
598
+
599
+ // Set color string
600
+ if (input.val() !== '' && hiprintJQuery.inArray(input.val().toLowerCase(), keywords) > -1) {
601
+ value = convertCase(input.val());
602
+ } else {
603
+ value = isRgb(input.val()) ? parseRgb(input.val()) : hex;
604
+ }
605
+
606
+ // Update input value
607
+ if (!preserveInputValue) input.val(value);
608
+
609
+ // Determine opacity value
610
+ if (settings.opacity) {
611
+ // Get from data-opacity attribute and keep within 0-1 range
612
+ opacity = input.attr('data-opacity') === '' ? 1 : keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2), 0, 1);
613
+ if (isNaN(opacity)) opacity = 1;
614
+ input.attr('data-opacity', opacity);
615
+ swatch.find('span').css('opacity', String(opacity));
616
+
617
+ // Set opacity picker position
618
+ y = keepWithin(opacitySlider.height() - (opacitySlider.height() * opacity), 0, opacitySlider.height());
619
+ opacityPicker.css('top', y + 'px');
620
+ }
621
+
622
+ // Set opacity to zero if input value is transparent
623
+ if (input.val().toLowerCase() === 'transparent') {
624
+ swatch.find('span').css('opacity', String(0));
625
+ }
626
+
627
+ // Update swatch
628
+ swatch.find('span').css('backgroundColor', hex);
629
+
630
+ // Determine picker locations
631
+ switch (settings.control) {
632
+ case 'wheel':
633
+ // Set grid position
634
+ r = keepWithin(Math.ceil(hsb.s * 0.75), 0, grid.height() / 2);
635
+ phi = hsb.h * Math.PI / 180;
636
+ x = keepWithin(75 - Math.cos(phi) * r, 0, grid.width());
637
+ y = keepWithin(75 - Math.sin(phi) * r, 0, grid.height());
638
+ gridPicker.css({
639
+ top: y + 'px',
640
+ left: x + 'px'
641
+ });
642
+
643
+ // Set slider position
644
+ y = 150 - (hsb.b / (100 / grid.height()));
645
+ if (hex === '') y = 0;
646
+ sliderPicker.css('top', y + 'px');
647
+
648
+ // Update panel color
649
+ slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 }));
650
+ break;
651
+
652
+ case 'saturation':
653
+ // Set grid position
654
+ x = keepWithin((5 * hsb.h) / 12, 0, 150);
655
+ y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height());
656
+ gridPicker.css({
657
+ top: y + 'px',
658
+ left: x + 'px'
659
+ });
660
+
661
+ // Set slider position
662
+ y = keepWithin(slider.height() - (hsb.s * (slider.height() / 100)), 0, slider.height());
663
+ sliderPicker.css('top', y + 'px');
664
+
665
+ // Update UI
666
+ slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: hsb.b }));
667
+ minicolors.find('.minicolors-grid-inner').css('opacity', hsb.s / 100);
668
+ break;
669
+
670
+ case 'brightness':
671
+ // Set grid position
672
+ x = keepWithin((5 * hsb.h) / 12, 0, 150);
673
+ y = keepWithin(grid.height() - Math.ceil(hsb.s / (100 / grid.height())), 0, grid.height());
674
+ gridPicker.css({
675
+ top: y + 'px',
676
+ left: x + 'px'
677
+ });
678
+
679
+ // Set slider position
680
+ y = keepWithin(slider.height() - (hsb.b * (slider.height() / 100)), 0, slider.height());
681
+ sliderPicker.css('top', y + 'px');
682
+
683
+ // Update UI
684
+ slider.css('backgroundColor', hsb2hex({ h: hsb.h, s: hsb.s, b: 100 }));
685
+ minicolors.find('.minicolors-grid-inner').css('opacity', 1 - (hsb.b / 100));
686
+ break;
687
+
688
+ default:
689
+ // Set grid position
690
+ x = keepWithin(Math.ceil(hsb.s / (100 / grid.width())), 0, grid.width());
691
+ y = keepWithin(grid.height() - Math.ceil(hsb.b / (100 / grid.height())), 0, grid.height());
692
+ gridPicker.css({
693
+ top: y + 'px',
694
+ left: x + 'px'
695
+ });
696
+
697
+ // Set slider position
698
+ y = keepWithin(slider.height() - (hsb.h / (360 / slider.height())), 0, slider.height());
699
+ sliderPicker.css('top', y + 'px');
700
+
701
+ // Update panel color
702
+ grid.css('backgroundColor', hsb2hex({ h: hsb.h, s: 100, b: 100 }));
703
+ break;
704
+ }
705
+
706
+ // Fire change event, but only if minicolors is fully initialized
707
+ if (input.data('minicolors-initialized')) {
708
+ doChange(input, value, opacity);
709
+ }
710
+ }
711
+
712
+ // Runs the change and changeDelay callbacks
713
+ function doChange (input, value, opacity) {
714
+ var settings = input.data('minicolors-settings');
715
+ var lastChange = input.data('minicolors-lastChange');
716
+ var obj, sel, i;
717
+
718
+ // Only run if it actually changed
719
+ if (!lastChange || lastChange.value !== value || lastChange.opacity !== opacity) {
720
+
721
+ // Remember last-changed value
722
+ input.data('minicolors-lastChange', {
723
+ value: value,
724
+ opacity: opacity
725
+ });
726
+
727
+ // Check and select applicable swatch
728
+ if (settings.swatches && settings.swatches.length !== 0) {
729
+ if (!isRgb(value)) {
730
+ obj = hex2rgb(value);
731
+ }
732
+ else {
733
+ obj = parseRgb(value, true);
734
+ }
735
+ sel = -1;
736
+ for (i = 0; i < settings.swatches.length; ++i) {
737
+ if (obj.r === settings.swatches[i].r && obj.g === settings.swatches[i].g && obj.b === settings.swatches[i].b && obj.a === settings.swatches[i].a) {
738
+ sel = i;
739
+ break;
740
+ }
741
+ }
742
+
743
+ input.parent().find('.minicolors-swatches .minicolors-swatch').removeClass('selected');
744
+ if (sel !== -1) {
745
+ input.parent().find('.minicolors-swatches .minicolors-swatch').eq(i).addClass('selected');
746
+ }
747
+ }
748
+
749
+ // Fire change event
750
+ if (settings.change) {
751
+ if (settings.changeDelay) {
752
+ // Call after a delay
753
+ clearTimeout(input.data('minicolors-changeTimeout'));
754
+ input.data('minicolors-changeTimeout', setTimeout(function () {
755
+ settings.change.call(input.get(0), value, opacity);
756
+ }, settings.changeDelay));
757
+ } else {
758
+ // Call immediately
759
+ settings.change.call(input.get(0), value, opacity);
760
+ }
761
+ }
762
+ input.trigger('change').trigger('input');
763
+ }
764
+ }
765
+
766
+ // Generates an RGB(A) object based on the input's value
767
+ function rgbObject (input) {
768
+ var rgb,
769
+ opacity = hiprintJQuery(input).attr('data-opacity');
770
+ if (isRgb(hiprintJQuery(input).val())) {
771
+ rgb = parseRgb(hiprintJQuery(input).val(), true);
772
+ } else {
773
+ var hex = parseHex(hiprintJQuery(input).val(), true);
774
+ rgb = hex2rgb(hex);
775
+ }
776
+ if (!rgb) return null;
777
+ if (opacity !== undefined) hiprintJQuery.extend(rgb, { a: parseFloat(opacity) });
778
+ return rgb;
779
+ }
780
+
781
+ // Generates an RGB(A) string based on the input's value
782
+ function rgbString (input, alpha) {
783
+ var rgb,
784
+ opacity = hiprintJQuery(input).attr('data-opacity');
785
+ if (isRgb(hiprintJQuery(input).val())) {
786
+ rgb = parseRgb(hiprintJQuery(input).val(), true);
787
+ } else {
788
+ var hex = parseHex(hiprintJQuery(input).val(), true);
789
+ rgb = hex2rgb(hex);
790
+ }
791
+ if (!rgb) return null;
792
+ if (opacity === undefined) opacity = 1;
793
+ if (alpha) {
794
+ return 'rgba(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ', ' + parseFloat(opacity) + ')';
795
+ } else {
796
+ return 'rgb(' + rgb.r + ', ' + rgb.g + ', ' + rgb.b + ')';
797
+ }
798
+ }
799
+
800
+ // Converts to the letter case specified in settings
801
+ function convertCase (string, letterCase) {
802
+ return letterCase === 'uppercase' ? string.toUpperCase() : string.toLowerCase();
803
+ }
804
+
805
+ // Parses a string and returns a valid hex string when possible
806
+ function parseHex (string, expand) {
807
+ string = string.replace(/^#/g, '');
808
+ if (!string.match(/^[A-F0-9]{3,6}/ig)) return '';
809
+ if (string.length !== 3 && string.length !== 6) return '';
810
+ if (string.length === 3 && expand) {
811
+ string = string[0] + string[0] + string[1] + string[1] + string[2] + string[2];
812
+ }
813
+ return '#' + string;
814
+ }
815
+
816
+ // Parses a string and returns a valid RGB(A) string when possible
817
+ function parseRgb (string, obj) {
818
+ var values = string.replace(/[^\d,.]/g, '');
819
+ var rgba = values.split(',');
820
+
821
+ rgba[0] = keepWithin(parseInt(rgba[0], 10), 0, 255);
822
+ rgba[1] = keepWithin(parseInt(rgba[1], 10), 0, 255);
823
+ rgba[2] = keepWithin(parseInt(rgba[2], 10), 0, 255);
824
+ if (rgba[3] !== undefined) {
825
+ rgba[3] = keepWithin(parseFloat(rgba[3], 10), 0, 1);
826
+ }
827
+
828
+ // Return RGBA object
829
+ if (obj) {
830
+ if (rgba[3] !== undefined) {
831
+ return {
832
+ r: rgba[0],
833
+ g: rgba[1],
834
+ b: rgba[2],
835
+ a: rgba[3]
836
+ };
837
+ } else {
838
+ return {
839
+ r: rgba[0],
840
+ g: rgba[1],
841
+ b: rgba[2]
842
+ };
843
+ }
844
+ }
845
+
846
+ // Return RGBA string
847
+ if (typeof (rgba[3]) !== 'undefined' && rgba[3] <= 1) {
848
+ return 'rgba(' + rgba[0] + ', ' + rgba[1] + ', ' + rgba[2] + ', ' + rgba[3] + ')';
849
+ } else {
850
+ return 'rgb(' + rgba[0] + ', ' + rgba[1] + ', ' + rgba[2] + ')';
851
+ }
852
+
853
+ }
854
+
855
+ // Parses a string and returns a valid color string when possible
856
+ function parseInput (string, expand) {
857
+ if (isRgb(string)) {
858
+ // Returns a valid rgb(a) string
859
+ return parseRgb(string);
860
+ } else {
861
+ return parseHex(string, expand);
862
+ }
863
+ }
864
+
865
+ // Keeps value within min and max
866
+ function keepWithin (value, min, max) {
867
+ if (value < min) value = min;
868
+ if (value > max) value = max;
869
+ return value;
870
+ }
871
+
872
+ // Checks if a string is a valid RGB(A) string
873
+ function isRgb (string) {
874
+ var rgb = string.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
875
+ return (rgb && rgb.length === 4) ? true : false;
876
+ }
877
+
878
+ // Function to get alpha from a RGB(A) string
879
+ function getAlpha (rgba) {
880
+ rgba = rgba.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+(\.\d{1,2})?|\.\d{1,2})[\s+]?/i);
881
+ return (rgba && rgba.length === 6) ? rgba[4] : '1';
882
+ }
883
+
884
+ // Converts an HSB object to an RGB object
885
+ function hsb2rgb (hsb) {
886
+ var rgb = {};
887
+ var h = Math.round(hsb.h);
888
+ var s = Math.round(hsb.s * 255 / 100);
889
+ var v = Math.round(hsb.b * 255 / 100);
890
+ if (s === 0) {
891
+ rgb.r = rgb.g = rgb.b = v;
892
+ } else {
893
+ var t1 = v;
894
+ var t2 = (255 - s) * v / 255;
895
+ var t3 = (t1 - t2) * (h % 60) / 60;
896
+ if (h === 360) h = 0;
897
+ if (h < 60) { rgb.r = t1; rgb.b = t2; rgb.g = t2 + t3; }
898
+ else if (h < 120) { rgb.g = t1; rgb.b = t2; rgb.r = t1 - t3; }
899
+ else if (h < 180) { rgb.g = t1; rgb.r = t2; rgb.b = t2 + t3; }
900
+ else if (h < 240) { rgb.b = t1; rgb.r = t2; rgb.g = t1 - t3; }
901
+ else if (h < 300) { rgb.b = t1; rgb.g = t2; rgb.r = t2 + t3; }
902
+ else if (h < 360) { rgb.r = t1; rgb.g = t2; rgb.b = t1 - t3; }
903
+ else { rgb.r = 0; rgb.g = 0; rgb.b = 0; }
904
+ }
905
+ return {
906
+ r: Math.round(rgb.r),
907
+ g: Math.round(rgb.g),
908
+ b: Math.round(rgb.b)
909
+ };
910
+ }
911
+
912
+ // Converts an RGB string to a hex string
913
+ function rgbString2hex (rgb) {
914
+ rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
915
+ return (rgb && rgb.length === 4) ? '#' +
916
+ ('0' + parseInt(rgb[1], 10).toString(16)).slice(-2) +
917
+ ('0' + parseInt(rgb[2], 10).toString(16)).slice(-2) +
918
+ ('0' + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
919
+ }
920
+
921
+ // Converts an RGB object to a hex string
922
+ function rgb2hex (rgb) {
923
+ var hex = [
924
+ rgb.r.toString(16),
925
+ rgb.g.toString(16),
926
+ rgb.b.toString(16)
927
+ ];
928
+ hiprintJQuery.each(hex, function (nr, val) {
929
+ if (val.length === 1) hex[nr] = '0' + val;
930
+ });
931
+ return '#' + hex.join('');
932
+ }
933
+
934
+ // Converts an HSB object to a hex string
935
+ function hsb2hex (hsb) {
936
+ return rgb2hex(hsb2rgb(hsb));
937
+ }
938
+
939
+ // Converts a hex string to an HSB object
940
+ function hex2hsb (hex) {
941
+ var hsb = rgb2hsb(hex2rgb(hex));
942
+ if (hsb.s === 0) hsb.h = 360;
943
+ return hsb;
944
+ }
945
+
946
+ // Converts an RGB object to an HSB object
947
+ function rgb2hsb (rgb) {
948
+ var hsb = { h: 0, s: 0, b: 0 };
949
+ var min = Math.min(rgb.r, rgb.g, rgb.b);
950
+ var max = Math.max(rgb.r, rgb.g, rgb.b);
951
+ var delta = max - min;
952
+ hsb.b = max;
953
+ hsb.s = max !== 0 ? 255 * delta / max : 0;
954
+ if (hsb.s !== 0) {
955
+ if (rgb.r === max) {
956
+ hsb.h = (rgb.g - rgb.b) / delta;
957
+ } else if (rgb.g === max) {
958
+ hsb.h = 2 + (rgb.b - rgb.r) / delta;
959
+ } else {
960
+ hsb.h = 4 + (rgb.r - rgb.g) / delta;
961
+ }
962
+ } else {
963
+ hsb.h = -1;
964
+ }
965
+ hsb.h *= 60;
966
+ if (hsb.h < 0) {
967
+ hsb.h += 360;
968
+ }
969
+ hsb.s *= 100 / 255;
970
+ hsb.b *= 100 / 255;
971
+ return hsb;
972
+ }
973
+
974
+ // Converts a hex string to an RGB object
975
+ function hex2rgb (hex) {
976
+ hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
977
+ return {
978
+ r: hex >> 16,
979
+ g: (hex & 0x00FF00) >> 8,
980
+ b: (hex & 0x0000FF)
981
+ };
982
+ }
983
+
984
+ // Handle events
985
+ hiprintJQuery([document])
986
+ // Hide on clicks outside of the control
987
+ .on('mousedown.minicolors touchstart.minicolors', function (event) {
988
+ if (!hiprintJQuery(event.target).parents().add(event.target).hasClass('minicolors')) {
989
+ hide();
990
+ }
991
+ })
992
+ // Start moving
993
+ .on('mousedown.minicolors touchstart.minicolors', '.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider', function (event) {
994
+ var target = hiprintJQuery(this);
995
+ event.preventDefault();
996
+ hiprintJQuery(event.delegateTarget).data('minicolors-target', target);
997
+ move(target, event, true);
998
+ })
999
+ // Move pickers
1000
+ .on('mousemove.minicolors touchmove.minicolors', function (event) {
1001
+ var target = hiprintJQuery(event.delegateTarget).data('minicolors-target');
1002
+ if (target) move(target, event);
1003
+ })
1004
+ // Stop moving
1005
+ .on('mouseup.minicolors touchend.minicolors', function () {
1006
+ hiprintJQuery(this).removeData('minicolors-target');
1007
+ })
1008
+ // Selected a swatch
1009
+ .on('click.minicolors', '.minicolors-swatches li', function (event) {
1010
+ event.preventDefault();
1011
+ var target = hiprintJQuery(this), input = target.parents('.minicolors').find('.minicolors-input'), color = target.data('swatch-color');
1012
+ updateInput(input, color, getAlpha(color));
1013
+ updateFromInput(input);
1014
+ })
1015
+ // Show panel when swatch is clicked
1016
+ .on('mousedown.minicolors touchstart.minicolors', '.minicolors-input-swatch', function (event) {
1017
+ var input = hiprintJQuery(this).parent().find('.minicolors-input');
1018
+ event.preventDefault();
1019
+ show(input);
1020
+ })
1021
+ // Show on focus
1022
+ .on('focus.minicolors', '.minicolors-input', function () {
1023
+ var input = hiprintJQuery(this);
1024
+ if (!input.data('minicolors-initialized')) return;
1025
+ show(input);
1026
+ })
1027
+ // Update value on blur
1028
+ .on('blur.minicolors', '.minicolors-input', function () {
1029
+ var input = hiprintJQuery(this);
1030
+ var settings = input.data('minicolors-settings');
1031
+ var keywords;
1032
+ var hex;
1033
+ var rgba;
1034
+ var swatchOpacity;
1035
+ var value;
1036
+
1037
+ if (!input.data('minicolors-initialized')) return;
1038
+
1039
+ // Get array of lowercase keywords
1040
+ keywords = !settings.keywords ? [] : hiprintJQuery.map(settings.keywords.split(','), function (a) {
1041
+ return a.toLowerCase().trim();
1042
+ });
1043
+
1044
+ // Set color string
1045
+ if (input.val() !== '' && hiprintJQuery.inArray(input.val().toLowerCase(), keywords) > -1) {
1046
+ value = input.val();
1047
+ } else {
1048
+ // Get RGBA values for easy conversion
1049
+ if (isRgb(input.val())) {
1050
+ rgba = parseRgb(input.val(), true);
1051
+ } else {
1052
+ hex = parseHex(input.val(), true);
1053
+ rgba = hex ? hex2rgb(hex) : null;
1054
+ }
1055
+
1056
+ // Convert to format
1057
+ if (rgba === null) {
1058
+ value = settings.defaultValue;
1059
+ } else if (settings.format === 'rgb') {
1060
+ value = settings.opacity ?
1061
+ parseRgb('rgba(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ',' + input.attr('data-opacity') + ')') :
1062
+ parseRgb('rgb(' + rgba.r + ',' + rgba.g + ',' + rgba.b + ')');
1063
+ } else {
1064
+ value = rgb2hex(rgba);
1065
+ }
1066
+ }
1067
+
1068
+ // Update swatch opacity
1069
+ swatchOpacity = settings.opacity ? input.attr('data-opacity') : 1;
1070
+ if (value.toLowerCase() === 'transparent') swatchOpacity = 0;
1071
+ input
1072
+ .closest('.minicolors')
1073
+ .find('.minicolors-input-swatch > span')
1074
+ .css('opacity', String(swatchOpacity));
1075
+
1076
+ // Set input value
1077
+ input.val(value);
1078
+
1079
+ // Is it blank?
1080
+ if (input.val() === '') input.val(parseInput(settings.defaultValue, true));
1081
+
1082
+ // Adjust case
1083
+ input.val(convertCase(input.val(), settings.letterCase));
1084
+
1085
+ })
1086
+ // Handle keypresses
1087
+ .on('keydown.minicolors', '.minicolors-input', function (event) {
1088
+ var input = hiprintJQuery(this);
1089
+ if (!input.data('minicolors-initialized')) return;
1090
+ switch (event.which) {
1091
+ case 9: // tab
1092
+ hide();
1093
+ break;
1094
+ case 13: // enter
1095
+ case 27: // esc
1096
+ hide();
1097
+ input.blur();
1098
+ break;
1099
+ }
1100
+ })
1101
+ // Update on keyup
1102
+ .on('keyup.minicolors', '.minicolors-input', function () {
1103
+ var input = hiprintJQuery(this);
1104
+ if (!input.data('minicolors-initialized')) return;
1105
+ updateFromInput(input, true);
1106
+ })
1107
+ // Update on paste
1108
+ .on('paste.minicolors', '.minicolors-input', function () {
1109
+ var input = hiprintJQuery(this);
1110
+ if (!input.data('minicolors-initialized')) return;
1111
+ setTimeout(function () {
1112
+ updateFromInput(input, true);
1113
+ }, 1);
1114
+ });