Timetable and Event Schedule by MotoPress - Version 2.3.12

Version Description

Download this release

Release Info

Developer MotoPress
Plugin Icon 128x128 Timetable and Event Schedule by MotoPress
Version 2.3.12
Comparing to
See all releases

Code changes from version 2.3.11 to 2.3.12

media/css/block-editor.css CHANGED
@@ -1 +1 @@
1
- .wp-block[data-type="mp-timetable/timetable"] div[data-block]{overflow:auto}
1
+ .wp-block[data-type="mp-timetable/timetable"] div[data-block]{overflow:auto}body.branch-5-6 .components-select-control.timetable-wp56-fix .components-select-control__input{height:auto!important}body.branch-5-6 .components-select-control.timetable-wp56-fix .components-input-control__suffix{display:none!important}
media/css/spectrum.css CHANGED
@@ -1,507 +1,507 @@
1
- /***
2
- Spectrum Colorpicker v1.8.0
3
- https://github.com/bgrins/spectrum
4
- Author: Brian Grinstead
5
- License: MIT
6
- ***/
7
-
8
- .sp-container {
9
- position:absolute;
10
- top:0;
11
- left:0;
12
- display:inline-block;
13
- *display: inline;
14
- *zoom: 1;
15
- /* https://github.com/bgrins/spectrum/issues/40 */
16
- z-index: 9999994;
17
- overflow: hidden;
18
- }
19
- .sp-container.sp-flat {
20
- position: relative;
21
- }
22
-
23
- /* Fix for * { box-sizing: border-box; } */
24
- .sp-container,
25
- .sp-container * {
26
- -webkit-box-sizing: content-box;
27
- -moz-box-sizing: content-box;
28
- box-sizing: content-box;
29
- }
30
-
31
- /* http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio */
32
- .sp-top {
33
- position:relative;
34
- width: 100%;
35
- display:inline-block;
36
- }
37
- .sp-top-inner {
38
- position:absolute;
39
- top:0;
40
- left:0;
41
- bottom:0;
42
- right:0;
43
- }
44
- .sp-color {
45
- position: absolute;
46
- top:0;
47
- left:0;
48
- bottom:0;
49
- right:20%;
50
- }
51
- .sp-hue {
52
- position: absolute;
53
- top:0;
54
- right:0;
55
- bottom:0;
56
- left:84%;
57
- height: 100%;
58
- }
59
-
60
- .sp-clear-enabled .sp-hue {
61
- top:33px;
62
- height: 77.5%;
63
- }
64
-
65
- .sp-fill {
66
- padding-top: 80%;
67
- }
68
- .sp-sat, .sp-val {
69
- position: absolute;
70
- top:0;
71
- left:0;
72
- right:0;
73
- bottom:0;
74
- }
75
-
76
- .sp-alpha-enabled .sp-top {
77
- margin-bottom: 18px;
78
- }
79
- .sp-alpha-enabled .sp-alpha {
80
- display: block;
81
- }
82
- .sp-alpha-handle {
83
- position:absolute;
84
- top:-4px;
85
- bottom: -4px;
86
- width: 6px;
87
- left: 50%;
88
- cursor: pointer;
89
- border: 1px solid black;
90
- background: white;
91
- opacity: .8;
92
- }
93
- .sp-alpha {
94
- display: none;
95
- position: absolute;
96
- bottom: -14px;
97
- right: 0;
98
- left: 0;
99
- height: 8px;
100
- }
101
- .sp-alpha-inner {
102
- border: solid 1px #333;
103
- }
104
-
105
- .sp-clear {
106
- display: none;
107
- }
108
-
109
- .sp-clear.sp-clear-display {
110
- background-position: center;
111
- }
112
-
113
- .sp-clear-enabled .sp-clear {
114
- display: block;
115
- position:absolute;
116
- top:0px;
117
- right:0;
118
- bottom:0;
119
- left:84%;
120
- height: 28px;
121
- }
122
-
123
- /* Don't allow text selection */
124
- .sp-container, .sp-replacer, .sp-preview, .sp-dragger, .sp-slider, .sp-alpha, .sp-clear, .sp-alpha-handle, .sp-container.sp-dragging .sp-input, .sp-container button {
125
- -webkit-user-select:none;
126
- -moz-user-select: -moz-none;
127
- -o-user-select:none;
128
- user-select: none;
129
- }
130
-
131
- .sp-container.sp-input-disabled .sp-input-container {
132
- display: none;
133
- }
134
- .sp-container.sp-buttons-disabled .sp-button-container {
135
- display: none;
136
- }
137
- .sp-container.sp-palette-buttons-disabled .sp-palette-button-container {
138
- display: none;
139
- }
140
- .sp-palette-only .sp-picker-container {
141
- display: none;
142
- }
143
- .sp-palette-disabled .sp-palette-container {
144
- display: none;
145
- }
146
-
147
- .sp-initial-disabled .sp-initial {
148
- display: none;
149
- }
150
-
151
-
152
- /* Gradients for hue, saturation and value instead of images. Not pretty... but it works */
153
- .sp-sat {
154
- background-image: -webkit-gradient(linear, 0 0, 100% 0, from(#FFF), to(rgba(204, 154, 129, 0)));
155
- background-image: -webkit-linear-gradient(left, #FFF, rgba(204, 154, 129, 0));
156
- background-image: -moz-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
157
- background-image: -o-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
158
- background-image: -ms-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
159
- background-image: linear-gradient(to right, #fff, rgba(204, 154, 129, 0));
160
- -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr=#FFFFFFFF, endColorstr=#00CC9A81)";
161
- filter : progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr='#FFFFFFFF', endColorstr='#00CC9A81');
162
- }
163
- .sp-val {
164
- background-image: -webkit-gradient(linear, 0 100%, 0 0, from(#000000), to(rgba(204, 154, 129, 0)));
165
- background-image: -webkit-linear-gradient(bottom, #000000, rgba(204, 154, 129, 0));
166
- background-image: -moz-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
167
- background-image: -o-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
168
- background-image: -ms-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
169
- background-image: linear-gradient(to top, #000, rgba(204, 154, 129, 0));
170
- -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)";
171
- filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000');
172
- }
173
-
174
- .sp-hue {
175
- background: -moz-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
176
- background: -ms-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
177
- background: -o-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
178
- background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), color-stop(0.17, #ffff00), color-stop(0.33, #00ff00), color-stop(0.5, #00ffff), color-stop(0.67, #0000ff), color-stop(0.83, #ff00ff), to(#ff0000));
179
- background: -webkit-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
180
- background: linear-gradient(to bottom, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
181
- }
182
-
183
- /* IE filters do not support multiple color stops.
184
- Generate 6 divs, line them up, and do two color gradients for each.
185
- Yes, really.
186
- */
187
- .sp-1 {
188
- height:17%;
189
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0000', endColorstr='#ffff00');
190
- }
191
- .sp-2 {
192
- height:16%;
193
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff00', endColorstr='#00ff00');
194
- }
195
- .sp-3 {
196
- height:17%;
197
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ff00', endColorstr='#00ffff');
198
- }
199
- .sp-4 {
200
- height:17%;
201
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffff', endColorstr='#0000ff');
202
- }
203
- .sp-5 {
204
- height:16%;
205
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0000ff', endColorstr='#ff00ff');
206
- }
207
- .sp-6 {
208
- height:17%;
209
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff00ff', endColorstr='#ff0000');
210
- }
211
-
212
- .sp-hidden {
213
- display: none !important;
214
- }
215
-
216
- /* Clearfix hack */
217
- .sp-cf:before, .sp-cf:after { content: ""; display: table; }
218
- .sp-cf:after { clear: both; }
219
- .sp-cf { *zoom: 1; }
220
-
221
- /* Mobile devices, make hue slider bigger so it is easier to slide */
222
- @media (max-device-width: 480px) {
223
- .sp-color { right: 40%; }
224
- .sp-hue { left: 63%; }
225
- .sp-fill { padding-top: 60%; }
226
- }
227
- .sp-dragger {
228
- border-radius: 5px;
229
- height: 5px;
230
- width: 5px;
231
- border: 1px solid #fff;
232
- background: #000;
233
- cursor: pointer;
234
- position:absolute;
235
- top:0;
236
- left: 0;
237
- }
238
- .sp-slider {
239
- position: absolute;
240
- top:0;
241
- cursor:pointer;
242
- height: 3px;
243
- left: -1px;
244
- right: -1px;
245
- border: 1px solid #000;
246
- background: white;
247
- opacity: .8;
248
- }
249
-
250
- /*
251
- Theme authors:
252
- Here are the basic themeable display options (colors, fonts, global widths).
253
- See http://bgrins.github.io/spectrum/themes/ for instructions.
254
- */
255
-
256
- .sp-container {
257
- border-radius: 0;
258
- background-color: #ECECEC;
259
- border: solid 1px #f0c49B;
260
- padding: 0;
261
- }
262
- .sp-container, .sp-container button, .sp-container input, .sp-color, .sp-hue, .sp-clear {
263
- font: normal 12px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
264
- -webkit-box-sizing: border-box;
265
- -moz-box-sizing: border-box;
266
- -ms-box-sizing: border-box;
267
- box-sizing: border-box;
268
- }
269
- .sp-top {
270
- margin-bottom: 3px;
271
- }
272
- .sp-color, .sp-hue, .sp-clear {
273
- border: solid 1px #666;
274
- }
275
-
276
- /* Input */
277
- .sp-input-container {
278
- float:right;
279
- width: 100px;
280
- margin-bottom: 4px;
281
- }
282
- .sp-initial-disabled .sp-input-container {
283
- width: 100%;
284
- }
285
- .sp-input {
286
- font-size: 12px !important;
287
- border: 1px inset;
288
- padding: 4px 5px;
289
- margin: 0;
290
- width: 100%;
291
- background:transparent;
292
- border-radius: 3px;
293
- color: #222;
294
- }
295
- .sp-input:focus {
296
- border: 1px solid orange;
297
- }
298
- .sp-input.sp-validation-error {
299
- border: 1px solid red;
300
- background: #fdd;
301
- }
302
- .sp-picker-container , .sp-palette-container {
303
- float:left;
304
- position: relative;
305
- padding: 10px;
306
- padding-bottom: 300px;
307
- margin-bottom: -290px;
308
- }
309
- .sp-picker-container {
310
- width: 172px;
311
- border-left: solid 1px #fff;
312
- }
313
-
314
- /* Palettes */
315
- .sp-palette-container {
316
- border-right: solid 1px #ccc;
317
- }
318
-
319
- .sp-palette-only .sp-palette-container {
320
- border: 0;
321
- }
322
-
323
- .sp-palette .sp-thumb-el {
324
- display: block;
325
- position:relative;
326
- float:left;
327
- width: 24px;
328
- height: 15px;
329
- margin: 3px;
330
- cursor: pointer;
331
- border:solid 2px transparent;
332
- }
333
- .sp-palette .sp-thumb-el:hover, .sp-palette .sp-thumb-el.sp-thumb-active {
334
- border-color: orange;
335
- }
336
- .sp-thumb-el {
337
- position:relative;
338
- }
339
-
340
- /* Initial */
341
- .sp-initial {
342
- float: left;
343
- border: solid 1px #333;
344
- }
345
- .sp-initial span {
346
- width: 30px;
347
- height: 25px;
348
- border:none;
349
- display:block;
350
- float:left;
351
- margin:0;
352
- }
353
-
354
- .sp-initial .sp-clear-display {
355
- background-position: center;
356
- }
357
-
358
- /* Buttons */
359
- .sp-palette-button-container,
360
- .sp-button-container {
361
- float: right;
362
- }
363
-
364
- /* Replacer (the little preview div that shows up instead of the <input>) */
365
- .sp-replacer {
366
- margin:0;
367
- overflow:hidden;
368
- cursor:pointer;
369
- padding: 4px;
370
- display:inline-block;
371
- *zoom: 1;
372
- *display: inline;
373
- border: solid 1px #91765d;
374
- background: #eee;
375
- color: #333;
376
- vertical-align: middle;
377
- }
378
- .sp-replacer:hover, .sp-replacer.sp-active {
379
- border-color: #F0C49B;
380
- color: #111;
381
- }
382
- .sp-replacer.sp-disabled {
383
- cursor:default;
384
- border-color: silver;
385
- color: silver;
386
- }
387
- .sp-dd {
388
- padding: 2px 0;
389
- height: 16px;
390
- line-height: 16px;
391
- float:left;
392
- font-size:10px;
393
- }
394
- .sp-preview {
395
- position:relative;
396
- width:25px;
397
- height: 20px;
398
- border: solid 1px #222;
399
- margin-right: 5px;
400
- float:left;
401
- z-index: 0;
402
- }
403
-
404
- .sp-palette {
405
- *width: 220px;
406
- max-width: 220px;
407
- }
408
- .sp-palette .sp-thumb-el {
409
- width:16px;
410
- height: 16px;
411
- margin:2px 1px;
412
- border: solid 1px #d0d0d0;
413
- }
414
-
415
- .sp-container {
416
- padding-bottom:0;
417
- }
418
-
419
-
420
- /* Buttons: http://hellohappy.org/css3-buttons/ */
421
- .sp-container button {
422
- background-color: #eeeeee;
423
- background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
424
- background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
425
- background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
426
- background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
427
- background-image: linear-gradient(to bottom, #eeeeee, #cccccc);
428
- border: 1px solid #ccc;
429
- border-bottom: 1px solid #bbb;
430
- border-radius: 3px;
431
- color: #333;
432
- font-size: 14px;
433
- line-height: 1;
434
- padding: 5px 4px;
435
- text-align: center;
436
- text-shadow: 0 1px 0 #eee;
437
- vertical-align: middle;
438
- }
439
- .sp-container button:hover {
440
- background-color: #dddddd;
441
- background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb);
442
- background-image: -moz-linear-gradient(top, #dddddd, #bbbbbb);
443
- background-image: -ms-linear-gradient(top, #dddddd, #bbbbbb);
444
- background-image: -o-linear-gradient(top, #dddddd, #bbbbbb);
445
- background-image: linear-gradient(to bottom, #dddddd, #bbbbbb);
446
- border: 1px solid #bbb;
447
- border-bottom: 1px solid #999;
448
- cursor: pointer;
449
- text-shadow: 0 1px 0 #ddd;
450
- }
451
- .sp-container button:active {
452
- border: 1px solid #aaa;
453
- border-bottom: 1px solid #888;
454
- -webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
455
- -moz-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
456
- -ms-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
457
- -o-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
458
- box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
459
- }
460
- .sp-cancel {
461
- font-size: 11px;
462
- color: #d93f3f !important;
463
- margin:0;
464
- padding:2px;
465
- margin-right: 5px;
466
- vertical-align: middle;
467
- text-decoration:none;
468
-
469
- }
470
- .sp-cancel:hover {
471
- color: #d93f3f !important;
472
- text-decoration: underline;
473
- }
474
-
475
-
476
- .sp-palette span:hover, .sp-palette span.sp-thumb-active {
477
- border-color: #000;
478
- }
479
-
480
- .sp-preview, .sp-alpha, .sp-thumb-el {
481
- position:relative;
482
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
483
- }
484
- .sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner {
485
- display:block;
486
- position:absolute;
487
- top:0;left:0;bottom:0;right:0;
488
- }
489
-
490
- .sp-palette .sp-thumb-inner {
491
- background-position: 50% 50%;
492
- background-repeat: no-repeat;
493
- }
494
-
495
- .sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner {
496
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=);
497
- }
498
-
499
- .sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner {
500
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=);
501
- }
502
-
503
- .sp-clear-display {
504
- background-repeat:no-repeat;
505
- background-position: center;
506
- background-image: url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==);
507
- }
1
+ /***
2
+ Spectrum Colorpicker v1.8.1
3
+ https://github.com/bgrins/spectrum
4
+ Author: Brian Grinstead
5
+ License: MIT
6
+ ***/
7
+
8
+ .sp-container {
9
+ position:absolute;
10
+ top:0;
11
+ left:0;
12
+ display:inline-block;
13
+ *display: inline;
14
+ *zoom: 1;
15
+ /* https://github.com/bgrins/spectrum/issues/40 */
16
+ z-index: 9999994;
17
+ overflow: hidden;
18
+ }
19
+ .sp-container.sp-flat {
20
+ position: relative;
21
+ }
22
+
23
+ /* Fix for * { box-sizing: border-box; } */
24
+ .sp-container,
25
+ .sp-container * {
26
+ -webkit-box-sizing: content-box;
27
+ -moz-box-sizing: content-box;
28
+ box-sizing: content-box;
29
+ }
30
+
31
+ /* http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio */
32
+ .sp-top {
33
+ position:relative;
34
+ width: 100%;
35
+ display:inline-block;
36
+ }
37
+ .sp-top-inner {
38
+ position:absolute;
39
+ top:0;
40
+ left:0;
41
+ bottom:0;
42
+ right:0;
43
+ }
44
+ .sp-color {
45
+ position: absolute;
46
+ top:0;
47
+ left:0;
48
+ bottom:0;
49
+ right:20%;
50
+ }
51
+ .sp-hue {
52
+ position: absolute;
53
+ top:0;
54
+ right:0;
55
+ bottom:0;
56
+ left:84%;
57
+ height: 100%;
58
+ }
59
+
60
+ .sp-clear-enabled .sp-hue {
61
+ top:33px;
62
+ height: 77.5%;
63
+ }
64
+
65
+ .sp-fill {
66
+ padding-top: 80%;
67
+ }
68
+ .sp-sat, .sp-val {
69
+ position: absolute;
70
+ top:0;
71
+ left:0;
72
+ right:0;
73
+ bottom:0;
74
+ }
75
+
76
+ .sp-alpha-enabled .sp-top {
77
+ margin-bottom: 18px;
78
+ }
79
+ .sp-alpha-enabled .sp-alpha {
80
+ display: block;
81
+ }
82
+ .sp-alpha-handle {
83
+ position:absolute;
84
+ top:-4px;
85
+ bottom: -4px;
86
+ width: 6px;
87
+ left: 50%;
88
+ cursor: pointer;
89
+ border: 1px solid black;
90
+ background: white;
91
+ opacity: .8;
92
+ }
93
+ .sp-alpha {
94
+ display: none;
95
+ position: absolute;
96
+ bottom: -14px;
97
+ right: 0;
98
+ left: 0;
99
+ height: 8px;
100
+ }
101
+ .sp-alpha-inner {
102
+ border: solid 1px #333;
103
+ }
104
+
105
+ .sp-clear {
106
+ display: none;
107
+ }
108
+
109
+ .sp-clear.sp-clear-display {
110
+ background-position: center;
111
+ }
112
+
113
+ .sp-clear-enabled .sp-clear {
114
+ display: block;
115
+ position:absolute;
116
+ top:0px;
117
+ right:0;
118
+ bottom:0;
119
+ left:84%;
120
+ height: 28px;
121
+ }
122
+
123
+ /* Don't allow text selection */
124
+ .sp-container, .sp-replacer, .sp-preview, .sp-dragger, .sp-slider, .sp-alpha, .sp-clear, .sp-alpha-handle, .sp-container.sp-dragging .sp-input, .sp-container button {
125
+ -webkit-user-select:none;
126
+ -moz-user-select: -moz-none;
127
+ -o-user-select:none;
128
+ user-select: none;
129
+ }
130
+
131
+ .sp-container.sp-input-disabled .sp-input-container {
132
+ display: none;
133
+ }
134
+ .sp-container.sp-buttons-disabled .sp-button-container {
135
+ display: none;
136
+ }
137
+ .sp-container.sp-palette-buttons-disabled .sp-palette-button-container {
138
+ display: none;
139
+ }
140
+ .sp-palette-only .sp-picker-container {
141
+ display: none;
142
+ }
143
+ .sp-palette-disabled .sp-palette-container {
144
+ display: none;
145
+ }
146
+
147
+ .sp-initial-disabled .sp-initial {
148
+ display: none;
149
+ }
150
+
151
+
152
+ /* Gradients for hue, saturation and value instead of images. Not pretty... but it works */
153
+ .sp-sat {
154
+ background-image: -webkit-gradient(linear, 0 0, 100% 0, from(#FFF), to(rgba(204, 154, 129, 0)));
155
+ background-image: -webkit-linear-gradient(left, #FFF, rgba(204, 154, 129, 0));
156
+ background-image: -moz-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
157
+ background-image: -o-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
158
+ background-image: -ms-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
159
+ background-image: linear-gradient(to right, #fff, rgba(204, 154, 129, 0));
160
+ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr=#FFFFFFFF, endColorstr=#00CC9A81)";
161
+ filter : progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr='#FFFFFFFF', endColorstr='#00CC9A81');
162
+ }
163
+ .sp-val {
164
+ background-image: -webkit-gradient(linear, 0 100%, 0 0, from(#000000), to(rgba(204, 154, 129, 0)));
165
+ background-image: -webkit-linear-gradient(bottom, #000000, rgba(204, 154, 129, 0));
166
+ background-image: -moz-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
167
+ background-image: -o-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
168
+ background-image: -ms-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
169
+ background-image: linear-gradient(to top, #000, rgba(204, 154, 129, 0));
170
+ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)";
171
+ filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000');
172
+ }
173
+
174
+ .sp-hue {
175
+ background: -moz-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
176
+ background: -ms-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
177
+ background: -o-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
178
+ background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), color-stop(0.17, #ffff00), color-stop(0.33, #00ff00), color-stop(0.5, #00ffff), color-stop(0.67, #0000ff), color-stop(0.83, #ff00ff), to(#ff0000));
179
+ background: -webkit-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
180
+ background: linear-gradient(to bottom, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
181
+ }
182
+
183
+ /* IE filters do not support multiple color stops.
184
+ Generate 6 divs, line them up, and do two color gradients for each.
185
+ Yes, really.
186
+ */
187
+ .sp-1 {
188
+ height:17%;
189
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0000', endColorstr='#ffff00');
190
+ }
191
+ .sp-2 {
192
+ height:16%;
193
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff00', endColorstr='#00ff00');
194
+ }
195
+ .sp-3 {
196
+ height:17%;
197
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ff00', endColorstr='#00ffff');
198
+ }
199
+ .sp-4 {
200
+ height:17%;
201
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffff', endColorstr='#0000ff');
202
+ }
203
+ .sp-5 {
204
+ height:16%;
205
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0000ff', endColorstr='#ff00ff');
206
+ }
207
+ .sp-6 {
208
+ height:17%;
209
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff00ff', endColorstr='#ff0000');
210
+ }
211
+
212
+ .sp-hidden {
213
+ display: none !important;
214
+ }
215
+
216
+ /* Clearfix hack */
217
+ .sp-cf:before, .sp-cf:after { content: ""; display: table; }
218
+ .sp-cf:after { clear: both; }
219
+ .sp-cf { *zoom: 1; }
220
+
221
+ /* Mobile devices, make hue slider bigger so it is easier to slide */
222
+ @media (max-device-width: 480px) {
223
+ .sp-color { right: 40%; }
224
+ .sp-hue { left: 63%; }
225
+ .sp-fill { padding-top: 60%; }
226
+ }
227
+ .sp-dragger {
228
+ border-radius: 5px;
229
+ height: 5px;
230
+ width: 5px;
231
+ border: 1px solid #fff;
232
+ background: #000;
233
+ cursor: pointer;
234
+ position:absolute;
235
+ top:0;
236
+ left: 0;
237
+ }
238
+ .sp-slider {
239
+ position: absolute;
240
+ top:0;
241
+ cursor:pointer;
242
+ height: 3px;
243
+ left: -1px;
244
+ right: -1px;
245
+ border: 1px solid #000;
246
+ background: white;
247
+ opacity: .8;
248
+ }
249
+
250
+ /*
251
+ Theme authors:
252
+ Here are the basic themeable display options (colors, fonts, global widths).
253
+ See http://bgrins.github.io/spectrum/themes/ for instructions.
254
+ */
255
+
256
+ .sp-container {
257
+ border-radius: 0;
258
+ background-color: #ECECEC;
259
+ border: solid 1px #f0c49B;
260
+ padding: 0;
261
+ }
262
+ .sp-container, .sp-container button, .sp-container input, .sp-color, .sp-hue, .sp-clear {
263
+ font: normal 12px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
264
+ -webkit-box-sizing: border-box;
265
+ -moz-box-sizing: border-box;
266
+ -ms-box-sizing: border-box;
267
+ box-sizing: border-box;
268
+ }
269
+ .sp-top {
270
+ margin-bottom: 3px;
271
+ }
272
+ .sp-color, .sp-hue, .sp-clear {
273
+ border: solid 1px #666;
274
+ }
275
+
276
+ /* Input */
277
+ .sp-input-container {
278
+ float:right;
279
+ width: 100px;
280
+ margin-bottom: 4px;
281
+ }
282
+ .sp-initial-disabled .sp-input-container {
283
+ width: 100%;
284
+ }
285
+ .sp-input {
286
+ font-size: 12px !important;
287
+ border: 1px inset;
288
+ padding: 4px 5px;
289
+ margin: 0;
290
+ width: 100%;
291
+ background:transparent;
292
+ border-radius: 3px;
293
+ color: #222;
294
+ }
295
+ .sp-input:focus {
296
+ border: 1px solid orange;
297
+ }
298
+ .sp-input.sp-validation-error {
299
+ border: 1px solid red;
300
+ background: #fdd;
301
+ }
302
+ .sp-picker-container , .sp-palette-container {
303
+ float:left;
304
+ position: relative;
305
+ padding: 10px;
306
+ padding-bottom: 300px;
307
+ margin-bottom: -290px;
308
+ }
309
+ .sp-picker-container {
310
+ width: 172px;
311
+ border-left: solid 1px #fff;
312
+ }
313
+
314
+ /* Palettes */
315
+ .sp-palette-container {
316
+ border-right: solid 1px #ccc;
317
+ }
318
+
319
+ .sp-palette-only .sp-palette-container {
320
+ border: 0;
321
+ }
322
+
323
+ .sp-palette .sp-thumb-el {
324
+ display: block;
325
+ position:relative;
326
+ float:left;
327
+ width: 24px;
328
+ height: 15px;
329
+ margin: 3px;
330
+ cursor: pointer;
331
+ border:solid 2px transparent;
332
+ }
333
+ .sp-palette .sp-thumb-el:hover, .sp-palette .sp-thumb-el.sp-thumb-active {
334
+ border-color: orange;
335
+ }
336
+ .sp-thumb-el {
337
+ position:relative;
338
+ }
339
+
340
+ /* Initial */
341
+ .sp-initial {
342
+ float: left;
343
+ border: solid 1px #333;
344
+ }
345
+ .sp-initial span {
346
+ width: 30px;
347
+ height: 25px;
348
+ border:none;
349
+ display:block;
350
+ float:left;
351
+ margin:0;
352
+ }
353
+
354
+ .sp-initial .sp-clear-display {
355
+ background-position: center;
356
+ }
357
+
358
+ /* Buttons */
359
+ .sp-palette-button-container,
360
+ .sp-button-container {
361
+ float: right;
362
+ }
363
+
364
+ /* Replacer (the little preview div that shows up instead of the <input>) */
365
+ .sp-replacer {
366
+ margin:0;
367
+ overflow:hidden;
368
+ cursor:pointer;
369
+ padding: 4px;
370
+ display:inline-block;
371
+ *zoom: 1;
372
+ *display: inline;
373
+ border: solid 1px #91765d;
374
+ background: #eee;
375
+ color: #333;
376
+ vertical-align: middle;
377
+ }
378
+ .sp-replacer:hover, .sp-replacer.sp-active {
379
+ border-color: #F0C49B;
380
+ color: #111;
381
+ }
382
+ .sp-replacer.sp-disabled {
383
+ cursor:default;
384
+ border-color: silver;
385
+ color: silver;
386
+ }
387
+ .sp-dd {
388
+ padding: 2px 0;
389
+ height: 16px;
390
+ line-height: 16px;
391
+ float:left;
392
+ font-size:10px;
393
+ }
394
+ .sp-preview {
395
+ position:relative;
396
+ width:25px;
397
+ height: 20px;
398
+ border: solid 1px #222;
399
+ margin-right: 5px;
400
+ float:left;
401
+ z-index: 0;
402
+ }
403
+
404
+ .sp-palette {
405
+ *width: 220px;
406
+ max-width: 220px;
407
+ }
408
+ .sp-palette .sp-thumb-el {
409
+ width:16px;
410
+ height: 16px;
411
+ margin:2px 1px;
412
+ border: solid 1px #d0d0d0;
413
+ }
414
+
415
+ .sp-container {
416
+ padding-bottom:0;
417
+ }
418
+
419
+
420
+ /* Buttons: http://hellohappy.org/css3-buttons/ */
421
+ .sp-container button {
422
+ background-color: #eeeeee;
423
+ background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
424
+ background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
425
+ background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
426
+ background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
427
+ background-image: linear-gradient(to bottom, #eeeeee, #cccccc);
428
+ border: 1px solid #ccc;
429
+ border-bottom: 1px solid #bbb;
430
+ border-radius: 3px;
431
+ color: #333;
432
+ font-size: 14px;
433
+ line-height: 1;
434
+ padding: 5px 4px;
435
+ text-align: center;
436
+ text-shadow: 0 1px 0 #eee;
437
+ vertical-align: middle;
438
+ }
439
+ .sp-container button:hover {
440
+ background-color: #dddddd;
441
+ background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb);
442
+ background-image: -moz-linear-gradient(top, #dddddd, #bbbbbb);
443
+ background-image: -ms-linear-gradient(top, #dddddd, #bbbbbb);
444
+ background-image: -o-linear-gradient(top, #dddddd, #bbbbbb);
445
+ background-image: linear-gradient(to bottom, #dddddd, #bbbbbb);
446
+ border: 1px solid #bbb;
447
+ border-bottom: 1px solid #999;
448
+ cursor: pointer;
449
+ text-shadow: 0 1px 0 #ddd;
450
+ }
451
+ .sp-container button:active {
452
+ border: 1px solid #aaa;
453
+ border-bottom: 1px solid #888;
454
+ -webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
455
+ -moz-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
456
+ -ms-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
457
+ -o-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
458
+ box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
459
+ }
460
+ .sp-cancel {
461
+ font-size: 11px;
462
+ color: #d93f3f !important;
463
+ margin:0;
464
+ padding:2px;
465
+ margin-right: 5px;
466
+ vertical-align: middle;
467
+ text-decoration:none;
468
+
469
+ }
470
+ .sp-cancel:hover {
471
+ color: #d93f3f !important;
472
+ text-decoration: underline;
473
+ }
474
+
475
+
476
+ .sp-palette span:hover, .sp-palette span.sp-thumb-active {
477
+ border-color: #000;
478
+ }
479
+
480
+ .sp-preview, .sp-alpha, .sp-thumb-el {
481
+ position:relative;
482
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
483
+ }
484
+ .sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner {
485
+ display:block;
486
+ position:absolute;
487
+ top:0;left:0;bottom:0;right:0;
488
+ }
489
+
490
+ .sp-palette .sp-thumb-inner {
491
+ background-position: 50% 50%;
492
+ background-repeat: no-repeat;
493
+ }
494
+
495
+ .sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner {
496
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=);
497
+ }
498
+
499
+ .sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner {
500
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=);
501
+ }
502
+
503
+ .sp-clear-display {
504
+ background-repeat:no-repeat;
505
+ background-position: center;
506
+ background-image: url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==);
507
+ }
media/js/blocks/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(l,a,function(t){return e[t]}.bind(null,a));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=lodash},,,function(e,t,n){"use strict";n.r(t);var l=n(0);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function i(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?u(e):t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var s=wp.i18n.__,b=wp.element.Component,f=wp.editor.InspectorControls,v=wp.components,h=v.SelectControl,d=v.CheckboxControl,y=v.PanelBody,g=v.TextControl,_=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(_,e);var t,n,a,b,v=(t=_,function(){var e,n=p(t);if(c()){var l=p(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return i(this,e)});function _(){var e;return o(this,_),(e=v.apply(this,arguments)).setOptions=e.setOptions.bind(u(e)),e}return n=_,(a=[{key:"setOptions",value:function(e){var t=[];return e&&(t=e.map((function(e){return{value:e.id.toString(),label:Object(l.get)(e,["title","raw"])||Object(l.get)(e,["name"])}}))),t}},{key:"render",value:function(){var e=this.props,t=e.attributes,n=t.col,l=t.events,a=t.event_categ,o=t.increment,r=t.view,i=t.view_sort,u=t.label,c=t.hide_label,p=t.hide_hrs,m=t.hide_empty_rows,b=t.title,v=t.time,_=t.sub_title,w=t.description,C=t.user,E=t.group,R=t.disable_event_url,O=t.text_align,S=t.text_align_vertical,j=t.id,k=t.custom_class,x=t.row_height,T=t.font_size,P=t.responsive,D=t.table_layout,I=e.selectedEvents,H=e.selectedColumns,z=e.selectedEventCategories,M=e.setAttributes;return React.createElement(f,null,React.createElement(y,{title:s("Settings","mp-timetable")},React.createElement(h,{multiple:!0,size:"7",label:s("Columns","mp-timetable"),help:s("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:n,onChange:function(e){return M({col:e})},options:this.setOptions(H)}),React.createElement(h,{multiple:!0,size:"7",label:s("Specific events","mp-timetable"),help:s("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:l,onChange:function(e){return M({events:e})},options:this.setOptions(I)}),React.createElement(h,{multiple:!0,size:"7",label:s("Event categories","mp-timetable"),help:s("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:a,onChange:function(e){return M({event_categ:e})},options:this.setOptions(z)}),React.createElement(d,{label:s("Title","mp-timetable"),checked:"1"==b,onChange:function(e){M({title:e?"1":"0"})}}),React.createElement(d,{label:s("Time","mp-timetable"),checked:"1"==v,onChange:function(e){M({time:e?"1":"0"})}}),React.createElement(d,{label:s("Subtitle","mp-timetable"),checked:"1"==_,onChange:function(e){M({sub_title:e?"1":"0"})}}),React.createElement(d,{label:s("Description","mp-timetable"),checked:"1"==w,onChange:function(e){M({description:e?"1":"0"})}}),React.createElement(d,{label:s("Event Head","mp-timetable"),checked:"1"==C,onChange:function(e){M({user:e?"1":"0"})}}),React.createElement(g,{label:s("Block height in pixels","mp-timetable"),type:"number",value:isNaN(x)?0:parseInt(x),onChange:function(e){M({row_height:e.toString()})},min:1,step:1}),React.createElement(g,{label:s("Base font size","mp-timetable"),help:s("Base font size for the table. Example 12px, 2em, 80%.","mp-timetable"),value:T,onChange:function(e){return M({font_size:e})}}),React.createElement(h,{label:s("Time frame for event","mp-timetable"),value:o,onChange:function(e){return M({increment:e})},options:[{value:"1",label:s("Hour (1h)","mp-timetable")},{value:"0.5",label:s("Half hour (30min)","mp-timetable")},{value:"0.25",label:s("Quarter hour (15min)","mp-timetable")}]}),React.createElement(h,{label:s("Filter events style","mp-timetable"),value:r,onChange:function(e){return M({view:e})},options:[{value:"dropdown_list",label:s("Dropdown list","mp-timetable")},{value:"tabs",label:s("Tabs","mp-timetable")}]}),React.createElement(h,{label:s("Order of items in filter","mp-timetable"),value:i,onChange:function(e){return M({view_sort:e})},options:[{value:"",label:s("Default","mp-timetable")},{value:"menu_order",label:s("Menu Order","mp-timetable")},{value:"post_title",label:s("Title","mp-timetable")}]}),React.createElement(g,{label:s("Filter title to display all events","mp-timetable"),value:u,onChange:function(e){return M({label:e})}}),React.createElement(h,{label:s("Hide 'All Events' option","mp-timetable"),value:c,onChange:function(e){return M({hide_label:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Hide column with hours","mp-timetable"),value:p,onChange:function(e){return M({hide_hrs:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Do not display empty rows","mp-timetable"),value:m,onChange:function(e){return M({hide_empty_rows:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Merge cells with common events","mp-timetable"),value:E,onChange:function(e){return M({group:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Disable event link","mp-timetable"),value:R,onChange:function(e){return M({disable_event_url:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Horizontal align","mp-timetable"),value:O,onChange:function(e){return M({text_align:e})},options:[{value:"center",label:s("center","mp-timetable")},{value:"left",label:s("left","mp-timetable")},{value:"right",label:s("right","mp-timetable")}]}),React.createElement(h,{label:s("Vertical align","mp-timetable"),value:S,onChange:function(e){return M({text_align_vertical:e})},options:[{value:"default",label:s("Default","mp-timetable")},{value:"top",label:s("top","mp-timetable")},{value:"middle",label:s("middle","mp-timetable")},{value:"bottom",label:s("bottom","mp-timetable")}]}),React.createElement(h,{label:s("Table layout","mp-timetable"),value:D,onChange:function(e){return M({table_layout:e})},options:[{value:"",label:s("Default","mp-timetable")},{value:"auto",label:s("Auto","mp-timetable")},{value:"fixed",label:s("Fixed","mp-timetable")}]}),React.createElement(g,{label:s("Unique ID","mp-timetable"),help:s("If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens.","mp-timetable"),value:j,onChange:function(e){return M({id:e})}}),React.createElement(g,{label:s("CSS class","mp-timetable"),value:k,onChange:function(e){return M({custom_class:e})}}),React.createElement(h,{label:s("Mobile behavior","mp-timetable"),value:P,onChange:function(e){return M({responsive:e})},options:[{value:"0",label:s("Table","mp-timetable")},{value:"1",label:s("List","mp-timetable")}]})))}}])&&r(n.prototype,a),b&&r(n,b),_}(b);function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function R(e,t){return!t||"object"!==w(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function O(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}wp.i18n.__;var k=wp.element,x=k.Component,T=k.Fragment,P=wp.compose.compose,D=wp.components,I=D.Disabled,H=D.ServerSideRender,z=wp.data.withSelect,M=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&j(e,t)}(i,e);var t,n,a,o,r=(t=i,function(){var e,n=S(t);if(O()){var l=S(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return R(this,e)});function i(){return C(this,i),r.apply(this,arguments)}return n=i,(a=[{key:"initTable",value:function(){var e=this.props.clientId,t=jQuery("#block-".concat(e)),n=setInterval((function(){t.find(".mptt-shortcode-wrapper").length&&!t.find(".mptt-shortcode-wrapper").hasClass("table-init")&&(clearInterval(n),window.mptt.tableInit())}),1)}},{key:"componentDidUpdate",value:function(e,t){Object(l.isEqual)(this.props.attributes,e.attributes)||this.initTable()}},{key:"componentDidMount",value:function(){this.initTable()}},{key:"render",value:function(){var e=this.props.attributes;return e.events,e.event_categ,React.createElement(T,null,React.createElement(_,this.props),React.createElement(I,null,React.createElement(H,{block:"mp-timetable/timetable",attributes:this.props.attributes})))}}])&&E(n.prototype,a),o&&E(n,o),i}(x),N=P([z((function(e,t){var n=e("core"),a=n.getEntityRecords,o=(n.getCategories,a("postType","mp-event",{per_page:-1,orderby:"title",order:"asc"})),r=a("postType","mp-column",{per_page:-1}),i=a("taxonomy","mp-event_category",{per_page:-1});return{selectedEvents:o?o.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedColumns:r?r.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedEventCategories:i?i.map((function(e){return Object(l.pick)(e,["id","name"])})):null}}))])(M);(0,wp.blocks.registerBlockType)("mp-timetable/timetable",{title:(0,wp.i18n.__)("Timetable","mp-timetable"),category:"common",icon:"calendar",supports:{align:["wide","full"]},getEditWrapperProps:function(e){var t=e.align;if(["wide","full"].includes(t))return{"data-align":t}},edit:N,save:function(){return null}})}]);
1
+ !function(e){var t={};function n(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,l){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:l})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var l=Object.create(null);if(n.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(l,a,function(t){return e[t]}.bind(null,a));return l},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=lodash},,,function(e,t,n){"use strict";n.r(t);var l=n(0);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function i(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?u(e):t}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var s=wp.i18n.__,b=wp.element.Component,f=wp.editor.InspectorControls,v=wp.components,h=v.SelectControl,d=v.CheckboxControl,y=v.PanelBody,g=v.TextControl,_=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}(_,e);var t,n,a,b,v=(t=_,function(){var e,n=p(t);if(c()){var l=p(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return i(this,e)});function _(){var e;return o(this,_),(e=v.apply(this,arguments)).setOptions=e.setOptions.bind(u(e)),e}return n=_,(a=[{key:"setOptions",value:function(e){var t=[];return e&&(t=e.map((function(e){return{value:e.id.toString(),label:Object(l.get)(e,["title","raw"])||Object(l.get)(e,["name"])}}))),t}},{key:"render",value:function(){var e=this.props,t=e.attributes,n=t.col,l=t.events,a=t.event_categ,o=t.increment,r=t.view,i=t.view_sort,u=t.label,c=t.hide_label,p=t.hide_hrs,m=t.hide_empty_rows,b=t.title,v=t.time,_=t.sub_title,w=t.description,C=t.user,E=t.group,R=t.disable_event_url,O=t.text_align,S=t.text_align_vertical,j=t.id,k=t.custom_class,x=t.row_height,T=t.font_size,P=t.responsive,D=t.table_layout,I=e.selectedEvents,N=e.selectedColumns,H=e.selectedEventCategories,z=e.setAttributes;return React.createElement(f,null,React.createElement(y,{title:s("Settings","mp-timetable")},React.createElement(h,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:s("Columns","mp-timetable"),help:s("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:n,onChange:function(e){return z({col:e})},options:this.setOptions(N)}),React.createElement(h,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:s("Specific events","mp-timetable"),help:s("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:l,onChange:function(e){return z({events:e})},options:this.setOptions(I)}),React.createElement(h,{className:"timetable-wp56-fix",multiple:!0,size:"7",label:s("Event categories","mp-timetable"),help:s("Hold the Ctrl or Command key to select/deselect multiple options.","mp-timetable"),value:a,onChange:function(e){return z({event_categ:e})},options:this.setOptions(H)}),React.createElement(d,{label:s("Title","mp-timetable"),checked:"1"==b,onChange:function(e){z({title:e?"1":"0"})}}),React.createElement(d,{label:s("Time","mp-timetable"),checked:"1"==v,onChange:function(e){z({time:e?"1":"0"})}}),React.createElement(d,{label:s("Subtitle","mp-timetable"),checked:"1"==_,onChange:function(e){z({sub_title:e?"1":"0"})}}),React.createElement(d,{label:s("Description","mp-timetable"),checked:"1"==w,onChange:function(e){z({description:e?"1":"0"})}}),React.createElement(d,{label:s("Event Head","mp-timetable"),checked:"1"==C,onChange:function(e){z({user:e?"1":"0"})}}),React.createElement(g,{label:s("Block height in pixels","mp-timetable"),type:"number",value:isNaN(x)?0:parseInt(x),onChange:function(e){z({row_height:e.toString()})},min:1,step:1}),React.createElement(g,{label:s("Base font size","mp-timetable"),help:s("Base font size for the table. Example 12px, 2em, 80%.","mp-timetable"),value:T,onChange:function(e){return z({font_size:e})}}),React.createElement(h,{label:s("Time frame for event","mp-timetable"),value:o,onChange:function(e){return z({increment:e})},options:[{value:"1",label:s("Hour (1h)","mp-timetable")},{value:"0.5",label:s("Half hour (30min)","mp-timetable")},{value:"0.25",label:s("Quarter hour (15min)","mp-timetable")}]}),React.createElement(h,{label:s("Filter events style","mp-timetable"),value:r,onChange:function(e){return z({view:e})},options:[{value:"dropdown_list",label:s("Dropdown list","mp-timetable")},{value:"tabs",label:s("Tabs","mp-timetable")}]}),React.createElement(h,{label:s("Order of items in filter","mp-timetable"),value:i,onChange:function(e){return z({view_sort:e})},options:[{value:"",label:s("Default","mp-timetable")},{value:"menu_order",label:s("Menu Order","mp-timetable")},{value:"post_title",label:s("Title","mp-timetable")}]}),React.createElement(g,{label:s("Filter title to display all events","mp-timetable"),value:u,onChange:function(e){return z({label:e})}}),React.createElement(h,{label:s("Hide 'All Events' option","mp-timetable"),value:c,onChange:function(e){return z({hide_label:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Hide column with hours","mp-timetable"),value:p,onChange:function(e){return z({hide_hrs:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Do not display empty rows","mp-timetable"),value:m,onChange:function(e){return z({hide_empty_rows:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Merge cells with common events","mp-timetable"),value:E,onChange:function(e){return z({group:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Disable event link","mp-timetable"),value:R,onChange:function(e){return z({disable_event_url:e})},options:[{value:"0",label:s("No","mp-timetable")},{value:"1",label:s("Yes","mp-timetable")}]}),React.createElement(h,{label:s("Horizontal align","mp-timetable"),value:O,onChange:function(e){return z({text_align:e})},options:[{value:"center",label:s("center","mp-timetable")},{value:"left",label:s("left","mp-timetable")},{value:"right",label:s("right","mp-timetable")}]}),React.createElement(h,{label:s("Vertical align","mp-timetable"),value:S,onChange:function(e){return z({text_align_vertical:e})},options:[{value:"default",label:s("Default","mp-timetable")},{value:"top",label:s("top","mp-timetable")},{value:"middle",label:s("middle","mp-timetable")},{value:"bottom",label:s("bottom","mp-timetable")}]}),React.createElement(h,{label:s("Table layout","mp-timetable"),value:D,onChange:function(e){return z({table_layout:e})},options:[{value:"",label:s("Default","mp-timetable")},{value:"auto",label:s("Auto","mp-timetable")},{value:"fixed",label:s("Fixed","mp-timetable")}]}),React.createElement(g,{label:s("Unique ID","mp-timetable"),help:s("If you use more than one table on a page specify the unique ID for a timetable. It is usually all lowercase and contains only letters, numbers, and hyphens.","mp-timetable"),value:j,onChange:function(e){return z({id:e})}}),React.createElement(g,{label:s("CSS class","mp-timetable"),value:k,onChange:function(e){return z({custom_class:e})}}),React.createElement(h,{label:s("Mobile behavior","mp-timetable"),value:P,onChange:function(e){return z({responsive:e})},options:[{value:"0",label:s("Table","mp-timetable")},{value:"1",label:s("List","mp-timetable")}]})))}}])&&r(n.prototype,a),b&&r(n,b),_}(b);function w(e){return(w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function C(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E(e,t){for(var n=0;n<t.length;n++){var l=t[n];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}function R(e,t){return!t||"object"!==w(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function O(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function S(e){return(S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function j(e,t){return(j=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}wp.i18n.__;var k=wp.element,x=k.Component,T=k.Fragment,P=wp.compose.compose,D=wp.components,I=D.Disabled,N=D.ServerSideRender,H=wp.data.withSelect,z=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&j(e,t)}(i,e);var t,n,a,o,r=(t=i,function(){var e,n=S(t);if(O()){var l=S(this).constructor;e=Reflect.construct(n,arguments,l)}else e=n.apply(this,arguments);return R(this,e)});function i(){return C(this,i),r.apply(this,arguments)}return n=i,(a=[{key:"initTable",value:function(){var e=this.props.clientId,t=jQuery("#block-".concat(e)),n=setInterval((function(){t.find(".mptt-shortcode-wrapper").length&&!t.find(".mptt-shortcode-wrapper").hasClass("table-init")&&(clearInterval(n),window.mptt.tableInit())}),1)}},{key:"componentDidUpdate",value:function(e,t){Object(l.isEqual)(this.props.attributes,e.attributes)||this.initTable()}},{key:"componentDidMount",value:function(){this.initTable()}},{key:"render",value:function(){var e=this.props.attributes;return e.events,e.event_categ,React.createElement(T,null,React.createElement(_,this.props),React.createElement(I,null,React.createElement(N,{block:"mp-timetable/timetable",attributes:this.props.attributes})))}}])&&E(n.prototype,a),o&&E(n,o),i}(x),M=P([H((function(e,t){var n=e("core"),a=n.getEntityRecords,o=(n.getCategories,a("postType","mp-event",{per_page:-1,orderby:"title",order:"asc"})),r=a("postType","mp-column",{per_page:-1}),i=a("taxonomy","mp-event_category",{per_page:-1});return{selectedEvents:o?o.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedColumns:r?r.map((function(e){return Object(l.pick)(e,["id","title"])})):null,selectedEventCategories:i?i.map((function(e){return Object(l.pick)(e,["id","name"])})):null}}))])(z);(0,wp.blocks.registerBlockType)("mp-timetable/timetable",{title:(0,wp.i18n.__)("Timetable","mp-timetable"),category:"common",icon:"calendar",supports:{align:["wide","full"]},getEditWrapperProps:function(e){var t=e.align;if(["wide","full"].includes(t))return{"data-align":t}},edit:M,save:function(){return null}})}]);
media/js/blocks/src/timetable/inspector.js CHANGED
@@ -84,6 +84,7 @@ class Inspector extends Component {
84
  title={__('Settings', 'mp-timetable')}
85
  >
86
  <SelectControl
 
87
  multiple
88
  size="7"
89
  label={__('Columns', 'mp-timetable')}
@@ -93,6 +94,7 @@ class Inspector extends Component {
93
  options={this.setOptions(selectedColumns)}
94
  />
95
  <SelectControl
 
96
  multiple
97
  size="7"
98
  label={__('Specific events', 'mp-timetable')}
@@ -102,6 +104,7 @@ class Inspector extends Component {
102
  options={this.setOptions(selectedEvents )}
103
  />
104
  <SelectControl
 
105
  multiple
106
  size="7"
107
  label={__('Event categories', 'mp-timetable')}
84
  title={__('Settings', 'mp-timetable')}
85
  >
86
  <SelectControl
87
+ className="timetable-wp56-fix"
88
  multiple
89
  size="7"
90
  label={__('Columns', 'mp-timetable')}
94
  options={this.setOptions(selectedColumns)}
95
  />
96
  <SelectControl
97
+ className="timetable-wp56-fix"
98
  multiple
99
  size="7"
100
  label={__('Specific events', 'mp-timetable')}
104
  options={this.setOptions(selectedEvents )}
105
  />
106
  <SelectControl
107
+ className="timetable-wp56-fix"
108
  multiple
109
  size="7"
110
  label={__('Event categories', 'mp-timetable')}
media/js/lib/spectrum.js CHANGED
@@ -1,2323 +1,2341 @@
1
- // Spectrum Colorpicker v1.8.0
2
- // https://github.com/bgrins/spectrum
3
- // Author: Brian Grinstead
4
- // License: MIT
5
-
6
- (function (factory) {
7
- "use strict";
8
-
9
- if (typeof define === 'function' && define.amd) { // AMD
10
- define(['jquery'], factory);
11
- }
12
- else if (typeof exports == "object" && typeof module == "object") { // CommonJS
13
- module.exports = factory(require('jquery'));
14
- }
15
- else { // Browser
16
- factory(jQuery);
17
- }
18
- })(function($, undefined) {
19
- "use strict";
20
-
21
- var defaultOpts = {
22
-
23
- // Callbacks
24
- beforeShow: noop,
25
- move: noop,
26
- change: noop,
27
- show: noop,
28
- hide: noop,
29
-
30
- // Options
31
- color: false,
32
- flat: false,
33
- showInput: false,
34
- allowEmpty: false,
35
- showButtons: true,
36
- clickoutFiresChange: true,
37
- showInitial: false,
38
- showPalette: false,
39
- showPaletteOnly: false,
40
- hideAfterPaletteSelect: false,
41
- togglePaletteOnly: false,
42
- showSelectionPalette: true,
43
- localStorageKey: false,
44
- appendTo: "body",
45
- maxSelectionSize: 7,
46
- cancelText: "cancel",
47
- chooseText: "choose",
48
- togglePaletteMoreText: "more",
49
- togglePaletteLessText: "less",
50
- clearText: "Clear Color Selection",
51
- noColorSelectedText: "No Color Selected",
52
- preferredFormat: false,
53
- className: "", // Deprecated - use containerClassName and replacerClassName instead.
54
- containerClassName: "",
55
- replacerClassName: "",
56
- showAlpha: false,
57
- theme: "sp-light",
58
- palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
59
- selectionPalette: [],
60
- disabled: false,
61
- offset: null
62
- },
63
- spectrums = [],
64
- IE = !!/msie/i.exec( window.navigator.userAgent ),
65
- rgbaSupport = (function() {
66
- function contains( str, substr ) {
67
- return !!~('' + str).indexOf(substr);
68
- }
69
-
70
- var elem = document.createElement('div');
71
- var style = elem.style;
72
- style.cssText = 'background-color:rgba(0,0,0,.5)';
73
- return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
74
- })(),
75
- replaceInput = [
76
- "<div class='sp-replacer'>",
77
- "<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
78
- "<div class='sp-dd'>&#9660;</div>",
79
- "</div>"
80
- ].join(''),
81
- markup = (function () {
82
-
83
- // IE does not support gradients with multiple stops, so we need to simulate
84
- // that for the rainbow slider with 8 divs that each have a single gradient
85
- var gradientFix = "";
86
- if (IE) {
87
- for (var i = 1; i <= 6; i++) {
88
- gradientFix += "<div class='sp-" + i + "'></div>";
89
- }
90
- }
91
-
92
- return [
93
- "<div class='sp-container sp-hidden'>",
94
- "<div class='sp-palette-container'>",
95
- "<div class='sp-palette sp-thumb sp-cf'></div>",
96
- "<div class='sp-palette-button-container sp-cf'>",
97
- "<button type='button' class='sp-palette-toggle'></button>",
98
- "</div>",
99
- "</div>",
100
- "<div class='sp-picker-container'>",
101
- "<div class='sp-top sp-cf'>",
102
- "<div class='sp-fill'></div>",
103
- "<div class='sp-top-inner'>",
104
- "<div class='sp-color'>",
105
- "<div class='sp-sat'>",
106
- "<div class='sp-val'>",
107
- "<div class='sp-dragger'></div>",
108
- "</div>",
109
- "</div>",
110
- "</div>",
111
- "<div class='sp-clear sp-clear-display'>",
112
- "</div>",
113
- "<div class='sp-hue'>",
114
- "<div class='sp-slider'></div>",
115
- gradientFix,
116
- "</div>",
117
- "</div>",
118
- "<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>",
119
- "</div>",
120
- "<div class='sp-input-container sp-cf'>",
121
- "<input class='sp-input' type='text' spellcheck='false' />",
122
- "</div>",
123
- "<div class='sp-initial sp-thumb sp-cf'></div>",
124
- "<div class='sp-button-container sp-cf'>",
125
- "<a class='sp-cancel' href='#'></a>",
126
- "<button type='button' class='sp-choose'></button>",
127
- "</div>",
128
- "</div>",
129
- "</div>"
130
- ].join("");
131
- })();
132
-
133
- function paletteTemplate (p, color, className, opts) {
134
- var html = [];
135
- for (var i = 0; i < p.length; i++) {
136
- var current = p[i];
137
- if(current) {
138
- var tiny = tinycolor(current);
139
- var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
140
- c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : "";
141
- var formattedString = tiny.toString(opts.preferredFormat || "rgb");
142
- var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
143
- html.push('<span title="' + formattedString + '" data-color="' + tiny.toRgbString() + '" class="' + c + '"><span class="sp-thumb-inner" style="' + swatchStyle + ';" /></span>');
144
- } else {
145
- var cls = 'sp-clear-display';
146
- html.push($('<div />')
147
- .append($('<span data-color="" style="background-color:transparent;" class="' + cls + '"></span>')
148
- .attr('title', opts.noColorSelectedText)
149
- )
150
- .html()
151
- );
152
- }
153
- }
154
- return "<div class='sp-cf " + className + "'>" + html.join('') + "</div>";
155
- }
156
-
157
- function hideAll() {
158
- for (var i = 0; i < spectrums.length; i++) {
159
- if (spectrums[i]) {
160
- spectrums[i].hide();
161
- }
162
- }
163
- }
164
-
165
- function instanceOptions(o, callbackContext) {
166
- var opts = $.extend({}, defaultOpts, o);
167
- opts.callbacks = {
168
- 'move': bind(opts.move, callbackContext),
169
- 'change': bind(opts.change, callbackContext),
170
- 'show': bind(opts.show, callbackContext),
171
- 'hide': bind(opts.hide, callbackContext),
172
- 'beforeShow': bind(opts.beforeShow, callbackContext)
173
- };
174
-
175
- return opts;
176
- }
177
-
178
- function spectrum(element, o) {
179
-
180
- var opts = instanceOptions(o, element),
181
- flat = opts.flat,
182
- showSelectionPalette = opts.showSelectionPalette,
183
- localStorageKey = opts.localStorageKey,
184
- theme = opts.theme,
185
- callbacks = opts.callbacks,
186
- resize = throttle(reflow, 10),
187
- visible = false,
188
- isDragging = false,
189
- dragWidth = 0,
190
- dragHeight = 0,
191
- dragHelperHeight = 0,
192
- slideHeight = 0,
193
- slideWidth = 0,
194
- alphaWidth = 0,
195
- alphaSlideHelperWidth = 0,
196
- slideHelperHeight = 0,
197
- currentHue = 0,
198
- currentSaturation = 0,
199
- currentValue = 0,
200
- currentAlpha = 1,
201
- palette = [],
202
- paletteArray = [],
203
- paletteLookup = {},
204
- selectionPalette = opts.selectionPalette.slice(0),
205
- maxSelectionSize = opts.maxSelectionSize,
206
- draggingClass = "sp-dragging",
207
- shiftMovementDirection = null;
208
-
209
- var doc = element.ownerDocument,
210
- body = doc.body,
211
- boundElement = $(element),
212
- disabled = false,
213
- container = $(markup, doc).addClass(theme),
214
- pickerContainer = container.find(".sp-picker-container"),
215
- dragger = container.find(".sp-color"),
216
- dragHelper = container.find(".sp-dragger"),
217
- slider = container.find(".sp-hue"),
218
- slideHelper = container.find(".sp-slider"),
219
- alphaSliderInner = container.find(".sp-alpha-inner"),
220
- alphaSlider = container.find(".sp-alpha"),
221
- alphaSlideHelper = container.find(".sp-alpha-handle"),
222
- textInput = container.find(".sp-input"),
223
- paletteContainer = container.find(".sp-palette"),
224
- initialColorContainer = container.find(".sp-initial"),
225
- cancelButton = container.find(".sp-cancel"),
226
- clearButton = container.find(".sp-clear"),
227
- chooseButton = container.find(".sp-choose"),
228
- toggleButton = container.find(".sp-palette-toggle"),
229
- isInput = boundElement.is("input"),
230
- isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
231
- shouldReplace = isInput && !flat,
232
- replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
233
- offsetElement = (shouldReplace) ? replacer : boundElement,
234
- previewElement = replacer.find(".sp-preview-inner"),
235
- initialColor = opts.color || (isInput && boundElement.val()),
236
- colorOnShow = false,
237
- currentPreferredFormat = opts.preferredFormat,
238
- clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,
239
- isEmpty = !initialColor,
240
- allowEmpty = opts.allowEmpty && !isInputTypeColor;
241
-
242
- function applyOptions() {
243
-
244
- if (opts.showPaletteOnly) {
245
- opts.showPalette = true;
246
- }
247
-
248
- toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
249
-
250
- if (opts.palette) {
251
- palette = opts.palette.slice(0);
252
- paletteArray = $.isArray(palette[0]) ? palette : [palette];
253
- paletteLookup = {};
254
- for (var i = 0; i < paletteArray.length; i++) {
255
- for (var j = 0; j < paletteArray[i].length; j++) {
256
- var rgb = tinycolor(paletteArray[i][j]).toRgbString();
257
- paletteLookup[rgb] = true;
258
- }
259
- }
260
- }
261
-
262
- container.toggleClass("sp-flat", flat);
263
- container.toggleClass("sp-input-disabled", !opts.showInput);
264
- container.toggleClass("sp-alpha-enabled", opts.showAlpha);
265
- container.toggleClass("sp-clear-enabled", allowEmpty);
266
- container.toggleClass("sp-buttons-disabled", !opts.showButtons);
267
- container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly);
268
- container.toggleClass("sp-palette-disabled", !opts.showPalette);
269
- container.toggleClass("sp-palette-only", opts.showPaletteOnly);
270
- container.toggleClass("sp-initial-disabled", !opts.showInitial);
271
- container.addClass(opts.className).addClass(opts.containerClassName);
272
-
273
- reflow();
274
- }
275
-
276
- function initialize() {
277
-
278
- if (IE) {
279
- container.find("*:not(input)").attr("unselectable", "on");
280
- }
281
-
282
- applyOptions();
283
-
284
- if (shouldReplace) {
285
- boundElement.after(replacer).hide();
286
- }
287
-
288
- if (!allowEmpty) {
289
- clearButton.hide();
290
- }
291
-
292
- if (flat) {
293
- boundElement.after(container).hide();
294
- }
295
- else {
296
-
297
- var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo);
298
- if (appendTo.length !== 1) {
299
- appendTo = $("body");
300
- }
301
-
302
- appendTo.append(container);
303
- }
304
-
305
- updateSelectionPaletteFromStorage();
306
-
307
- offsetElement.bind("click.spectrum touchstart.spectrum", function (e) {
308
- if (!disabled) {
309
- toggle();
310
- }
311
-
312
- e.stopPropagation();
313
-
314
- if (!$(e.target).is("input")) {
315
- e.preventDefault();
316
- }
317
- });
318
-
319
- if(boundElement.is(":disabled") || (opts.disabled === true)) {
320
- disable();
321
- }
322
-
323
- // Prevent clicks from bubbling up to document. This would cause it to be hidden.
324
- container.click(stopPropagation);
325
-
326
- // Handle user typed input
327
- textInput.change(setFromTextInput);
328
- textInput.bind("paste", function () {
329
- setTimeout(setFromTextInput, 1);
330
- });
331
- textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
332
-
333
- cancelButton.text(opts.cancelText);
334
- cancelButton.bind("click.spectrum", function (e) {
335
- e.stopPropagation();
336
- e.preventDefault();
337
- revert();
338
- hide();
339
- });
340
-
341
- clearButton.attr("title", opts.clearText);
342
- clearButton.bind("click.spectrum", function (e) {
343
- e.stopPropagation();
344
- e.preventDefault();
345
- isEmpty = true;
346
- move();
347
-
348
- if(flat) {
349
- //for the flat style, this is a change event
350
- updateOriginalInput(true);
351
- }
352
- });
353
-
354
- chooseButton.text(opts.chooseText);
355
- chooseButton.bind("click.spectrum", function (e) {
356
- e.stopPropagation();
357
- e.preventDefault();
358
-
359
- if (IE && textInput.is(":focus")) {
360
- textInput.trigger('change');
361
- }
362
-
363
- if (isValid()) {
364
- updateOriginalInput(true);
365
- hide();
366
- }
367
- });
368
-
369
- toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
370
- toggleButton.bind("click.spectrum", function (e) {
371
- e.stopPropagation();
372
- e.preventDefault();
373
-
374
- opts.showPaletteOnly = !opts.showPaletteOnly;
375
-
376
- // To make sure the Picker area is drawn on the right, next to the
377
- // Palette area (and not below the palette), first move the Palette
378
- // to the left to make space for the picker, plus 5px extra.
379
- // The 'applyOptions' function puts the whole container back into place
380
- // and takes care of the button-text and the sp-palette-only CSS class.
381
- if (!opts.showPaletteOnly && !flat) {
382
- container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5));
383
- }
384
- applyOptions();
385
- });
386
-
387
- draggable(alphaSlider, function (dragX, dragY, e) {
388
- currentAlpha = (dragX / alphaWidth);
389
- isEmpty = false;
390
- if (e.shiftKey) {
391
- currentAlpha = Math.round(currentAlpha * 10) / 10;
392
- }
393
-
394
- move();
395
- }, dragStart, dragStop);
396
-
397
- draggable(slider, function (dragX, dragY) {
398
- currentHue = parseFloat(dragY / slideHeight);
399
- isEmpty = false;
400
- if (!opts.showAlpha) {
401
- currentAlpha = 1;
402
- }
403
- move();
404
- }, dragStart, dragStop);
405
-
406
- draggable(dragger, function (dragX, dragY, e) {
407
-
408
- // shift+drag should snap the movement to either the x or y axis.
409
- if (!e.shiftKey) {
410
- shiftMovementDirection = null;
411
- }
412
- else if (!shiftMovementDirection) {
413
- var oldDragX = currentSaturation * dragWidth;
414
- var oldDragY = dragHeight - (currentValue * dragHeight);
415
- var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);
416
-
417
- shiftMovementDirection = furtherFromX ? "x" : "y";
418
- }
419
-
420
- var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x";
421
- var setValue = !shiftMovementDirection || shiftMovementDirection === "y";
422
-
423
- if (setSaturation) {
424
- currentSaturation = parseFloat(dragX / dragWidth);
425
- }
426
- if (setValue) {
427
- currentValue = parseFloat((dragHeight - dragY) / dragHeight);
428
- }
429
-
430
- isEmpty = false;
431
- if (!opts.showAlpha) {
432
- currentAlpha = 1;
433
- }
434
-
435
- move();
436
-
437
- }, dragStart, dragStop);
438
-
439
- if (!!initialColor) {
440
- set(initialColor);
441
-
442
- // In case color was black - update the preview UI and set the format
443
- // since the set function will not run (default color is black).
444
- updateUI();
445
- currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format;
446
-
447
- addColorToSelectionPalette(initialColor);
448
- }
449
- else {
450
- updateUI();
451
- }
452
-
453
- if (flat) {
454
- show();
455
- }
456
-
457
- function paletteElementClick(e) {
458
- if (e.data && e.data.ignore) {
459
- set($(e.target).closest(".sp-thumb-el").data("color"));
460
- move();
461
- }
462
- else {
463
- set($(e.target).closest(".sp-thumb-el").data("color"));
464
- move();
465
- updateOriginalInput(true);
466
- if (opts.hideAfterPaletteSelect) {
467
- hide();
468
- }
469
- }
470
-
471
- return false;
472
- }
473
-
474
- var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
475
- paletteContainer.delegate(".sp-thumb-el", paletteEvent, paletteElementClick);
476
- initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, paletteElementClick);
477
- }
478
-
479
- function updateSelectionPaletteFromStorage() {
480
-
481
- if (localStorageKey && window.localStorage) {
482
-
483
- // Migrate old palettes over to new format. May want to remove this eventually.
484
- try {
485
- var oldPalette = window.localStorage[localStorageKey].split(",#");
486
- if (oldPalette.length > 1) {
487
- delete window.localStorage[localStorageKey];
488
- $.each(oldPalette, function(i, c) {
489
- addColorToSelectionPalette(c);
490
- });
491
- }
492
- }
493
- catch(e) { }
494
-
495
- try {
496
- selectionPalette = window.localStorage[localStorageKey].split(";");
497
- }
498
- catch (e) { }
499
- }
500
- }
501
-
502
- function addColorToSelectionPalette(color) {
503
- if (showSelectionPalette) {
504
- var rgb = tinycolor(color).toRgbString();
505
- if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) {
506
- selectionPalette.push(rgb);
507
- while(selectionPalette.length > maxSelectionSize) {
508
- selectionPalette.shift();
509
- }
510
- }
511
-
512
- if (localStorageKey && window.localStorage) {
513
- try {
514
- window.localStorage[localStorageKey] = selectionPalette.join(";");
515
- }
516
- catch(e) { }
517
- }
518
- }
519
- }
520
-
521
- function getUniqueSelectionPalette() {
522
- var unique = [];
523
- if (opts.showPalette) {
524
- for (var i = 0; i < selectionPalette.length; i++) {
525
- var rgb = tinycolor(selectionPalette[i]).toRgbString();
526
-
527
- if (!paletteLookup[rgb]) {
528
- unique.push(selectionPalette[i]);
529
- }
530
- }
531
- }
532
-
533
- return unique.reverse().slice(0, opts.maxSelectionSize);
534
- }
535
-
536
- function drawPalette() {
537
-
538
- var currentColor = get();
539
-
540
- var html = $.map(paletteArray, function (palette, i) {
541
- return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts);
542
- });
543
-
544
- updateSelectionPaletteFromStorage();
545
-
546
- if (selectionPalette) {
547
- html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts));
548
- }
549
-
550
- paletteContainer.html(html.join(""));
551
- }
552
-
553
- function drawInitial() {
554
- if (opts.showInitial) {
555
- var initial = colorOnShow;
556
- var current = get();
557
- initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts));
558
- }
559
- }
560
-
561
- function dragStart() {
562
- if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
563
- reflow();
564
- }
565
- isDragging = true;
566
- container.addClass(draggingClass);
567
- shiftMovementDirection = null;
568
- boundElement.trigger('dragstart.spectrum', [ get() ]);
569
- }
570
-
571
- function dragStop() {
572
- isDragging = false;
573
- container.removeClass(draggingClass);
574
- boundElement.trigger('dragstop.spectrum', [ get() ]);
575
- }
576
-
577
- function setFromTextInput() {
578
-
579
- var value = textInput.val();
580
-
581
- if ((value === null || value === "") && allowEmpty) {
582
- set(null);
583
- updateOriginalInput(true);
584
- }
585
- else {
586
- var tiny = tinycolor(value);
587
- if (tiny.isValid()) {
588
- set(tiny);
589
- updateOriginalInput(true);
590
- }
591
- else {
592
- textInput.addClass("sp-validation-error");
593
- }
594
- }
595
- }
596
-
597
- function toggle() {
598
- if (visible) {
599
- hide();
600
- }
601
- else {
602
- show();
603
- }
604
- }
605
-
606
- function show() {
607
- var event = $.Event('beforeShow.spectrum');
608
-
609
- if (visible) {
610
- reflow();
611
- return;
612
- }
613
-
614
- boundElement.trigger(event, [ get() ]);
615
-
616
- if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {
617
- return;
618
- }
619
-
620
- hideAll();
621
- visible = true;
622
-
623
- $(doc).bind("keydown.spectrum", onkeydown);
624
- $(doc).bind("click.spectrum", clickout);
625
- $(window).bind("resize.spectrum", resize);
626
- replacer.addClass("sp-active");
627
- container.removeClass("sp-hidden");
628
-
629
- reflow();
630
- updateUI();
631
-
632
- colorOnShow = get();
633
-
634
- drawInitial();
635
- callbacks.show(colorOnShow);
636
- boundElement.trigger('show.spectrum', [ colorOnShow ]);
637
- }
638
-
639
- function onkeydown(e) {
640
- // Close on ESC
641
- if (e.keyCode === 27) {
642
- hide();
643
- }
644
- }
645
-
646
- function clickout(e) {
647
- // Return on right click.
648
- if (e.button == 2) { return; }
649
-
650
- // If a drag event was happening during the mouseup, don't hide
651
- // on click.
652
- if (isDragging) { return; }
653
-
654
- if (clickoutFiresChange) {
655
- updateOriginalInput(true);
656
- }
657
- else {
658
- revert();
659
- }
660
- hide();
661
- }
662
-
663
- function hide() {
664
- // Return if hiding is unnecessary
665
- if (!visible || flat) { return; }
666
- visible = false;
667
-
668
- $(doc).unbind("keydown.spectrum", onkeydown);
669
- $(doc).unbind("click.spectrum", clickout);
670
- $(window).unbind("resize.spectrum", resize);
671
-
672
- replacer.removeClass("sp-active");
673
- container.addClass("sp-hidden");
674
-
675
- callbacks.hide(get());
676
- boundElement.trigger('hide.spectrum', [ get() ]);
677
- }
678
-
679
- function revert() {
680
- set(colorOnShow, true);
681
- }
682
-
683
- function set(color, ignoreFormatChange) {
684
- if (tinycolor.equals(color, get())) {
685
- // Update UI just in case a validation error needs
686
- // to be cleared.
687
- updateUI();
688
- return;
689
- }
690
-
691
- var newColor, newHsv;
692
- if (!color && allowEmpty) {
693
- isEmpty = true;
694
- } else {
695
- isEmpty = false;
696
- newColor = tinycolor(color);
697
- newHsv = newColor.toHsv();
698
-
699
- currentHue = (newHsv.h % 360) / 360;
700
- currentSaturation = newHsv.s;
701
- currentValue = newHsv.v;
702
- currentAlpha = newHsv.a;
703
- }
704
- updateUI();
705
-
706
- if (newColor && newColor.isValid() && !ignoreFormatChange) {
707
- currentPreferredFormat = opts.preferredFormat || newColor.getFormat();
708
- }
709
- }
710
-
711
- function get(opts) {
712
- opts = opts || { };
713
-
714
- if (allowEmpty && isEmpty) {
715
- return null;
716
- }
717
-
718
- return tinycolor.fromRatio({
719
- h: currentHue,
720
- s: currentSaturation,
721
- v: currentValue,
722
- a: Math.round(currentAlpha * 100) / 100
723
- }, { format: opts.format || currentPreferredFormat });
724
- }
725
-
726
- function isValid() {
727
- return !textInput.hasClass("sp-validation-error");
728
- }
729
-
730
- function move() {
731
- updateUI();
732
-
733
- callbacks.move(get());
734
- boundElement.trigger('move.spectrum', [ get() ]);
735
- }
736
-
737
- function updateUI() {
738
-
739
- textInput.removeClass("sp-validation-error");
740
-
741
- updateHelperLocations();
742
-
743
- // Update dragger background color (gradients take care of saturation and value).
744
- var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });
745
- dragger.css("background-color", flatColor.toHexString());
746
-
747
- // Get a format that alpha will be included in (hex and names ignore alpha)
748
- var format = currentPreferredFormat;
749
- if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) {
750
- if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") {
751
- format = "rgb";
752
- }
753
- }
754
-
755
- var realColor = get({ format: format }),
756
- displayColor = '';
757
-
758
- //reset background info for preview element
759
- previewElement.removeClass("sp-clear-display");
760
- previewElement.css('background-color', 'transparent');
761
-
762
- if (!realColor && allowEmpty) {
763
- // Update the replaced elements background with icon indicating no color selection
764
- previewElement.addClass("sp-clear-display");
765
- }
766
- else {
767
- var realHex = realColor.toHexString(),
768
- realRgb = realColor.toRgbString();
769
-
770
- // Update the replaced elements background color (with actual selected color)
771
- if (rgbaSupport || realColor.alpha === 1) {
772
- previewElement.css("background-color", realRgb);
773
- }
774
- else {
775
- previewElement.css("background-color", "transparent");
776
- previewElement.css("filter", realColor.toFilter());
777
- }
778
-
779
- if (opts.showAlpha) {
780
- var rgb = realColor.toRgb();
781
- rgb.a = 0;
782
- var realAlpha = tinycolor(rgb).toRgbString();
783
- var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
784
-
785
- if (IE) {
786
- alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
787
- }
788
- else {
789
- alphaSliderInner.css("background", "-webkit-" + gradient);
790
- alphaSliderInner.css("background", "-moz-" + gradient);
791
- alphaSliderInner.css("background", "-ms-" + gradient);
792
- // Use current syntax gradient on unprefixed property.
793
- alphaSliderInner.css("background",
794
- "linear-gradient(to right, " + realAlpha + ", " + realHex + ")");
795
- }
796
- }
797
-
798
- displayColor = realColor.toString(format);
799
- }
800
-
801
- // Update the text entry input as it changes happen
802
- if (opts.showInput) {
803
- textInput.val(displayColor);
804
- }
805
-
806
- if (opts.showPalette) {
807
- drawPalette();
808
- }
809
-
810
- drawInitial();
811
- }
812
-
813
- function updateHelperLocations() {
814
- var s = currentSaturation;
815
- var v = currentValue;
816
-
817
- if(allowEmpty && isEmpty) {
818
- //if selected color is empty, hide the helpers
819
- alphaSlideHelper.hide();
820
- slideHelper.hide();
821
- dragHelper.hide();
822
- }
823
- else {
824
- //make sure helpers are visible
825
- alphaSlideHelper.show();
826
- slideHelper.show();
827
- dragHelper.show();
828
-
829
- // Where to show the little circle in that displays your current selected color
830
- var dragX = s * dragWidth;
831
- var dragY = dragHeight - (v * dragHeight);
832
- dragX = Math.max(
833
- -dragHelperHeight,
834
- Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
835
- );
836
- dragY = Math.max(
837
- -dragHelperHeight,
838
- Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
839
- );
840
- dragHelper.css({
841
- "top": dragY + "px",
842
- "left": dragX + "px"
843
- });
844
-
845
- var alphaX = currentAlpha * alphaWidth;
846
- alphaSlideHelper.css({
847
- "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px"
848
- });
849
-
850
- // Where to show the bar that displays your current selected hue
851
- var slideY = (currentHue) * slideHeight;
852
- slideHelper.css({
853
- "top": (slideY - slideHelperHeight) + "px"
854
- });
855
- }
856
- }
857
-
858
- function updateOriginalInput(fireCallback) {
859
- var color = get(),
860
- displayColor = '',
861
- hasChanged = !tinycolor.equals(color, colorOnShow);
862
-
863
- if (color) {
864
- displayColor = color.toString(currentPreferredFormat);
865
- // Update the selection palette with the current color
866
- addColorToSelectionPalette(color);
867
- }
868
-
869
- if (isInput) {
870
- boundElement.val(displayColor);
871
- }
872
-
873
- if (fireCallback && hasChanged) {
874
- callbacks.change(color);
875
- boundElement.trigger('change', [ color ]);
876
- }
877
- }
878
-
879
- function reflow() {
880
- if (!visible) {
881
- return; // Calculations would be useless and wouldn't be reliable anyways
882
- }
883
- dragWidth = dragger.width();
884
- dragHeight = dragger.height();
885
- dragHelperHeight = dragHelper.height();
886
- slideWidth = slider.width();
887
- slideHeight = slider.height();
888
- slideHelperHeight = slideHelper.height();
889
- alphaWidth = alphaSlider.width();
890
- alphaSlideHelperWidth = alphaSlideHelper.width();
891
-
892
- if (!flat) {
893
- container.css("position", "absolute");
894
- if (opts.offset) {
895
- container.offset(opts.offset);
896
- } else {
897
- container.offset(getOffset(container, offsetElement));
898
- }
899
- }
900
-
901
- updateHelperLocations();
902
-
903
- if (opts.showPalette) {
904
- drawPalette();
905
- }
906
-
907
- boundElement.trigger('reflow.spectrum');
908
- }
909
-
910
- function destroy() {
911
- boundElement.show();
912
- offsetElement.unbind("click.spectrum touchstart.spectrum");
913
- container.remove();
914
- replacer.remove();
915
- spectrums[spect.id] = null;
916
- }
917
-
918
- function option(optionName, optionValue) {
919
- if (optionName === undefined) {
920
- return $.extend({}, opts);
921
- }
922
- if (optionValue === undefined) {
923
- return opts[optionName];
924
- }
925
-
926
- opts[optionName] = optionValue;
927
-
928
- if (optionName === "preferredFormat") {
929
- currentPreferredFormat = opts.preferredFormat;
930
- }
931
- applyOptions();
932
- }
933
-
934
- function enable() {
935
- disabled = false;
936
- boundElement.attr("disabled", false);
937
- offsetElement.removeClass("sp-disabled");
938
- }
939
-
940
- function disable() {
941
- hide();
942
- disabled = true;
943
- boundElement.attr("disabled", true);
944
- offsetElement.addClass("sp-disabled");
945
- }
946
-
947
- function setOffset(coord) {
948
- opts.offset = coord;
949
- reflow();
950
- }
951
-
952
- initialize();
953
-
954
- var spect = {
955
- show: show,
956
- hide: hide,
957
- toggle: toggle,
958
- reflow: reflow,
959
- option: option,
960
- enable: enable,
961
- disable: disable,
962
- offset: setOffset,
963
- set: function (c) {
964
- set(c);
965
- updateOriginalInput();
966
- },
967
- get: get,
968
- destroy: destroy,
969
- container: container
970
- };
971
-
972
- spect.id = spectrums.push(spect) - 1;
973
-
974
- return spect;
975
- }
976
-
977
- /**
978
- * checkOffset - get the offset below/above and left/right element depending on screen position
979
- * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
980
- */
981
- function getOffset(picker, input) {
982
- var extraY = 0;
983
- var dpWidth = picker.outerWidth();
984
- var dpHeight = picker.outerHeight();
985
- var inputHeight = input.outerHeight();
986
- var doc = picker[0].ownerDocument;
987
- var docElem = doc.documentElement;
988
- var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
989
- var viewHeight = docElem.clientHeight + $(doc).scrollTop();
990
- var offset = input.offset();
991
- offset.top += inputHeight;
992
-
993
- offset.left -=
994
- Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
995
- Math.abs(offset.left + dpWidth - viewWidth) : 0);
996
-
997
- offset.top -=
998
- Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
999
- Math.abs(dpHeight + inputHeight - extraY) : extraY));
1000
-
1001
- return offset;
1002
- }
1003
-
1004
- /**
1005
- * noop - do nothing
1006
- */
1007
- function noop() {
1008
-
1009
- }
1010
-
1011
- /**
1012
- * stopPropagation - makes the code only doing this a little easier to read in line
1013
- */
1014
- function stopPropagation(e) {
1015
- e.stopPropagation();
1016
- }
1017
-
1018
- /**
1019
- * Create a function bound to a given object
1020
- * Thanks to underscore.js
1021
- */
1022
- function bind(func, obj) {
1023
- var slice = Array.prototype.slice;
1024
- var args = slice.call(arguments, 2);
1025
- return function () {
1026
- return func.apply(obj, args.concat(slice.call(arguments)));
1027
- };
1028
- }
1029
-
1030
- /**
1031
- * Lightweight drag helper. Handles containment within the element, so that
1032
- * when dragging, the x is within [0,element.width] and y is within [0,element.height]
1033
- */
1034
- function draggable(element, onmove, onstart, onstop) {
1035
- onmove = onmove || function () { };
1036
- onstart = onstart || function () { };
1037
- onstop = onstop || function () { };
1038
- var doc = document;
1039
- var dragging = false;
1040
- var offset = {};
1041
- var maxHeight = 0;
1042
- var maxWidth = 0;
1043
- var hasTouch = ('ontouchstart' in window);
1044
-
1045
- var duringDragEvents = {};
1046
- duringDragEvents["selectstart"] = prevent;
1047
- duringDragEvents["dragstart"] = prevent;
1048
- duringDragEvents["touchmove mousemove"] = move;
1049
- duringDragEvents["touchend mouseup"] = stop;
1050
-
1051
- function prevent(e) {
1052
- if (e.stopPropagation) {
1053
- e.stopPropagation();
1054
- }
1055
- if (e.preventDefault) {
1056
- e.preventDefault();
1057
- }
1058
- e.returnValue = false;
1059
- }
1060
-
1061
- function move(e) {
1062
- if (dragging) {
1063
- // Mouseup happened outside of window
1064
- if (IE && doc.documentMode < 9 && !e.button) {
1065
- return stop();
1066
- }
1067
-
1068
- var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
1069
- var pageX = t0 && t0.pageX || e.pageX;
1070
- var pageY = t0 && t0.pageY || e.pageY;
1071
-
1072
- var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
1073
- var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
1074
-
1075
- if (hasTouch) {
1076
- // Stop scrolling in iOS
1077
- prevent(e);
1078
- }
1079
-
1080
- onmove.apply(element, [dragX, dragY, e]);
1081
- }
1082
- }
1083
-
1084
- function start(e) {
1085
- var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
1086
-
1087
- if (!rightclick && !dragging) {
1088
- if (onstart.apply(element, arguments) !== false) {
1089
- dragging = true;
1090
- maxHeight = $(element).height();
1091
- maxWidth = $(element).width();
1092
- offset = $(element).offset();
1093
-
1094
- $(doc).bind(duringDragEvents);
1095
- $(doc.body).addClass("sp-dragging");
1096
-
1097
- move(e);
1098
-
1099
- prevent(e);
1100
- }
1101
- }
1102
- }
1103
-
1104
- function stop() {
1105
- if (dragging) {
1106
- $(doc).unbind(duringDragEvents);
1107
- $(doc.body).removeClass("sp-dragging");
1108
-
1109
- // Wait a tick before notifying observers to allow the click event
1110
- // to fire in Chrome.
1111
- setTimeout(function() {
1112
- onstop.apply(element, arguments);
1113
- }, 0);
1114
- }
1115
- dragging = false;
1116
- }
1117
-
1118
- $(element).bind("touchstart mousedown", start);
1119
- }
1120
-
1121
- function throttle(func, wait, debounce) {
1122
- var timeout;
1123
- return function () {
1124
- var context = this, args = arguments;
1125
- var throttler = function () {
1126
- timeout = null;
1127
- func.apply(context, args);
1128
- };
1129
- if (debounce) clearTimeout(timeout);
1130
- if (debounce || !timeout) timeout = setTimeout(throttler, wait);
1131
- };
1132
- }
1133
-
1134
- function inputTypeColorSupport() {
1135
- return $.fn.spectrum.inputTypeColorSupport();
1136
- }
1137
-
1138
- /**
1139
- * Define a jQuery plugin
1140
- */
1141
- var dataID = "spectrum.id";
1142
- $.fn.spectrum = function (opts, extra) {
1143
-
1144
- if (typeof opts == "string") {
1145
-
1146
- var returnValue = this;
1147
- var args = Array.prototype.slice.call( arguments, 1 );
1148
-
1149
- this.each(function () {
1150
- var spect = spectrums[$(this).data(dataID)];
1151
- if (spect) {
1152
- var method = spect[opts];
1153
- if (!method) {
1154
- throw new Error( "Spectrum: no such method: '" + opts + "'" );
1155
- }
1156
-
1157
- if (opts == "get") {
1158
- returnValue = spect.get();
1159
- }
1160
- else if (opts == "container") {
1161
- returnValue = spect.container;
1162
- }
1163
- else if (opts == "option") {
1164
- returnValue = spect.option.apply(spect, args);
1165
- }
1166
- else if (opts == "destroy") {
1167
- spect.destroy();
1168
- $(this).removeData(dataID);
1169
- }
1170
- else {
1171
- method.apply(spect, args);
1172
- }
1173
- }
1174
- });
1175
-
1176
- return returnValue;
1177
- }
1178
-
1179
- // Initializing a new instance of spectrum
1180
- return this.spectrum("destroy").each(function () {
1181
- var options = $.extend({}, opts, $(this).data());
1182
- var spect = spectrum(this, options);
1183
- $(this).data(dataID, spect.id);
1184
- });
1185
- };
1186
-
1187
- $.fn.spectrum.load = true;
1188
- $.fn.spectrum.loadOpts = {};
1189
- $.fn.spectrum.draggable = draggable;
1190
- $.fn.spectrum.defaults = defaultOpts;
1191
- $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
1192
- if (typeof inputTypeColorSupport._cachedResult === "undefined") {
1193
- var colorInput = $("<input type='color'/>")[0]; // if color element is supported, value will default to not null
1194
- inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "";
1195
- }
1196
- return inputTypeColorSupport._cachedResult;
1197
- };
1198
-
1199
- $.spectrum = { };
1200
- $.spectrum.localization = { };
1201
- $.spectrum.palettes = { };
1202
-
1203
- $.fn.spectrum.processNativeColorInputs = function () {
1204
- var colorInputs = $("input[type=color]");
1205
- if (colorInputs.length && !inputTypeColorSupport()) {
1206
- colorInputs.spectrum({
1207
- preferredFormat: "hex6"
1208
- });
1209
- }
1210
- };
1211
-
1212
- // TinyColor v1.1.2
1213
- // https://github.com/bgrins/TinyColor
1214
- // Brian Grinstead, MIT License
1215
-
1216
- (function() {
1217
-
1218
- var trimLeft = /^[\s,#]+/,
1219
- trimRight = /\s+$/,
1220
- tinyCounter = 0,
1221
- math = Math,
1222
- mathRound = math.round,
1223
- mathMin = math.min,
1224
- mathMax = math.max,
1225
- mathRandom = math.random;
1226
-
1227
- var tinycolor = function(color, opts) {
1228
-
1229
- color = (color) ? color : '';
1230
- opts = opts || { };
1231
-
1232
- // If input is already a tinycolor, return itself
1233
- if (color instanceof tinycolor) {
1234
- return color;
1235
- }
1236
- // If we are called as a function, call using new instead
1237
- if (!(this instanceof tinycolor)) {
1238
- return new tinycolor(color, opts);
1239
- }
1240
-
1241
- var rgb = inputToRGB(color);
1242
- this._originalInput = color,
1243
- this._r = rgb.r,
1244
- this._g = rgb.g,
1245
- this._b = rgb.b,
1246
- this._a = rgb.a,
1247
- this._roundA = mathRound(100*this._a) / 100,
1248
- this._format = opts.format || rgb.format;
1249
- this._gradientType = opts.gradientType;
1250
-
1251
- // Don't let the range of [0,255] come back in [0,1].
1252
- // Potentially lose a little bit of precision here, but will fix issues where
1253
- // .5 gets interpreted as half of the total, instead of half of 1
1254
- // If it was supposed to be 128, this was already taken care of by `inputToRgb`
1255
- if (this._r < 1) { this._r = mathRound(this._r); }
1256
- if (this._g < 1) { this._g = mathRound(this._g); }
1257
- if (this._b < 1) { this._b = mathRound(this._b); }
1258
-
1259
- this._ok = rgb.ok;
1260
- this._tc_id = tinyCounter++;
1261
- };
1262
-
1263
- tinycolor.prototype = {
1264
- isDark: function() {
1265
- return this.getBrightness() < 128;
1266
- },
1267
- isLight: function() {
1268
- return !this.isDark();
1269
- },
1270
- isValid: function() {
1271
- return this._ok;
1272
- },
1273
- getOriginalInput: function() {
1274
- return this._originalInput;
1275
- },
1276
- getFormat: function() {
1277
- return this._format;
1278
- },
1279
- getAlpha: function() {
1280
- return this._a;
1281
- },
1282
- getBrightness: function() {
1283
- var rgb = this.toRgb();
1284
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
1285
- },
1286
- setAlpha: function(value) {
1287
- this._a = boundAlpha(value);
1288
- this._roundA = mathRound(100*this._a) / 100;
1289
- return this;
1290
- },
1291
- toHsv: function() {
1292
- var hsv = rgbToHsv(this._r, this._g, this._b);
1293
- return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
1294
- },
1295
- toHsvString: function() {
1296
- var hsv = rgbToHsv(this._r, this._g, this._b);
1297
- var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
1298
- return (this._a == 1) ?
1299
- "hsv(" + h + ", " + s + "%, " + v + "%)" :
1300
- "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
1301
- },
1302
- toHsl: function() {
1303
- var hsl = rgbToHsl(this._r, this._g, this._b);
1304
- return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
1305
- },
1306
- toHslString: function() {
1307
- var hsl = rgbToHsl(this._r, this._g, this._b);
1308
- var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
1309
- return (this._a == 1) ?
1310
- "hsl(" + h + ", " + s + "%, " + l + "%)" :
1311
- "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
1312
- },
1313
- toHex: function(allow3Char) {
1314
- return rgbToHex(this._r, this._g, this._b, allow3Char);
1315
- },
1316
- toHexString: function(allow3Char) {
1317
- return '#' + this.toHex(allow3Char);
1318
- },
1319
- toHex8: function() {
1320
- return rgbaToHex(this._r, this._g, this._b, this._a);
1321
- },
1322
- toHex8String: function() {
1323
- return '#' + this.toHex8();
1324
- },
1325
- toRgb: function() {
1326
- return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
1327
- },
1328
- toRgbString: function() {
1329
- return (this._a == 1) ?
1330
- "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
1331
- "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
1332
- },
1333
- toPercentageRgb: function() {
1334
- return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
1335
- },
1336
- toPercentageRgbString: function() {
1337
- return (this._a == 1) ?
1338
- "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
1339
- "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
1340
- },
1341
- toName: function() {
1342
- if (this._a === 0) {
1343
- return "transparent";
1344
- }
1345
-
1346
- if (this._a < 1) {
1347
- return false;
1348
- }
1349
-
1350
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
1351
- },
1352
- toFilter: function(secondColor) {
1353
- var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a);
1354
- var secondHex8String = hex8String;
1355
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
1356
-
1357
- if (secondColor) {
1358
- var s = tinycolor(secondColor);
1359
- secondHex8String = s.toHex8String();
1360
- }
1361
-
1362
- return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
1363
- },
1364
- toString: function(format) {
1365
- var formatSet = !!format;
1366
- format = format || this._format;
1367
-
1368
- var formattedString = false;
1369
- var hasAlpha = this._a < 1 && this._a >= 0;
1370
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
1371
-
1372
- if (needsAlphaFormat) {
1373
- // Special case for "transparent", all other non-alpha formats
1374
- // will return rgba when there is transparency.
1375
- if (format === "name" && this._a === 0) {
1376
- return this.toName();
1377
- }
1378
- return this.toRgbString();
1379
- }
1380
- if (format === "rgb") {
1381
- formattedString = this.toRgbString();
1382
- }
1383
- if (format === "prgb") {
1384
- formattedString = this.toPercentageRgbString();
1385
- }
1386
- if (format === "hex" || format === "hex6") {
1387
- formattedString = this.toHexString();
1388
- }
1389
- if (format === "hex3") {
1390
- formattedString = this.toHexString(true);
1391
- }
1392
- if (format === "hex8") {
1393
- formattedString = this.toHex8String();
1394
- }
1395
- if (format === "name") {
1396
- formattedString = this.toName();
1397
- }
1398
- if (format === "hsl") {
1399
- formattedString = this.toHslString();
1400
- }
1401
- if (format === "hsv") {
1402
- formattedString = this.toHsvString();
1403
- }
1404
-
1405
- return formattedString || this.toHexString();
1406
- },
1407
-
1408
- _applyModification: function(fn, args) {
1409
- var color = fn.apply(null, [this].concat([].slice.call(args)));
1410
- this._r = color._r;
1411
- this._g = color._g;
1412
- this._b = color._b;
1413
- this.setAlpha(color._a);
1414
- return this;
1415
- },
1416
- lighten: function() {
1417
- return this._applyModification(lighten, arguments);
1418
- },
1419
- brighten: function() {
1420
- return this._applyModification(brighten, arguments);
1421
- },
1422
- darken: function() {
1423
- return this._applyModification(darken, arguments);
1424
- },
1425
- desaturate: function() {
1426
- return this._applyModification(desaturate, arguments);
1427
- },
1428
- saturate: function() {
1429
- return this._applyModification(saturate, arguments);
1430
- },
1431
- greyscale: function() {
1432
- return this._applyModification(greyscale, arguments);
1433
- },
1434
- spin: function() {
1435
- return this._applyModification(spin, arguments);
1436
- },
1437
-
1438
- _applyCombination: function(fn, args) {
1439
- return fn.apply(null, [this].concat([].slice.call(args)));
1440
- },
1441
- analogous: function() {
1442
- return this._applyCombination(analogous, arguments);
1443
- },
1444
- complement: function() {
1445
- return this._applyCombination(complement, arguments);
1446
- },
1447
- monochromatic: function() {
1448
- return this._applyCombination(monochromatic, arguments);
1449
- },
1450
- splitcomplement: function() {
1451
- return this._applyCombination(splitcomplement, arguments);
1452
- },
1453
- triad: function() {
1454
- return this._applyCombination(triad, arguments);
1455
- },
1456
- tetrad: function() {
1457
- return this._applyCombination(tetrad, arguments);
1458
- }
1459
- };
1460
-
1461
- // If input is an object, force 1 into "1.0" to handle ratios properly
1462
- // String input requires "1.0" as input, so 1 will be treated as 1
1463
- tinycolor.fromRatio = function(color, opts) {
1464
- if (typeof color == "object") {
1465
- var newColor = {};
1466
- for (var i in color) {
1467
- if (color.hasOwnProperty(i)) {
1468
- if (i === "a") {
1469
- newColor[i] = color[i];
1470
- }
1471
- else {
1472
- newColor[i] = convertToPercentage(color[i]);
1473
- }
1474
- }
1475
- }
1476
- color = newColor;
1477
- }
1478
-
1479
- return tinycolor(color, opts);
1480
- };
1481
-
1482
- // Given a string or object, convert that input to RGB
1483
- // Possible string inputs:
1484
- //
1485
- // "red"
1486
- // "#f00" or "f00"
1487
- // "#ff0000" or "ff0000"
1488
- // "#ff000000" or "ff000000"
1489
- // "rgb 255 0 0" or "rgb (255, 0, 0)"
1490
- // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
1491
- // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
1492
- // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
1493
- // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
1494
- // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
1495
- // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
1496
- //
1497
- function inputToRGB(color) {
1498
-
1499
- var rgb = { r: 0, g: 0, b: 0 };
1500
- var a = 1;
1501
- var ok = false;
1502
- var format = false;
1503
-
1504
- if (typeof color == "string") {
1505
- color = stringInputToObject(color);
1506
- }
1507
-
1508
- if (typeof color == "object") {
1509
- if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
1510
- rgb = rgbToRgb(color.r, color.g, color.b);
1511
- ok = true;
1512
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
1513
- }
1514
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
1515
- color.s = convertToPercentage(color.s);
1516
- color.v = convertToPercentage(color.v);
1517
- rgb = hsvToRgb(color.h, color.s, color.v);
1518
- ok = true;
1519
- format = "hsv";
1520
- }
1521
- else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
1522
- color.s = convertToPercentage(color.s);
1523
- color.l = convertToPercentage(color.l);
1524
- rgb = hslToRgb(color.h, color.s, color.l);
1525
- ok = true;
1526
- format = "hsl";
1527
- }
1528
-
1529
- if (color.hasOwnProperty("a")) {
1530
- a = color.a;
1531
- }
1532
- }
1533
-
1534
- a = boundAlpha(a);
1535
-
1536
- return {
1537
- ok: ok,
1538
- format: color.format || format,
1539
- r: mathMin(255, mathMax(rgb.r, 0)),
1540
- g: mathMin(255, mathMax(rgb.g, 0)),
1541
- b: mathMin(255, mathMax(rgb.b, 0)),
1542
- a: a
1543
- };
1544
- }
1545
-
1546
-
1547
- // Conversion Functions
1548
- // --------------------
1549
-
1550
- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
1551
- // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
1552
-
1553
- // `rgbToRgb`
1554
- // Handle bounds / percentage checking to conform to CSS color spec
1555
- // <http://www.w3.org/TR/css3-color/>
1556
- // *Assumes:* r, g, b in [0, 255] or [0, 1]
1557
- // *Returns:* { r, g, b } in [0, 255]
1558
- function rgbToRgb(r, g, b){
1559
- return {
1560
- r: bound01(r, 255) * 255,
1561
- g: bound01(g, 255) * 255,
1562
- b: bound01(b, 255) * 255
1563
- };
1564
- }
1565
-
1566
- // `rgbToHsl`
1567
- // Converts an RGB color value to HSL.
1568
- // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
1569
- // *Returns:* { h, s, l } in [0,1]
1570
- function rgbToHsl(r, g, b) {
1571
-
1572
- r = bound01(r, 255);
1573
- g = bound01(g, 255);
1574
- b = bound01(b, 255);
1575
-
1576
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
1577
- var h, s, l = (max + min) / 2;
1578
-
1579
- if(max == min) {
1580
- h = s = 0; // achromatic
1581
- }
1582
- else {
1583
- var d = max - min;
1584
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
1585
- switch(max) {
1586
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
1587
- case g: h = (b - r) / d + 2; break;
1588
- case b: h = (r - g) / d + 4; break;
1589
- }
1590
-
1591
- h /= 6;
1592
- }
1593
-
1594
- return { h: h, s: s, l: l };
1595
- }
1596
-
1597
- // `hslToRgb`
1598
- // Converts an HSL color value to RGB.
1599
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
1600
- // *Returns:* { r, g, b } in the set [0, 255]
1601
- function hslToRgb(h, s, l) {
1602
- var r, g, b;
1603
-
1604
- h = bound01(h, 360);
1605
- s = bound01(s, 100);
1606
- l = bound01(l, 100);
1607
-
1608
- function hue2rgb(p, q, t) {
1609
- if(t < 0) t += 1;
1610
- if(t > 1) t -= 1;
1611
- if(t < 1/6) return p + (q - p) * 6 * t;
1612
- if(t < 1/2) return q;
1613
- if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
1614
- return p;
1615
- }
1616
-
1617
- if(s === 0) {
1618
- r = g = b = l; // achromatic
1619
- }
1620
- else {
1621
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
1622
- var p = 2 * l - q;
1623
- r = hue2rgb(p, q, h + 1/3);
1624
- g = hue2rgb(p, q, h);
1625
- b = hue2rgb(p, q, h - 1/3);
1626
- }
1627
-
1628
- return { r: r * 255, g: g * 255, b: b * 255 };
1629
- }
1630
-
1631
- // `rgbToHsv`
1632
- // Converts an RGB color value to HSV
1633
- // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
1634
- // *Returns:* { h, s, v } in [0,1]
1635
- function rgbToHsv(r, g, b) {
1636
-
1637
- r = bound01(r, 255);
1638
- g = bound01(g, 255);
1639
- b = bound01(b, 255);
1640
-
1641
- var max = mathMax(r, g, b), min = mathMin(r, g, b);
1642
- var h, s, v = max;
1643
-
1644
- var d = max - min;
1645
- s = max === 0 ? 0 : d / max;
1646
-
1647
- if(max == min) {
1648
- h = 0; // achromatic
1649
- }
1650
- else {
1651
- switch(max) {
1652
- case r: h = (g - b) / d + (g < b ? 6 : 0); break;
1653
- case g: h = (b - r) / d + 2; break;
1654
- case b: h = (r - g) / d + 4; break;
1655
- }
1656
- h /= 6;
1657
- }
1658
- return { h: h, s: s, v: v };
1659
- }
1660
-
1661
- // `hsvToRgb`
1662
- // Converts an HSV color value to RGB.
1663
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
1664
- // *Returns:* { r, g, b } in the set [0, 255]
1665
- function hsvToRgb(h, s, v) {
1666
-
1667
- h = bound01(h, 360) * 6;
1668
- s = bound01(s, 100);
1669
- v = bound01(v, 100);
1670
-
1671
- var i = math.floor(h),
1672
- f = h - i,
1673
- p = v * (1 - s),
1674
- q = v * (1 - f * s),
1675
- t = v * (1 - (1 - f) * s),
1676
- mod = i % 6,
1677
- r = [v, q, p, p, t, v][mod],
1678
- g = [t, v, v, q, p, p][mod],
1679
- b = [p, p, t, v, v, q][mod];
1680
-
1681
- return { r: r * 255, g: g * 255, b: b * 255 };
1682
- }
1683
-
1684
- // `rgbToHex`
1685
- // Converts an RGB color to hex
1686
- // Assumes r, g, and b are contained in the set [0, 255]
1687
- // Returns a 3 or 6 character hex
1688
- function rgbToHex(r, g, b, allow3Char) {
1689
-
1690
- var hex = [
1691
- pad2(mathRound(r).toString(16)),
1692
- pad2(mathRound(g).toString(16)),
1693
- pad2(mathRound(b).toString(16))
1694
- ];
1695
-
1696
- // Return a 3 character hex if possible
1697
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
1698
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
1699
- }
1700
-
1701
- return hex.join("");
1702
- }
1703
- // `rgbaToHex`
1704
- // Converts an RGBA color plus alpha transparency to hex
1705
- // Assumes r, g, b and a are contained in the set [0, 255]
1706
- // Returns an 8 character hex
1707
- function rgbaToHex(r, g, b, a) {
1708
-
1709
- var hex = [
1710
- pad2(convertDecimalToHex(a)),
1711
- pad2(mathRound(r).toString(16)),
1712
- pad2(mathRound(g).toString(16)),
1713
- pad2(mathRound(b).toString(16))
1714
- ];
1715
-
1716
- return hex.join("");
1717
- }
1718
-
1719
- // `equals`
1720
- // Can be called with any tinycolor input
1721
- tinycolor.equals = function (color1, color2) {
1722
- if (!color1 || !color2) { return false; }
1723
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
1724
- };
1725
- tinycolor.random = function() {
1726
- return tinycolor.fromRatio({
1727
- r: mathRandom(),
1728
- g: mathRandom(),
1729
- b: mathRandom()
1730
- });
1731
- };
1732
-
1733
-
1734
- // Modification Functions
1735
- // ----------------------
1736
- // Thanks to less.js for some of the basics here
1737
- // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
1738
-
1739
- function desaturate(color, amount) {
1740
- amount = (amount === 0) ? 0 : (amount || 10);
1741
- var hsl = tinycolor(color).toHsl();
1742
- hsl.s -= amount / 100;
1743
- hsl.s = clamp01(hsl.s);
1744
- return tinycolor(hsl);
1745
- }
1746
-
1747
- function saturate(color, amount) {
1748
- amount = (amount === 0) ? 0 : (amount || 10);
1749
- var hsl = tinycolor(color).toHsl();
1750
- hsl.s += amount / 100;
1751
- hsl.s = clamp01(hsl.s);
1752
- return tinycolor(hsl);
1753
- }
1754
-
1755
- function greyscale(color) {
1756
- return tinycolor(color).desaturate(100);
1757
- }
1758
-
1759
- function lighten (color, amount) {
1760
- amount = (amount === 0) ? 0 : (amount || 10);
1761
- var hsl = tinycolor(color).toHsl();
1762
- hsl.l += amount / 100;
1763
- hsl.l = clamp01(hsl.l);
1764
- return tinycolor(hsl);
1765
- }
1766
-
1767
- function brighten(color, amount) {
1768
- amount = (amount === 0) ? 0 : (amount || 10);
1769
- var rgb = tinycolor(color).toRgb();
1770
- rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
1771
- rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
1772
- rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
1773
- return tinycolor(rgb);
1774
- }
1775
-
1776
- function darken (color, amount) {
1777
- amount = (amount === 0) ? 0 : (amount || 10);
1778
- var hsl = tinycolor(color).toHsl();
1779
- hsl.l -= amount / 100;
1780
- hsl.l = clamp01(hsl.l);
1781
- return tinycolor(hsl);
1782
- }
1783
-
1784
- // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
1785
- // Values outside of this range will be wrapped into this range.
1786
- function spin(color, amount) {
1787
- var hsl = tinycolor(color).toHsl();
1788
- var hue = (mathRound(hsl.h) + amount) % 360;
1789
- hsl.h = hue < 0 ? 360 + hue : hue;
1790
- return tinycolor(hsl);
1791
- }
1792
-
1793
- // Combination Functions
1794
- // ---------------------
1795
- // Thanks to jQuery xColor for some of the ideas behind these
1796
- // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
1797
-
1798
- function complement(color) {
1799
- var hsl = tinycolor(color).toHsl();
1800
- hsl.h = (hsl.h + 180) % 360;
1801
- return tinycolor(hsl);
1802
- }
1803
-
1804
- function triad(color) {
1805
- var hsl = tinycolor(color).toHsl();
1806
- var h = hsl.h;
1807
- return [
1808
- tinycolor(color),
1809
- tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
1810
- tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
1811
- ];
1812
- }
1813
-
1814
- function tetrad(color) {
1815
- var hsl = tinycolor(color).toHsl();
1816
- var h = hsl.h;
1817
- return [
1818
- tinycolor(color),
1819
- tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
1820
- tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
1821
- tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
1822
- ];
1823
- }
1824
-
1825
- function splitcomplement(color) {
1826
- var hsl = tinycolor(color).toHsl();
1827
- var h = hsl.h;
1828
- return [
1829
- tinycolor(color),
1830
- tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
1831
- tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
1832
- ];
1833
- }
1834
-
1835
- function analogous(color, results, slices) {
1836
- results = results || 6;
1837
- slices = slices || 30;
1838
-
1839
- var hsl = tinycolor(color).toHsl();
1840
- var part = 360 / slices;
1841
- var ret = [tinycolor(color)];
1842
-
1843
- for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
1844
- hsl.h = (hsl.h + part) % 360;
1845
- ret.push(tinycolor(hsl));
1846
- }
1847
- return ret;
1848
- }
1849
-
1850
- function monochromatic(color, results) {
1851
- results = results || 6;
1852
- var hsv = tinycolor(color).toHsv();
1853
- var h = hsv.h, s = hsv.s, v = hsv.v;
1854
- var ret = [];
1855
- var modification = 1 / results;
1856
-
1857
- while (results--) {
1858
- ret.push(tinycolor({ h: h, s: s, v: v}));
1859
- v = (v + modification) % 1;
1860
- }
1861
-
1862
- return ret;
1863
- }
1864
-
1865
- // Utility Functions
1866
- // ---------------------
1867
-
1868
- tinycolor.mix = function(color1, color2, amount) {
1869
- amount = (amount === 0) ? 0 : (amount || 50);
1870
-
1871
- var rgb1 = tinycolor(color1).toRgb();
1872
- var rgb2 = tinycolor(color2).toRgb();
1873
-
1874
- var p = amount / 100;
1875
- var w = p * 2 - 1;
1876
- var a = rgb2.a - rgb1.a;
1877
-
1878
- var w1;
1879
-
1880
- if (w * a == -1) {
1881
- w1 = w;
1882
- } else {
1883
- w1 = (w + a) / (1 + w * a);
1884
- }
1885
-
1886
- w1 = (w1 + 1) / 2;
1887
-
1888
- var w2 = 1 - w1;
1889
-
1890
- var rgba = {
1891
- r: rgb2.r * w1 + rgb1.r * w2,
1892
- g: rgb2.g * w1 + rgb1.g * w2,
1893
- b: rgb2.b * w1 + rgb1.b * w2,
1894
- a: rgb2.a * p + rgb1.a * (1 - p)
1895
- };
1896
-
1897
- return tinycolor(rgba);
1898
- };
1899
-
1900
-
1901
- // Readability Functions
1902
- // ---------------------
1903
- // <http://www.w3.org/TR/AERT#color-contrast>
1904
-
1905
- // `readability`
1906
- // Analyze the 2 colors and returns an object with the following properties:
1907
- // `brightness`: difference in brightness between the two colors
1908
- // `color`: difference in color/hue between the two colors
1909
- tinycolor.readability = function(color1, color2) {
1910
- var c1 = tinycolor(color1);
1911
- var c2 = tinycolor(color2);
1912
- var rgb1 = c1.toRgb();
1913
- var rgb2 = c2.toRgb();
1914
- var brightnessA = c1.getBrightness();
1915
- var brightnessB = c2.getBrightness();
1916
- var colorDiff = (
1917
- Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +
1918
- Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +
1919
- Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)
1920
- );
1921
-
1922
- return {
1923
- brightness: Math.abs(brightnessA - brightnessB),
1924
- color: colorDiff
1925
- };
1926
- };
1927
-
1928
- // `readable`
1929
- // http://www.w3.org/TR/AERT#color-contrast
1930
- // Ensure that foreground and background color combinations provide sufficient contrast.
1931
- // *Example*
1932
- // tinycolor.isReadable("#000", "#111") => false
1933
- tinycolor.isReadable = function(color1, color2) {
1934
- var readability = tinycolor.readability(color1, color2);
1935
- return readability.brightness > 125 && readability.color > 500;
1936
- };
1937
-
1938
- // `mostReadable`
1939
- // Given a base color and a list of possible foreground or background
1940
- // colors for that base, returns the most readable color.
1941
- // *Example*
1942
- // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
1943
- tinycolor.mostReadable = function(baseColor, colorList) {
1944
- var bestColor = null;
1945
- var bestScore = 0;
1946
- var bestIsReadable = false;
1947
- for (var i=0; i < colorList.length; i++) {
1948
-
1949
- // We normalize both around the "acceptable" breaking point,
1950
- // but rank brightness constrast higher than hue.
1951
-
1952
- var readability = tinycolor.readability(baseColor, colorList[i]);
1953
- var readable = readability.brightness > 125 && readability.color > 500;
1954
- var score = 3 * (readability.brightness / 125) + (readability.color / 500);
1955
-
1956
- if ((readable && ! bestIsReadable) ||
1957
- (readable && bestIsReadable && score > bestScore) ||
1958
- ((! readable) && (! bestIsReadable) && score > bestScore)) {
1959
- bestIsReadable = readable;
1960
- bestScore = score;
1961
- bestColor = tinycolor(colorList[i]);
1962
- }
1963
- }
1964
- return bestColor;
1965
- };
1966
-
1967
-
1968
- // Big List of Colors
1969
- // ------------------
1970
- // <http://www.w3.org/TR/css3-color/#svg-color>
1971
- var names = tinycolor.names = {
1972
- aliceblue: "f0f8ff",
1973
- antiquewhite: "faebd7",
1974
- aqua: "0ff",
1975
- aquamarine: "7fffd4",
1976
- azure: "f0ffff",
1977
- beige: "f5f5dc",
1978
- bisque: "ffe4c4",
1979
- black: "000",
1980
- blanchedalmond: "ffebcd",
1981
- blue: "00f",
1982
- blueviolet: "8a2be2",
1983
- brown: "a52a2a",
1984
- burlywood: "deb887",
1985
- burntsienna: "ea7e5d",
1986
- cadetblue: "5f9ea0",
1987
- chartreuse: "7fff00",
1988
- chocolate: "d2691e",
1989
- coral: "ff7f50",
1990
- cornflowerblue: "6495ed",
1991
- cornsilk: "fff8dc",
1992
- crimson: "dc143c",
1993
- cyan: "0ff",
1994
- darkblue: "00008b",
1995
- darkcyan: "008b8b",
1996
- darkgoldenrod: "b8860b",
1997
- darkgray: "a9a9a9",
1998
- darkgreen: "006400",
1999
- darkgrey: "a9a9a9",
2000
- darkkhaki: "bdb76b",
2001
- darkmagenta: "8b008b",
2002
- darkolivegreen: "556b2f",
2003
- darkorange: "ff8c00",
2004
- darkorchid: "9932cc",
2005
- darkred: "8b0000",
2006
- darksalmon: "e9967a",
2007
- darkseagreen: "8fbc8f",
2008
- darkslateblue: "483d8b",
2009
- darkslategray: "2f4f4f",
2010
- darkslategrey: "2f4f4f",
2011
- darkturquoise: "00ced1",
2012
- darkviolet: "9400d3",
2013
- deeppink: "ff1493",
2014
- deepskyblue: "00bfff",
2015
- dimgray: "696969",
2016
- dimgrey: "696969",
2017
- dodgerblue: "1e90ff",
2018
- firebrick: "b22222",
2019
- floralwhite: "fffaf0",
2020
- forestgreen: "228b22",
2021
- fuchsia: "f0f",
2022
- gainsboro: "dcdcdc",
2023
- ghostwhite: "f8f8ff",
2024
- gold: "ffd700",
2025
- goldenrod: "daa520",
2026
- gray: "808080",
2027
- green: "008000",
2028
- greenyellow: "adff2f",
2029
- grey: "808080",
2030
- honeydew: "f0fff0",
2031
- hotpink: "ff69b4",
2032
- indianred: "cd5c5c",
2033
- indigo: "4b0082",
2034
- ivory: "fffff0",
2035
- khaki: "f0e68c",
2036
- lavender: "e6e6fa",
2037
- lavenderblush: "fff0f5",
2038
- lawngreen: "7cfc00",
2039
- lemonchiffon: "fffacd",
2040
- lightblue: "add8e6",
2041
- lightcoral: "f08080",
2042
- lightcyan: "e0ffff",
2043
- lightgoldenrodyellow: "fafad2",
2044
- lightgray: "d3d3d3",
2045
- lightgreen: "90ee90",
2046
- lightgrey: "d3d3d3",
2047
- lightpink: "ffb6c1",
2048
- lightsalmon: "ffa07a",
2049
- lightseagreen: "20b2aa",
2050
- lightskyblue: "87cefa",
2051
- lightslategray: "789",
2052
- lightslategrey: "789",
2053
- lightsteelblue: "b0c4de",
2054
- lightyellow: "ffffe0",
2055
- lime: "0f0",
2056
- limegreen: "32cd32",
2057
- linen: "faf0e6",
2058
- magenta: "f0f",
2059
- maroon: "800000",
2060
- mediumaquamarine: "66cdaa",
2061
- mediumblue: "0000cd",
2062
- mediumorchid: "ba55d3",
2063
- mediumpurple: "9370db",
2064
- mediumseagreen: "3cb371",
2065
- mediumslateblue: "7b68ee",
2066
- mediumspringgreen: "00fa9a",
2067
- mediumturquoise: "48d1cc",
2068
- mediumvioletred: "c71585",
2069
- midnightblue: "191970",
2070
- mintcream: "f5fffa",
2071
- mistyrose: "ffe4e1",
2072
- moccasin: "ffe4b5",
2073
- navajowhite: "ffdead",
2074
- navy: "000080",
2075
- oldlace: "fdf5e6",
2076
- olive: "808000",
2077
- olivedrab: "6b8e23",
2078
- orange: "ffa500",
2079
- orangered: "ff4500",
2080
- orchid: "da70d6",
2081
- palegoldenrod: "eee8aa",
2082
- palegreen: "98fb98",
2083
- paleturquoise: "afeeee",
2084
- palevioletred: "db7093",
2085
- papayawhip: "ffefd5",
2086
- peachpuff: "ffdab9",
2087
- peru: "cd853f",
2088
- pink: "ffc0cb",
2089
- plum: "dda0dd",
2090
- powderblue: "b0e0e6",
2091
- purple: "800080",
2092
- rebeccapurple: "663399",
2093
- red: "f00",
2094
- rosybrown: "bc8f8f",
2095
- royalblue: "4169e1",
2096
- saddlebrown: "8b4513",
2097
- salmon: "fa8072",
2098
- sandybrown: "f4a460",
2099
- seagreen: "2e8b57",
2100
- seashell: "fff5ee",
2101
- sienna: "a0522d",
2102
- silver: "c0c0c0",
2103
- skyblue: "87ceeb",
2104
- slateblue: "6a5acd",
2105
- slategray: "708090",
2106
- slategrey: "708090",
2107
- snow: "fffafa",
2108
- springgreen: "00ff7f",
2109
- steelblue: "4682b4",
2110
- tan: "d2b48c",
2111
- teal: "008080",
2112
- thistle: "d8bfd8",
2113
- tomato: "ff6347",
2114
- turquoise: "40e0d0",
2115
- violet: "ee82ee",
2116
- wheat: "f5deb3",
2117
- white: "fff",
2118
- whitesmoke: "f5f5f5",
2119
- yellow: "ff0",
2120
- yellowgreen: "9acd32"
2121
- };
2122
-
2123
- // Make it easy to access colors via `hexNames[hex]`
2124
- var hexNames = tinycolor.hexNames = flip(names);
2125
-
2126
-
2127
- // Utilities
2128
- // ---------
2129
-
2130
- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
2131
- function flip(o) {
2132
- var flipped = { };
2133
- for (var i in o) {
2134
- if (o.hasOwnProperty(i)) {
2135
- flipped[o[i]] = i;
2136
- }
2137
- }
2138
- return flipped;
2139
- }
2140
-
2141
- // Return a valid alpha value [0,1] with all invalid values being set to 1
2142
- function boundAlpha(a) {
2143
- a = parseFloat(a);
2144
-
2145
- if (isNaN(a) || a < 0 || a > 1) {
2146
- a = 1;
2147
- }
2148
-
2149
- return a;
2150
- }
2151
-
2152
- // Take input from [0, n] and return it as [0, 1]
2153
- function bound01(n, max) {
2154
- if (isOnePointZero(n)) { n = "100%"; }
2155
-
2156
- var processPercent = isPercentage(n);
2157
- n = mathMin(max, mathMax(0, parseFloat(n)));
2158
-
2159
- // Automatically convert percentage into number
2160
- if (processPercent) {
2161
- n = parseInt(n * max, 10) / 100;
2162
- }
2163
-
2164
- // Handle floating point rounding errors
2165
- if ((math.abs(n - max) < 0.000001)) {
2166
- return 1;
2167
- }
2168
-
2169
- // Convert into [0, 1] range if it isn't already
2170
- return (n % max) / parseFloat(max);
2171
- }
2172
-
2173
- // Force a number between 0 and 1
2174
- function clamp01(val) {
2175
- return mathMin(1, mathMax(0, val));
2176
- }
2177
-
2178
- // Parse a base-16 hex value into a base-10 integer
2179
- function parseIntFromHex(val) {
2180
- return parseInt(val, 16);
2181
- }
2182
-
2183
- // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
2184
- // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
2185
- function isOnePointZero(n) {
2186
- return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
2187
- }
2188
-
2189
- // Check to see if string passed in is a percentage
2190
- function isPercentage(n) {
2191
- return typeof n === "string" && n.indexOf('%') != -1;
2192
- }
2193
-
2194
- // Force a hex value to have 2 characters
2195
- function pad2(c) {
2196
- return c.length == 1 ? '0' + c : '' + c;
2197
- }
2198
-
2199
- // Replace a decimal with it's percentage value
2200
- function convertToPercentage(n) {
2201
- if (n <= 1) {
2202
- n = (n * 100) + "%";
2203
- }
2204
-
2205
- return n;
2206
- }
2207
-
2208
- // Converts a decimal to a hex value
2209
- function convertDecimalToHex(d) {
2210
- return Math.round(parseFloat(d) * 255).toString(16);
2211
- }
2212
- // Converts a hex value to a decimal
2213
- function convertHexToDecimal(h) {
2214
- return (parseIntFromHex(h) / 255);
2215
- }
2216
-
2217
- var matchers = (function() {
2218
-
2219
- // <http://www.w3.org/TR/css3-values/#integers>
2220
- var CSS_INTEGER = "[-\\+]?\\d+%?";
2221
-
2222
- // <http://www.w3.org/TR/css3-values/#number-value>
2223
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
2224
-
2225
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
2226
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
2227
-
2228
- // Actual matching.
2229
- // Parentheses and commas are optional, but not required.
2230
- // Whitespace can take the place of commas or opening paren
2231
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
2232
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
2233
-
2234
- return {
2235
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
2236
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
2237
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
2238
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
2239
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
2240
- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
2241
- hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
2242
- hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
2243
- hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
2244
- };
2245
- })();
2246
-
2247
- // `stringInputToObject`
2248
- // Permissive string parsing. Take in a number of formats, and output an object
2249
- // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
2250
- function stringInputToObject(color) {
2251
-
2252
- color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
2253
- var named = false;
2254
- if (names[color]) {
2255
- color = names[color];
2256
- named = true;
2257
- }
2258
- else if (color == 'transparent') {
2259
- return { r: 0, g: 0, b: 0, a: 0, format: "name" };
2260
- }
2261
-
2262
- // Try to match string input using regular expressions.
2263
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
2264
- // Just return an object and let the conversion functions handle that.
2265
- // This way the result will be the same whether the tinycolor is initialized with string or object.
2266
- var match;
2267
- if ((match = matchers.rgb.exec(color))) {
2268
- return { r: match[1], g: match[2], b: match[3] };
2269
- }
2270
- if ((match = matchers.rgba.exec(color))) {
2271
- return { r: match[1], g: match[2], b: match[3], a: match[4] };
2272
- }
2273
- if ((match = matchers.hsl.exec(color))) {
2274
- return { h: match[1], s: match[2], l: match[3] };
2275
- }
2276
- if ((match = matchers.hsla.exec(color))) {
2277
- return { h: match[1], s: match[2], l: match[3], a: match[4] };
2278
- }
2279
- if ((match = matchers.hsv.exec(color))) {
2280
- return { h: match[1], s: match[2], v: match[3] };
2281
- }
2282
- if ((match = matchers.hsva.exec(color))) {
2283
- return { h: match[1], s: match[2], v: match[3], a: match[4] };
2284
- }
2285
- if ((match = matchers.hex8.exec(color))) {
2286
- return {
2287
- a: convertHexToDecimal(match[1]),
2288
- r: parseIntFromHex(match[2]),
2289
- g: parseIntFromHex(match[3]),
2290
- b: parseIntFromHex(match[4]),
2291
- format: named ? "name" : "hex8"
2292
- };
2293
- }
2294
- if ((match = matchers.hex6.exec(color))) {
2295
- return {
2296
- r: parseIntFromHex(match[1]),
2297
- g: parseIntFromHex(match[2]),
2298
- b: parseIntFromHex(match[3]),
2299
- format: named ? "name" : "hex"
2300
- };
2301
- }
2302
- if ((match = matchers.hex3.exec(color))) {
2303
- return {
2304
- r: parseIntFromHex(match[1] + '' + match[1]),
2305
- g: parseIntFromHex(match[2] + '' + match[2]),
2306
- b: parseIntFromHex(match[3] + '' + match[3]),
2307
- format: named ? "name" : "hex"
2308
- };
2309
- }
2310
-
2311
- return false;
2312
- }
2313
-
2314
- window.tinycolor = tinycolor;
2315
- })();
2316
-
2317
- $(function () {
2318
- if ($.fn.spectrum.load) {
2319
- $.fn.spectrum.processNativeColorInputs();
2320
- }
2321
- });
2322
-
2323
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Spectrum Colorpicker v1.8.1
2
+ // https://github.com/bgrins/spectrum
3
+ // Author: Brian Grinstead
4
+ // License: MIT
5
+
6
+ (function (factory) {
7
+ "use strict";
8
+
9
+ if (typeof define === 'function' && define.amd) { // AMD
10
+ define(['jquery'], factory);
11
+ }
12
+ else if (typeof exports == "object" && typeof module == "object") { // CommonJS
13
+ module.exports = factory(require('jquery'));
14
+ }
15
+ else { // Browser
16
+ factory(jQuery);
17
+ }
18
+ })(function($, undefined) {
19
+ "use strict";
20
+
21
+ var defaultOpts = {
22
+
23
+ // Callbacks
24
+ beforeShow: noop,
25
+ move: noop,
26
+ change: noop,
27
+ show: noop,
28
+ hide: noop,
29
+
30
+ // Options
31
+ color: false,
32
+ flat: false,
33
+ showInput: false,
34
+ allowEmpty: false,
35
+ showButtons: true,
36
+ clickoutFiresChange: true,
37
+ showInitial: false,
38
+ showPalette: false,
39
+ showPaletteOnly: false,
40
+ hideAfterPaletteSelect: false,
41
+ togglePaletteOnly: false,
42
+ showSelectionPalette: true,
43
+ localStorageKey: false,
44
+ appendTo: "body",
45
+ maxSelectionSize: 7,
46
+ cancelText: "cancel",
47
+ chooseText: "choose",
48
+ togglePaletteMoreText: "more",
49
+ togglePaletteLessText: "less",
50
+ clearText: "Clear Color Selection",
51
+ noColorSelectedText: "No Color Selected",
52
+ preferredFormat: false,
53
+ className: "", // Deprecated - use containerClassName and replacerClassName instead.
54
+ containerClassName: "",
55
+ replacerClassName: "",
56
+ showAlpha: false,
57
+ theme: "sp-light",
58
+ palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
59
+ selectionPalette: [],
60
+ disabled: false,
61
+ offset: null
62
+ },
63
+ spectrums = [],
64
+ IE = !!/msie/i.exec( window.navigator.userAgent ),
65
+ rgbaSupport = (function() {
66
+ function contains( str, substr ) {
67
+ return !!~('' + str).indexOf(substr);
68
+ }
69
+
70
+ var elem = document.createElement('div');
71
+ var style = elem.style;
72
+ style.cssText = 'background-color:rgba(0,0,0,.5)';
73
+ return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
74
+ })(),
75
+ replaceInput = [
76
+ "<div class='sp-replacer'>",
77
+ "<div class='sp-preview'><div class='sp-preview-inner'></div></div>",
78
+ "<div class='sp-dd'>&#9660;</div>",
79
+ "</div>"
80
+ ].join(''),
81
+ markup = (function () {
82
+
83
+ // IE does not support gradients with multiple stops, so we need to simulate
84
+ // that for the rainbow slider with 8 divs that each have a single gradient
85
+ var gradientFix = "";
86
+ if (IE) {
87
+ for (var i = 1; i <= 6; i++) {
88
+ gradientFix += "<div class='sp-" + i + "'></div>";
89
+ }
90
+ }
91
+
92
+ return [
93
+ "<div class='sp-container sp-hidden'>",
94
+ "<div class='sp-palette-container'>",
95
+ "<div class='sp-palette sp-thumb sp-cf'></div>",
96
+ "<div class='sp-palette-button-container sp-cf'>",
97
+ "<button type='button' class='sp-palette-toggle'></button>",
98
+ "</div>",
99
+ "</div>",
100
+ "<div class='sp-picker-container'>",
101
+ "<div class='sp-top sp-cf'>",
102
+ "<div class='sp-fill'></div>",
103
+ "<div class='sp-top-inner'>",
104
+ "<div class='sp-color'>",
105
+ "<div class='sp-sat'>",
106
+ "<div class='sp-val'>",
107
+ "<div class='sp-dragger'></div>",
108
+ "</div>",
109
+ "</div>",
110
+ "</div>",
111
+ "<div class='sp-clear sp-clear-display'>",
112
+ "</div>",
113
+ "<div class='sp-hue'>",
114
+ "<div class='sp-slider'></div>",
115
+ gradientFix,
116
+ "</div>",
117
+ "</div>",
118
+ "<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>",
119
+ "</div>",
120
+ "<div class='sp-input-container sp-cf'>",
121
+ "<input class='sp-input' type='text' spellcheck='false' />",
122
+ "</div>",
123
+ "<div class='sp-initial sp-thumb sp-cf'></div>",
124
+ "<div class='sp-button-container sp-cf'>",
125
+ "<a class='sp-cancel' href='#'></a>",
126
+ "<button type='button' class='sp-choose'></button>",
127
+ "</div>",
128
+ "</div>",
129
+ "</div>"
130
+ ].join("");
131
+ })();
132
+
133
+ function paletteTemplate (p, color, className, opts) {
134
+ var html = [];
135
+ for (var i = 0; i < p.length; i++) {
136
+ var current = p[i];
137
+ if(current) {
138
+ var tiny = tinycolor(current);
139
+ var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
140
+ c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : "";
141
+ var formattedString = tiny.toString(opts.preferredFormat || "rgb");
142
+ var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
143
+ html.push('<span title="' + formattedString + '" data-color="' + tiny.toRgbString() + '" class="' + c + '"><span class="sp-thumb-inner" style="' + swatchStyle + ';"></span></span>');
144
+ } else {
145
+ var cls = 'sp-clear-display';
146
+ html.push($('<div />')
147
+ .append($('<span data-color="" style="background-color:transparent;" class="' + cls + '"></span>')
148
+ .attr('title', opts.noColorSelectedText)
149
+ )
150
+ .html()
151
+ );
152
+ }
153
+ }
154
+ return "<div class='sp-cf " + className + "'>" + html.join('') + "</div>";
155
+ }
156
+
157
+ function hideAll() {
158
+ for (var i = 0; i < spectrums.length; i++) {
159
+ if (spectrums[i]) {
160
+ spectrums[i].hide();
161
+ }
162
+ }
163
+ }
164
+
165
+ function instanceOptions(o, callbackContext) {
166
+ var opts = $.extend({}, defaultOpts, o);
167
+ opts.callbacks = {
168
+ 'move': bind(opts.move, callbackContext),
169
+ 'change': bind(opts.change, callbackContext),
170
+ 'show': bind(opts.show, callbackContext),
171
+ 'hide': bind(opts.hide, callbackContext),
172
+ 'beforeShow': bind(opts.beforeShow, callbackContext)
173
+ };
174
+
175
+ return opts;
176
+ }
177
+
178
+ function spectrum(element, o) {
179
+
180
+ var opts = instanceOptions(o, element),
181
+ flat = opts.flat,
182
+ showSelectionPalette = opts.showSelectionPalette,
183
+ localStorageKey = opts.localStorageKey,
184
+ theme = opts.theme,
185
+ callbacks = opts.callbacks,
186
+ resize = throttle(reflow, 10),
187
+ visible = false,
188
+ isDragging = false,
189
+ dragWidth = 0,
190
+ dragHeight = 0,
191
+ dragHelperHeight = 0,
192
+ slideHeight = 0,
193
+ slideWidth = 0,
194
+ alphaWidth = 0,
195
+ alphaSlideHelperWidth = 0,
196
+ slideHelperHeight = 0,
197
+ currentHue = 0,
198
+ currentSaturation = 0,
199
+ currentValue = 0,
200
+ currentAlpha = 1,
201
+ palette = [],
202
+ paletteArray = [],
203
+ paletteLookup = {},
204
+ selectionPalette = opts.selectionPalette.slice(0),
205
+ maxSelectionSize = opts.maxSelectionSize,
206
+ draggingClass = "sp-dragging",
207
+ shiftMovementDirection = null;
208
+
209
+ var doc = element.ownerDocument,
210
+ body = doc.body,
211
+ boundElement = $(element),
212
+ disabled = false,
213
+ container = $(markup, doc).addClass(theme),
214
+ pickerContainer = container.find(".sp-picker-container"),
215
+ dragger = container.find(".sp-color"),
216
+ dragHelper = container.find(".sp-dragger"),
217
+ slider = container.find(".sp-hue"),
218
+ slideHelper = container.find(".sp-slider"),
219
+ alphaSliderInner = container.find(".sp-alpha-inner"),
220
+ alphaSlider = container.find(".sp-alpha"),
221
+ alphaSlideHelper = container.find(".sp-alpha-handle"),
222
+ textInput = container.find(".sp-input"),
223
+ paletteContainer = container.find(".sp-palette"),
224
+ initialColorContainer = container.find(".sp-initial"),
225
+ cancelButton = container.find(".sp-cancel"),
226
+ clearButton = container.find(".sp-clear"),
227
+ chooseButton = container.find(".sp-choose"),
228
+ toggleButton = container.find(".sp-palette-toggle"),
229
+ isInput = boundElement.is("input"),
230
+ isInputTypeColor = isInput && boundElement.attr("type") === "color" && inputTypeColorSupport(),
231
+ shouldReplace = isInput && !flat,
232
+ replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
233
+ offsetElement = (shouldReplace) ? replacer : boundElement,
234
+ previewElement = replacer.find(".sp-preview-inner"),
235
+ initialColor = opts.color || (isInput && boundElement.val()),
236
+ colorOnShow = false,
237
+ currentPreferredFormat = opts.preferredFormat,
238
+ clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,
239
+ isEmpty = !initialColor,
240
+ allowEmpty = opts.allowEmpty && !isInputTypeColor;
241
+
242
+ function applyOptions() {
243
+
244
+ if (opts.showPaletteOnly) {
245
+ opts.showPalette = true;
246
+ }
247
+
248
+ toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
249
+
250
+ if (opts.palette) {
251
+ palette = opts.palette.slice(0);
252
+ paletteArray = $.isArray(palette[0]) ? palette : [palette];
253
+ paletteLookup = {};
254
+ for (var i = 0; i < paletteArray.length; i++) {
255
+ for (var j = 0; j < paletteArray[i].length; j++) {
256
+ var rgb = tinycolor(paletteArray[i][j]).toRgbString();
257
+ paletteLookup[rgb] = true;
258
+ }
259
+ }
260
+ }
261
+
262
+ container.toggleClass("sp-flat", flat);
263
+ container.toggleClass("sp-input-disabled", !opts.showInput);
264
+ container.toggleClass("sp-alpha-enabled", opts.showAlpha);
265
+ container.toggleClass("sp-clear-enabled", allowEmpty);
266
+ container.toggleClass("sp-buttons-disabled", !opts.showButtons);
267
+ container.toggleClass("sp-palette-buttons-disabled", !opts.togglePaletteOnly);
268
+ container.toggleClass("sp-palette-disabled", !opts.showPalette);
269
+ container.toggleClass("sp-palette-only", opts.showPaletteOnly);
270
+ container.toggleClass("sp-initial-disabled", !opts.showInitial);
271
+ container.addClass(opts.className).addClass(opts.containerClassName);
272
+
273
+ reflow();
274
+ }
275
+
276
+ function initialize() {
277
+
278
+ if (IE) {
279
+ container.find("*:not(input)").attr("unselectable", "on");
280
+ }
281
+
282
+ applyOptions();
283
+
284
+ if (shouldReplace) {
285
+ boundElement.after(replacer).hide();
286
+ }
287
+
288
+ if (!allowEmpty) {
289
+ clearButton.hide();
290
+ }
291
+
292
+ if (flat) {
293
+ boundElement.after(container).hide();
294
+ }
295
+ else {
296
+
297
+ var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo);
298
+ if (appendTo.length !== 1) {
299
+ appendTo = $("body");
300
+ }
301
+
302
+ appendTo.append(container);
303
+ }
304
+
305
+ updateSelectionPaletteFromStorage();
306
+
307
+ offsetElement.on("click.spectrum touchstart.spectrum", function (e) {
308
+ if (!disabled) {
309
+ toggle();
310
+ }
311
+
312
+ e.stopPropagation();
313
+
314
+ if (!$(e.target).is("input")) {
315
+ e.preventDefault();
316
+ }
317
+ });
318
+
319
+ if(boundElement.is(":disabled") || (opts.disabled === true)) {
320
+ disable();
321
+ }
322
+
323
+ // Prevent clicks from bubbling up to document. This would cause it to be hidden.
324
+ container.click(stopPropagation);
325
+
326
+ // Handle user typed input
327
+ textInput.change(setFromTextInput);
328
+ textInput.on("paste", function () {
329
+ setTimeout(setFromTextInput, 1);
330
+ });
331
+ textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
332
+
333
+ cancelButton.text(opts.cancelText);
334
+ cancelButton.on("click.spectrum", function (e) {
335
+ e.stopPropagation();
336
+ e.preventDefault();
337
+ revert();
338
+ hide();
339
+ });
340
+
341
+ clearButton.attr("title", opts.clearText);
342
+ clearButton.on("click.spectrum", function (e) {
343
+ e.stopPropagation();
344
+ e.preventDefault();
345
+ isEmpty = true;
346
+ move();
347
+
348
+ if(flat) {
349
+ //for the flat style, this is a change event
350
+ updateOriginalInput(true);
351
+ }
352
+ });
353
+
354
+ chooseButton.text(opts.chooseText);
355
+ chooseButton.on("click.spectrum", function (e) {
356
+ e.stopPropagation();
357
+ e.preventDefault();
358
+
359
+ if (IE && textInput.is(":focus")) {
360
+ textInput.trigger('change');
361
+ }
362
+
363
+ if (isValid()) {
364
+ updateOriginalInput(true);
365
+ hide();
366
+ }
367
+ });
368
+
369
+ toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);
370
+ toggleButton.on("click.spectrum", function (e) {
371
+ e.stopPropagation();
372
+ e.preventDefault();
373
+
374
+ opts.showPaletteOnly = !opts.showPaletteOnly;
375
+
376
+ // To make sure the Picker area is drawn on the right, next to the
377
+ // Palette area (and not below the palette), first move the Palette
378
+ // to the left to make space for the picker, plus 5px extra.
379
+ // The 'applyOptions' function puts the whole container back into place
380
+ // and takes care of the button-text and the sp-palette-only CSS class.
381
+ if (!opts.showPaletteOnly && !flat) {
382
+ container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5));
383
+ }
384
+ applyOptions();
385
+ });
386
+
387
+ draggable(alphaSlider, function (dragX, dragY, e) {
388
+ currentAlpha = (dragX / alphaWidth);
389
+ isEmpty = false;
390
+ if (e.shiftKey) {
391
+ currentAlpha = Math.round(currentAlpha * 10) / 10;
392
+ }
393
+
394
+ move();
395
+ }, dragStart, dragStop);
396
+
397
+ draggable(slider, function (dragX, dragY) {
398
+ currentHue = parseFloat(dragY / slideHeight);
399
+ isEmpty = false;
400
+ if (!opts.showAlpha) {
401
+ currentAlpha = 1;
402
+ }
403
+ move();
404
+ }, dragStart, dragStop);
405
+
406
+ draggable(dragger, function (dragX, dragY, e) {
407
+
408
+ // shift+drag should snap the movement to either the x or y axis.
409
+ if (!e.shiftKey) {
410
+ shiftMovementDirection = null;
411
+ }
412
+ else if (!shiftMovementDirection) {
413
+ var oldDragX = currentSaturation * dragWidth;
414
+ var oldDragY = dragHeight - (currentValue * dragHeight);
415
+ var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);
416
+
417
+ shiftMovementDirection = furtherFromX ? "x" : "y";
418
+ }
419
+
420
+ var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x";
421
+ var setValue = !shiftMovementDirection || shiftMovementDirection === "y";
422
+
423
+ if (setSaturation) {
424
+ currentSaturation = parseFloat(dragX / dragWidth);
425
+ }
426
+ if (setValue) {
427
+ currentValue = parseFloat((dragHeight - dragY) / dragHeight);
428
+ }
429
+
430
+ isEmpty = false;
431
+ if (!opts.showAlpha) {
432
+ currentAlpha = 1;
433
+ }
434
+
435
+ move();
436
+
437
+ }, dragStart, dragStop);
438
+
439
+ if (!!initialColor) {
440
+ set(initialColor);
441
+
442
+ // In case color was black - update the preview UI and set the format
443
+ // since the set function will not run (default color is black).
444
+ updateUI();
445
+ currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format;
446
+
447
+ addColorToSelectionPalette(initialColor);
448
+ }
449
+ else {
450
+ updateUI();
451
+ }
452
+
453
+ if (flat) {
454
+ show();
455
+ }
456
+
457
+ function paletteElementClick(e) {
458
+ if (e.data && e.data.ignore) {
459
+ set($(e.target).closest(".sp-thumb-el").data("color"));
460
+ move();
461
+ }
462
+ else {
463
+ set($(e.target).closest(".sp-thumb-el").data("color"));
464
+ move();
465
+
466
+ // If the picker is going to close immediately, a palette selection
467
+ // is a change. Otherwise, it's a move only.
468
+ if (opts.hideAfterPaletteSelect) {
469
+ updateOriginalInput(true);
470
+ hide();
471
+ } else {
472
+ updateOriginalInput();
473
+ }
474
+ }
475
+
476
+ return false;
477
+ }
478
+
479
+ var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
480
+ paletteContainer.on(paletteEvent, ".sp-thumb-el", paletteElementClick);
481
+ initialColorContainer.on(paletteEvent, ".sp-thumb-el:nth-child(1)", { ignore: true }, paletteElementClick);
482
+ }
483
+
484
+ function updateSelectionPaletteFromStorage() {
485
+
486
+ if (localStorageKey && window.localStorage) {
487
+
488
+ // Migrate old palettes over to new format. May want to remove this eventually.
489
+ try {
490
+ var oldPalette = window.localStorage[localStorageKey].split(",#");
491
+ if (oldPalette.length > 1) {
492
+ delete window.localStorage[localStorageKey];
493
+ $.each(oldPalette, function(i, c) {
494
+ addColorToSelectionPalette(c);
495
+ });
496
+ }
497
+ }
498
+ catch(e) { }
499
+
500
+ try {
501
+ selectionPalette = window.localStorage[localStorageKey].split(";");
502
+ }
503
+ catch (e) { }
504
+ }
505
+ }
506
+
507
+ function addColorToSelectionPalette(color) {
508
+ if (showSelectionPalette) {
509
+ var rgb = tinycolor(color).toRgbString();
510
+ if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) {
511
+ selectionPalette.push(rgb);
512
+ while(selectionPalette.length > maxSelectionSize) {
513
+ selectionPalette.shift();
514
+ }
515
+ }
516
+
517
+ if (localStorageKey && window.localStorage) {
518
+ try {
519
+ window.localStorage[localStorageKey] = selectionPalette.join(";");
520
+ }
521
+ catch(e) { }
522
+ }
523
+ }
524
+ }
525
+
526
+ function getUniqueSelectionPalette() {
527
+ var unique = [];
528
+ if (opts.showPalette) {
529
+ for (var i = 0; i < selectionPalette.length; i++) {
530
+ var rgb = tinycolor(selectionPalette[i]).toRgbString();
531
+
532
+ if (!paletteLookup[rgb]) {
533
+ unique.push(selectionPalette[i]);
534
+ }
535
+ }
536
+ }
537
+
538
+ return unique.reverse().slice(0, opts.maxSelectionSize);
539
+ }
540
+
541
+ function drawPalette() {
542
+
543
+ var currentColor = get();
544
+
545
+ var html = $.map(paletteArray, function (palette, i) {
546
+ return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts);
547
+ });
548
+
549
+ updateSelectionPaletteFromStorage();
550
+
551
+ if (selectionPalette) {
552
+ html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts));
553
+ }
554
+
555
+ paletteContainer.html(html.join(""));
556
+ }
557
+
558
+ function drawInitial() {
559
+ if (opts.showInitial) {
560
+ var initial = colorOnShow;
561
+ var current = get();
562
+ initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts));
563
+ }
564
+ }
565
+
566
+ function dragStart() {
567
+ if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
568
+ reflow();
569
+ }
570
+ isDragging = true;
571
+ container.addClass(draggingClass);
572
+ shiftMovementDirection = null;
573
+ boundElement.trigger('dragstart.spectrum', [ get() ]);
574
+ }
575
+
576
+ function dragStop() {
577
+ isDragging = false;
578
+ container.removeClass(draggingClass);
579
+ boundElement.trigger('dragstop.spectrum', [ get() ]);
580
+ }
581
+
582
+ function setFromTextInput() {
583
+
584
+ var value = textInput.val();
585
+
586
+ if ((value === null || value === "") && allowEmpty) {
587
+ set(null);
588
+ move();
589
+ updateOriginalInput();
590
+ }
591
+ else {
592
+ var tiny = tinycolor(value);
593
+ if (tiny.isValid()) {
594
+ set(tiny);
595
+ move();
596
+ updateOriginalInput();
597
+ }
598
+ else {
599
+ textInput.addClass("sp-validation-error");
600
+ }
601
+ }
602
+ }
603
+
604
+ function toggle() {
605
+ if (visible) {
606
+ hide();
607
+ }
608
+ else {
609
+ show();
610
+ }
611
+ }
612
+
613
+ function show() {
614
+ var event = $.Event('beforeShow.spectrum');
615
+
616
+ if (visible) {
617
+ reflow();
618
+ return;
619
+ }
620
+
621
+ boundElement.trigger(event, [ get() ]);
622
+
623
+ if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {
624
+ return;
625
+ }
626
+
627
+ hideAll();
628
+ visible = true;
629
+
630
+ $(doc).on("keydown.spectrum", onkeydown);
631
+ $(doc).on("click.spectrum", clickout);
632
+ $(window).on("resize.spectrum", resize);
633
+ replacer.addClass("sp-active");
634
+ container.removeClass("sp-hidden");
635
+
636
+ reflow();
637
+ updateUI();
638
+
639
+ colorOnShow = get();
640
+
641
+ drawInitial();
642
+ callbacks.show(colorOnShow);
643
+ boundElement.trigger('show.spectrum', [ colorOnShow ]);
644
+ }
645
+
646
+ function onkeydown(e) {
647
+ // Close on ESC
648
+ if (e.keyCode === 27) {
649
+ hide();
650
+ }
651
+ }
652
+
653
+ function clickout(e) {
654
+ // Return on right click.
655
+ if (e.button == 2) { return; }
656
+
657
+ // If a drag event was happening during the mouseup, don't hide
658
+ // on click.
659
+ if (isDragging) { return; }
660
+
661
+ if (clickoutFiresChange) {
662
+ updateOriginalInput(true);
663
+ }
664
+ else {
665
+ revert();
666
+ }
667
+ hide();
668
+ }
669
+
670
+ function hide() {
671
+ // Return if hiding is unnecessary
672
+ if (!visible || flat) { return; }
673
+ visible = false;
674
+
675
+ $(doc).off("keydown.spectrum", onkeydown);
676
+ $(doc).off("click.spectrum", clickout);
677
+ $(window).off("resize.spectrum", resize);
678
+
679
+ replacer.removeClass("sp-active");
680
+ container.addClass("sp-hidden");
681
+
682
+ callbacks.hide(get());
683
+ boundElement.trigger('hide.spectrum', [ get() ]);
684
+ }
685
+
686
+ function revert() {
687
+ set(colorOnShow, true);
688
+ updateOriginalInput(true);
689
+ }
690
+
691
+ function set(color, ignoreFormatChange) {
692
+ if (tinycolor.equals(color, get())) {
693
+ // Update UI just in case a validation error needs
694
+ // to be cleared.
695
+ updateUI();
696
+ return;
697
+ }
698
+
699
+ var newColor, newHsv;
700
+ if (!color && allowEmpty) {
701
+ isEmpty = true;
702
+ } else {
703
+ isEmpty = false;
704
+ newColor = tinycolor(color);
705
+ newHsv = newColor.toHsv();
706
+
707
+ currentHue = (newHsv.h % 360) / 360;
708
+ currentSaturation = newHsv.s;
709
+ currentValue = newHsv.v;
710
+ currentAlpha = newHsv.a;
711
+ }
712
+ updateUI();
713
+
714
+ if (newColor && newColor.isValid() && !ignoreFormatChange) {
715
+ currentPreferredFormat = opts.preferredFormat || newColor.getFormat();
716
+ }
717
+ }
718
+
719
+ function get(opts) {
720
+ opts = opts || { };
721
+
722
+ if (allowEmpty && isEmpty) {
723
+ return null;
724
+ }
725
+
726
+ return tinycolor.fromRatio({
727
+ h: currentHue,
728
+ s: currentSaturation,
729
+ v: currentValue,
730
+ a: Math.round(currentAlpha * 1000) / 1000
731
+ }, { format: opts.format || currentPreferredFormat });
732
+ }
733
+
734
+ function isValid() {
735
+ return !textInput.hasClass("sp-validation-error");
736
+ }
737
+
738
+ function move() {
739
+ updateUI();
740
+
741
+ callbacks.move(get());
742
+ boundElement.trigger('move.spectrum', [ get() ]);
743
+ }
744
+
745
+ function updateUI() {
746
+
747
+ textInput.removeClass("sp-validation-error");
748
+
749
+ updateHelperLocations();
750
+
751
+ // Update dragger background color (gradients take care of saturation and value).
752
+ var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });
753
+ dragger.css("background-color", flatColor.toHexString());
754
+
755
+ // Get a format that alpha will be included in (hex and names ignore alpha)
756
+ var format = currentPreferredFormat;
757
+ if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) {
758
+ if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") {
759
+ format = "rgb";
760
+ }
761
+ }
762
+
763
+ var realColor = get({ format: format }),
764
+ displayColor = '';
765
+
766
+ //reset background info for preview element
767
+ previewElement.removeClass("sp-clear-display");
768
+ previewElement.css('background-color', 'transparent');
769
+
770
+ if (!realColor && allowEmpty) {
771
+ // Update the replaced elements background with icon indicating no color selection
772
+ previewElement.addClass("sp-clear-display");
773
+ }
774
+ else {
775
+ var realHex = realColor.toHexString(),
776
+ realRgb = realColor.toRgbString();
777
+
778
+ // Update the replaced elements background color (with actual selected color)
779
+ if (rgbaSupport || realColor.alpha === 1) {
780
+ previewElement.css("background-color", realRgb);
781
+ }
782
+ else {
783
+ previewElement.css("background-color", "transparent");
784
+ previewElement.css("filter", realColor.toFilter());
785
+ }
786
+
787
+ if (opts.showAlpha) {
788
+ var rgb = realColor.toRgb();
789
+ rgb.a = 0;
790
+ var realAlpha = tinycolor(rgb).toRgbString();
791
+ var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
792
+
793
+ if (IE) {
794
+ alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
795
+ }
796
+ else {
797
+ alphaSliderInner.css("background", "-webkit-" + gradient);
798
+ alphaSliderInner.css("background", "-moz-" + gradient);
799
+ alphaSliderInner.css("background", "-ms-" + gradient);
800
+ // Use current syntax gradient on unprefixed property.
801
+ alphaSliderInner.css("background",
802
+ "linear-gradient(to right, " + realAlpha + ", " + realHex + ")");
803
+ }
804
+ }
805
+
806
+ displayColor = realColor.toString(format);
807
+ }
808
+
809
+ // Update the text entry input as it changes happen
810
+ if (opts.showInput) {
811
+ textInput.val(displayColor);
812
+ }
813
+
814
+ if (opts.showPalette) {
815
+ drawPalette();
816
+ }
817
+
818
+ drawInitial();
819
+ }
820
+
821
+ function updateHelperLocations() {
822
+ var s = currentSaturation;
823
+ var v = currentValue;
824
+
825
+ if(allowEmpty && isEmpty) {
826
+ //if selected color is empty, hide the helpers
827
+ alphaSlideHelper.hide();
828
+ slideHelper.hide();
829
+ dragHelper.hide();
830
+ }
831
+ else {
832
+ //make sure helpers are visible
833
+ alphaSlideHelper.show();
834
+ slideHelper.show();
835
+ dragHelper.show();
836
+
837
+ // Where to show the little circle in that displays your current selected color
838
+ var dragX = s * dragWidth;
839
+ var dragY = dragHeight - (v * dragHeight);
840
+ dragX = Math.max(
841
+ -dragHelperHeight,
842
+ Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
843
+ );
844
+ dragY = Math.max(
845
+ -dragHelperHeight,
846
+ Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
847
+ );
848
+ dragHelper.css({
849
+ "top": dragY + "px",
850
+ "left": dragX + "px"
851
+ });
852
+
853
+ var alphaX = currentAlpha * alphaWidth;
854
+ alphaSlideHelper.css({
855
+ "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px"
856
+ });
857
+
858
+ // Where to show the bar that displays your current selected hue
859
+ var slideY = (currentHue) * slideHeight;
860
+ slideHelper.css({
861
+ "top": (slideY - slideHelperHeight) + "px"
862
+ });
863
+ }
864
+ }
865
+
866
+ function updateOriginalInput(fireCallback) {
867
+ var color = get(),
868
+ displayColor = '',
869
+ hasChanged = !tinycolor.equals(color, colorOnShow);
870
+
871
+ if (color) {
872
+ displayColor = color.toString(currentPreferredFormat);
873
+ // Update the selection palette with the current color
874
+ addColorToSelectionPalette(color);
875
+ }
876
+
877
+ if (isInput) {
878
+ boundElement.val(displayColor);
879
+ }
880
+
881
+ if (fireCallback && hasChanged) {
882
+ callbacks.change(color);
883
+ boundElement.trigger('change', [ color ]);
884
+ }
885
+ }
886
+
887
+ function reflow() {
888
+ if (!visible) {
889
+ return; // Calculations would be useless and wouldn't be reliable anyways
890
+ }
891
+ dragWidth = dragger.width();
892
+ dragHeight = dragger.height();
893
+ dragHelperHeight = dragHelper.height();
894
+ slideWidth = slider.width();
895
+ slideHeight = slider.height();
896
+ slideHelperHeight = slideHelper.height();
897
+ alphaWidth = alphaSlider.width();
898
+ alphaSlideHelperWidth = alphaSlideHelper.width();
899
+
900
+ if (!flat) {
901
+ container.css("position", "absolute");
902
+ if (opts.offset) {
903
+ container.offset(opts.offset);
904
+ } else {
905
+ container.offset(getOffset(container, offsetElement));
906
+ }
907
+ }
908
+
909
+ updateHelperLocations();
910
+
911
+ if (opts.showPalette) {
912
+ drawPalette();
913
+ }
914
+
915
+ boundElement.trigger('reflow.spectrum');
916
+ }
917
+
918
+ function destroy() {
919
+ boundElement.show();
920
+ offsetElement.off("click.spectrum touchstart.spectrum");
921
+ container.remove();
922
+ replacer.remove();
923
+ spectrums[spect.id] = null;
924
+ }
925
+
926
+ function option(optionName, optionValue) {
927
+ if (optionName === undefined) {
928
+ return $.extend({}, opts);
929
+ }
930
+ if (optionValue === undefined) {
931
+ return opts[optionName];
932
+ }
933
+
934
+ opts[optionName] = optionValue;
935
+
936
+ if (optionName === "preferredFormat") {
937
+ currentPreferredFormat = opts.preferredFormat;
938
+ }
939
+ applyOptions();
940
+ }
941
+
942
+ function enable() {
943
+ disabled = false;
944
+ boundElement.attr("disabled", false);
945
+ offsetElement.removeClass("sp-disabled");
946
+ }
947
+
948
+ function disable() {
949
+ hide();
950
+ disabled = true;
951
+ boundElement.attr("disabled", true);
952
+ offsetElement.addClass("sp-disabled");
953
+ }
954
+
955
+ function setOffset(coord) {
956
+ opts.offset = coord;
957
+ reflow();
958
+ }
959
+
960
+ initialize();
961
+
962
+ var spect = {
963
+ show: show,
964
+ hide: hide,
965
+ toggle: toggle,
966
+ reflow: reflow,
967
+ option: option,
968
+ enable: enable,
969
+ disable: disable,
970
+ offset: setOffset,
971
+ set: function (c) {
972
+ set(c);
973
+ updateOriginalInput();
974
+ },
975
+ get: get,
976
+ destroy: destroy,
977
+ container: container
978
+ };
979
+
980
+ spect.id = spectrums.push(spect) - 1;
981
+
982
+ return spect;
983
+ }
984
+
985
+ /**
986
+ * checkOffset - get the offset below/above and left/right element depending on screen position
987
+ * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
988
+ */
989
+ function getOffset(picker, input) {
990
+ var extraY = 0;
991
+ var dpWidth = picker.outerWidth();
992
+ var dpHeight = picker.outerHeight();
993
+ var inputHeight = input.outerHeight();
994
+ var doc = picker[0].ownerDocument;
995
+ var docElem = doc.documentElement;
996
+ var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
997
+ var viewHeight = docElem.clientHeight + $(doc).scrollTop();
998
+ var offset = input.offset();
999
+ var offsetLeft = offset.left;
1000
+ var offsetTop = offset.top;
1001
+
1002
+ offsetTop += inputHeight;
1003
+
1004
+ offsetLeft -=
1005
+ Math.min(offsetLeft, (offsetLeft + dpWidth > viewWidth && viewWidth > dpWidth) ?
1006
+ Math.abs(offsetLeft + dpWidth - viewWidth) : 0);
1007
+
1008
+ offsetTop -=
1009
+ Math.min(offsetTop, ((offsetTop + dpHeight > viewHeight && viewHeight > dpHeight) ?
1010
+ Math.abs(dpHeight + inputHeight - extraY) : extraY));
1011
+
1012
+ return {
1013
+ top: offsetTop,
1014
+ bottom: offset.bottom,
1015
+ left: offsetLeft,
1016
+ right: offset.right,
1017
+ width: offset.width,
1018
+ height: offset.height
1019
+ };
1020
+ }
1021
+
1022
+ /**
1023
+ * noop - do nothing
1024
+ */
1025
+ function noop() {
1026
+
1027
+ }
1028
+
1029
+ /**
1030
+ * stopPropagation - makes the code only doing this a little easier to read in line
1031
+ */
1032
+ function stopPropagation(e) {
1033
+ e.stopPropagation();
1034
+ }
1035
+
1036
+ /**
1037
+ * Create a function bound to a given object
1038
+ * Thanks to underscore.js
1039
+ */
1040
+ function bind(func, obj) {
1041
+ var slice = Array.prototype.slice;
1042
+ var args = slice.call(arguments, 2);
1043
+ return function () {
1044
+ return func.apply(obj, args.concat(slice.call(arguments)));
1045
+ };
1046
+ }
1047
+
1048
+ /**
1049
+ * Lightweight drag helper. Handles containment within the element, so that
1050
+ * when dragging, the x is within [0,element.width] and y is within [0,element.height]
1051
+ */
1052
+ function draggable(element, onmove, onstart, onstop) {
1053
+ onmove = onmove || function () { };
1054
+ onstart = onstart || function () { };
1055
+ onstop = onstop || function () { };
1056
+ var doc = document;
1057
+ var dragging = false;
1058
+ var offset = {};
1059
+ var maxHeight = 0;
1060
+ var maxWidth = 0;
1061
+ var hasTouch = ('ontouchstart' in window);
1062
+
1063
+ var duringDragEvents = {};
1064
+ duringDragEvents["selectstart"] = prevent;
1065
+ duringDragEvents["dragstart"] = prevent;
1066
+ duringDragEvents["touchmove mousemove"] = move;
1067
+ duringDragEvents["touchend mouseup"] = stop;
1068
+
1069
+ function prevent(e) {
1070
+ if (e.stopPropagation) {
1071
+ e.stopPropagation();
1072
+ }
1073
+ if (e.preventDefault) {
1074
+ e.preventDefault();
1075
+ }
1076
+ e.returnValue = false;
1077
+ }
1078
+
1079
+ function move(e) {
1080
+ if (dragging) {
1081
+ // Mouseup happened outside of window
1082
+ if (IE && doc.documentMode < 9 && !e.button) {
1083
+ return stop();
1084
+ }
1085
+
1086
+ var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];
1087
+ var pageX = t0 && t0.pageX || e.pageX;
1088
+ var pageY = t0 && t0.pageY || e.pageY;
1089
+
1090
+ var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
1091
+ var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
1092
+
1093
+ if (hasTouch) {
1094
+ // Stop scrolling in iOS
1095
+ prevent(e);
1096
+ }
1097
+
1098
+ onmove.apply(element, [dragX, dragY, e]);
1099
+ }
1100
+ }
1101
+
1102
+ function start(e) {
1103
+ var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
1104
+
1105
+ if (!rightclick && !dragging) {
1106
+ if (onstart.apply(element, arguments) !== false) {
1107
+ dragging = true;
1108
+ maxHeight = $(element).height();
1109
+ maxWidth = $(element).width();
1110
+ offset = $(element).offset();
1111
+
1112
+ $(doc).on(duringDragEvents);
1113
+ $(doc.body).addClass("sp-dragging");
1114
+
1115
+ move(e);
1116
+
1117
+ prevent(e);
1118
+ }
1119
+ }
1120
+ }
1121
+
1122
+ function stop() {
1123
+ if (dragging) {
1124
+ $(doc).off(duringDragEvents);
1125
+ $(doc.body).removeClass("sp-dragging");
1126
+
1127
+ // Wait a tick before notifying observers to allow the click event
1128
+ // to fire in Chrome.
1129
+ setTimeout(function() {
1130
+ onstop.apply(element, arguments);
1131
+ }, 0);
1132
+ }
1133
+ dragging = false;
1134
+ }
1135
+
1136
+ $(element).on("touchstart mousedown", start);
1137
+ }
1138
+
1139
+ function throttle(func, wait, debounce) {
1140
+ var timeout;
1141
+ return function () {
1142
+ var context = this, args = arguments;
1143
+ var throttler = function () {
1144
+ timeout = null;
1145
+ func.apply(context, args);
1146
+ };
1147
+ if (debounce) clearTimeout(timeout);
1148
+ if (debounce || !timeout) timeout = setTimeout(throttler, wait);
1149
+ };
1150
+ }
1151
+
1152
+ function inputTypeColorSupport() {
1153
+ return $.fn.spectrum.inputTypeColorSupport();
1154
+ }
1155
+
1156
+ /**
1157
+ * Define a jQuery plugin
1158
+ */
1159
+ var dataID = "spectrum.id";
1160
+ $.fn.spectrum = function (opts, extra) {
1161
+
1162
+ if (typeof opts == "string") {
1163
+
1164
+ var returnValue = this;
1165
+ var args = Array.prototype.slice.call( arguments, 1 );
1166
+
1167
+ this.each(function () {
1168
+ var spect = spectrums[$(this).data(dataID)];
1169
+ if (spect) {
1170
+ var method = spect[opts];
1171
+ if (!method) {
1172
+ throw new Error( "Spectrum: no such method: '" + opts + "'" );
1173
+ }
1174
+
1175
+ if (opts == "get") {
1176
+ returnValue = spect.get();
1177
+ }
1178
+ else if (opts == "container") {
1179
+ returnValue = spect.container;
1180
+ }
1181
+ else if (opts == "option") {
1182
+ returnValue = spect.option.apply(spect, args);
1183
+ }
1184
+ else if (opts == "destroy") {
1185
+ spect.destroy();
1186
+ $(this).removeData(dataID);
1187
+ }
1188
+ else {
1189
+ method.apply(spect, args);
1190
+ }
1191
+ }
1192
+ });
1193
+
1194
+ return returnValue;
1195
+ }
1196
+
1197
+ // Initializing a new instance of spectrum
1198
+ return this.spectrum("destroy").each(function () {
1199
+ var options = $.extend({}, $(this).data(), opts);
1200
+ var spect = spectrum(this, options);
1201
+ $(this).data(dataID, spect.id);
1202
+ });
1203
+ };
1204
+
1205
+ $.fn.spectrum.load = true;
1206
+ $.fn.spectrum.loadOpts = {};
1207
+ $.fn.spectrum.draggable = draggable;
1208
+ $.fn.spectrum.defaults = defaultOpts;
1209
+ $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {
1210
+ if (typeof inputTypeColorSupport._cachedResult === "undefined") {
1211
+ var colorInput = $("<input type='color'/>")[0]; // if color element is supported, value will default to not null
1212
+ inputTypeColorSupport._cachedResult = colorInput.type === "color" && colorInput.value !== "";
1213
+ }
1214
+ return inputTypeColorSupport._cachedResult;
1215
+ };
1216
+
1217
+ $.spectrum = { };
1218
+ $.spectrum.localization = { };
1219
+ $.spectrum.palettes = { };
1220
+
1221
+ $.fn.spectrum.processNativeColorInputs = function () {
1222
+ var colorInputs = $("input[type=color]");
1223
+ if (colorInputs.length && !inputTypeColorSupport()) {
1224
+ colorInputs.spectrum({
1225
+ preferredFormat: "hex6"
1226
+ });
1227
+ }
1228
+ };
1229
+
1230
+ // TinyColor v1.1.2
1231
+ // https://github.com/bgrins/TinyColor
1232
+ // Brian Grinstead, MIT License
1233
+
1234
+ (function() {
1235
+
1236
+ var trimLeft = /^[\s,#]+/,
1237
+ trimRight = /\s+$/,
1238
+ tinyCounter = 0,
1239
+ math = Math,
1240
+ mathRound = math.round,
1241
+ mathMin = math.min,
1242
+ mathMax = math.max,
1243
+ mathRandom = math.random;
1244
+
1245
+ var tinycolor = function(color, opts) {
1246
+
1247
+ color = (color) ? color : '';
1248
+ opts = opts || { };
1249
+
1250
+ // If input is already a tinycolor, return itself
1251
+ if (color instanceof tinycolor) {
1252
+ return color;
1253
+ }
1254
+ // If we are called as a function, call using new instead
1255
+ if (!(this instanceof tinycolor)) {
1256
+ return new tinycolor(color, opts);
1257
+ }
1258
+
1259
+ var rgb = inputToRGB(color);
1260
+ this._originalInput = color;
1261
+ this._r = rgb.r;
1262
+ this._g = rgb.g;
1263
+ this._b = rgb.b;
1264
+ this._a = rgb.a;
1265
+ this._roundA = mathRound(1000 * this._a) / 1000;
1266
+ this._format = opts.format || rgb.format;
1267
+ this._gradientType = opts.gradientType;
1268
+
1269
+ // Don't let the range of [0,255] come back in [0,1].
1270
+ // Potentially lose a little bit of precision here, but will fix issues where
1271
+ // .5 gets interpreted as half of the total, instead of half of 1
1272
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
1273
+ if (this._r < 1) { this._r = mathRound(this._r); }
1274
+ if (this._g < 1) { this._g = mathRound(this._g); }
1275
+ if (this._b < 1) { this._b = mathRound(this._b); }
1276
+
1277
+ this._ok = rgb.ok;
1278
+ this._tc_id = tinyCounter++;
1279
+ };
1280
+
1281
+ tinycolor.prototype = {
1282
+ isDark: function() {
1283
+ return this.getBrightness() < 128;
1284
+ },
1285
+ isLight: function() {
1286
+ return !this.isDark();
1287
+ },
1288
+ isValid: function() {
1289
+ return this._ok;
1290
+ },
1291
+ getOriginalInput: function() {
1292
+ return this._originalInput;
1293
+ },
1294
+ getFormat: function() {
1295
+ return this._format;
1296
+ },
1297
+ getAlpha: function() {
1298
+ return this._a;
1299
+ },
1300
+ getBrightness: function() {
1301
+ var rgb = this.toRgb();
1302
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
1303
+ },
1304
+ setAlpha: function(value) {
1305
+ this._a = boundAlpha(value);
1306
+ this._roundA = mathRound(1000 * this._a) / 1000;
1307
+ return this;
1308
+ },
1309
+ toHsv: function() {
1310
+ var hsv = rgbToHsv(this._r, this._g, this._b);
1311
+ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
1312
+ },
1313
+ toHsvString: function() {
1314
+ var hsv = rgbToHsv(this._r, this._g, this._b);
1315
+ var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
1316
+ return (this._a == 1) ?
1317
+ "hsv(" + h + ", " + s + "%, " + v + "%)" :
1318
+ "hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
1319
+ },
1320
+ toHsl: function() {
1321
+ var hsl = rgbToHsl(this._r, this._g, this._b);
1322
+ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
1323
+ },
1324
+ toHslString: function() {
1325
+ var hsl = rgbToHsl(this._r, this._g, this._b);
1326
+ var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
1327
+ return (this._a == 1) ?
1328
+ "hsl(" + h + ", " + s + "%, " + l + "%)" :
1329
+ "hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
1330
+ },
1331
+ toHex: function(allow3Char) {
1332
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
1333
+ },
1334
+ toHexString: function(allow3Char) {
1335
+ return '#' + this.toHex(allow3Char);
1336
+ },
1337
+ toHex8: function() {
1338
+ return rgbaToHex(this._r, this._g, this._b, this._a);
1339
+ },
1340
+ toHex8String: function() {
1341
+ return '#' + this.toHex8();
1342
+ },
1343
+ toRgb: function() {
1344
+ return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
1345
+ },
1346
+ toRgbString: function() {
1347
+ return (this._a == 1) ?
1348
+ "rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
1349
+ "rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
1350
+ },
1351
+ toPercentageRgb: function() {
1352
+ return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
1353
+ },
1354
+ toPercentageRgbString: function() {
1355
+ return (this._a == 1) ?
1356
+ "rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
1357
+ "rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
1358
+ },
1359
+ toName: function() {
1360
+ if (this._a === 0) {
1361
+ return "transparent";
1362
+ }
1363
+
1364
+ if (this._a < 1) {
1365
+ return false;
1366
+ }
1367
+
1368
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
1369
+ },
1370
+ toFilter: function(secondColor) {
1371
+ var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a);
1372
+ var secondHex8String = hex8String;
1373
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
1374
+
1375
+ if (secondColor) {
1376
+ var s = tinycolor(secondColor);
1377
+ secondHex8String = s.toHex8String();
1378
+ }
1379
+
1380
+ return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
1381
+ },
1382
+ toString: function(format) {
1383
+ var formatSet = !!format;
1384
+ format = format || this._format;
1385
+
1386
+ var formattedString = false;
1387
+ var hasAlpha = this._a < 1 && this._a >= 0;
1388
+ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
1389
+
1390
+ if (needsAlphaFormat) {
1391
+ // Special case for "transparent", all other non-alpha formats
1392
+ // will return rgba when there is transparency.
1393
+ if (format === "name" && this._a === 0) {
1394
+ return this.toName();
1395
+ }
1396
+ return this.toRgbString();
1397
+ }
1398
+ if (format === "rgb") {
1399
+ formattedString = this.toRgbString();
1400
+ }
1401
+ if (format === "prgb") {
1402
+ formattedString = this.toPercentageRgbString();
1403
+ }
1404
+ if (format === "hex" || format === "hex6") {
1405
+ formattedString = this.toHexString();
1406
+ }
1407
+ if (format === "hex3") {
1408
+ formattedString = this.toHexString(true);
1409
+ }
1410
+ if (format === "hex8") {
1411
+ formattedString = this.toHex8String();
1412
+ }
1413
+ if (format === "name") {
1414
+ formattedString = this.toName();
1415
+ }
1416
+ if (format === "hsl") {
1417
+ formattedString = this.toHslString();
1418
+ }
1419
+ if (format === "hsv") {
1420
+ formattedString = this.toHsvString();
1421
+ }
1422
+
1423
+ return formattedString || this.toHexString();
1424
+ },
1425
+
1426
+ _applyModification: function(fn, args) {
1427
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
1428
+ this._r = color._r;
1429
+ this._g = color._g;
1430
+ this._b = color._b;
1431
+ this.setAlpha(color._a);
1432
+ return this;
1433
+ },
1434
+ lighten: function() {
1435
+ return this._applyModification(lighten, arguments);
1436
+ },
1437
+ brighten: function() {
1438
+ return this._applyModification(brighten, arguments);
1439
+ },
1440
+ darken: function() {
1441
+ return this._applyModification(darken, arguments);
1442
+ },
1443
+ desaturate: function() {
1444
+ return this._applyModification(desaturate, arguments);
1445
+ },
1446
+ saturate: function() {
1447
+ return this._applyModification(saturate, arguments);
1448
+ },
1449
+ greyscale: function() {
1450
+ return this._applyModification(greyscale, arguments);
1451
+ },
1452
+ spin: function() {
1453
+ return this._applyModification(spin, arguments);
1454
+ },
1455
+
1456
+ _applyCombination: function(fn, args) {
1457
+ return fn.apply(null, [this].concat([].slice.call(args)));
1458
+ },
1459
+ analogous: function() {
1460
+ return this._applyCombination(analogous, arguments);
1461
+ },
1462
+ complement: function() {
1463
+ return this._applyCombination(complement, arguments);
1464
+ },
1465
+ monochromatic: function() {
1466
+ return this._applyCombination(monochromatic, arguments);
1467
+ },
1468
+ splitcomplement: function() {
1469
+ return this._applyCombination(splitcomplement, arguments);
1470
+ },
1471
+ triad: function() {
1472
+ return this._applyCombination(triad, arguments);
1473
+ },
1474
+ tetrad: function() {
1475
+ return this._applyCombination(tetrad, arguments);
1476
+ }
1477
+ };
1478
+
1479
+ // If input is an object, force 1 into "1.0" to handle ratios properly
1480
+ // String input requires "1.0" as input, so 1 will be treated as 1
1481
+ tinycolor.fromRatio = function(color, opts) {
1482
+ if (typeof color == "object") {
1483
+ var newColor = {};
1484
+ for (var i in color) {
1485
+ if (color.hasOwnProperty(i)) {
1486
+ if (i === "a") {
1487
+ newColor[i] = color[i];
1488
+ }
1489
+ else {
1490
+ newColor[i] = convertToPercentage(color[i]);
1491
+ }
1492
+ }
1493
+ }
1494
+ color = newColor;
1495
+ }
1496
+
1497
+ return tinycolor(color, opts);
1498
+ };
1499
+
1500
+ // Given a string or object, convert that input to RGB
1501
+ // Possible string inputs:
1502
+ //
1503
+ // "red"
1504
+ // "#f00" or "f00"
1505
+ // "#ff0000" or "ff0000"
1506
+ // "#ff000000" or "ff000000"
1507
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
1508
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
1509
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
1510
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
1511
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
1512
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
1513
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
1514
+ //
1515
+ function inputToRGB(color) {
1516
+
1517
+ var rgb = { r: 0, g: 0, b: 0 };
1518
+ var a = 1;
1519
+ var ok = false;
1520
+ var format = false;
1521
+
1522
+ if (typeof color == "string") {
1523
+ color = stringInputToObject(color);
1524
+ }
1525
+
1526
+ if (typeof color == "object") {
1527
+ if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
1528
+ rgb = rgbToRgb(color.r, color.g, color.b);
1529
+ ok = true;
1530
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
1531
+ }
1532
+ else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
1533
+ color.s = convertToPercentage(color.s);
1534
+ color.v = convertToPercentage(color.v);
1535
+ rgb = hsvToRgb(color.h, color.s, color.v);
1536
+ ok = true;
1537
+ format = "hsv";
1538
+ }
1539
+ else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
1540
+ color.s = convertToPercentage(color.s);
1541
+ color.l = convertToPercentage(color.l);
1542
+ rgb = hslToRgb(color.h, color.s, color.l);
1543
+ ok = true;
1544
+ format = "hsl";
1545
+ }
1546
+
1547
+ if (color.hasOwnProperty("a")) {
1548
+ a = color.a;
1549
+ }
1550
+ }
1551
+
1552
+ a = boundAlpha(a);
1553
+
1554
+ return {
1555
+ ok: ok,
1556
+ format: color.format || format,
1557
+ r: mathMin(255, mathMax(rgb.r, 0)),
1558
+ g: mathMin(255, mathMax(rgb.g, 0)),
1559
+ b: mathMin(255, mathMax(rgb.b, 0)),
1560
+ a: a
1561
+ };
1562
+ }
1563
+
1564
+
1565
+ // Conversion Functions
1566
+ // --------------------
1567
+
1568
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
1569
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
1570
+
1571
+ // `rgbToRgb`
1572
+ // Handle bounds / percentage checking to conform to CSS color spec
1573
+ // <http://www.w3.org/TR/css3-color/>
1574
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
1575
+ // *Returns:* { r, g, b } in [0, 255]
1576
+ function rgbToRgb(r, g, b){
1577
+ return {
1578
+ r: bound01(r, 255) * 255,
1579
+ g: bound01(g, 255) * 255,
1580
+ b: bound01(b, 255) * 255
1581
+ };
1582
+ }
1583
+
1584
+ // `rgbToHsl`
1585
+ // Converts an RGB color value to HSL.
1586
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
1587
+ // *Returns:* { h, s, l } in [0,1]
1588
+ function rgbToHsl(r, g, b) {
1589
+
1590
+ r = bound01(r, 255);
1591
+ g = bound01(g, 255);
1592
+ b = bound01(b, 255);
1593
+
1594
+ var max = mathMax(r, g, b), min = mathMin(r, g, b);
1595
+ var h, s, l = (max + min) / 2;
1596
+
1597
+ if(max == min) {
1598
+ h = s = 0; // achromatic
1599
+ }
1600
+ else {
1601
+ var d = max - min;
1602
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
1603
+ switch(max) {
1604
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
1605
+ case g: h = (b - r) / d + 2; break;
1606
+ case b: h = (r - g) / d + 4; break;
1607
+ }
1608
+
1609
+ h /= 6;
1610
+ }
1611
+
1612
+ return { h: h, s: s, l: l };
1613
+ }
1614
+
1615
+ // `hslToRgb`
1616
+ // Converts an HSL color value to RGB.
1617
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
1618
+ // *Returns:* { r, g, b } in the set [0, 255]
1619
+ function hslToRgb(h, s, l) {
1620
+ var r, g, b;
1621
+
1622
+ h = bound01(h, 360);
1623
+ s = bound01(s, 100);
1624
+ l = bound01(l, 100);
1625
+
1626
+ function hue2rgb(p, q, t) {
1627
+ if(t < 0) t += 1;
1628
+ if(t > 1) t -= 1;
1629
+ if(t < 1/6) return p + (q - p) * 6 * t;
1630
+ if(t < 1/2) return q;
1631
+ if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
1632
+ return p;
1633
+ }
1634
+
1635
+ if(s === 0) {
1636
+ r = g = b = l; // achromatic
1637
+ }
1638
+ else {
1639
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
1640
+ var p = 2 * l - q;
1641
+ r = hue2rgb(p, q, h + 1/3);
1642
+ g = hue2rgb(p, q, h);
1643
+ b = hue2rgb(p, q, h - 1/3);
1644
+ }
1645
+
1646
+ return { r: r * 255, g: g * 255, b: b * 255 };
1647
+ }
1648
+
1649
+ // `rgbToHsv`
1650
+ // Converts an RGB color value to HSV
1651
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
1652
+ // *Returns:* { h, s, v } in [0,1]
1653
+ function rgbToHsv(r, g, b) {
1654
+
1655
+ r = bound01(r, 255);
1656
+ g = bound01(g, 255);
1657
+ b = bound01(b, 255);
1658
+
1659
+ var max = mathMax(r, g, b), min = mathMin(r, g, b);
1660
+ var h, s, v = max;
1661
+
1662
+ var d = max - min;
1663
+ s = max === 0 ? 0 : d / max;
1664
+
1665
+ if(max == min) {
1666
+ h = 0; // achromatic
1667
+ }
1668
+ else {
1669
+ switch(max) {
1670
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
1671
+ case g: h = (b - r) / d + 2; break;
1672
+ case b: h = (r - g) / d + 4; break;
1673
+ }
1674
+ h /= 6;
1675
+ }
1676
+ return { h: h, s: s, v: v };
1677
+ }
1678
+
1679
+ // `hsvToRgb`
1680
+ // Converts an HSV color value to RGB.
1681
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
1682
+ // *Returns:* { r, g, b } in the set [0, 255]
1683
+ function hsvToRgb(h, s, v) {
1684
+
1685
+ h = bound01(h, 360) * 6;
1686
+ s = bound01(s, 100);
1687
+ v = bound01(v, 100);
1688
+
1689
+ var i = math.floor(h),
1690
+ f = h - i,
1691
+ p = v * (1 - s),
1692
+ q = v * (1 - f * s),
1693
+ t = v * (1 - (1 - f) * s),
1694
+ mod = i % 6,
1695
+ r = [v, q, p, p, t, v][mod],
1696
+ g = [t, v, v, q, p, p][mod],
1697
+ b = [p, p, t, v, v, q][mod];
1698
+
1699
+ return { r: r * 255, g: g * 255, b: b * 255 };
1700
+ }
1701
+
1702
+ // `rgbToHex`
1703
+ // Converts an RGB color to hex
1704
+ // Assumes r, g, and b are contained in the set [0, 255]
1705
+ // Returns a 3 or 6 character hex
1706
+ function rgbToHex(r, g, b, allow3Char) {
1707
+
1708
+ var hex = [
1709
+ pad2(mathRound(r).toString(16)),
1710
+ pad2(mathRound(g).toString(16)),
1711
+ pad2(mathRound(b).toString(16))
1712
+ ];
1713
+
1714
+ // Return a 3 character hex if possible
1715
+ if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
1716
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
1717
+ }
1718
+
1719
+ return hex.join("");
1720
+ }
1721
+ // `rgbaToHex`
1722
+ // Converts an RGBA color plus alpha transparency to hex
1723
+ // Assumes r, g, b and a are contained in the set [0, 255]
1724
+ // Returns an 8 character hex
1725
+ function rgbaToHex(r, g, b, a) {
1726
+
1727
+ var hex = [
1728
+ pad2(convertDecimalToHex(a)),
1729
+ pad2(mathRound(r).toString(16)),
1730
+ pad2(mathRound(g).toString(16)),
1731
+ pad2(mathRound(b).toString(16))
1732
+ ];
1733
+
1734
+ return hex.join("");
1735
+ }
1736
+
1737
+ // `equals`
1738
+ // Can be called with any tinycolor input
1739
+ tinycolor.equals = function (color1, color2) {
1740
+ if (!color1 || !color2) { return false; }
1741
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
1742
+ };
1743
+ tinycolor.random = function() {
1744
+ return tinycolor.fromRatio({
1745
+ r: mathRandom(),
1746
+ g: mathRandom(),
1747
+ b: mathRandom()
1748
+ });
1749
+ };
1750
+
1751
+
1752
+ // Modification Functions
1753
+ // ----------------------
1754
+ // Thanks to less.js for some of the basics here
1755
+ // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
1756
+
1757
+ function desaturate(color, amount) {
1758
+ amount = (amount === 0) ? 0 : (amount || 10);
1759
+ var hsl = tinycolor(color).toHsl();
1760
+ hsl.s -= amount / 100;
1761
+ hsl.s = clamp01(hsl.s);
1762
+ return tinycolor(hsl);
1763
+ }
1764
+
1765
+ function saturate(color, amount) {
1766
+ amount = (amount === 0) ? 0 : (amount || 10);
1767
+ var hsl = tinycolor(color).toHsl();
1768
+ hsl.s += amount / 100;
1769
+ hsl.s = clamp01(hsl.s);
1770
+ return tinycolor(hsl);
1771
+ }
1772
+
1773
+ function greyscale(color) {
1774
+ return tinycolor(color).desaturate(100);
1775
+ }
1776
+
1777
+ function lighten (color, amount) {
1778
+ amount = (amount === 0) ? 0 : (amount || 10);
1779
+ var hsl = tinycolor(color).toHsl();
1780
+ hsl.l += amount / 100;
1781
+ hsl.l = clamp01(hsl.l);
1782
+ return tinycolor(hsl);
1783
+ }
1784
+
1785
+ function brighten(color, amount) {
1786
+ amount = (amount === 0) ? 0 : (amount || 10);
1787
+ var rgb = tinycolor(color).toRgb();
1788
+ rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
1789
+ rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
1790
+ rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
1791
+ return tinycolor(rgb);
1792
+ }
1793
+
1794
+ function darken (color, amount) {
1795
+ amount = (amount === 0) ? 0 : (amount || 10);
1796
+ var hsl = tinycolor(color).toHsl();
1797
+ hsl.l -= amount / 100;
1798
+ hsl.l = clamp01(hsl.l);
1799
+ return tinycolor(hsl);
1800
+ }
1801
+
1802
+ // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
1803
+ // Values outside of this range will be wrapped into this range.
1804
+ function spin(color, amount) {
1805
+ var hsl = tinycolor(color).toHsl();
1806
+ var hue = (mathRound(hsl.h) + amount) % 360;
1807
+ hsl.h = hue < 0 ? 360 + hue : hue;
1808
+ return tinycolor(hsl);
1809
+ }
1810
+
1811
+ // Combination Functions
1812
+ // ---------------------
1813
+ // Thanks to jQuery xColor for some of the ideas behind these
1814
+ // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
1815
+
1816
+ function complement(color) {
1817
+ var hsl = tinycolor(color).toHsl();
1818
+ hsl.h = (hsl.h + 180) % 360;
1819
+ return tinycolor(hsl);
1820
+ }
1821
+
1822
+ function triad(color) {
1823
+ var hsl = tinycolor(color).toHsl();
1824
+ var h = hsl.h;
1825
+ return [
1826
+ tinycolor(color),
1827
+ tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
1828
+ tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
1829
+ ];
1830
+ }
1831
+
1832
+ function tetrad(color) {
1833
+ var hsl = tinycolor(color).toHsl();
1834
+ var h = hsl.h;
1835
+ return [
1836
+ tinycolor(color),
1837
+ tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
1838
+ tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
1839
+ tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
1840
+ ];
1841
+ }
1842
+
1843
+ function splitcomplement(color) {
1844
+ var hsl = tinycolor(color).toHsl();
1845
+ var h = hsl.h;
1846
+ return [
1847
+ tinycolor(color),
1848
+ tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
1849
+ tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
1850
+ ];
1851
+ }
1852
+
1853
+ function analogous(color, results, slices) {
1854
+ results = results || 6;
1855
+ slices = slices || 30;
1856
+
1857
+ var hsl = tinycolor(color).toHsl();
1858
+ var part = 360 / slices;
1859
+ var ret = [tinycolor(color)];
1860
+
1861
+ for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
1862
+ hsl.h = (hsl.h + part) % 360;
1863
+ ret.push(tinycolor(hsl));
1864
+ }
1865
+ return ret;
1866
+ }
1867
+
1868
+ function monochromatic(color, results) {
1869
+ results = results || 6;
1870
+ var hsv = tinycolor(color).toHsv();
1871
+ var h = hsv.h, s = hsv.s, v = hsv.v;
1872
+ var ret = [];
1873
+ var modification = 1 / results;
1874
+
1875
+ while (results--) {
1876
+ ret.push(tinycolor({ h: h, s: s, v: v}));
1877
+ v = (v + modification) % 1;
1878
+ }
1879
+
1880
+ return ret;
1881
+ }
1882
+
1883
+ // Utility Functions
1884
+ // ---------------------
1885
+
1886
+ tinycolor.mix = function(color1, color2, amount) {
1887
+ amount = (amount === 0) ? 0 : (amount || 50);
1888
+
1889
+ var rgb1 = tinycolor(color1).toRgb();
1890
+ var rgb2 = tinycolor(color2).toRgb();
1891
+
1892
+ var p = amount / 100;
1893
+ var w = p * 2 - 1;
1894
+ var a = rgb2.a - rgb1.a;
1895
+
1896
+ var w1;
1897
+
1898
+ if (w * a == -1) {
1899
+ w1 = w;
1900
+ } else {
1901
+ w1 = (w + a) / (1 + w * a);
1902
+ }
1903
+
1904
+ w1 = (w1 + 1) / 2;
1905
+
1906
+ var w2 = 1 - w1;
1907
+
1908
+ var rgba = {
1909
+ r: rgb2.r * w1 + rgb1.r * w2,
1910
+ g: rgb2.g * w1 + rgb1.g * w2,
1911
+ b: rgb2.b * w1 + rgb1.b * w2,
1912
+ a: rgb2.a * p + rgb1.a * (1 - p)
1913
+ };
1914
+
1915
+ return tinycolor(rgba);
1916
+ };
1917
+
1918
+
1919
+ // Readability Functions
1920
+ // ---------------------
1921
+ // <http://www.w3.org/TR/AERT#color-contrast>
1922
+
1923
+ // `readability`
1924
+ // Analyze the 2 colors and returns an object with the following properties:
1925
+ // `brightness`: difference in brightness between the two colors
1926
+ // `color`: difference in color/hue between the two colors
1927
+ tinycolor.readability = function(color1, color2) {
1928
+ var c1 = tinycolor(color1);
1929
+ var c2 = tinycolor(color2);
1930
+ var rgb1 = c1.toRgb();
1931
+ var rgb2 = c2.toRgb();
1932
+ var brightnessA = c1.getBrightness();
1933
+ var brightnessB = c2.getBrightness();
1934
+ var colorDiff = (
1935
+ Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +
1936
+ Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +
1937
+ Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)
1938
+ );
1939
+
1940
+ return {
1941
+ brightness: Math.abs(brightnessA - brightnessB),
1942
+ color: colorDiff
1943
+ };
1944
+ };
1945
+
1946
+ // `readable`
1947
+ // http://www.w3.org/TR/AERT#color-contrast
1948
+ // Ensure that foreground and background color combinations provide sufficient contrast.
1949
+ // *Example*
1950
+ // tinycolor.isReadable("#000", "#111") => false
1951
+ tinycolor.isReadable = function(color1, color2) {
1952
+ var readability = tinycolor.readability(color1, color2);
1953
+ return readability.brightness > 125 && readability.color > 500;
1954
+ };
1955
+
1956
+ // `mostReadable`
1957
+ // Given a base color and a list of possible foreground or background
1958
+ // colors for that base, returns the most readable color.
1959
+ // *Example*
1960
+ // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
1961
+ tinycolor.mostReadable = function(baseColor, colorList) {
1962
+ var bestColor = null;
1963
+ var bestScore = 0;
1964
+ var bestIsReadable = false;
1965
+ for (var i=0; i < colorList.length; i++) {
1966
+
1967
+ // We normalize both around the "acceptable" breaking point,
1968
+ // but rank brightness constrast higher than hue.
1969
+
1970
+ var readability = tinycolor.readability(baseColor, colorList[i]);
1971
+ var readable = readability.brightness > 125 && readability.color > 500;
1972
+ var score = 3 * (readability.brightness / 125) + (readability.color / 500);
1973
+
1974
+ if ((readable && ! bestIsReadable) ||
1975
+ (readable && bestIsReadable && score > bestScore) ||
1976
+ ((! readable) && (! bestIsReadable) && score > bestScore)) {
1977
+ bestIsReadable = readable;
1978
+ bestScore = score;
1979
+ bestColor = tinycolor(colorList[i]);
1980
+ }
1981
+ }
1982
+ return bestColor;
1983
+ };
1984
+
1985
+
1986
+ // Big List of Colors
1987
+ // ------------------
1988
+ // <http://www.w3.org/TR/css3-color/#svg-color>
1989
+ var names = tinycolor.names = {
1990
+ aliceblue: "f0f8ff",
1991
+ antiquewhite: "faebd7",
1992
+ aqua: "0ff",
1993
+ aquamarine: "7fffd4",
1994
+ azure: "f0ffff",
1995
+ beige: "f5f5dc",
1996
+ bisque: "ffe4c4",
1997
+ black: "000",
1998
+ blanchedalmond: "ffebcd",
1999
+ blue: "00f",
2000
+ blueviolet: "8a2be2",
2001
+ brown: "a52a2a",
2002
+ burlywood: "deb887",
2003
+ burntsienna: "ea7e5d",
2004
+ cadetblue: "5f9ea0",
2005
+ chartreuse: "7fff00",
2006
+ chocolate: "d2691e",
2007
+ coral: "ff7f50",
2008
+ cornflowerblue: "6495ed",
2009
+ cornsilk: "fff8dc",
2010
+ crimson: "dc143c",
2011
+ cyan: "0ff",
2012
+ darkblue: "00008b",
2013
+ darkcyan: "008b8b",
2014
+ darkgoldenrod: "b8860b",
2015
+ darkgray: "a9a9a9",
2016
+ darkgreen: "006400",
2017
+ darkgrey: "a9a9a9",
2018
+ darkkhaki: "bdb76b",
2019
+ darkmagenta: "8b008b",
2020
+ darkolivegreen: "556b2f",
2021
+ darkorange: "ff8c00",
2022
+ darkorchid: "9932cc",
2023
+ darkred: "8b0000",
2024
+ darksalmon: "e9967a",
2025
+ darkseagreen: "8fbc8f",
2026
+ darkslateblue: "483d8b",
2027
+ darkslategray: "2f4f4f",
2028
+ darkslategrey: "2f4f4f",
2029
+ darkturquoise: "00ced1",
2030
+ darkviolet: "9400d3",
2031
+ deeppink: "ff1493",
2032
+ deepskyblue: "00bfff",
2033
+ dimgray: "696969",
2034
+ dimgrey: "696969",
2035
+ dodgerblue: "1e90ff",
2036
+ firebrick: "b22222",
2037
+ floralwhite: "fffaf0",
2038
+ forestgreen: "228b22",
2039
+ fuchsia: "f0f",
2040
+ gainsboro: "dcdcdc",
2041
+ ghostwhite: "f8f8ff",
2042
+ gold: "ffd700",
2043
+ goldenrod: "daa520",
2044
+ gray: "808080",
2045
+ green: "008000",
2046
+ greenyellow: "adff2f",
2047
+ grey: "808080",
2048
+ honeydew: "f0fff0",
2049
+ hotpink: "ff69b4",
2050
+ indianred: "cd5c5c",
2051
+ indigo: "4b0082",
2052
+ ivory: "fffff0",
2053
+ khaki: "f0e68c",
2054
+ lavender: "e6e6fa",
2055
+ lavenderblush: "fff0f5",
2056
+ lawngreen: "7cfc00",
2057
+ lemonchiffon: "fffacd",
2058
+ lightblue: "add8e6",
2059
+ lightcoral: "f08080",
2060
+ lightcyan: "e0ffff",
2061
+ lightgoldenrodyellow: "fafad2",
2062
+ lightgray: "d3d3d3",
2063
+ lightgreen: "90ee90",
2064
+ lightgrey: "d3d3d3",
2065
+ lightpink: "ffb6c1",
2066
+ lightsalmon: "ffa07a",
2067
+ lightseagreen: "20b2aa",
2068
+ lightskyblue: "87cefa",
2069
+ lightslategray: "789",
2070
+ lightslategrey: "789",
2071
+ lightsteelblue: "b0c4de",
2072
+ lightyellow: "ffffe0",
2073
+ lime: "0f0",
2074
+ limegreen: "32cd32",
2075
+ linen: "faf0e6",
2076
+ magenta: "f0f",
2077
+ maroon: "800000",
2078
+ mediumaquamarine: "66cdaa",
2079
+ mediumblue: "0000cd",
2080
+ mediumorchid: "ba55d3",
2081
+ mediumpurple: "9370db",
2082
+ mediumseagreen: "3cb371",
2083
+ mediumslateblue: "7b68ee",
2084
+ mediumspringgreen: "00fa9a",
2085
+ mediumturquoise: "48d1cc",
2086
+ mediumvioletred: "c71585",
2087
+ midnightblue: "191970",
2088
+ mintcream: "f5fffa",
2089
+ mistyrose: "ffe4e1",
2090
+ moccasin: "ffe4b5",
2091
+ navajowhite: "ffdead",
2092
+ navy: "000080",
2093
+ oldlace: "fdf5e6",
2094
+ olive: "808000",
2095
+ olivedrab: "6b8e23",
2096
+ orange: "ffa500",
2097
+ orangered: "ff4500",
2098
+ orchid: "da70d6",
2099
+ palegoldenrod: "eee8aa",
2100
+ palegreen: "98fb98",
2101
+ paleturquoise: "afeeee",
2102
+ palevioletred: "db7093",
2103
+ papayawhip: "ffefd5",
2104
+ peachpuff: "ffdab9",
2105
+ peru: "cd853f",
2106
+ pink: "ffc0cb",
2107
+ plum: "dda0dd",
2108
+ powderblue: "b0e0e6",
2109
+ purple: "800080",
2110
+ rebeccapurple: "663399",
2111
+ red: "f00",
2112
+ rosybrown: "bc8f8f",
2113
+ royalblue: "4169e1",
2114
+ saddlebrown: "8b4513",
2115
+ salmon: "fa8072",
2116
+ sandybrown: "f4a460",
2117
+ seagreen: "2e8b57",
2118
+ seashell: "fff5ee",
2119
+ sienna: "a0522d",
2120
+ silver: "c0c0c0",
2121
+ skyblue: "87ceeb",
2122
+ slateblue: "6a5acd",
2123
+ slategray: "708090",
2124
+ slategrey: "708090",
2125
+ snow: "fffafa",
2126
+ springgreen: "00ff7f",
2127
+ steelblue: "4682b4",
2128
+ tan: "d2b48c",
2129
+ teal: "008080",
2130
+ thistle: "d8bfd8",
2131
+ tomato: "ff6347",
2132
+ turquoise: "40e0d0",
2133
+ violet: "ee82ee",
2134
+ wheat: "f5deb3",
2135
+ white: "fff",
2136
+ whitesmoke: "f5f5f5",
2137
+ yellow: "ff0",
2138
+ yellowgreen: "9acd32"
2139
+ };
2140
+
2141
+ // Make it easy to access colors via `hexNames[hex]`
2142
+ var hexNames = tinycolor.hexNames = flip(names);
2143
+
2144
+
2145
+ // Utilities
2146
+ // ---------
2147
+
2148
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
2149
+ function flip(o) {
2150
+ var flipped = { };
2151
+ for (var i in o) {
2152
+ if (o.hasOwnProperty(i)) {
2153
+ flipped[o[i]] = i;
2154
+ }
2155
+ }
2156
+ return flipped;
2157
+ }
2158
+
2159
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
2160
+ function boundAlpha(a) {
2161
+ a = parseFloat(a);
2162
+
2163
+ if (isNaN(a) || a < 0 || a > 1) {
2164
+ a = 1;
2165
+ }
2166
+
2167
+ return a;
2168
+ }
2169
+
2170
+ // Take input from [0, n] and return it as [0, 1]
2171
+ function bound01(n, max) {
2172
+ if (isOnePointZero(n)) { n = "100%"; }
2173
+
2174
+ var processPercent = isPercentage(n);
2175
+ n = mathMin(max, mathMax(0, parseFloat(n)));
2176
+
2177
+ // Automatically convert percentage into number
2178
+ if (processPercent) {
2179
+ n = parseInt(n * max, 10) / 100;
2180
+ }
2181
+
2182
+ // Handle floating point rounding errors
2183
+ if ((math.abs(n - max) < 0.000001)) {
2184
+ return 1;
2185
+ }
2186
+
2187
+ // Convert into [0, 1] range if it isn't already
2188
+ return (n % max) / parseFloat(max);
2189
+ }
2190
+
2191
+ // Force a number between 0 and 1
2192
+ function clamp01(val) {
2193
+ return mathMin(1, mathMax(0, val));
2194
+ }
2195
+
2196
+ // Parse a base-16 hex value into a base-10 integer
2197
+ function parseIntFromHex(val) {
2198
+ return parseInt(val, 16);
2199
+ }
2200
+
2201
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
2202
+ // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
2203
+ function isOnePointZero(n) {
2204
+ return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
2205
+ }
2206
+
2207
+ // Check to see if string passed in is a percentage
2208
+ function isPercentage(n) {
2209
+ return typeof n === "string" && n.indexOf('%') != -1;
2210
+ }
2211
+
2212
+ // Force a hex value to have 2 characters
2213
+ function pad2(c) {
2214
+ return c.length == 1 ? '0' + c : '' + c;
2215
+ }
2216
+
2217
+ // Replace a decimal with it's percentage value
2218
+ function convertToPercentage(n) {
2219
+ if (n <= 1) {
2220
+ n = (n * 100) + "%";
2221
+ }
2222
+
2223
+ return n;
2224
+ }
2225
+
2226
+ // Converts a decimal to a hex value
2227
+ function convertDecimalToHex(d) {
2228
+ return Math.round(parseFloat(d) * 255).toString(16);
2229
+ }
2230
+ // Converts a hex value to a decimal
2231
+ function convertHexToDecimal(h) {
2232
+ return (parseIntFromHex(h) / 255);
2233
+ }
2234
+
2235
+ var matchers = (function() {
2236
+
2237
+ // <http://www.w3.org/TR/css3-values/#integers>
2238
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
2239
+
2240
+ // <http://www.w3.org/TR/css3-values/#number-value>
2241
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
2242
+
2243
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
2244
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
2245
+
2246
+ // Actual matching.
2247
+ // Parentheses and commas are optional, but not required.
2248
+ // Whitespace can take the place of commas or opening paren
2249
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
2250
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
2251
+
2252
+ return {
2253
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
2254
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
2255
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
2256
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
2257
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
2258
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
2259
+ hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
2260
+ hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
2261
+ hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
2262
+ };
2263
+ })();
2264
+
2265
+ // `stringInputToObject`
2266
+ // Permissive string parsing. Take in a number of formats, and output an object
2267
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
2268
+ function stringInputToObject(color) {
2269
+
2270
+ color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
2271
+ var named = false;
2272
+ if (names[color]) {
2273
+ color = names[color];
2274
+ named = true;
2275
+ }
2276
+ else if (color == 'transparent') {
2277
+ return { r: 0, g: 0, b: 0, a: 0, format: "name" };
2278
+ }
2279
+
2280
+ // Try to match string input using regular expressions.
2281
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
2282
+ // Just return an object and let the conversion functions handle that.
2283
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
2284
+ var match;
2285
+ if ((match = matchers.rgb.exec(color))) {
2286
+ return { r: match[1], g: match[2], b: match[3] };
2287
+ }
2288
+ if ((match = matchers.rgba.exec(color))) {
2289
+ return { r: match[1], g: match[2], b: match[3], a: match[4] };
2290
+ }
2291
+ if ((match = matchers.hsl.exec(color))) {
2292
+ return { h: match[1], s: match[2], l: match[3] };
2293
+ }
2294
+ if ((match = matchers.hsla.exec(color))) {
2295
+ return { h: match[1], s: match[2], l: match[3], a: match[4] };
2296
+ }
2297
+ if ((match = matchers.hsv.exec(color))) {
2298
+ return { h: match[1], s: match[2], v: match[3] };
2299
+ }
2300
+ if ((match = matchers.hsva.exec(color))) {
2301
+ return { h: match[1], s: match[2], v: match[3], a: match[4] };
2302
+ }
2303
+ if ((match = matchers.hex8.exec(color))) {
2304
+ return {
2305
+ a: convertHexToDecimal(match[1]),
2306
+ r: parseIntFromHex(match[2]),
2307
+ g: parseIntFromHex(match[3]),
2308
+ b: parseIntFromHex(match[4]),
2309
+ format: named ? "name" : "hex8"
2310
+ };
2311
+ }
2312
+ if ((match = matchers.hex6.exec(color))) {
2313
+ return {
2314
+ r: parseIntFromHex(match[1]),
2315
+ g: parseIntFromHex(match[2]),
2316
+ b: parseIntFromHex(match[3]),
2317
+ format: named ? "name" : "hex"
2318
+ };
2319
+ }
2320
+ if ((match = matchers.hex3.exec(color))) {
2321
+ return {
2322
+ r: parseIntFromHex(match[1] + '' + match[1]),
2323
+ g: parseIntFromHex(match[2] + '' + match[2]),
2324
+ b: parseIntFromHex(match[3] + '' + match[3]),
2325
+ format: named ? "name" : "hex"
2326
+ };
2327
+ }
2328
+
2329
+ return false;
2330
+ }
2331
+
2332
+ window.tinycolor = tinycolor;
2333
+ })();
2334
+
2335
+ $(function () {
2336
+ if ($.fn.spectrum.load) {
2337
+ $.fn.spectrum.processNativeColorInputs();
2338
+ }
2339
+ });
2340
+
2341
+ });
media/js/lib/spectrum.min.js CHANGED
@@ -1,5 +1,5 @@
1
- // Spectrum Colorpicker v1.8.0
2
- // https://github.com/bgrins/spectrum
3
- // Author: Brian Grinstead
4
- // License: MIT
5
- !function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):t(jQuery)}(function(t,e){"use strict";function r(e,r,n,a){for(var i=[],s=0;s<e.length;s++){var o=e[s];if(o){var l=tinycolor(o),c=l.toHsl().l<.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light";c+=tinycolor.equals(r,o)?" sp-thumb-active":"";var f=l.toString(a.preferredFormat||"rgb"),u=b?"background-color:"+l.toRgbString():"filter:"+l.toFilter();i.push('<span title="'+f+'" data-color="'+l.toRgbString()+'" class="'+c+'"><span class="sp-thumb-inner" style="'+u+';" /></span>')}else{var h="sp-clear-display";i.push(t("<div />").append(t('<span data-color="" style="background-color:transparent;" class="'+h+'"></span>').attr("title",a.noColorSelectedText)).html())}}return"<div class='sp-cf "+n+"'>"+i.join("")+"</div>"}function n(){for(var t=0;t<p.length;t++)p[t]&&p[t].hide()}function a(e,r){var n=t.extend({},d,e);return n.callbacks={move:c(n.move,r),change:c(n.change,r),show:c(n.show,r),hide:c(n.hide,r),beforeShow:c(n.beforeShow,r)},n}function i(i,o){function c(){if(W.showPaletteOnly&&(W.showPalette=!0),Dt.text(W.showPaletteOnly?W.togglePaletteMoreText:W.togglePaletteLessText),W.palette){dt=W.palette.slice(0),pt=t.isArray(dt[0])?dt:[dt],gt={};for(var e=0;e<pt.length;e++)for(var r=0;r<pt[e].length;r++){var n=tinycolor(pt[e][r]).toRgbString();gt[n]=!0}}kt.toggleClass("sp-flat",X),kt.toggleClass("sp-input-disabled",!W.showInput),kt.toggleClass("sp-alpha-enabled",W.showAlpha),kt.toggleClass("sp-clear-enabled",Qt),kt.toggleClass("sp-buttons-disabled",!W.showButtons),kt.toggleClass("sp-palette-buttons-disabled",!W.togglePaletteOnly),kt.toggleClass("sp-palette-disabled",!W.showPalette),kt.toggleClass("sp-palette-only",W.showPaletteOnly),kt.toggleClass("sp-initial-disabled",!W.showInitial),kt.addClass(W.className).addClass(W.containerClassName),z()}function d(){function e(e){return e.data&&e.data.ignore?(O(t(e.target).closest(".sp-thumb-el").data("color")),j()):(O(t(e.target).closest(".sp-thumb-el").data("color")),j(),I(!0),W.hideAfterPaletteSelect&&F()),!1}if(g&&kt.find("*:not(input)").attr("unselectable","on"),c(),Bt&&_t.after(Lt).hide(),Qt||jt.hide(),X)_t.after(kt).hide();else{var r="parent"===W.appendTo?_t.parent():t(W.appendTo);1!==r.length&&(r=t("body")),r.append(kt)}y(),Kt.bind("click.spectrum touchstart.spectrum",function(e){xt||A(),e.stopPropagation(),t(e.target).is("input")||e.preventDefault()}),(_t.is(":disabled")||W.disabled===!0)&&V(),kt.click(l),Tt.change(P),Tt.bind("paste",function(){setTimeout(P,1)}),Tt.keydown(function(t){13==t.keyCode&&P()}),Nt.text(W.cancelText),Nt.bind("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),T(),F()}),jt.attr("title",W.clearText),jt.bind("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),Gt=!0,j(),X&&I(!0)}),Et.text(W.chooseText),Et.bind("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),g&&Tt.is(":focus")&&Tt.trigger("change"),N()&&(I(!0),F())}),Dt.text(W.showPaletteOnly?W.togglePaletteMoreText:W.togglePaletteLessText),Dt.bind("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),W.showPaletteOnly=!W.showPaletteOnly,W.showPaletteOnly||X||kt.css("left","-="+(St.outerWidth(!0)+5)),c()}),f(Ht,function(t,e,r){ht=t/st,Gt=!1,r.shiftKey&&(ht=Math.round(10*ht)/10),j()},S,C),f(At,function(t,e){ct=parseFloat(e/at),Gt=!1,W.showAlpha||(ht=1),j()},S,C),f(Ct,function(t,e,r){if(r.shiftKey){if(!yt){var n=ft*et,a=rt-ut*rt,i=Math.abs(t-n)>Math.abs(e-a);yt=i?"x":"y"}}else yt=null;var s=!yt||"x"===yt,o=!yt||"y"===yt;s&&(ft=parseFloat(t/et)),o&&(ut=parseFloat((rt-e)/rt)),Gt=!1,W.showAlpha||(ht=1),j()},S,C),$t?(O($t),E(),Xt=W.preferredFormat||tinycolor($t).format,w($t)):E(),X&&M();var n=g?"mousedown.spectrum":"click.spectrum touchstart.spectrum";Ot.delegate(".sp-thumb-el",n,e),qt.delegate(".sp-thumb-el:nth-child(1)",n,{ignore:!0},e)}function y(){if(G&&window.localStorage){try{var e=window.localStorage[G].split(",#");e.length>1&&(delete window.localStorage[G],t.each(e,function(t,e){w(e)}))}catch(r){}try{bt=window.localStorage[G].split(";")}catch(r){}}}function w(e){if(Y){var r=tinycolor(e).toRgbString();if(!gt[r]&&-1===t.inArray(r,bt))for(bt.push(r);bt.length>vt;)bt.shift();if(G&&window.localStorage)try{window.localStorage[G]=bt.join(";")}catch(n){}}}function _(){var t=[];if(W.showPalette)for(var e=0;e<bt.length;e++){var r=tinycolor(bt[e]).toRgbString();gt[r]||t.push(bt[e])}return t.reverse().slice(0,W.maxSelectionSize)}function x(){var e=q(),n=t.map(pt,function(t,n){return r(t,e,"sp-palette-row sp-palette-row-"+n,W)});y(),bt&&n.push(r(_(),e,"sp-palette-row sp-palette-row-selection",W)),Ot.html(n.join(""))}function k(){if(W.showInitial){var t=Wt,e=q();qt.html(r([t,e],e,"sp-palette-row-initial",W))}}function S(){(0>=rt||0>=et||0>=at)&&z(),tt=!0,kt.addClass(mt),yt=null,_t.trigger("dragstart.spectrum",[q()])}function C(){tt=!1,kt.removeClass(mt),_t.trigger("dragstop.spectrum",[q()])}function P(){var t=Tt.val();if(null!==t&&""!==t||!Qt){var e=tinycolor(t);e.isValid()?(O(e),I(!0)):Tt.addClass("sp-validation-error")}else O(null),I(!0)}function A(){Z?F():M()}function M(){var e=t.Event("beforeShow.spectrum");return Z?void z():(_t.trigger(e,[q()]),void(J.beforeShow(q())===!1||e.isDefaultPrevented()||(n(),Z=!0,t(wt).bind("keydown.spectrum",R),t(wt).bind("click.spectrum",H),t(window).bind("resize.spectrum",U),Lt.addClass("sp-active"),kt.removeClass("sp-hidden"),z(),E(),Wt=q(),k(),J.show(Wt),_t.trigger("show.spectrum",[Wt]))))}function R(t){27===t.keyCode&&F()}function H(t){2!=t.button&&(tt||(Yt?I(!0):T(),F()))}function F(){Z&&!X&&(Z=!1,t(wt).unbind("keydown.spectrum",R),t(wt).unbind("click.spectrum",H),t(window).unbind("resize.spectrum",U),Lt.removeClass("sp-active"),kt.addClass("sp-hidden"),J.hide(q()),_t.trigger("hide.spectrum",[q()]))}function T(){O(Wt,!0)}function O(t,e){if(tinycolor.equals(t,q()))return void E();var r,n;!t&&Qt?Gt=!0:(Gt=!1,r=tinycolor(t),n=r.toHsv(),ct=n.h%360/360,ft=n.s,ut=n.v,ht=n.a),E(),r&&r.isValid()&&!e&&(Xt=W.preferredFormat||r.getFormat())}function q(t){return t=t||{},Qt&&Gt?null:tinycolor.fromRatio({h:ct,s:ft,v:ut,a:Math.round(100*ht)/100},{format:t.format||Xt})}function N(){return!Tt.hasClass("sp-validation-error")}function j(){E(),J.move(q()),_t.trigger("move.spectrum",[q()])}function E(){Tt.removeClass("sp-validation-error"),D();var t=tinycolor.fromRatio({h:ct,s:1,v:1});Ct.css("background-color",t.toHexString());var e=Xt;1>ht&&(0!==ht||"name"!==e)&&("hex"===e||"hex3"===e||"hex6"===e||"name"===e)&&(e="rgb");var r=q({format:e}),n="";if(Vt.removeClass("sp-clear-display"),Vt.css("background-color","transparent"),!r&&Qt)Vt.addClass("sp-clear-display");else{var a=r.toHexString(),i=r.toRgbString();if(b||1===r.alpha?Vt.css("background-color",i):(Vt.css("background-color","transparent"),Vt.css("filter",r.toFilter())),W.showAlpha){var s=r.toRgb();s.a=0;var o=tinycolor(s).toRgbString(),l="linear-gradient(left, "+o+", "+a+")";g?Rt.css("filter",tinycolor(o).toFilter({gradientType:1},a)):(Rt.css("background","-webkit-"+l),Rt.css("background","-moz-"+l),Rt.css("background","-ms-"+l),Rt.css("background","linear-gradient(to right, "+o+", "+a+")"))}n=r.toString(e)}W.showInput&&Tt.val(n),W.showPalette&&x(),k()}function D(){var t=ft,e=ut;if(Qt&&Gt)Ft.hide(),Mt.hide(),Pt.hide();else{Ft.show(),Mt.show(),Pt.show();var r=t*et,n=rt-e*rt;r=Math.max(-nt,Math.min(et-nt,r-nt)),n=Math.max(-nt,Math.min(rt-nt,n-nt)),Pt.css({top:n+"px",left:r+"px"});var a=ht*st;Ft.css({left:a-ot/2+"px"});var i=ct*at;Mt.css({top:i-lt+"px"})}}function I(t){var e=q(),r="",n=!tinycolor.equals(e,Wt);e&&(r=e.toString(Xt),w(e)),It&&_t.val(r),t&&n&&(J.change(e),_t.trigger("change",[e]))}function z(){Z&&(et=Ct.width(),rt=Ct.height(),nt=Pt.height(),it=At.width(),at=At.height(),lt=Mt.height(),st=Ht.width(),ot=Ft.width(),X||(kt.css("position","absolute"),W.offset?kt.offset(W.offset):kt.offset(s(kt,Kt))),D(),W.showPalette&&x(),_t.trigger("reflow.spectrum"))}function B(){_t.show(),Kt.unbind("click.spectrum touchstart.spectrum"),kt.remove(),Lt.remove(),p[Jt.id]=null}function L(r,n){return r===e?t.extend({},W):n===e?W[r]:(W[r]=n,"preferredFormat"===r&&(Xt=W.preferredFormat),void c())}function K(){xt=!1,_t.attr("disabled",!1),Kt.removeClass("sp-disabled")}function V(){F(),xt=!0,_t.attr("disabled",!0),Kt.addClass("sp-disabled")}function $(t){W.offset=t,z()}var W=a(o,i),X=W.flat,Y=W.showSelectionPalette,G=W.localStorageKey,Q=W.theme,J=W.callbacks,U=u(z,10),Z=!1,tt=!1,et=0,rt=0,nt=0,at=0,it=0,st=0,ot=0,lt=0,ct=0,ft=0,ut=0,ht=1,dt=[],pt=[],gt={},bt=W.selectionPalette.slice(0),vt=W.maxSelectionSize,mt="sp-dragging",yt=null,wt=i.ownerDocument,_t=(wt.body,t(i)),xt=!1,kt=t(m,wt).addClass(Q),St=kt.find(".sp-picker-container"),Ct=kt.find(".sp-color"),Pt=kt.find(".sp-dragger"),At=kt.find(".sp-hue"),Mt=kt.find(".sp-slider"),Rt=kt.find(".sp-alpha-inner"),Ht=kt.find(".sp-alpha"),Ft=kt.find(".sp-alpha-handle"),Tt=kt.find(".sp-input"),Ot=kt.find(".sp-palette"),qt=kt.find(".sp-initial"),Nt=kt.find(".sp-cancel"),jt=kt.find(".sp-clear"),Et=kt.find(".sp-choose"),Dt=kt.find(".sp-palette-toggle"),It=_t.is("input"),zt=It&&"color"===_t.attr("type")&&h(),Bt=It&&!X,Lt=Bt?t(v).addClass(Q).addClass(W.className).addClass(W.replacerClassName):t([]),Kt=Bt?Lt:_t,Vt=Lt.find(".sp-preview-inner"),$t=W.color||It&&_t.val(),Wt=!1,Xt=W.preferredFormat,Yt=!W.showButtons||W.clickoutFiresChange,Gt=!$t,Qt=W.allowEmpty&&!zt;d();var Jt={show:M,hide:F,toggle:A,reflow:z,option:L,enable:K,disable:V,offset:$,set:function(t){O(t),I()},get:q,destroy:B,container:kt};return Jt.id=p.push(Jt)-1,Jt}function s(e,r){var n=0,a=e.outerWidth(),i=e.outerHeight(),s=r.outerHeight(),o=e[0].ownerDocument,l=o.documentElement,c=l.clientWidth+t(o).scrollLeft(),f=l.clientHeight+t(o).scrollTop(),u=r.offset();return u.top+=s,u.left-=Math.min(u.left,u.left+a>c&&c>a?Math.abs(u.left+a-c):0),u.top-=Math.min(u.top,u.top+i>f&&f>i?Math.abs(i+s-n):n),u}function o(){}function l(t){t.stopPropagation()}function c(t,e){var r=Array.prototype.slice,n=r.call(arguments,2);return function(){return t.apply(e,n.concat(r.call(arguments)))}}function f(e,r,n,a){function i(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function s(t){if(f){if(g&&c.documentMode<9&&!t.button)return l();var n=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],a=n&&n.pageX||t.pageX,s=n&&n.pageY||t.pageY,o=Math.max(0,Math.min(a-u.left,d)),b=Math.max(0,Math.min(s-u.top,h));p&&i(t),r.apply(e,[o,b,t])}}function o(r){var a=r.which?3==r.which:2==r.button;a||f||n.apply(e,arguments)!==!1&&(f=!0,h=t(e).height(),d=t(e).width(),u=t(e).offset(),t(c).bind(b),t(c.body).addClass("sp-dragging"),s(r),i(r))}function l(){f&&(t(c).unbind(b),t(c.body).removeClass("sp-dragging"),setTimeout(function(){a.apply(e,arguments)},0)),f=!1}r=r||function(){},n=n||function(){},a=a||function(){};var c=document,f=!1,u={},h=0,d=0,p="ontouchstart"in window,b={};b.selectstart=i,b.dragstart=i,b["touchmove mousemove"]=s,b["touchend mouseup"]=l,t(e).bind("touchstart mousedown",o)}function u(t,e,r){var n;return function(){var a=this,i=arguments,s=function(){n=null,t.apply(a,i)};r&&clearTimeout(n),(r||!n)&&(n=setTimeout(s,e))}}function h(){return t.fn.spectrum.inputTypeColorSupport()}var d={beforeShow:o,move:o,change:o,show:o,hide:o,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!0,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},p=[],g=!!/msie/i.exec(window.navigator.userAgent),b=function(){function t(t,e){return!!~(""+t).indexOf(e)}var e=document.createElement("div"),r=e.style;return r.cssText="background-color:rgba(0,0,0,.5)",t(r.backgroundColor,"rgba")||t(r.backgroundColor,"hsla")}(),v=["<div class='sp-replacer'>","<div class='sp-preview'><div class='sp-preview-inner'></div></div>","<div class='sp-dd'>&#9660;</div>","</div>"].join(""),m=function(){var t="";if(g)for(var e=1;6>=e;e++)t+="<div class='sp-"+e+"'></div>";return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'></div>","<div class='sp-palette-button-container sp-cf'>","<button type='button' class='sp-palette-toggle'></button>","</div>","</div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'></div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'></div>","</div>","</div>","</div>","<div class='sp-clear sp-clear-display'>","</div>","<div class='sp-hue'>","<div class='sp-slider'></div>",t,"</div>","</div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>","</div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false' />","</div>","<div class='sp-initial sp-thumb sp-cf'></div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'></a>","<button type='button' class='sp-choose'></button>","</div>","</div>","</div>"].join("")}(),y="spectrum.id";t.fn.spectrum=function(e,r){if("string"==typeof e){var n=this,a=Array.prototype.slice.call(arguments,1);return this.each(function(){var r=p[t(this).data(y)];if(r){var i=r[e];if(!i)throw new Error("Spectrum: no such method: '"+e+"'");"get"==e?n=r.get():"container"==e?n=r.container:"option"==e?n=r.option.apply(r,a):"destroy"==e?(r.destroy(),t(this).removeData(y)):i.apply(r,a)}}),n}return this.spectrum("destroy").each(function(){var r=t.extend({},e,t(this).data()),n=i(this,r);t(this).data(y,n.id)})},t.fn.spectrum.load=!0,t.fn.spectrum.loadOpts={},t.fn.spectrum.draggable=f,t.fn.spectrum.defaults=d,t.fn.spectrum.inputTypeColorSupport=function w(){if("undefined"==typeof w._cachedResult){var e=t("<input type='color'/>")[0];w._cachedResult="color"===e.type&&""!==e.value}return w._cachedResult},t.spectrum={},t.spectrum.localization={},t.spectrum.palettes={},t.fn.spectrum.processNativeColorInputs=function(){var e=t("input[type=color]");e.length&&!h()&&e.spectrum({preferredFormat:"hex6"})},function(){function t(t){var r={r:0,g:0,b:0},a=1,s=!1,o=!1;return"string"==typeof t&&(t=T(t)),"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(r=e(t.r,t.g,t.b),s=!0,o="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=R(t.s),t.v=R(t.v),r=i(t.h,t.s,t.v),s=!0,o="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=R(t.s),t.l=R(t.l),r=n(t.h,t.s,t.l),s=!0,o="hsl"),t.hasOwnProperty("a")&&(a=t.a)),a=x(a),{ok:s,format:t.format||o,r:D(255,I(r.r,0)),g:D(255,I(r.g,0)),b:D(255,I(r.b,0)),a:a}}function e(t,e,r){return{r:255*k(t,255),g:255*k(e,255),b:255*k(r,255)}}function r(t,e,r){t=k(t,255),e=k(e,255),r=k(r,255);var n,a,i=I(t,e,r),s=D(t,e,r),o=(i+s)/2;if(i==s)n=a=0;else{var l=i-s;switch(a=o>.5?l/(2-i-s):l/(i+s),i){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:a,l:o}}function n(t,e,r){function n(t,e,r){return 0>r&&(r+=1),r>1&&(r-=1),1/6>r?t+6*(e-t)*r:.5>r?e:2/3>r?t+(e-t)*(2/3-r)*6:t}var a,i,s;if(t=k(t,360),e=k(e,100),r=k(r,100),0===e)a=i=s=r;else{var o=.5>r?r*(1+e):r+e-r*e,l=2*r-o;a=n(l,o,t+1/3),i=n(l,o,t),s=n(l,o,t-1/3)}return{r:255*a,g:255*i,b:255*s}}function a(t,e,r){t=k(t,255),e=k(e,255),r=k(r,255);var n,a,i=I(t,e,r),s=D(t,e,r),o=i,l=i-s;if(a=0===i?0:l/i,i==s)n=0;else{switch(i){case t:n=(e-r)/l+(r>e?6:0);break;case e:n=(r-t)/l+2;break;case r:n=(t-e)/l+4}n/=6}return{h:n,s:a,v:o}}function i(t,e,r){t=6*k(t,360),e=k(e,100),r=k(r,100);var n=j.floor(t),a=t-n,i=r*(1-e),s=r*(1-a*e),o=r*(1-(1-a)*e),l=n%6,c=[r,s,i,i,o,r][l],f=[o,r,r,s,i,i][l],u=[i,i,o,r,r,s][l];return{r:255*c,g:255*f,b:255*u}}function s(t,e,r,n){var a=[M(E(t).toString(16)),M(E(e).toString(16)),M(E(r).toString(16))];return n&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0):a.join("")}function o(t,e,r,n){var a=[M(H(n)),M(E(t).toString(16)),M(E(e).toString(16)),M(E(r).toString(16))];return a.join("")}function l(t,e){e=0===e?0:e||10;var r=B(t).toHsl();return r.s-=e/100,r.s=S(r.s),B(r)}function c(t,e){e=0===e?0:e||10;var r=B(t).toHsl();return r.s+=e/100,r.s=S(r.s),B(r)}function f(t){return B(t).desaturate(100)}function u(t,e){e=0===e?0:e||10;var r=B(t).toHsl();return r.l+=e/100,r.l=S(r.l),B(r)}function h(t,e){e=0===e?0:e||10;var r=B(t).toRgb();return r.r=I(0,D(255,r.r-E(255*-(e/100)))),r.g=I(0,D(255,r.g-E(255*-(e/100)))),r.b=I(0,D(255,r.b-E(255*-(e/100)))),B(r)}function d(t,e){e=0===e?0:e||10;var r=B(t).toHsl();return r.l-=e/100,r.l=S(r.l),B(r)}function p(t,e){var r=B(t).toHsl(),n=(E(r.h)+e)%360;return r.h=0>n?360+n:n,B(r)}function g(t){var e=B(t).toHsl();return e.h=(e.h+180)%360,B(e)}function b(t){var e=B(t).toHsl(),r=e.h;return[B(t),B({h:(r+120)%360,s:e.s,l:e.l}),B({h:(r+240)%360,s:e.s,l:e.l})]}function v(t){var e=B(t).toHsl(),r=e.h;return[B(t),B({h:(r+90)%360,s:e.s,l:e.l}),B({h:(r+180)%360,s:e.s,l:e.l}),B({h:(r+270)%360,s:e.s,l:e.l})]}function m(t){var e=B(t).toHsl(),r=e.h;return[B(t),B({h:(r+72)%360,s:e.s,l:e.l}),B({h:(r+216)%360,s:e.s,l:e.l})]}function y(t,e,r){e=e||6,r=r||30;var n=B(t).toHsl(),a=360/r,i=[B(t)];for(n.h=(n.h-(a*e>>1)+720)%360;--e;)n.h=(n.h+a)%360,i.push(B(n));return i}function w(t,e){e=e||6;for(var r=B(t).toHsv(),n=r.h,a=r.s,i=r.v,s=[],o=1/e;e--;)s.push(B({h:n,s:a,v:i})),i=(i+o)%1;return s}function _(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}function x(t){return t=parseFloat(t),(isNaN(t)||0>t||t>1)&&(t=1),t}function k(t,e){P(t)&&(t="100%");var r=A(t);return t=D(e,I(0,parseFloat(t))),r&&(t=parseInt(t*e,10)/100),j.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function S(t){return D(1,I(0,t))}function C(t){return parseInt(t,16)}function P(t){return"string"==typeof t&&-1!=t.indexOf(".")&&1===parseFloat(t)}function A(t){return"string"==typeof t&&-1!=t.indexOf("%")}function M(t){return 1==t.length?"0"+t:""+t}function R(t){return 1>=t&&(t=100*t+"%"),t}function H(t){return Math.round(255*parseFloat(t)).toString(16)}function F(t){return C(t)/255}function T(t){t=t.replace(O,"").replace(q,"").toLowerCase();var e=!1;if(L[t])t=L[t],e=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};var r;return(r=V.rgb.exec(t))?{r:r[1],g:r[2],b:r[3]}:(r=V.rgba.exec(t))?{r:r[1],g:r[2],b:r[3],a:r[4]}:(r=V.hsl.exec(t))?{h:r[1],s:r[2],l:r[3]}:(r=V.hsla.exec(t))?{h:r[1],s:r[2],l:r[3],a:r[4]}:(r=V.hsv.exec(t))?{h:r[1],s:r[2],v:r[3]}:(r=V.hsva.exec(t))?{h:r[1],s:r[2],v:r[3],a:r[4]}:(r=V.hex8.exec(t))?{a:F(r[1]),r:C(r[2]),g:C(r[3]),b:C(r[4]),format:e?"name":"hex8"}:(r=V.hex6.exec(t))?{r:C(r[1]),g:C(r[2]),b:C(r[3]),format:e?"name":"hex"}:(r=V.hex3.exec(t))?{r:C(r[1]+""+r[1]),g:C(r[2]+""+r[2]),b:C(r[3]+""+r[3]),format:e?"name":"hex"}:!1}var O=/^[\s,#]+/,q=/\s+$/,N=0,j=Math,E=j.round,D=j.min,I=j.max,z=j.random,B=function(e,r){if(e=e?e:"",r=r||{},e instanceof B)return e;if(!(this instanceof B))return new B(e,r);var n=t(e);this._originalInput=e,this._r=n.r,this._g=n.g,this._b=n.b,this._a=n.a,this._roundA=E(100*this._a)/100,this._format=r.format||n.format,this._gradientType=r.gradientType,this._r<1&&(this._r=E(this._r)),this._g<1&&(this._g=E(this._g)),this._b<1&&(this._b=E(this._b)),this._ok=n.ok,this._tc_id=N++};B.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=x(t),this._roundA=E(100*this._a)/100,this},toHsv:function(){var t=a(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=a(this._r,this._g,this._b),e=E(360*t.h),r=E(100*t.s),n=E(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+n+"%)":"hsva("+e+", "+r+"%, "+n+"%, "+this._roundA+")"},toHsl:function(){var t=r(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=r(this._r,this._g,this._b),e=E(360*t.h),n=E(100*t.s),a=E(100*t.l);return 1==this._a?"hsl("+e+", "+n+"%, "+a+"%)":"hsla("+e+", "+n+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return s(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return o(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:E(this._r),g:E(this._g),b:E(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+E(this._r)+", "+E(this._g)+", "+E(this._b)+")":"rgba("+E(this._r)+", "+E(this._g)+", "+E(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:E(100*k(this._r,255))+"%",g:E(100*k(this._g,255))+"%",b:E(100*k(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+E(100*k(this._r,255))+"%, "+E(100*k(this._g,255))+"%, "+E(100*k(this._b,255))+"%)":"rgba("+E(100*k(this._r,255))+"%, "+E(100*k(this._g,255))+"%, "+E(100*k(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":this._a<1?!1:K[s(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+o(this._r,this._g,this._b,this._a),r=e,n=this._gradientType?"GradientType = 1, ":"";if(t){var a=B(t);r=a.toHex8String()}return"progid:DXImageTransform.Microsoft.gradient("+n+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,n=this._a<1&&this._a>=0,a=!e&&n&&("hex"===t||"hex6"===t||"hex3"===t||"name"===t);return a?"name"===t&&0===this._a?this.toName():this.toRgbString():("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),("hex"===t||"hex6"===t)&&(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString())},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(u,arguments)},brighten:function(){return this._applyModification(h,arguments)},darken:function(){return this._applyModification(d,arguments)},desaturate:function(){return this._applyModification(l,arguments)},saturate:function(){return this._applyModification(c,arguments)},greyscale:function(){return this._applyModification(f,arguments)},spin:function(){return this._applyModification(p,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(y,arguments)},complement:function(){return this._applyCombination(g,arguments)},monochromatic:function(){return this._applyCombination(w,arguments)},splitcomplement:function(){return this._applyCombination(m,arguments)},triad:function(){return this._applyCombination(b,arguments)},tetrad:function(){return this._applyCombination(v,arguments)}},B.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var n in t)t.hasOwnProperty(n)&&("a"===n?r[n]=t[n]:r[n]=R(t[n]));t=r}return B(t,e)},B.equals=function(t,e){return t&&e?B(t).toRgbString()==B(e).toRgbString():!1},B.random=function(){return B.fromRatio({r:z(),g:z(),b:z()})},B.mix=function(t,e,r){r=0===r?0:r||50;var n,a=B(t).toRgb(),i=B(e).toRgb(),s=r/100,o=2*s-1,l=i.a-a.a;n=o*l==-1?o:(o+l)/(1+o*l),n=(n+1)/2;var c=1-n,f={r:i.r*n+a.r*c,g:i.g*n+a.g*c,b:i.b*n+a.b*c,a:i.a*s+a.a*(1-s)};return B(f)},B.readability=function(t,e){var r=B(t),n=B(e),a=r.toRgb(),i=n.toRgb(),s=r.getBrightness(),o=n.getBrightness(),l=Math.max(a.r,i.r)-Math.min(a.r,i.r)+Math.max(a.g,i.g)-Math.min(a.g,i.g)+Math.max(a.b,i.b)-Math.min(a.b,i.b);return{brightness:Math.abs(s-o),color:l}},B.isReadable=function(t,e){var r=B.readability(t,e);return r.brightness>125&&r.color>500},B.mostReadable=function(t,e){for(var r=null,n=0,a=!1,i=0;i<e.length;i++){var s=B.readability(t,e[i]),o=s.brightness>125&&s.color>500,l=3*(s.brightness/125)+s.color/500;(o&&!a||o&&a&&l>n||!o&&!a&&l>n)&&(a=o,n=l,r=B(e[i]))}return r};var L=B.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},K=B.hexNames=_(L),V=function(){var t="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",r="(?:"+e+")|(?:"+t+")",n="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?",a="[\\s|\\(]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")[,|\\s]+("+r+")\\s*\\)?";return{rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+a),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+a),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+a),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();window.tinycolor=B}(),t(function(){t.fn.spectrum.load&&t.fn.spectrum.processNativeColorInputs()})});
1
+ // Spectrum Colorpicker v1.8.1
2
+ // https://github.com/bgrins/spectrum
3
+ // Author: Brian Grinstead
4
+ // License: MIT
5
+ !function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof exports&&"object"==typeof module?module.exports=t(require("jquery")):t(jQuery)}(function(jt,Et){"use strict";var t,Dt={beforeShow:r,move:r,change:r,show:r,hide:r,color:!1,flat:!1,showInput:!1,allowEmpty:!1,showButtons:!0,clickoutFiresChange:!0,showInitial:!1,showPalette:!1,showPaletteOnly:!1,hideAfterPaletteSelect:!1,togglePaletteOnly:!1,showSelectionPalette:!0,localStorageKey:!1,appendTo:"body",maxSelectionSize:7,cancelText:"cancel",chooseText:"choose",togglePaletteMoreText:"more",togglePaletteLessText:"less",clearText:"Clear Color Selection",noColorSelectedText:"No Color Selected",preferredFormat:!1,className:"",containerClassName:"",replacerClassName:"",showAlpha:!1,theme:"sp-light",palette:[["#ffffff","#000000","#ff0000","#ff8000","#ffff00","#008000","#0000ff","#4b0082","#9400d3"]],selectionPalette:[],disabled:!1,offset:null},It=[],zt=!!/msie/i.exec(window.navigator.userAgent),Bt=((t=document.createElement("div").style).cssText="background-color:rgba(0,0,0,.5)",e(t.backgroundColor,"rgba")||e(t.backgroundColor,"hsla")),Lt=["<div class='sp-replacer'>","<div class='sp-preview'><div class='sp-preview-inner'></div></div>","<div class='sp-dd'>&#9660;</div>","</div>"].join(""),Kt=function(){var t="";if(zt)for(var e=1;e<=6;e++)t+="<div class='sp-"+e+"'></div>";return["<div class='sp-container sp-hidden'>","<div class='sp-palette-container'>","<div class='sp-palette sp-thumb sp-cf'></div>","<div class='sp-palette-button-container sp-cf'>","<button type='button' class='sp-palette-toggle'></button>","</div>","</div>","<div class='sp-picker-container'>","<div class='sp-top sp-cf'>","<div class='sp-fill'></div>","<div class='sp-top-inner'>","<div class='sp-color'>","<div class='sp-sat'>","<div class='sp-val'>","<div class='sp-dragger'></div>","</div>","</div>","</div>","<div class='sp-clear sp-clear-display'>","</div>","<div class='sp-hue'>","<div class='sp-slider'></div>",t,"</div>","</div>","<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>","</div>","<div class='sp-input-container sp-cf'>","<input class='sp-input' type='text' spellcheck='false' />","</div>","<div class='sp-initial sp-thumb sp-cf'></div>","<div class='sp-button-container sp-cf'>","<a class='sp-cancel' href='#'></a>","<button type='button' class='sp-choose'></button>","</div>","</div>","</div>"].join("")}();function e(t,e){return!!~(""+t).indexOf(e)}function Vt(t,e,r,a){for(var n=[],o=0;o<t.length;o++){var i,s,l,c,f=t[o];f?(s=(i=tinycolor(f)).toHsl().l<.5?"sp-thumb-el sp-thumb-dark":"sp-thumb-el sp-thumb-light",s+=tinycolor.equals(e,f)?" sp-thumb-active":"",l=i.toString(a.preferredFormat||"rgb"),c=Bt?"background-color:"+i.toRgbString():"filter:"+i.toFilter(),n.push('<span title="'+l+'" data-color="'+i.toRgbString()+'" class="'+s+'"><span class="sp-thumb-inner" style="'+c+';"></span></span>')):n.push(jt("<div />").append(jt('<span data-color="" style="background-color:transparent;" class="sp-clear-display"></span>').attr("title",a.noColorSelectedText)).html())}return"<div class='sp-cf "+r+"'>"+n.join("")+"</div>"}function o(t,e){var r,a,n,o,i,s,l,u=(i=e,s=t,(l=jt.extend({},Dt,i)).callbacks={move:Wt(l.move,s),change:Wt(l.change,s),show:Wt(l.show,s),hide:Wt(l.hide,s),beforeShow:Wt(l.beforeShow,s)},l),d=u.flat,c=u.showSelectionPalette,f=u.localStorageKey,h=u.theme,p=u.callbacks,g=(r=Ot,function(){var t=this,e=arguments;n&&clearTimeout(o),!n&&o||(o=setTimeout(function(){o=null,r.apply(t,e)},a))}),b=!(a=10),v=!1,m=0,y=0,w=0,_=0,x=0,k=0,S=0,C=0,P=0,A=0,M=1,R=[],H=[],F={},T=u.selectionPalette.slice(0),O=u.maxSelectionSize,q="sp-dragging",N=null,j=t.ownerDocument,E=(j.body,jt(t)),D=!1,I=jt(Kt,j).addClass(h),z=I.find(".sp-picker-container"),B=I.find(".sp-color"),L=I.find(".sp-dragger"),K=I.find(".sp-hue"),V=I.find(".sp-slider"),$=I.find(".sp-alpha-inner"),W=I.find(".sp-alpha"),X=I.find(".sp-alpha-handle"),Y=I.find(".sp-input"),G=I.find(".sp-palette"),Q=I.find(".sp-initial"),J=I.find(".sp-cancel"),U=I.find(".sp-clear"),Z=I.find(".sp-choose"),tt=I.find(".sp-palette-toggle"),et=E.is("input"),rt=et&&"color"===E.attr("type")&&Yt(),at=et&&!d,nt=at?jt(Lt).addClass(h).addClass(u.className).addClass(u.replacerClassName):jt([]),ot=at?nt:E,it=nt.find(".sp-preview-inner"),st=u.color||et&&E.val(),lt=!1,ct=u.preferredFormat,ft=!u.showButtons||u.clickoutFiresChange,ht=!st,ut=u.allowEmpty&&!rt;function dt(){if(u.showPaletteOnly&&(u.showPalette=!0),tt.text(u.showPaletteOnly?u.togglePaletteMoreText:u.togglePaletteLessText),u.palette){R=u.palette.slice(0),H=jt.isArray(R[0])?R:[R],F={};for(var t=0;t<H.length;t++)for(var e=0;e<H[t].length;e++){var r=tinycolor(H[t][e]).toRgbString();F[r]=!0}}I.toggleClass("sp-flat",d),I.toggleClass("sp-input-disabled",!u.showInput),I.toggleClass("sp-alpha-enabled",u.showAlpha),I.toggleClass("sp-clear-enabled",ut),I.toggleClass("sp-buttons-disabled",!u.showButtons),I.toggleClass("sp-palette-buttons-disabled",!u.togglePaletteOnly),I.toggleClass("sp-palette-disabled",!u.showPalette),I.toggleClass("sp-palette-only",u.showPaletteOnly),I.toggleClass("sp-initial-disabled",!u.showInitial),I.addClass(u.className).addClass(u.containerClassName),Ot()}function pt(){if(f&&window.localStorage){try{var t=window.localStorage[f].split(",#");1<t.length&&(delete window.localStorage[f],jt.each(t,function(t,e){gt(e)}))}catch(t){}try{T=window.localStorage[f].split(";")}catch(t){}}}function gt(t){if(c){var e=tinycolor(t).toRgbString();if(!F[e]&&-1===jt.inArray(e,T))for(T.push(e);T.length>O;)T.shift();if(f&&window.localStorage)try{window.localStorage[f]=T.join(";")}catch(t){}}}function bt(){var r=Mt(),t=jt.map(H,function(t,e){return Vt(t,r,"sp-palette-row sp-palette-row-"+e,u)});pt(),T&&t.push(Vt(function(){var t=[];if(u.showPalette)for(var e=0;e<T.length;e++){var r=tinycolor(T[e]).toRgbString();F[r]||t.push(T[e])}return t.reverse().slice(0,u.maxSelectionSize)}(),r,"sp-palette-row sp-palette-row-selection",u)),G.html(t.join(""))}function vt(){var t,e;u.showInitial&&(t=lt,e=Mt(),Q.html(Vt([t,e],e,"sp-palette-row-initial",u)))}function mt(){(y<=0||m<=0||_<=0)&&Ot(),v=!0,I.addClass(q),N=null,E.trigger("dragstart.spectrum",[Mt()])}function yt(){v=!1,I.removeClass(q),E.trigger("dragstop.spectrum",[Mt()])}function wt(){var t,e=Y.val();null!==e&&""!==e||!ut?(t=tinycolor(e)).isValid()?(At(t),Rt(),Tt()):Y.addClass("sp-validation-error"):(At(null),Rt(),Tt())}function _t(){(b?Ct:xt)()}function xt(){var t=jt.Event("beforeShow.spectrum");b?Ot():(E.trigger(t,[Mt()]),!1===p.beforeShow(Mt())||t.isDefaultPrevented()||(function(){for(var t=0;t<It.length;t++)It[t]&&It[t].hide()}(),b=!0,jt(j).on("keydown.spectrum",kt),jt(j).on("click.spectrum",St),jt(window).on("resize.spectrum",g),nt.addClass("sp-active"),I.removeClass("sp-hidden"),Ot(),Ht(),lt=Mt(),vt(),p.show(lt),E.trigger("show.spectrum",[lt])))}function kt(t){27===t.keyCode&&Ct()}function St(t){2!=t.button&&(v||(ft?Tt(!0):Pt(),Ct()))}function Ct(){b&&!d&&(b=!1,jt(j).off("keydown.spectrum",kt),jt(j).off("click.spectrum",St),jt(window).off("resize.spectrum",g),nt.removeClass("sp-active"),I.addClass("sp-hidden"),p.hide(Mt()),E.trigger("hide.spectrum",[Mt()]))}function Pt(){At(lt,!0),Tt(!0)}function At(t,e){var r,a;tinycolor.equals(t,Mt())?Ht():(!t&&ut?ht=!0:(ht=!1,a=(r=tinycolor(t)).toHsv(),C=a.h%360/360,P=a.s,A=a.v,M=a.a),Ht(),r&&r.isValid()&&!e&&(ct=u.preferredFormat||r.getFormat()))}function Mt(t){return t=t||{},ut&&ht?null:tinycolor.fromRatio({h:C,s:P,v:A,a:Math.round(1e3*M)/1e3},{format:t.format||ct})}function Rt(){Ht(),p.move(Mt()),E.trigger("move.spectrum",[Mt()])}function Ht(){Y.removeClass("sp-validation-error"),Ft();var t=tinycolor.fromRatio({h:C,s:1,v:1});B.css("background-color",t.toHexString());var e=ct;M<1&&(0!==M||"name"!==e)&&("hex"!==e&&"hex3"!==e&&"hex6"!==e&&"name"!==e||(e="rgb"));var r,a,n,o,i,s=Mt({format:e}),l="";it.removeClass("sp-clear-display"),it.css("background-color","transparent"),!s&&ut?it.addClass("sp-clear-display"):(r=s.toHexString(),a=s.toRgbString(),Bt||1===s.alpha?it.css("background-color",a):(it.css("background-color","transparent"),it.css("filter",s.toFilter())),u.showAlpha&&((n=s.toRgb()).a=0,i="linear-gradient(left, "+(o=tinycolor(n).toRgbString())+", "+r+")",zt?$.css("filter",tinycolor(o).toFilter({gradientType:1},r)):($.css("background","-webkit-"+i),$.css("background","-moz-"+i),$.css("background","-ms-"+i),$.css("background","linear-gradient(to right, "+o+", "+r+")"))),l=s.toString(e)),u.showInput&&Y.val(l),u.showPalette&&bt(),vt()}function Ft(){var t,e,r,a,n=P,o=A;ut&&ht?(X.hide(),V.hide(),L.hide()):(X.show(),V.show(),L.show(),t=n*m,e=y-o*y,t=Math.max(-w,Math.min(m-w,t-w)),e=Math.max(-w,Math.min(y-w,e-w)),L.css({top:e+"px",left:t+"px"}),r=M*x,X.css({left:r-k/2+"px"}),a=C*_,V.css({top:a-S+"px"}))}function Tt(t){var e=Mt(),r="",a=!tinycolor.equals(e,lt);e&&(r=e.toString(ct),gt(e)),et&&E.val(r),t&&a&&(p.change(e),E.trigger("change",[e]))}function Ot(){var t,e,r,a,n,o,i,s,l,c,f,h;b&&(m=B.width(),y=B.height(),w=L.height(),K.width(),_=K.height(),S=V.height(),x=W.width(),k=X.width(),d||(I.css("position","absolute"),u.offset?I.offset(u.offset):I.offset((e=ot,r=(t=I).outerWidth(),a=t.outerHeight(),n=e.outerHeight(),o=t[0].ownerDocument,i=o.documentElement,s=i.clientWidth+jt(o).scrollLeft(),l=i.clientHeight+jt(o).scrollTop(),c=e.offset(),f=c.left,h=c.top,h+=n,f-=Math.min(f,s<f+r&&r<s?Math.abs(f+r-s):0),{top:h-=Math.min(h,l<h+a&&a<l?Math.abs(+(a+n)):0),bottom:c.bottom,left:f,right:c.right,width:c.width,height:c.height}))),Ft(),u.showPalette&&bt(),E.trigger("reflow.spectrum"))}function qt(){Ct(),D=!0,E.attr("disabled",!0),ot.addClass("sp-disabled")}!function(){var t;function e(t){return t.data&&t.data.ignore?(At(jt(t.target).closest(".sp-thumb-el").data("color")),Rt()):(At(jt(t.target).closest(".sp-thumb-el").data("color")),Rt(),u.hideAfterPaletteSelect?(Tt(!0),Ct()):Tt()),!1}zt&&I.find("*:not(input)").attr("unselectable","on"),dt(),at&&E.after(nt).hide(),ut||U.hide(),d?E.after(I).hide():(1!==(t="parent"===u.appendTo?E.parent():jt(u.appendTo)).length&&(t=jt("body")),t.append(I)),pt(),ot.on("click.spectrum touchstart.spectrum",function(t){D||_t(),t.stopPropagation(),jt(t.target).is("input")||t.preventDefault()}),!E.is(":disabled")&&!0!==u.disabled||qt(),I.click($t),Y.change(wt),Y.on("paste",function(){setTimeout(wt,1)}),Y.keydown(function(t){13==t.keyCode&&wt()}),J.text(u.cancelText),J.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),Pt(),Ct()}),U.attr("title",u.clearText),U.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),ht=!0,Rt(),d&&Tt(!0)}),Z.text(u.chooseText),Z.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),zt&&Y.is(":focus")&&Y.trigger("change"),Y.hasClass("sp-validation-error")||(Tt(!0),Ct())}),tt.text(u.showPaletteOnly?u.togglePaletteMoreText:u.togglePaletteLessText),tt.on("click.spectrum",function(t){t.stopPropagation(),t.preventDefault(),u.showPaletteOnly=!u.showPaletteOnly,u.showPaletteOnly||d||I.css("left","-="+(z.outerWidth(!0)+5)),dt()}),Xt(W,function(t,e,r){M=t/x,ht=!1,r.shiftKey&&(M=Math.round(10*M)/10),Rt()},mt,yt),Xt(K,function(t,e){C=parseFloat(e/_),ht=!1,u.showAlpha||(M=1),Rt()},mt,yt),Xt(B,function(t,e,r){var a,n,o;r.shiftKey?N||(a=P*m,n=y-A*y,o=Math.abs(t-a)>Math.abs(e-n),N=o?"x":"y"):N=null;var i=!N||"y"===N;N&&"x"!==N||(P=parseFloat(t/m)),i&&(A=parseFloat((y-e)/y)),ht=!1,u.showAlpha||(M=1),Rt()},mt,yt),st?(At(st),Ht(),ct=u.preferredFormat||tinycolor(st).format,gt(st)):Ht(),d&&xt();var r=zt?"mousedown.spectrum":"click.spectrum touchstart.spectrum";G.on(r,".sp-thumb-el",e),Q.on(r,".sp-thumb-el:nth-child(1)",{ignore:!0},e)}();var Nt={show:xt,hide:Ct,toggle:_t,reflow:Ot,option:function(t,e){return t===Et?jt.extend({},u):e===Et?u[t]:(u[t]=e,"preferredFormat"===t&&(ct=u.preferredFormat),void dt())},enable:function(){D=!1,E.attr("disabled",!1),ot.removeClass("sp-disabled")},disable:qt,offset:function(t){u.offset=t,Ot()},set:function(t){At(t),Tt()},get:Mt,destroy:function(){E.show(),ot.off("click.spectrum touchstart.spectrum"),I.remove(),nt.remove(),It[Nt.id]=null},container:I};return Nt.id=It.push(Nt)-1,Nt}function r(){}function $t(t){t.stopPropagation()}function Wt(t,e){var r=Array.prototype.slice,a=r.call(arguments,2);return function(){return t.apply(e,a.concat(r.call(arguments)))}}function Xt(i,s,e,t){s=s||function(){},e=e||function(){},t=t||function(){};var l=document,c=!1,f={},h=0,u=0,d="ontouchstart"in window,r={};function p(t){t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.returnValue=!1}function a(t){if(c){if(zt&&l.documentMode<9&&!t.button)return g();var e=t.originalEvent&&t.originalEvent.touches&&t.originalEvent.touches[0],r=e&&e.pageX||t.pageX,a=e&&e.pageY||t.pageY,n=Math.max(0,Math.min(r-f.left,u)),o=Math.max(0,Math.min(a-f.top,h));d&&p(t),s.apply(i,[n,o,t])}}function g(){c&&(jt(l).off(r),jt(l.body).removeClass("sp-dragging"),setTimeout(function(){t.apply(i,arguments)},0)),c=!1}r.selectstart=p,r.dragstart=p,r["touchmove mousemove"]=a,r["touchend mouseup"]=g,jt(i).on("touchstart mousedown",function(t){(t.which?3==t.which:2==t.button)||c||!1!==e.apply(i,arguments)&&(c=!0,h=jt(i).height(),u=jt(i).width(),f=jt(i).offset(),jt(l).on(r),jt(l.body).addClass("sp-dragging"),a(t),p(t))})}function Yt(){return jt.fn.spectrum.inputTypeColorSupport()}var i="spectrum.id";jt.fn.spectrum=function(r,t){if("string"!=typeof r)return this.spectrum("destroy").each(function(){var t=o(this,jt.extend({},jt(this).data(),r));jt(this).data(i,t.id)});var a=this,n=Array.prototype.slice.call(arguments,1);return this.each(function(){var t=It[jt(this).data(i)];if(t){var e=t[r];if(!e)throw new Error("Spectrum: no such method: '"+r+"'");"get"==r?a=t.get():"container"==r?a=t.container:"option"==r?a=t.option.apply(t,n):"destroy"==r?(t.destroy(),jt(this).removeData(i)):e.apply(t,n)}}),a},jt.fn.spectrum.load=!0,jt.fn.spectrum.loadOpts={},jt.fn.spectrum.draggable=Xt,jt.fn.spectrum.defaults=Dt,jt.fn.spectrum.inputTypeColorSupport=function t(){var e;return void 0===t._cachedResult&&(e=jt("<input type='color'/>")[0],t._cachedResult="color"===e.type&&""!==e.value),t._cachedResult},jt.spectrum={},jt.spectrum.localization={},jt.spectrum.palettes={},jt.fn.spectrum.processNativeColorInputs=function(){var t=jt("input[type=color]");t.length&&!Yt()&&t.spectrum({preferredFormat:"hex6"})},function(){var o=/^[\s,#]+/,i=/\s+$/,a=0,c=Math,s=c.round,f=c.min,h=c.max,t=c.random,u=function(t,e){if(e=e||{},(t=t||"")instanceof u)return t;if(!(this instanceof u))return new u(t,e);var r=function(t){var e={r:0,g:0,b:0},r=1,a=!1,n=!1;"string"==typeof t&&(t=function(t){t=t.replace(o,"").replace(i,"").toLowerCase();var e,r=!1;if(P[t])t=P[t],r=!0;else if("transparent"==t)return{r:0,g:0,b:0,a:0,format:"name"};if(e=E.rgb.exec(t))return{r:e[1],g:e[2],b:e[3]};if(e=E.rgba.exec(t))return{r:e[1],g:e[2],b:e[3],a:e[4]};if(e=E.hsl.exec(t))return{h:e[1],s:e[2],l:e[3]};if(e=E.hsla.exec(t))return{h:e[1],s:e[2],l:e[3],a:e[4]};if(e=E.hsv.exec(t))return{h:e[1],s:e[2],v:e[3]};if(e=E.hsva.exec(t))return{h:e[1],s:e[2],v:e[3],a:e[4]};if(e=E.hex8.exec(t))return{a:function(t){return F(t)/255}(e[1]),r:F(e[2]),g:F(e[3]),b:F(e[4]),format:r?"name":"hex8"};if(e=E.hex6.exec(t))return{r:F(e[1]),g:F(e[2]),b:F(e[3]),format:r?"name":"hex"};if(e=E.hex3.exec(t))return{r:F(e[1]+""+e[1]),g:F(e[2]+""+e[2]),b:F(e[3]+""+e[3]),format:r?"name":"hex"};return!1}(t));"object"==typeof t&&(t.hasOwnProperty("r")&&t.hasOwnProperty("g")&&t.hasOwnProperty("b")?(e=function(t,e,r){return{r:255*R(t,255),g:255*R(e,255),b:255*R(r,255)}}(t.r,t.g,t.b),a=!0,n="%"===String(t.r).substr(-1)?"prgb":"rgb"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("v")?(t.s=O(t.s),t.v=O(t.v),e=function(t,e,r){t=6*R(t,360),e=R(e,100),r=R(r,100);var a=c.floor(t),n=t-a,o=r*(1-e),i=r*(1-n*e),s=r*(1-(1-n)*e),l=a%6;return{r:255*[r,i,o,o,s,r][l],g:255*[s,r,r,i,o,o][l],b:255*[o,o,s,r,r,i][l]}}(t.h,t.s,t.v),a=!0,n="hsv"):t.hasOwnProperty("h")&&t.hasOwnProperty("s")&&t.hasOwnProperty("l")&&(t.s=O(t.s),t.l=O(t.l),e=function(t,e,r){var a,n,o;function i(t,e,r){return r<0&&(r+=1),1<r&&--r,r<1/6?t+6*(e-t)*r:r<.5?e:r<2/3?t+(e-t)*(2/3-r)*6:t}{var s,l;t=R(t,360),e=R(e,100),r=R(r,100),0===e?a=n=o=r:(a=i(l=2*r-(s=r<.5?r*(1+e):r+e-r*e),s,t+1/3),n=i(l,s,t),o=i(l,s,t-1/3))}return{r:255*a,g:255*n,b:255*o}}(t.h,t.s,t.l),a=!0,n="hsl"),t.hasOwnProperty("a")&&(r=t.a));return r=M(r),{ok:a,format:t.format||n,r:f(255,h(e.r,0)),g:f(255,h(e.g,0)),b:f(255,h(e.b,0)),a:r}}(t);this._originalInput=t,this._r=r.r,this._g=r.g,this._b=r.b,this._a=r.a,this._roundA=s(1e3*this._a)/1e3,this._format=e.format||r.format,this._gradientType=e.gradientType,this._r<1&&(this._r=s(this._r)),this._g<1&&(this._g=s(this._g)),this._b<1&&(this._b=s(this._b)),this._ok=r.ok,this._tc_id=a++};function n(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var a,n=h(t,e,r),o=f(t,e,r),i=(n+o)/2;if(n==o)a=l=0;else{var s=n-o,l=.5<i?s/(2-n-o):s/(n+o);switch(n){case t:a=(e-r)/s+(e<r?6:0);break;case e:a=(r-t)/s+2;break;case r:a=(t-e)/s+4}a/=6}return{h:a,s:l,l:i}}function l(t,e,r){t=R(t,255),e=R(e,255),r=R(r,255);var a,n=h(t,e,r),o=f(t,e,r),i=n,s=n-o,l=0===n?0:s/n;if(n==o)a=0;else{switch(n){case t:a=(e-r)/s+(e<r?6:0);break;case e:a=(r-t)/s+2;break;case r:a=(t-e)/s+4}a/=6}return{h:a,s:l,v:i}}function e(t,e,r,a){var n=[T(s(t).toString(16)),T(s(e).toString(16)),T(s(r).toString(16))];return a&&n[0].charAt(0)==n[0].charAt(1)&&n[1].charAt(0)==n[1].charAt(1)&&n[2].charAt(0)==n[2].charAt(1)?n[0].charAt(0)+n[1].charAt(0)+n[2].charAt(0):n.join("")}function d(t,e,r,a){var n;return[T((n=a,Math.round(255*parseFloat(n)).toString(16))),T(s(t).toString(16)),T(s(e).toString(16)),T(s(r).toString(16))].join("")}function r(t,e){e=0===e?0:e||10;var r=u(t).toHsl();return r.s-=e/100,r.s=H(r.s),u(r)}function p(t,e){e=0===e?0:e||10;var r=u(t).toHsl();return r.s+=e/100,r.s=H(r.s),u(r)}function g(t){return u(t).desaturate(100)}function b(t,e){e=0===e?0:e||10;var r=u(t).toHsl();return r.l+=e/100,r.l=H(r.l),u(r)}function v(t,e){e=0===e?0:e||10;var r=u(t).toRgb();return r.r=h(0,f(255,r.r-s(-e/100*255))),r.g=h(0,f(255,r.g-s(-e/100*255))),r.b=h(0,f(255,r.b-s(-e/100*255))),u(r)}function m(t,e){e=0===e?0:e||10;var r=u(t).toHsl();return r.l-=e/100,r.l=H(r.l),u(r)}function y(t,e){var r=u(t).toHsl(),a=(s(r.h)+e)%360;return r.h=a<0?360+a:a,u(r)}function w(t){var e=u(t).toHsl();return e.h=(e.h+180)%360,u(e)}function _(t){var e=u(t).toHsl(),r=e.h;return[u(t),u({h:(r+120)%360,s:e.s,l:e.l}),u({h:(r+240)%360,s:e.s,l:e.l})]}function x(t){var e=u(t).toHsl(),r=e.h;return[u(t),u({h:(r+90)%360,s:e.s,l:e.l}),u({h:(r+180)%360,s:e.s,l:e.l}),u({h:(r+270)%360,s:e.s,l:e.l})]}function k(t){var e=u(t).toHsl(),r=e.h;return[u(t),u({h:(r+72)%360,s:e.s,l:e.l}),u({h:(r+216)%360,s:e.s,l:e.l})]}function S(t,e,r){e=e||6,r=r||30;var a=u(t).toHsl(),n=360/r,o=[u(t)];for(a.h=(a.h-(n*e>>1)+720)%360;--e;)a.h=(a.h+n)%360,o.push(u(a));return o}function C(t,e){e=e||6;for(var r=u(t).toHsv(),a=r.h,n=r.s,o=r.v,i=[],s=1/e;e--;)i.push(u({h:a,s:n,v:o})),o=(o+s)%1;return i}u.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var t=this.toRgb();return(299*t.r+587*t.g+114*t.b)/1e3},setAlpha:function(t){return this._a=M(t),this._roundA=s(1e3*this._a)/1e3,this},toHsv:function(){var t=l(this._r,this._g,this._b);return{h:360*t.h,s:t.s,v:t.v,a:this._a}},toHsvString:function(){var t=l(this._r,this._g,this._b),e=s(360*t.h),r=s(100*t.s),a=s(100*t.v);return 1==this._a?"hsv("+e+", "+r+"%, "+a+"%)":"hsva("+e+", "+r+"%, "+a+"%, "+this._roundA+")"},toHsl:function(){var t=n(this._r,this._g,this._b);return{h:360*t.h,s:t.s,l:t.l,a:this._a}},toHslString:function(){var t=n(this._r,this._g,this._b),e=s(360*t.h),r=s(100*t.s),a=s(100*t.l);return 1==this._a?"hsl("+e+", "+r+"%, "+a+"%)":"hsla("+e+", "+r+"%, "+a+"%, "+this._roundA+")"},toHex:function(t){return e(this._r,this._g,this._b,t)},toHexString:function(t){return"#"+this.toHex(t)},toHex8:function(){return d(this._r,this._g,this._b,this._a)},toHex8String:function(){return"#"+this.toHex8()},toRgb:function(){return{r:s(this._r),g:s(this._g),b:s(this._b),a:this._a}},toRgbString:function(){return 1==this._a?"rgb("+s(this._r)+", "+s(this._g)+", "+s(this._b)+")":"rgba("+s(this._r)+", "+s(this._g)+", "+s(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:s(100*R(this._r,255))+"%",g:s(100*R(this._g,255))+"%",b:s(100*R(this._b,255))+"%",a:this._a}},toPercentageRgbString:function(){return 1==this._a?"rgb("+s(100*R(this._r,255))+"%, "+s(100*R(this._g,255))+"%, "+s(100*R(this._b,255))+"%)":"rgba("+s(100*R(this._r,255))+"%, "+s(100*R(this._g,255))+"%, "+s(100*R(this._b,255))+"%, "+this._roundA+")"},toName:function(){return 0===this._a?"transparent":!(this._a<1)&&A[e(this._r,this._g,this._b,!0)]||!1},toFilter:function(t){var e="#"+d(this._r,this._g,this._b,this._a),r=e,a=this._gradientType?"GradientType = 1, ":"";return t&&(r=u(t).toHex8String()),"progid:DXImageTransform.Microsoft.gradient("+a+"startColorstr="+e+",endColorstr="+r+")"},toString:function(t){var e=!!t;t=t||this._format;var r=!1,a=this._a<1&&0<=this._a;return e||!a||"hex"!==t&&"hex6"!==t&&"hex3"!==t&&"name"!==t?("rgb"===t&&(r=this.toRgbString()),"prgb"===t&&(r=this.toPercentageRgbString()),"hex"!==t&&"hex6"!==t||(r=this.toHexString()),"hex3"===t&&(r=this.toHexString(!0)),"hex8"===t&&(r=this.toHex8String()),"name"===t&&(r=this.toName()),"hsl"===t&&(r=this.toHslString()),"hsv"===t&&(r=this.toHsvString()),r||this.toHexString()):"name"===t&&0===this._a?this.toName():this.toRgbString()},_applyModification:function(t,e){var r=t.apply(null,[this].concat([].slice.call(e)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(b,arguments)},brighten:function(){return this._applyModification(v,arguments)},darken:function(){return this._applyModification(m,arguments)},desaturate:function(){return this._applyModification(r,arguments)},saturate:function(){return this._applyModification(p,arguments)},greyscale:function(){return this._applyModification(g,arguments)},spin:function(){return this._applyModification(y,arguments)},_applyCombination:function(t,e){return t.apply(null,[this].concat([].slice.call(e)))},analogous:function(){return this._applyCombination(S,arguments)},complement:function(){return this._applyCombination(w,arguments)},monochromatic:function(){return this._applyCombination(C,arguments)},splitcomplement:function(){return this._applyCombination(k,arguments)},triad:function(){return this._applyCombination(_,arguments)},tetrad:function(){return this._applyCombination(x,arguments)}},u.fromRatio=function(t,e){if("object"==typeof t){var r={};for(var a in t)t.hasOwnProperty(a)&&(r[a]="a"===a?t[a]:O(t[a]));t=r}return u(t,e)},u.equals=function(t,e){return!(!t||!e)&&u(t).toRgbString()==u(e).toRgbString()},u.random=function(){return u.fromRatio({r:t(),g:t(),b:t()})},u.mix=function(t,e,r){r=0===r?0:r||50;var a=u(t).toRgb(),n=u(e).toRgb(),o=r/100,i=2*o-1,s=n.a-a.a,l=i*s==-1?i:(i+s)/(1+i*s),c=1-(l=(l+1)/2),f={r:n.r*l+a.r*c,g:n.g*l+a.g*c,b:n.b*l+a.b*c,a:n.a*o+a.a*(1-o)};return u(f)},u.readability=function(t,e){var r=u(t),a=u(e),n=r.toRgb(),o=a.toRgb(),i=r.getBrightness(),s=a.getBrightness(),l=Math.max(n.r,o.r)-Math.min(n.r,o.r)+Math.max(n.g,o.g)-Math.min(n.g,o.g)+Math.max(n.b,o.b)-Math.min(n.b,o.b);return{brightness:Math.abs(i-s),color:l}},u.isReadable=function(t,e){var r=u.readability(t,e);return 125<r.brightness&&500<r.color},u.mostReadable=function(t,e){for(var r=null,a=0,n=!1,o=0;o<e.length;o++){var i=u.readability(t,e[o]),s=125<i.brightness&&500<i.color,l=i.brightness/125*3+i.color/500;(s&&!n||s&&n&&a<l||!s&&!n&&a<l)&&(n=s,a=l,r=u(e[o]))}return r};var P=u.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},A=u.hexNames=function(t){var e={};for(var r in t)t.hasOwnProperty(r)&&(e[t[r]]=r);return e}(P);function M(t){return t=parseFloat(t),(isNaN(t)||t<0||1<t)&&(t=1),t}function R(t,e){var r;"string"==typeof(r=t)&&-1!=r.indexOf(".")&&1===parseFloat(r)&&(t="100%");var a,n="string"==typeof(a=t)&&-1!=a.indexOf("%");return t=f(e,h(0,parseFloat(t))),n&&(t=parseInt(t*e,10)/100),c.abs(t-e)<1e-6?1:t%e/parseFloat(e)}function H(t){return f(1,h(0,t))}function F(t){return parseInt(t,16)}function T(t){return 1==t.length?"0"+t:""+t}function O(t){return t<=1&&(t=100*t+"%"),t}var q,N,j,E=(N="[\\s|\\(]+("+(q="(?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?)")+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?",j="[\\s|\\(]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")[,|\\s]+("+q+")\\s*\\)?",{rgb:new RegExp("rgb"+N),rgba:new RegExp("rgba"+j),hsl:new RegExp("hsl"+N),hsla:new RegExp("hsla"+j),hsv:new RegExp("hsv"+N),hsva:new RegExp("hsva"+j),hex3:/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex8:/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/});window.tinycolor=u}(),jt(function(){jt.fn.spectrum.load&&jt.fn.spectrum.processNativeColorInputs()})});
media/less/block-editor.less CHANGED
@@ -1,3 +1,13 @@
1
- .wp-block[data-type="mp-timetable/timetable"] div[data-block] {
2
- overflow: auto;
3
- }
 
 
 
 
 
 
 
 
 
 
1
+ .wp-block[data-type="mp-timetable/timetable"] div[data-block] {
2
+ overflow: auto;
3
+ }
4
+
5
+ /*
6
+ * TODO: WordPress 5.6 Select Multiple Fix
7
+ */
8
+ body.branch-5-6 .components-select-control.timetable-wp56-fix .components-select-control__input {
9
+ height: auto !important;
10
+ }
11
+ body.branch-5-6 .components-select-control.timetable-wp56-fix .components-input-control__suffix {
12
+ display: none !important;
13
+ }
mp-timetable.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Timetable and Event Schedule
5
  * Plugin URI: https://motopress.com/products/timetable-event-schedule/
6
  * Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
7
- * Version: 2.3.11
8
  * Author: MotoPress
9
  * Author URI: https://motopress.com
10
  * License: GPLv2 or later
4
  * Plugin Name: Timetable and Event Schedule
5
  * Plugin URI: https://motopress.com/products/timetable-event-schedule/
6
  * Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
7
+ * Version: 2.3.12
8
  * Author: MotoPress
9
  * Author URI: https://motopress.com
10
  * License: GPLv2 or later
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: MotoPress
3
  Donate link: https://motopress.com/
4
  Tags: schedule, timetable, calendar, event, events calendar, dates, event organizer, booking, appointments, upcoming events
5
  Requires at least: 4.6
6
- Tested up to: 5.5
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -19,7 +19,7 @@ The plugin can be used for timetabling different types of events like various le
19
  * Check [Timetable and Event Schedule Plugin Demo](https://mpttdemo.getmotopress.com/)
20
  * Please find the step-by-step [instructions of working with the plugin](https://motopress.com/files/motopress-timetable-plugin-documentation.pdf)
21
 
22
- = Key advantages =
23
 
24
  **Responsive design.** It's optimized to be viewed perfectly on different devices. A good step forward, the plugin was supplied with the ability to manually adjust the way to show your timetable on mobile devices and desktops.
25
 
@@ -33,7 +33,7 @@ The plugin can be used for timetabling different types of events like various le
33
 
34
  **Flexibility.** If any unexpected delays or total dates' changes take place, your timetable can bend easily in one direction or another thanks to a couple of qucik time edits in the backend.
35
 
36
- = Main features =
37
  * Several column types
38
  * Selecting/deselecting the preferable columns and events to be displayed in the timetable
39
  * Ability to add event tags and categories
@@ -53,6 +53,10 @@ Timetable can be added to Elementor, Divi, Beaver or any other builder via short
53
 
54
  Proud developers of Timetable plugin and the biggest set of blocks for Gutenberg - [Getwid WordPress Blocks](https://wordpress.org/plugins/getwid/).
55
 
 
 
 
 
56
  == Installation ==
57
 
58
  1. Upload the plugin files to the /wp-content/plugins/ directory
@@ -81,6 +85,9 @@ Plugin bundles the following third-party resources:
81
 
82
  == Changelog ==
83
 
 
 
 
84
  = 2.3.11, May 18 2020 =
85
  * Added the ability to duplicate events.
86
  * Added the ability to set table layout fixed or auto.
3
  Donate link: https://motopress.com/
4
  Tags: schedule, timetable, calendar, event, events calendar, dates, event organizer, booking, appointments, upcoming events
5
  Requires at least: 4.6
6
+ Tested up to: 5.6
7
  Stable tag: trunk
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
19
  * Check [Timetable and Event Schedule Plugin Demo](https://mpttdemo.getmotopress.com/)
20
  * Please find the step-by-step [instructions of working with the plugin](https://motopress.com/files/motopress-timetable-plugin-documentation.pdf)
21
 
22
+ ### Key advantages
23
 
24
  **Responsive design.** It's optimized to be viewed perfectly on different devices. A good step forward, the plugin was supplied with the ability to manually adjust the way to show your timetable on mobile devices and desktops.
25
 
33
 
34
  **Flexibility.** If any unexpected delays or total dates' changes take place, your timetable can bend easily in one direction or another thanks to a couple of qucik time edits in the backend.
35
 
36
+ ### Main features
37
  * Several column types
38
  * Selecting/deselecting the preferable columns and events to be displayed in the timetable
39
  * Ability to add event tags and categories
53
 
54
  Proud developers of Timetable plugin and the biggest set of blocks for Gutenberg - [Getwid WordPress Blocks](https://wordpress.org/plugins/getwid/).
55
 
56
+ ### Power up your timetables with the Appointment Booking plugin
57
+
58
+ Want to take automatic online appointment reservations through your website for events, classes, and any other type of services? Enable [hourly appointment booking](https://motopress.com/products/appointment-booking/?utm_source=wp_org_tt_page&utm_medium=text_link&utm_campaign=appointment_plugin) with our custom-crafted plugin optimized for easy appointment scheduling and quick online reservations.
59
+
60
  == Installation ==
61
 
62
  1. Upload the plugin files to the /wp-content/plugins/ directory
85
 
86
  == Changelog ==
87
 
88
+ = 2.3.12, Dec 11 2020 =
89
+ * Improved compatibility with WordPress 5.6.
90
+
91
  = 2.3.11, May 18 2020 =
92
  * Added the ability to duplicate events.
93
  * Added the ability to set table layout fixed or auto.